You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@trafficserver.apache.org by Walt Karas <wk...@oath.com.INVALID> on 2018/12/13 00:54:49 UTC

TSHttpHookAdd() thread safety

The documentation says that TS API functionTSHttpHookAdd() is _typically_
called from TSPluginInit() or TSRemapInit().  The implementation of
TSHttpHookAdd() doesn't look thread-safe, so how could it be called
anywhere else?

Re: TSHttpHookAdd() thread safety

Posted by Walt Karas <wk...@oath.com.INVALID>.
Nevermind, I think I see now that the continuations on a hook are
serialized.  Submitted https://github.com/apache/trafficserver/pull/4707
since this unused code got me confused.

On Thu, Dec 13, 2018 at 2:35 PM Walt Karas <wk...@oath.com> wrote:

> Can anyone explain the mutual exclusion mechanism when different plugins
> call TSHttpTxnHookAdd() for the same hook on the same transaction?
>
> On Thu, Dec 13, 2018 at 12:15 PM xuchao@Gmail <xu...@gmail.com> wrote:
>
>> yes!
>>
>> The TSHttpHookAdd() should _only_ and _always_ be
>> called from TSPluginInit() or TSRemapInit().
>>
>> - oknet
>>
>> 发自我的 iPhone
>>
>> > 在 2018年12月13日,23:42,Walt Karas <wk...@oath.com.INVALID> 写道:
>> >
>> > TSHttpHookAdd() should _only_ be
>> > called from TSPluginInit() or TSRemapInit().
>>
>

Re: TSHttpHookAdd() thread safety

Posted by Walt Karas <wk...@oath.com.INVALID>.
Can anyone explain the mutual exclusion mechanism when different plugins
call TSHttpTxnHookAdd() for the same hook on the same transaction?

On Thu, Dec 13, 2018 at 12:15 PM xuchao@Gmail <xu...@gmail.com> wrote:

> yes!
>
> The TSHttpHookAdd() should _only_ and _always_ be
> called from TSPluginInit() or TSRemapInit().
>
> - oknet
>
> 发自我的 iPhone
>
> > 在 2018年12月13日,23:42,Walt Karas <wk...@oath.com.INVALID> 写道:
> >
> > TSHttpHookAdd() should _only_ be
> > called from TSPluginInit() or TSRemapInit().
>

Re: TSHttpHookAdd() thread safety

Posted by "xuchao@Gmail" <xu...@gmail.com>.
yes!

The TSHttpHookAdd() should _only_ and _always_ be
called from TSPluginInit() or TSRemapInit(). 

- oknet

发自我的 iPhone

> 在 2018年12月13日,23:42,Walt Karas <wk...@oath.com.INVALID> 写道:
> 
> TSHttpHookAdd() should _only_ be
> called from TSPluginInit() or TSRemapInit().

Re: TSHttpHookAdd() thread safety

Posted by Walt Karas <wk...@oath.com.INVALID>.
Chao Xu it seems you are saying that TSHttpHookAdd() should _only_ be
called from TSPluginInit() or TSRemapInit().  Which would mean that the
documentation is incorrect in implying that there are some cases where it
should be called later.

On Thu, Dec 13, 2018 at 3:14 AM Chao Xu <ok...@apache.org> wrote:

> The plugins are loaded and initialized within Main.cc by calling
> plugin_init() one by one.
>
> The global hooks list is initialized before any http port / service is
> ready to serve.
>
>  There is no thread issue because all the threads are blocked for
> incoming events.
>
> - oknet
> Walt Karas <wk...@oath.com.invalid> 于2018年12月13日周四 上午9:20写道:
> >
> > I don't understand your and answer Leif.  You can't possibly call those
> > function from TSPluginInit() or TSRemapInit().
> >
> > On Wed, Dec 12, 2018 at 7:01 PM Leif Hedstrom <zw...@apache.org> wrote:
> >
> > >
> > >
> > > > On Dec 12, 2018, at 4:54 PM, Walt Karas <wk...@oath.com.INVALID>
> wrote:
> > > >
> > > > The documentation says that TS API functionTSHttpHookAdd() is
> _typically_
> > > > called from TSPluginInit() or TSRemapInit().  The implementation of
> > > > TSHttpHookAdd() doesn't look thread-safe, so how could it be called
> > > > anywhere else?
> > >
> > >
> > > I don’t think you would. For TXN or SSN continuations, you use
> > >
> > >         tsapi void TSHttpSsnHookAdd(TSHttpSsn ssnp, TSHttpHookID id,
> > > TSCont contp);
> > >         tsapi void TSHttpTxnHookAdd(TSHttpTxn txnp, TSHttpHookID id,
> > > TSCont contp);
> > >
> > >
> > > — Leif
> > >
> > >
>
>
>
> --
> - Oknet Xu
>

