diff options
author | June McEnroe <june@causal.agency> | 2017-08-08 20:44:22 -0400 |
---|---|---|
committer | June McEnroe <june@causal.agency> | 2017-08-08 20:44:22 -0400 |
commit | 8402acf0fe1451b8508d4d81a2fae8e7927d0720 (patch) | |
tree | 694b48f73f4c55f209eb6cd0b1d966c8c10550bd | |
parent | Reverse order of main loop (diff) | |
download | torus-8402acf0fe1451b8508d4d81a2fae8e7927d0720.tar.gz torus-8402acf0fe1451b8508d4d81a2fae8e7927d0720.zip |
Completely retry if a send fails during a broadcast
This fixes a bug where the saved next client to iterate through would also get removed. This can result in messages being sent multiple times to a client, but that will have no negative effect.
Diffstat (limited to '')
-rwxr-xr-x | server.c | 7 |
1 files changed, 3 insertions, 4 deletions
diff --git a/server.c b/server.c index 64e4e18..2fcdff7 100755 --- a/server.c +++ b/server.c @@ -123,16 +123,15 @@ 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)) { - struct Client *dead = client; - client = client->next; - clientRemove(dead); - if (!client) break; + clientRemove(client); + goto retry; } } } |