From d3bd1ab56b11b14c9f3f3e4254093c2a7ad4c8c5 Mon Sep 17 00:00:00 2001 From: John Sully Date: Sun, 24 May 2020 01:58:33 -0400 Subject: [PATCH] Fix ASAN races Former-commit-id: 8665f250314c4e3de32f3b31a2c0158908ef982b --- src/networking.cpp | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) diff --git a/src/networking.cpp b/src/networking.cpp index e3e0b0e00..dbef33655 100644 --- a/src/networking.cpp +++ b/src/networking.cpp @@ -80,6 +80,7 @@ int listMatchObjects(void *a, void *b) { /* This function links the client to the global linked list of clients. * unlinkClient() does the opposite, among other things. */ void linkClient(client *c) { + serverAssert(GlobalLocksAcquired()); listAddNodeTail(g_pserver->clients,c); /* Note that we remember the linked list node where the client is stored, * this way removing the client in unlinkClient() will not require @@ -1957,12 +1958,9 @@ int handleClientsWithPendingWrites(int iel, int aof_state) { } } - if (listLength(serverTL->clients_pending_asyncwrite)) - { - AeLocker locker; - locker.arm(nullptr); - ProcessPendingAsyncWrites(); - } + AeLocker locker; + locker.arm(nullptr); + ProcessPendingAsyncWrites(); return processed; } @@ -2298,13 +2296,13 @@ void commandProcessed(client *c) { * part of the replication stream, will be propagated to the * sub-replicas and to the replication backlog. */ if (c->flags & CLIENT_MASTER) { + AeLocker ae; + ae.arm(c); long long applied = c->reploff - prev_offset; long long prev_master_repl_meaningful_offset = g_pserver->master_repl_meaningful_offset; if (applied) { if (!g_pserver->fActiveReplica) { - AeLocker ae; - ae.arm(c); replicationFeedSlavesFromMasterStream(g_pserver->slaves, c->pending_querybuf, applied); }