diff options
author | June McEnroe <programble@gmail.com> | 2017-08-08 20:44:22 -0400 |
---|---|---|
committer | June McEnroe <programble@gmail.com> | 2017-08-08 20:44:22 -0400 |
commit | 1f410444568f733e8044b6f60a53c704cfbc0c6f (patch) | |
tree | 2b8cfaf555629125c474963aa5d7ed3d25bd5544 | |
parent | Reverse order of main loop (diff) | |
download | torus-1f410444568f733e8044b6f60a53c704cfbc0c6f.tar.gz torus-1f410444568f733e8044b6f60a53c704cfbc0c6f.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; } } } |