summaryrefslogtreecommitdiff
path: root/src/networking.c
diff options
context:
space:
mode:
authorzhaozhao.zz <zhaozhao.zz@alibaba-inc.com>2020-06-02 11:34:28 +0800
committerantirez <antirez@gmail.com>2020-06-09 11:53:01 +0200
commit4846c0c8af3226c7a2d575ff93391b9cf0590655 (patch)
tree230168a0805af8c36c0141343f1d8767e628f57f /src/networking.c
parentf33de403edd1ab9bd1edee97708fadb8bdd0adf9 (diff)
downloadredis-4846c0c8af3226c7a2d575ff93391b9cf0590655.tar.gz
donot free protected client in freeClientsInAsyncFreeQueue
related #7234
Diffstat (limited to 'src/networking.c')
-rw-r--r--src/networking.c12
1 files changed, 9 insertions, 3 deletions
diff --git a/src/networking.c b/src/networking.c
index 8d3e057b7..cc28732d1 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;
}