diff --git a/src/networking.c b/src/networking.c index 8d3e057b71266d9046cf5e86a3e5ae9387658318..cc28732d1eec3ab29fa4c83112e3fe2e9d391388 100644 --- a/src/networking.c +++ b/src/networking.c @@ -1239,14 +1239,20 @@ void freeClientAsync(client *c) { /* Free the clietns marked as CLOSE_ASAP, return the number of clients * freed. */ int freeClientsInAsyncFreeQueue(void) { - int freed = listLength(server.clients_to_close); - while (listLength(server.clients_to_close)) { - listNode *ln = listFirst(server.clients_to_close); + int freed = 0; + listIter li; + listNode *ln; + + listRewind(server.clients_to_close,&li); + while ((ln = listNext(&li)) != NULL) { client *c = listNodeValue(ln); + if (c->flags & CLIENT_PROTECTED) continue; + c->flags &= ~CLIENT_CLOSE_ASAP; freeClient(c); listDelNode(server.clients_to_close,ln); + freed++; } return freed; }