Prevent crashes on shutdown due to lock being held
Former-commit-id: 6a74f524e558100dfb3e54779020cd3407706e08
This commit is contained in:
parent
cba89cf9f9
commit
b226b318ff
@ -2221,10 +2221,11 @@ void processClients();
|
|||||||
* The most important is freeClientsInAsyncFreeQueue but we also
|
* The most important is freeClientsInAsyncFreeQueue but we also
|
||||||
* call some other low-risk functions. */
|
* call some other low-risk functions. */
|
||||||
void beforeSleep(struct aeEventLoop *eventLoop) {
|
void beforeSleep(struct aeEventLoop *eventLoop) {
|
||||||
|
AeLocker locker;
|
||||||
UNUSED(eventLoop);
|
UNUSED(eventLoop);
|
||||||
int iel = ielFromEventLoop(eventLoop);
|
int iel = ielFromEventLoop(eventLoop);
|
||||||
|
|
||||||
aeAcquireLock();
|
locker.arm();
|
||||||
processClients();
|
processClients();
|
||||||
|
|
||||||
/* Handle precise timeouts of blocked clients. */
|
/* Handle precise timeouts of blocked clients. */
|
||||||
@ -2232,9 +2233,9 @@ void beforeSleep(struct aeEventLoop *eventLoop) {
|
|||||||
|
|
||||||
/* Handle TLS pending data. (must be done before flushAppendOnlyFile) */
|
/* Handle TLS pending data. (must be done before flushAppendOnlyFile) */
|
||||||
if (tlsHasPendingData()) {
|
if (tlsHasPendingData()) {
|
||||||
aeReleaseLock();
|
locker.release();
|
||||||
tlsProcessPendingData();
|
tlsProcessPendingData();
|
||||||
aeAcquireLock();
|
locker.arm();
|
||||||
}
|
}
|
||||||
|
|
||||||
/* If tls still has pending unread data don't sleep at all. */
|
/* 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 */
|
first so perform it here */
|
||||||
bool fSentReplies = false;
|
bool fSentReplies = false;
|
||||||
if (listLength(g_pserver->clients_to_close)) {
|
if (listLength(g_pserver->clients_to_close)) {
|
||||||
aeReleaseLock();
|
locker.disarm();
|
||||||
handleClientsWithPendingWrites(iel, aof_state);
|
handleClientsWithPendingWrites(iel, aof_state);
|
||||||
aeAcquireLock();
|
locker.arm();
|
||||||
fSentReplies = true;
|
fSentReplies = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -2311,7 +2312,7 @@ void beforeSleep(struct aeEventLoop *eventLoop) {
|
|||||||
/* Before we are going to sleep, let the threads access the dataset by
|
/* 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
|
* releasing the GIL. Redis main thread will not touch anything at this
|
||||||
* time. */
|
* time. */
|
||||||
aeReleaseLock();
|
locker.disarm();
|
||||||
if (!fSentReplies)
|
if (!fSentReplies)
|
||||||
handleClientsWithPendingWrites(iel, aof_state);
|
handleClientsWithPendingWrites(iel, aof_state);
|
||||||
if (moduleCount()) moduleReleaseGIL(TRUE /*fServerThread*/);
|
if (moduleCount()) moduleReleaseGIL(TRUE /*fServerThread*/);
|
||||||
|
@ -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 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)}]
|
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
|
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
|
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}
|
assert {$delta < $delta_max && $delta > -$delta_max}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user