1
0
mirror of https://git.sr.ht/~sircmpwn/gmnisrv synced 2024-12-04 14:46:42 -05:00

Update pollfd pointers when destroying a client

The client pollfd pointer would go stale when the server pollfd array
was moved to compensate for a destroyed client, which in turn led to
poll breakage.

Refresh the pollfd pointers after memmove.
This commit is contained in:
Kenny Levinsen 2020-11-08 23:59:41 +01:00 committed by Drew DeVault
parent 74077b6f95
commit fdd27bb4c1

View File

@ -209,6 +209,10 @@ disconnect_client(struct gmnisrv_server *server, struct gmnisrv_client *client)
(server->fdsz - (server->nlisten + index + 1)) * sizeof(struct pollfd));
--server->nfds;
--server->nclients;
for (size_t idx = index; idx < server->nclients; idx++) {
server->clients[idx].pollfd = &server->fds[server->nlisten + index];
}
}
static int