Fix crash when client running async keys disconnects before keys finishes

Former-commit-id: dd9233c49d82c89a9d92b7251a56f91c2ee98e77
This commit is contained in:
John Sully 2019-11-21 20:40:58 -05:00
parent 5e692ff15a
commit fbc7821244
2 changed files with 5 additions and 2 deletions

View File

@ -111,6 +111,8 @@ void blockClient(client *c, int btype) {
serverAssert(GlobalLocksAcquired());
c->flags |= CLIENT_BLOCKED;
c->btype = btype;
if (btype == BLOCKED_ASYNC)
c->casyncOpsPending++;
g_pserver->blocked_clients++;
g_pserver->blocked_clients_by_type[btype]++;
}
@ -191,7 +193,8 @@ void unblockClient(client *c) {
} else if (c->btype == BLOCKED_MODULE) {
unblockClientFromModule(c);
} else if (c->btype == BLOCKED_ASYNC) {
serverAssert(c->casyncOpsPending > 0);
c->casyncOpsPending--;
} else {
serverPanic("Unknown btype in unblockClient().");
}

View File

@ -1624,7 +1624,7 @@ void ProcessPendingAsyncWrites()
std::atomic_thread_fence(std::memory_order_seq_cst);
if (c->casyncOpsPending == 0)
if (c->casyncOpsPending == 0 || c->btype == BLOCKED_ASYNC) // It's ok to send data if we're in a bgthread op
{
if (FCorrectThread(c))
{