diff --git a/src/server.cpp b/src/server.cpp index e5ddd7a83..492937e40 100644 --- a/src/server.cpp +++ b/src/server.cpp @@ -2221,10 +2221,11 @@ void processClients(); * The most important is freeClientsInAsyncFreeQueue but we also * call some other low-risk functions. */ void beforeSleep(struct aeEventLoop *eventLoop) { + AeLocker locker; UNUSED(eventLoop); int iel = ielFromEventLoop(eventLoop); - aeAcquireLock(); + locker.arm(); processClients(); /* Handle precise timeouts of blocked clients. */ @@ -2232,9 +2233,9 @@ void beforeSleep(struct aeEventLoop *eventLoop) { /* Handle TLS pending data. (must be done before flushAppendOnlyFile) */ if (tlsHasPendingData()) { - aeReleaseLock(); + locker.release(); tlsProcessPendingData(); - aeAcquireLock(); + locker.arm(); } /* If tls still has pending unread data don't sleep at all. */ @@ -2299,9 +2300,9 @@ void beforeSleep(struct aeEventLoop *eventLoop) { first so perform it here */ bool fSentReplies = false; if (listLength(g_pserver->clients_to_close)) { - aeReleaseLock(); + locker.disarm(); handleClientsWithPendingWrites(iel, aof_state); - aeAcquireLock(); + locker.arm(); fSentReplies = true; } @@ -2311,7 +2312,7 @@ void beforeSleep(struct aeEventLoop *eventLoop) { /* Before we are going to sleep, let the threads access the dataset by * releasing the GIL. Redis main thread will not touch anything at this * time. */ - aeReleaseLock(); + locker.disarm(); if (!fSentReplies) handleClientsWithPendingWrites(iel, aof_state); if (moduleCount()) moduleReleaseGIL(TRUE /*fServerThread*/); diff --git a/tests/unit/maxmemory.tcl b/tests/unit/maxmemory.tcl index e12fedc91..b399e9b06 100644 --- a/tests/unit/maxmemory.tcl +++ b/tests/unit/maxmemory.tcl @@ -215,7 +215,7 @@ proc test_slave_buffers {test_name cmd_count payload_len limit_memory pipeline} set used_no_repl [expr {$new_used - $mem_not_counted_for_evict}] set delta [expr {($used_no_repl - $client_buf) - ($orig_used_no_repl - $orig_client_buf)}] - assert {[$master dbsize] == 100} + assert_equal [$master dbsize] 100 assert {$slave_buf > 2*1024*1024} ;# some of the data may have been pushed to the OS buffers set delta_max [expr {$cmd_count / 2}] ;# 1 byte unaccounted for, with 1M commands will consume some 1MB assert {$delta < $delta_max && $delta > -$delta_max}