Skip to content

Commit 98f41e9

Browse files
oknetzwoop
authored andcommitted
Don't sleep if ProtectedQueue.localQueue is not empty. (#6234)
(cherry picked from commit aa5b2ea)
1 parent 9ebbd60 commit 98f41e9

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
@@ -264,7 +264,13 @@ EThread::execute_regular()
264264
next_time = EventQueue.earliest_timeout();
265265
ink_hrtime sleep_time = next_time - Thread::get_hrtime_updated();
266266
if (sleep_time > 0) {
267-
sleep_time = std::min(sleep_time, HRTIME_MSECONDS(thread_max_heartbeat_mseconds));
267+
if (EventQueueExternal.localQueue.empty()) {
268+
sleep_time = std::min(sleep_time, HRTIME_MSECONDS(thread_max_heartbeat_mseconds));
269+
} else {
270+
// Because of a missed lock, Timed-Event and Negative-Event have been pushed into localQueue for retry in awhile.
271+
// Therefore, we have to set the limitation of sleep time in order to handle the next retry in time.
272+
sleep_time = std::min(sleep_time, DELAY_FOR_RETRY);
273+
}
268274
++(current_metric->_wait);
269275
} else {
270276
sleep_time = 0;

0 commit comments

Comments
 (0)