serverAsserts on sleeping_threads, remove bare locks
Former-commit-id: 8c64ca2333d8eb2ee92d835907474ec63e127b62
This commit is contained in:
parent
9dde193c1d
commit
ce8705451a
@ -2514,9 +2514,11 @@ void beforeSleep(struct aeEventLoop *eventLoop) {
|
|||||||
serverAssert(g_pserver->repl_batch_offStart < 0);
|
serverAssert(g_pserver->repl_batch_offStart < 0);
|
||||||
runAndPropogateToReplicas(processClients);
|
runAndPropogateToReplicas(processClients);
|
||||||
|
|
||||||
time_thread_mutex.lock();
|
{
|
||||||
sleeping_threads++;
|
std::lock_guard<std::mutex> lock(time_thread_mutex);
|
||||||
time_thread_mutex.unlock();
|
sleeping_threads++;
|
||||||
|
serverAssert(sleeping_threads <= cserver.cthreads);
|
||||||
|
}
|
||||||
|
|
||||||
/* Handle precise timeouts of blocked clients. */
|
/* Handle precise timeouts of blocked clients. */
|
||||||
handleBlockedClientsTimeout();
|
handleBlockedClientsTimeout();
|
||||||
@ -6088,9 +6090,9 @@ void OnTerminate()
|
|||||||
}
|
}
|
||||||
|
|
||||||
void wakeTimeThread() {
|
void wakeTimeThread() {
|
||||||
time_thread_mutex.lock();
|
std::lock_guard<std::mutex> lock(time_thread_mutex);
|
||||||
sleeping_threads--;
|
sleeping_threads--;
|
||||||
time_thread_mutex.unlock();
|
serverAssert(sleeping_threads >= 0);
|
||||||
time_thread_cv.notify_one();
|
time_thread_cv.notify_one();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -6099,9 +6101,11 @@ void *timeThreadMain(void*) {
|
|||||||
delay.tv_sec = 0;
|
delay.tv_sec = 0;
|
||||||
delay.tv_nsec = 100;
|
delay.tv_nsec = 100;
|
||||||
while (true) {
|
while (true) {
|
||||||
std::unique_lock<std::mutex> lock(time_thread_mutex);
|
{
|
||||||
if (sleeping_threads >= cserver.cthreads) {
|
std::unique_lock<std::mutex> lock(time_thread_mutex);
|
||||||
time_thread_cv.wait(lock);
|
if (sleeping_threads >= cserver.cthreads) {
|
||||||
|
time_thread_cv.wait(lock);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
updateCachedTime();
|
updateCachedTime();
|
||||||
clock_nanosleep(CLOCK_REALTIME, 0, &delay, NULL);
|
clock_nanosleep(CLOCK_REALTIME, 0, &delay, NULL);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user