This is an automated email from the ASF dual-hosted git repository.
bcall 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 1b5c6fc fix a segfault on mac
1b5c6fc is described below
commit 1b5c6fc454fe9b1a939313cecaf17ebb2f80fcb3
Author: Fei Deng <[email protected]>
AuthorDate: Mon Jan 28 11:07:16 2019 -0600
fix a segfault on mac
---
iocore/eventsystem/I_Continuation.h | 2 +-
iocore/eventsystem/P_Thread.h | 2 +-
iocore/eventsystem/P_UnixEThread.h | 2 +-
src/traffic_server/InkAPI.cc | 20 ++++++++++++++++++--
4 files changed, 21 insertions(+), 5 deletions(-)
diff --git a/iocore/eventsystem/I_Continuation.h
b/iocore/eventsystem/I_Continuation.h
index abb1d7d..a7cceb6 100644
--- a/iocore/eventsystem/I_Continuation.h
+++ b/iocore/eventsystem/I_Continuation.h
@@ -145,7 +145,7 @@ public:
*/
ContFlags control_flags;
- EThread *thread_affinity = this_event_thread();
+ EThread *thread_affinity = nullptr;
bool
setThreadAffinity(EThread *ethread)
diff --git a/iocore/eventsystem/P_Thread.h b/iocore/eventsystem/P_Thread.h
index 6e2a907..f303004 100644
--- a/iocore/eventsystem/P_Thread.h
+++ b/iocore/eventsystem/P_Thread.h
@@ -45,5 +45,5 @@ Thread::set_specific()
TS_INLINE Thread *
this_thread()
{
- return (Thread *)ink_thread_getspecific(Thread::thread_data_key);
+ return static_cast<Thread
*>(ink_thread_getspecific(Thread::thread_data_key));
}
diff --git a/iocore/eventsystem/P_UnixEThread.h
b/iocore/eventsystem/P_UnixEThread.h
index 042757b..cccda6b 100644
--- a/iocore/eventsystem/P_UnixEThread.h
+++ b/iocore/eventsystem/P_UnixEThread.h
@@ -176,7 +176,7 @@ EThread::schedule_spawn(Continuation *c, int ev, void
*cookie)
TS_INLINE EThread *
this_ethread()
{
- return (EThread *)this_thread();
+ return dynamic_cast<EThread *>(this_thread());
}
TS_INLINE EThread *
diff --git a/src/traffic_server/InkAPI.cc b/src/traffic_server/InkAPI.cc
index 55a8c13..b7c540f 100644
--- a/src/traffic_server/InkAPI.cc
+++ b/src/traffic_server/InkAPI.cc
@@ -4413,7 +4413,8 @@ TSContSchedule(TSCont contp, TSHRTime timeout)
EThread *eth = i->getThreadAffinity();
if (eth == nullptr) {
- return nullptr;
+ eth = this_event_thread();
+ i->setThreadAffinity(eth);
}
TSAction action;
@@ -4441,6 +4442,10 @@ TSContScheduleOnPool(TSCont contp, TSHRTime timeout,
TSThreadPool tp)
ink_assert(!"not reached");
}
+ if (i->getThreadAffinity() == nullptr) {
+ i->setThreadAffinity(this_event_thread());
+ }
+
EventType etype;
switch (tp) {
@@ -4495,6 +4500,9 @@ TSContScheduleOnThread(TSCont contp, TSHRTime timeout,
TSEventThread ethread)
}
EThread *eth = reinterpret_cast<EThread *>(ethread);
+ if (i->getThreadAffinity() == nullptr) {
+ i->setThreadAffinity(eth);
+ }
TSAction action;
if (timeout == 0) {
@@ -4523,7 +4531,8 @@ TSContScheduleEvery(TSCont contp, TSHRTime every /*
millisecs */)
EThread *eth = i->getThreadAffinity();
if (eth == nullptr) {
- return nullptr;
+ eth = this_event_thread();
+ i->setThreadAffinity(eth);
}
TSAction action = reinterpret_cast<TSAction>(eth->schedule_every(i,
HRTIME_MSECONDS(every)));
@@ -4546,6 +4555,10 @@ TSContScheduleEveryOnPool(TSCont contp, TSHRTime every,
TSThreadPool tp)
ink_assert(!"not reached");
}
+ if (i->getThreadAffinity() == nullptr) {
+ i->setThreadAffinity(this_event_thread());
+ }
+
EventType etype;
switch (tp) {
@@ -4583,6 +4596,9 @@ TSContScheduleEveryOnThread(TSCont contp, TSHRTime every
/* millisecs */, TSEven
}
EThread *eth = reinterpret_cast<EThread *>(ethread);
+ if (i->getThreadAffinity() == nullptr) {
+ i->setThreadAffinity(eth);
+ }
TSAction action = reinterpret_cast<TSAction>(eth->schedule_every(i,
HRTIME_MSECONDS(every)));