aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSeebs <seebs@seebs.net>2018-02-19 11:52:56 -0600
committerSeebs <seebs@seebs.net>2018-02-19 11:52:56 -0600
commitf3f4459031004fbac06f729354ec73aa0653bc74 (patch)
tree7e555c5157bc94647f94cfffe1e22e181467da54
parent26e30fa2e1a0fe4e885d7eea3f55d23cd2c3158f (diff)
downloadpseudo-f3f4459031004fbac06f729354ec73aa0653bc74.tar.gz
pseudo-f3f4459031004fbac06f729354ec73aa0653bc74.tar.bz2
pseudo-f3f4459031004fbac06f729354ec73aa0653bc74.zip
Epoll: use the correct client
So in the non-listen-fd case, apparently I broke the code to use the index of the returned event, rather than the corresponding ID value registered with epoll, as the index into the clients array. This, of course, was nonsense, and explains why we were seeing a ton of attempts to modify client 0. This also reverts the previous, incorrect, attempt to address all those messages. Signed-off-by: seebs <seebs@seebs.net>
-rw-r--r--ChangeLog.txt3
-rw-r--r--pseudo_server.c11
2 files changed, 9 insertions, 5 deletions
diff --git a/ChangeLog.txt b/ChangeLog.txt
index ae27a6a..8c886c6 100644
--- a/ChangeLog.txt
+++ b/ChangeLog.txt
@@ -1,3 +1,6 @@
+2018-02-19:
+ * (seebs) fix using index of request rather than request's value
+
2018-02-16:
* (seebs) allow closing client #0.
diff --git a/pseudo_server.c b/pseudo_server.c
index c12ba9b..d4428cf 100644
--- a/pseudo_server.c
+++ b/pseudo_server.c
@@ -449,7 +449,7 @@ close_client(int client) {
pseudo_debug(PDBGF_SERVER, "lost client %d [%d], closing fd %d\n", client,
clients[client].pid, clients[client].fd);
/* client went away... */
- if (client > highest_client || client < 0) {
+ if (client > highest_client || client <= 0) {
pseudo_diag("tried to close client %d (highest is %d)\n",
client, highest_client);
return;
@@ -700,7 +700,8 @@ static void pseudo_server_loop_epoll(void)
} else if (rc > 0) {
loop_timeout = pseudo_server_timeout;
for (i = 0; i < rc; ++i) {
- if (clients[events[i].data.u64].fd == listen_fd) {
+ int client_id = events[i].data.u64;
+ if (clients[client_id].fd == listen_fd) {
if (!die_forcefully) {
len = sizeof(client);
if ((fd = accept(listen_fd, (struct sockaddr *) &client, &len)) != -1) {
@@ -733,11 +734,11 @@ static void pseudo_server_loop_epoll(void)
}
} else {
int n = 0;
- ioctl(clients[i].fd, FIONREAD, &n);
+ ioctl(clients[client_id].fd, FIONREAD, &n);
if (n == 0) {
- close_client(i);
+ close_client(client_id);
} else {
- serve_client(i);
+ serve_client(client_id);
}
}
if (die_forcefully)