From 8b44d86c7c6d53870f202ba9ed13557e4c60baf8 Mon Sep 17 00:00:00 2001 From: John Sully Date: Wed, 23 Oct 2019 13:19:57 -0400 Subject: [PATCH] processEventsWhileBlocked needs to release the lock in a safe way Former-commit-id: 1a70af2ae13962db038b0635cc29488019323538 --- src/networking.cpp | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/src/networking.cpp b/src/networking.cpp index 45a66e387..0ebe1575e 100644 --- a/src/networking.cpp +++ b/src/networking.cpp @@ -2998,6 +2998,14 @@ int processEventsWhileBlocked(int iel) { int iterations = 4; /* See the function top-comment. */ int count = 0; + client *c = serverTL->current_client; + if (c != nullptr) + { + serverAssert(c->flags & CLIENT_PROTECTED); + c->lock.unlock(); + c->db->lock.unlock(); + } + aeReleaseLock(); while (iterations--) { int events = 0; events += aeProcessEvents(g_pserver->rgthreadvar[iel].el, AE_FILE_EVENTS|AE_DONT_WAIT); @@ -3005,6 +3013,13 @@ int processEventsWhileBlocked(int iel) { if (!events) break; count += events; } + AeLocker locker; + if (c != nullptr) + c->lock.lock(); + locker.arm(c); + if (c != nullptr) + c->db->lock.lock(); + locker.release(); return count; }