Re: TSHttpHookAdd() thread safety

Posted by Chao Xu <ok...@apache.org>.
The plugins are loaded and initialized within Main.cc by calling
plugin_init() one by one.

The global hooks list is initialized before any http port / service is
ready to serve.

 There is no thread issue because all the threads are blocked for
incoming events.

- oknet
Walt Karas <wk...@oath.com.invalid> 于2018年12月13日周四 上午9:20写道:
>
> I don't understand your and answer Leif.  You can't possibly call those
> function from TSPluginInit() or TSRemapInit().
>
> On Wed, Dec 12, 2018 at 7:01 PM Leif Hedstrom <zw...@apache.org> wrote:
>
> >
> >
> > > On Dec 12, 2018, at 4:54 PM, Walt Karas <wk...@oath.com.INVALID> wrote:
> > >
> > > The documentation says that TS API functionTSHttpHookAdd() is _typically_
> > > called from TSPluginInit() or TSRemapInit().  The implementation of
> > > TSHttpHookAdd() doesn't look thread-safe, so how could it be called
> > > anywhere else?
> >
> >
> > I don’t think you would. For TXN or SSN continuations, you use
> >
> >         tsapi void TSHttpSsnHookAdd(TSHttpSsn ssnp, TSHttpHookID id,
> > TSCont contp);
> >         tsapi void TSHttpTxnHookAdd(TSHttpTxn txnp, TSHttpHookID id,
> > TSCont contp);
> >
> >
> > — Leif
> >
> >



-- 
- Oknet Xu

Re: TSHttpHookAdd() thread safety

Posted by Walt Karas <wk...@oath.com.INVALID>.
I don't understand your and answer Leif.  You can't possibly call those
function from TSPluginInit() or TSRemapInit().

On Wed, Dec 12, 2018 at 7:01 PM Leif Hedstrom <zw...@apache.org> wrote:

>
>
> > On Dec 12, 2018, at 4:54 PM, Walt Karas <wk...@oath.com.INVALID> wrote:
> >
> > The documentation says that TS API functionTSHttpHookAdd() is _typically_
> > called from TSPluginInit() or TSRemapInit().  The implementation of
> > TSHttpHookAdd() doesn't look thread-safe, so how could it be called
> > anywhere else?
>
>
> I don’t think you would. For TXN or SSN continuations, you use
>
>         tsapi void TSHttpSsnHookAdd(TSHttpSsn ssnp, TSHttpHookID id,
> TSCont contp);
>         tsapi void TSHttpTxnHookAdd(TSHttpTxn txnp, TSHttpHookID id,
> TSCont contp);
>
>
> — Leif
>
>

Re: TSHttpHookAdd() thread safety

Posted by Leif Hedstrom <zw...@apache.org>.

> On Dec 12, 2018, at 4:54 PM, Walt Karas <wk...@oath.com.INVALID> wrote:
> 
> The documentation says that TS API functionTSHttpHookAdd() is _typically_
> called from TSPluginInit() or TSRemapInit().  The implementation of
> TSHttpHookAdd() doesn't look thread-safe, so how could it be called
> anywhere else?


I don’t think you would. For TXN or SSN continuations, you use

	tsapi void TSHttpSsnHookAdd(TSHttpSsn ssnp, TSHttpHookID id, TSCont contp);
	tsapi void TSHttpTxnHookAdd(TSHttpTxn txnp, TSHttpHookID id, TSCont contp);


— Leif