This is an automated email from the ASF dual-hosted git repository.
duke8253 pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/trafficserver.git
The following commit(s) were added to refs/heads/master by this push:
new 3340005 set thread affinity to current thread if the current thread
type is the same as the target thread
3340005 is described below
commit 33400052698c0c8bd1787654171173bf8bbcfcd6
Author: Fei Deng <[email protected]>
AuthorDate: Thu Feb 28 15:24:56 2019 -0600
set thread affinity to current thread if the current thread type is the
same as the target thread
---
iocore/eventsystem/P_UnixEventProcessor.h | 10 ++++++++--
tests/gold_tests/cont_schedule/gold/schedule_on_pool.gold | 3 +--
tests/tools/plugins/cont_schedule.cc | 8 ++++----
3 files changed, 13 insertions(+), 8 deletions(-)
diff --git a/iocore/eventsystem/P_UnixEventProcessor.h
b/iocore/eventsystem/P_UnixEventProcessor.h
index 003d425..b4dea2e 100644
--- a/iocore/eventsystem/P_UnixEventProcessor.h
+++ b/iocore/eventsystem/P_UnixEventProcessor.h
@@ -70,8 +70,14 @@ EventProcessor::schedule(Event *e, EventType etype, bool
fast_signal)
if (ethread != nullptr && ethread->is_event_type(etype)) {
e->ethread = ethread;
} else {
- e->ethread = assign_thread(etype);
- if (ethread == nullptr) {
+ ethread = this_ethread();
+ // Is the current thread eligible?
+ if (ethread != nullptr && ethread->is_event_type(etype)) {
+ e->ethread = ethread;
+ } else {
+ e->ethread = assign_thread(etype);
+ }
+ if (e->continuation->getThreadAffinity() == nullptr) {
e->continuation->setThreadAffinity(e->ethread);
}
}
diff --git a/tests/gold_tests/cont_schedule/gold/schedule_on_pool.gold
b/tests/gold_tests/cont_schedule/gold/schedule_on_pool.gold
index 42328e0..df9cf85 100644
--- a/tests/gold_tests/cont_schedule/gold/schedule_on_pool.gold
+++ b/tests/gold_tests/cont_schedule/gold/schedule_on_pool.gold
@@ -3,7 +3,6 @@
``ET_NET``TSContScheduleOnPool handler 1``
``(TSContSchedule_test.check) pass [should not be the same thread]
``ET_TASK``TSContScheduleOnPool handler 2``
-``(TSContSchedule_test.check) pass [should not be the same thread]
``ET_TASK``TSContScheduleOnPool handler 2``
-``(TSContSchedule_test.check) pass [should not be the same thread]
+``(TSContSchedule_test.check) pass [should be the same thread]
``
diff --git a/tests/tools/plugins/cont_schedule.cc
b/tests/tools/plugins/cont_schedule.cc
index abc8066..e678029 100644
--- a/tests/tools/plugins/cont_schedule.cc
+++ b/tests/tools/plugins/cont_schedule.cc
@@ -103,7 +103,7 @@ TSContScheduleOnPool_handler_1(TSCont contp, TSEvent event,
void *edata)
} else {
TSDebug(DEBUG_TAG_CHK, "fail [on the same thread]");
}
- check_thread = TSThreadSelf();
+ check_thread = nullptr;
}
return 0;
}
@@ -115,10 +115,10 @@ TSContScheduleOnPool_handler_2(TSCont contp, TSEvent
event, void *edata)
if (check_thread == nullptr) {
check_thread = TSThreadSelf();
} else {
- if (check_thread != TSThreadSelf()) {
- TSDebug(DEBUG_TAG_CHK, "pass [should not be the same thread]");
+ if (check_thread == TSThreadSelf()) {
+ TSDebug(DEBUG_TAG_CHK, "pass [should be the same thread]");
} else {
- TSDebug(DEBUG_TAG_CHK, "fail [on the same thread]");
+ TSDebug(DEBUG_TAG_CHK, "fail [not the same thread]");
}
check_thread = TSThreadSelf();
}