Skip to content

Commit aa5b2ea

Browse files
committed
Don't sleep if ProtectedQueue.localQueue is not empty. (#6234)
1 parent bed0184 commit aa5b2ea

File tree

2 files changed

+8
-2
lines changed

2 files changed

+8
-2
lines changed

iocore/eventsystem/P_UnixEThread.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@
3333
#include "I_EThread.h"
3434
#include "I_EventProcessor.h"
3535

36-
const int DELAY_FOR_RETRY = HRTIME_MSECONDS(10);
36+
const ink_hrtime DELAY_FOR_RETRY = HRTIME_MSECONDS(10);
3737

3838
TS_INLINE Event *
3939
EThread::schedule_imm(Continuation *cont, int callback_event, void *cookie)

iocore/eventsystem/UnixEThread.cc

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -254,7 +254,13 @@ EThread::execute_regular()
254254
next_time = EventQueue.earliest_timeout();
255255
ink_hrtime sleep_time = next_time - Thread::get_hrtime_updated();
256256
if (sleep_time > 0) {
257-
sleep_time = std::min(sleep_time, HRTIME_MSECONDS(thread_max_heartbeat_mseconds));
257+
if (EventQueueExternal.localQueue.empty()) {
258+
sleep_time = std::min(sleep_time, HRTIME_MSECONDS(thread_max_heartbeat_mseconds));
259+
} else {
260+
// Because of a missed lock, Timed-Event and Negative-Event have been pushed into localQueue for retry in awhile.
261+
// Therefore, we have to set the limitation of sleep time in order to handle the next retry in time.
262+
sleep_time = std::min(sleep_time, DELAY_FOR_RETRY);
263+
}
258264
++(current_metric->_wait);
259265
} else {
260266
sleep_time = 0;

0 commit comments

Comments
 (0)