diff --git a/iocore/eventsystem/P_UnixEThread.h b/iocore/eventsystem/P_UnixEThread.h index 61c7153ca91..f0749753e84 100644 --- a/iocore/eventsystem/P_UnixEThread.h +++ b/iocore/eventsystem/P_UnixEThread.h @@ -33,7 +33,7 @@ #include "I_EThread.h" #include "I_EventProcessor.h" -const int DELAY_FOR_RETRY = HRTIME_MSECONDS(10); +const ink_hrtime DELAY_FOR_RETRY = HRTIME_MSECONDS(10); TS_INLINE Event * EThread::schedule_imm(Continuation *cont, int callback_event, void *cookie) diff --git a/iocore/eventsystem/UnixEThread.cc b/iocore/eventsystem/UnixEThread.cc index c415a724968..2913ba6f86a 100644 --- a/iocore/eventsystem/UnixEThread.cc +++ b/iocore/eventsystem/UnixEThread.cc @@ -254,7 +254,13 @@ EThread::execute_regular() next_time = EventQueue.earliest_timeout(); ink_hrtime sleep_time = next_time - Thread::get_hrtime_updated(); if (sleep_time > 0) { - sleep_time = std::min(sleep_time, HRTIME_MSECONDS(thread_max_heartbeat_mseconds)); + if (EventQueueExternal.localQueue.empty()) { + sleep_time = std::min(sleep_time, HRTIME_MSECONDS(thread_max_heartbeat_mseconds)); + } else { + // Because of a missed lock, Timed-Event and Negative-Event have been pushed into localQueue for retry in awhile. + // Therefore, we have to set the limitation of sleep time in order to handle the next retry in time. + sleep_time = std::min(sleep_time, DELAY_FOR_RETRY); + } ++(current_metric->_wait); } else { sleep_time = 0;