facing an issue with writing transform plugin

classic Classic list List threaded Threaded
5 messages Options
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

facing an issue with writing transform plugin

Gaurav Bansal
hi all,
We are writing a transform plugin where we keep on sending the data to the client (after performing some checks) as and when it is received from the server. When the transaction is finished, we call the below api :
TSContCall(TSVIOContGet(write_vio), TS_EVENT_VCONN_WRITE_COMPLETE, write_vio);

Using this api, we expect the hook-transform (similar to bnull_transform here) function to get called with TS_EVENT_VCONN_WRITE_COMPLETE event and connection getting closed because of code shown below (our code here is same as bnull-transform code pasted below) :

bnull_transform(TSCont contp, TSEvent event, void *edata ATS_UNUSED)
{
....
    switch (event) {
....
    case TS_EVENT_VCONN_WRITE_COMPLETE:

      TSVConnShutdown(TSTransformOutputVConnGet(contp), 0, 1);
      break;


But somehow the hook-transform function is getting called with TS_EVENT_VCONN_WRITE_READY event (though we called the api with the write-complete event). Can anyone please let me know what might be the reason for this ? What can be done to avoid it ? Is there any other way to close the connection rather than sending the write-complete event ?

thanks,
gaurav  
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: facing an issue with writing transform plugin

Brian Geffon-2
The C++ API is a good reference for writing transformation plugins.

Brian

On Sun, Jul 2, 2017, 20:49 Gaurav Bansal <[hidden email]> wrote:
hi all,
We are writing a transform plugin where we keep on sending the data to the client (after performing some checks) as and when it is received from the server. When the transaction is finished, we call the below api :
TSContCall(TSVIOContGet(write_vio), TS_EVENT_VCONN_WRITE_COMPLETE, write_vio);

Using this api, we expect the hook-transform (similar to bnull_transform here) function to get called with TS_EVENT_VCONN_WRITE_COMPLETE event and connection getting closed because of code shown below (our code here is same as bnull-transform code pasted below) :

bnull_transform(TSCont contp, TSEvent event, void *edata ATS_UNUSED)
{
....
    switch (event) {
....
    case TS_EVENT_VCONN_WRITE_COMPLETE:

      TSVConnShutdown(TSTransformOutputVConnGet(contp), 0, 1);
      break;


But somehow the hook-transform function is getting called with TS_EVENT_VCONN_WRITE_READY event (though we called the api with the write-complete event). Can anyone please let me know what might be the reason for this ? What can be done to avoid it ? Is there any other way to close the connection rather than sending the write-complete event ?

thanks,
gaurav  
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: facing an issue with writing transform plugin

Nick Kew
In reply to this post by Gaurav Bansal
On Mon, 2017-07-03 at 09:19 +0530, Gaurav Bansal wrote:
>  When the transaction is finished, we call the below api :
> TSContCall(TSVIOContGet(write_vio), TS_EVENT_VCONN_WRITE_COMPLETE,
> write_vio);

Is it possible your downstream is still expecting more data?
You might want to be sure you've got it right by setting
NBytes on your VIO at this point.

--
Nick Kew


Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: facing an issue with writing transform plugin

Gaurav Bansal
Thanks Nick for the reply. I am using following code but still the behaviour remains the same :

if (!data->output_vio) {
    data->output_vio = TSVConnWrite(TSTransformOutputVConnGet(contp), contp, data->output_reader, TSVIONBytesGet(write_vio));
    TSVIONBytesSet(data->output_vio, TSVIONBytesGet(write_vio));
}

The above code is used, when we have just got the first packet from the upstream (server-side) connection & no data has yet been sent to the client. And as and when we keep getting packets, we keep on sending them to the client (after performing some checks) using the following api :

TSVConnWrite(TSTransformOutputVConnGet(contp), contp, data->output_reader, data->content_length);

Still we don't get any TS_EVENT_VCONN_WRITE_COMPLETE event. Any idea on what might be going wrong ? What else can be tried ?

On Mon, Jul 3, 2017 at 1:32 PM, Nick Kew <[hidden email]> wrote:
On Mon, 2017-07-03 at 09:19 +0530, Gaurav Bansal wrote:
>  When the transaction is finished, we call the below api :
> TSContCall(TSVIOContGet(write_vio), TS_EVENT_VCONN_WRITE_COMPLETE,
> write_vio);

Is it possible your downstream is still expecting more data?
You might want to be sure you've got it right by setting
NBytes on your VIO at this point.

--
Nick Kew



Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: facing an issue with writing transform plugin

Gaurav Bansal
Can anyone please let us know if there are any issues in calling the 'TSVConnWrite' api multiple times (with 4th argument equal to content length) as i pointed in my previous reply ?

On Tue, Jul 4, 2017 at 9:43 AM, Gaurav Bansal <[hidden email]> wrote:
Thanks Nick for the reply. I am using following code but still the behaviour remains the same :

if (!data->output_vio) {
    data->output_vio = TSVConnWrite(TSTransformOutputVConnGet(contp), contp, data->output_reader, TSVIONBytesGet(write_vio));
    TSVIONBytesSet(data->output_vio, TSVIONBytesGet(write_vio));
}

The above code is used, when we have just got the first packet from the upstream (server-side) connection & no data has yet been sent to the client. And as and when we keep getting packets, we keep on sending them to the client (after performing some checks) using the following api :

TSVConnWrite(TSTransformOutputVConnGet(contp), contp, data->output_reader, data->content_length);

Still we don't get any TS_EVENT_VCONN_WRITE_COMPLETE event. Any idea on what might be going wrong ? What else can be tried ?

On Mon, Jul 3, 2017 at 1:32 PM, Nick Kew <[hidden email]> wrote:
On Mon, 2017-07-03 at 09:19 +0530, Gaurav Bansal wrote:
>  When the transaction is finished, we call the below api :
> TSContCall(TSVIOContGet(write_vio), TS_EVENT_VCONN_WRITE_COMPLETE,
> write_vio);

Is it possible your downstream is still expecting more data?
You might want to be sure you've got it right by setting
NBytes on your VIO at this point.

--
Nick Kew




Loading...