You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@trafficserver.apache.org by oksana fishman <ok...@gmail.com> on 2012/08/01 12:21:17 UTC

How to pass data between two different plugins?

In the same plugin this is done by TSContDataGet / TSContDataSet
How to set data in some plugin, so that anythe plugin can get the data (in
a later stage) ?

Re: How to pass data between two different plugins?

Posted by Igor Galić <i....@brainsware.org>.

----- Original Message -----
> In plugin A init:
> 
> TSHttpArgIndexReserve("shared_state_foo", "shared state data",
> &txn_slot);
> 
> In plugin B init:
> 
> TSHttpArgIndexNameLookup("shared_state_foo", &txn_slot,
> &description);
> 
> Now both plugins have the same value in their txn_slot. A must be
> init
> before B or perhaps do the lookup in a handler instead. Then you can
> use:
> 
> TSHttpTxnArgSet(TSHttpTxn txnp, int arg_idx, void* arg);
> TSHttpTxnArgGet(TSHttpTxn txnp, int arg_idx);
> 
> To get and set the data per transaction. Use a mutex where
> appropriate. There are also equivalent Ssn functions for dealing with
> sessions instead of transactions. The same ArgReserve and
> ArgNameLookup are used for both transactions and sessions.

Phil, thank you very much.

For anyone wondering if this is included in the
docs, check http://trafficserver.apache.org/docs/trunk/sdk/

if you would like to contribute patches to these docs

https://svn.apache.org/repos/asf/trafficserver/site/trunk/content/docs/trunk/sdk


> On Wed, Aug 1, 2012 at 9:48 AM, oksana fishman
> <ok...@gmail.com> wrote:
> > Thank you for quick response.
> > Could you give a specific example?
> > I use TSContDataGet / TSContDataSet , and it doesn't work when
> > using two
> > plugins.
> >
> >
> > On Wed, Aug 1, 2012 at 4:29 PM, Leif Hedstrom <zw...@apache.org>
> > wrote:
> >
> >> On Aug 1, 2012, at 4:21 AM, oksana fishman
> >> <ok...@gmail.com>
> >> wrote:
> >>
> >> > In the same plugin this is done by TSContDataGet / TSContDataSet
> >> > How to set data in some plugin, so that anythe plugin can get
> >> > the data
> >> (in
> >> > a later stage) ?
> >>
> >>
> >> Look for the APIs to set/get Txn and Ssn data.
> >>
> >> -- Leif
> 

-- 
Igor Galić

Tel: +43 (0) 664 886 22 883
Mail: i.galic@brainsware.org
URL: http://brainsware.org/
GPG: 6880 4155 74BD FD7C B515  2EA5 4B1D 9E08 A097 C9AE


Re: How to pass data between two different plugins?

Posted by Phil Sorber <ph...@omniti.com>.
In plugin A init:

TSHttpArgIndexReserve("shared_state_foo", "shared state data", &txn_slot);

In plugin B init:

TSHttpArgIndexNameLookup("shared_state_foo", &txn_slot, &description);

Now both plugins have the same value in their txn_slot. A must be init
before B or perhaps do the lookup in a handler instead. Then you can
use:

TSHttpTxnArgSet(TSHttpTxn txnp, int arg_idx, void* arg);
TSHttpTxnArgGet(TSHttpTxn txnp, int arg_idx);

To get and set the data per transaction. Use a mutex where
appropriate. There are also equivalent Ssn functions for dealing with
sessions instead of transactions. The same ArgReserve and
ArgNameLookup are used for both transactions and sessions.

On Wed, Aug 1, 2012 at 9:48 AM, oksana fishman
<ok...@gmail.com> wrote:
> Thank you for quick response.
> Could you give a specific example?
> I use TSContDataGet / TSContDataSet , and it doesn't work when using two
> plugins.
>
>
> On Wed, Aug 1, 2012 at 4:29 PM, Leif Hedstrom <zw...@apache.org> wrote:
>
>> On Aug 1, 2012, at 4:21 AM, oksana fishman <ok...@gmail.com>
>> wrote:
>>
>> > In the same plugin this is done by TSContDataGet / TSContDataSet
>> > How to set data in some plugin, so that anythe plugin can get the data
>> (in
>> > a later stage) ?
>>
>>
>> Look for the APIs to set/get Txn and Ssn data.
>>
>> -- Leif

Re: How to pass data between two different plugins?

Posted by oksana fishman <ok...@gmail.com>.
Thank you for quick response.
Could you give a specific example?
I use TSContDataGet / TSContDataSet , and it doesn't work when using two
plugins.


On Wed, Aug 1, 2012 at 4:29 PM, Leif Hedstrom <zw...@apache.org> wrote:

> On Aug 1, 2012, at 4:21 AM, oksana fishman <ok...@gmail.com>
> wrote:
>
> > In the same plugin this is done by TSContDataGet / TSContDataSet
> > How to set data in some plugin, so that anythe plugin can get the data
> (in
> > a later stage) ?
>
>
> Look for the APIs to set/get Txn and Ssn data.
>
> -- Leif

Re: How to pass data between two different plugins?

Posted by Leif Hedstrom <zw...@apache.org>.
On Aug 1, 2012, at 4:21 AM, oksana fishman <ok...@gmail.com> wrote:

> In the same plugin this is done by TSContDataGet / TSContDataSet
> How to set data in some plugin, so that anythe plugin can get the data (in
> a later stage) ?


Look for the APIs to set/get Txn and Ssn data.

-- Leif