This is an automated email from the ASF dual-hosted git repository.
zwoop pushed a commit to branch 8.1.x
in repository https://gitbox.apache.org/repos/asf/trafficserver.git
The following commit(s) were added to refs/heads/8.1.x by this push:
new 46b6310 Don't sleep if ProtectedQueue.localQueue is not empty. (#6234)
46b6310 is described below
commit 46b63106c79daf420472685213088a9e3260388f
Author: Oknet Xu <[email protected]>
AuthorDate: Wed Nov 27 22:28:33 2019 +0800
Don't sleep if ProtectedQueue.localQueue is not empty. (#6234)
(cherry picked from commit aa5b2eafda2667621f443b455829ce3b5c3be0b0)
---
iocore/eventsystem/P_UnixEThread.h | 2 +-
iocore/eventsystem/UnixEThread.cc | 8 +++++++-
2 files changed, 8 insertions(+), 2 deletions(-)
diff --git a/iocore/eventsystem/P_UnixEThread.h
b/iocore/eventsystem/P_UnixEThread.h
index 9328c3b..45931e6 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 225d81f..137a063 100644
--- a/iocore/eventsystem/UnixEThread.cc
+++ b/iocore/eventsystem/UnixEThread.cc
@@ -259,7 +259,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;