[
https://issues.apache.org/jira/browse/TS-4387?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=15259253#comment-15259253
]
Shen Zhang commented on TS-4387:
--------------------------------
[~jamespeach]
I'll first talk a little about backgroud:
In ATS 5.x, at the same position I added FORCE_PLUGIN_SCOPED_MUTEX(contp) in
this pull request, we had FORCE_PLUGIN_MUTEX(contp); this macro check at this
point, if the TSCont doesn't have a mutex, create one.
In ATS 6.x, macro FORCE_PLUGIN_MUTEX() is replaced by
FORCE_PLUGIN_SCOPED_MUTEX() which basically just an assert() to make sure the
TSCont has the mutex.
So my pull request is basically restores previous behavior.
===========================
Then to answer your question, look at the code below:
EThread::schedule(Event *e, bool fast_signal)
{
e->ethread = this;
ink_assert(tt == REGULAR);
if (e->continuation->mutex)
e->mutex = e->continuation->mutex; <- second time
calling
else
e->mutex = e->continuation->mutex = e->ethread->mutex; <- first time
calling
ink_assert(e->mutex.m_ptr);
EventQueueExternal.enqueue(e, fast_signal);
return e;
}
say I call TSHttpSchedule() with TSCont A (and A doesn't have a mutex), its
calling chain will create a Event A, assign a thread A; while calling this
function, e->continuation->mutex is NULL, so "e->mutex = e->continuation->mutex
= e->ethread->mutex" is executed.
now EventA's mutex = TSContA's mutex = thread A's mutex
Then the second time I call TSHttpSchedule() with TSCont A, its calling chain
will create a Event B, assign a thread B;
while calling this function, e->continuation->mutex is NOT NULL, so "e->mutex =
e->continuation->mutex;" is executed.
now EventB's mutex = TSContA's mutex (which actually is EventA's mutex)
Now EventA and EventB use a same mutex; however, they are totally separate
event, no any relationship.
> Add enforcement of TSCont having MUTEX when passed to
> TSContSchedule()/TSContScheduleEvery()
> --------------------------------------------------------------------------------------------
>
> Key: TS-4387
> URL: https://issues.apache.org/jira/browse/TS-4387
> Project: Traffic Server
> Issue Type: Bug
> Reporter: Shen Zhang
>
> When calling TSContSchedule()/TSContScheduleEvery(), the passed in parameter
> TSCont have to have MUTEX; otherwise if we call
> TSContSchedule()/TSContScheduleEvery() more than once using same TSCont, only
> the first call will take effect; all the following schedule are ignored due
> to MUTEX issue.
--
This message was sent by Atlassian JIRA
(v6.3.4#6332)