Discussion:
facing an issue with writing transform plugin
Gaurav Bansal
2017-07-03 03:49:43 UTC
Permalink
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
Brian Geffon
2017-07-03 04:47:09 UTC
Permalink
The C++ API is a good reference for writing transformation plugins.

Brian
Post by 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
*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
*bnull_transform(TSCont contp, TSEvent event, void *edata
ATS_UNUSED){.... switch (event) {.... case
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
Nick Kew
2017-07-03 08:02:26 UTC
Permalink
Post by Gaurav Bansal
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
Gaurav Bansal
2017-07-04 04:13:13 UTC
Permalink
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 ?
Post by Nick Kew
Post by Gaurav Bansal
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
Gaurav Bansal
2017-07-04 10:00:14 UTC
Permalink
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 ?
Post by Gaurav Bansal
Thanks Nick for the reply. I am using following code but still the
*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
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 ?
Post by Nick Kew
Post by Gaurav Bansal
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...