about summary refs log tree commit diff homepage
diff options
context:
space:
mode:
authorJune McEnroe <programble@gmail.com>2017-09-01 12:33:54 -0400
committerJune McEnroe <programble@gmail.com>2017-09-01 12:33:54 -0400
commit0dae2c10c7db909964d0c00607e983c1fc9db978 (patch)
tree4a8fb79672769e916f511fc59adbeec3331d0621
parentAdd client readOnly mode (diff)
downloadtorus-0dae2c10c7db909964d0c00607e983c1fc9db978.tar.gz
torus-0dae2c10c7db909964d0c00607e983c1fc9db978.zip
Remove clientRemove call from clientCast
If an error occurs on a client socket during a broadcast, that client
will show up in the kqueue loop with EV_EOF and get removed that way.

Tested by sending SIGKILL to a client and watching its cursor disappear.
Diffstat (limited to '')
-rw-r--r--server.c9
1 files changed, 1 insertions, 8 deletions
diff --git a/server.c b/server.c
index 6992dc5..85b1f6c 100644
--- a/server.c
+++ b/server.c
@@ -114,8 +114,6 @@ static struct Client *clientAdd(int fd) {
     return client;
 }
 
-static void clientRemove(struct Client *client);
-
 static bool clientSend(const struct Client *client, const struct ServerMessage *msg) {
     ssize_t len = send(client->fd, msg, sizeof(*msg), 0);
     if (len < 0) return false;
@@ -130,16 +128,11 @@ static bool clientSend(const struct Client *client, const struct ServerMessage *
 }
 
 static void clientCast(const struct Client *origin, const struct ServerMessage *msg) {
-retry:
     for (struct Client *client = clientHead; client; client = client->next) {
         if (client == origin) continue;
         if (client->tileX != origin->tileX) continue;
         if (client->tileY != origin->tileY) continue;
-
-        if (!clientSend(client, msg)) {
-            clientRemove(client);
-            goto retry;
-        }
+        clientSend(client, msg);
     }
 }