You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@trafficserver.apache.org by deepak srinivasan <sd...@gmail.com> on 2013/03/12 13:36:57 UTC

Issue with VConn close

Hi All,

I am trying to implement cache write using plugin cache.

After the null transfrom has made a cont call for event
TS_EVENT_VCONN_WRITE_COMPLETE, I try to
do cache write.
In order to handle these cases I create a queue of cache data. I check if
the
queue has data in a infinite running thread(threadcacheWrite), created
using TSThreadCreate. If It has, I create a cont for cache write
and perform cache write(TSCacheWrite).
After the cache write is complete I close the VConn.
However the the closed vconn instead of calling the same
function(cacheHandler), it calls null_transform function.
This function is again called when the null_transform vconn is also closed.
Also the data passed to null_transform function is same in both the cases.

Can anybody suggest me why the cache vconn is going to null transform
handler.
I checked this by using function (TSVConnClosedGet) and printing cont data.
The cont data printed is same in both the cases.
Due to this I am unable to free the Cont and it is resulting in memory
leaks.

I have also attached sample code in two files for the reference.

Am I missing something

Regards

Re: Issue with VConn close

Posted by deepak srinivasan <sd...@gmail.com>.
Hi Alan,

Thanks for the reply.

I guess by chunk you mean a request to origin server.
I dont get it why I will get two VConn close events due to chunks not
consistent in size. I think they will only impact performace of read/write.

Code Logic:-
I have created a thread function for read/write/remove from cache.(i.e
total 3 threads)
I have presented one of the function
threadcacheWrite(CacheHandler.cpp).This function runs in infinite loop.
In each loop I check if there is a data in queue, I pop the data. I then
create a cont and set the data retrieved from queue.
Then I make a call to TSCacheWrite.

Events for TS_EVENT_CACHE_OPEN_WRITE and TS_EVENT_VCONN_WRITE_COMPLETE are
getting called correctly as expected.
But for event TS_EVENT_IMMEDIATE generated by VConn Close goes to
null_transform instead of calling cacheHandler.
Also the cont data which i observe is of null_transform.

For populating the data for reading and writing, I perform the following
operations-
I get the queue(stl queue) using function getWriteCacheQueue. I then push
the cache data object using push function call(Line 30 in NullTransform)
After the object is pushed in the queue, I wait for the signal using
pthread_cond_wait. To wake the main thread, I send the signal from the
function
which I send from cacheHandler.

Similary are the calls for threadcacheRead and threadcacheRemove.

I didn't understand your comment regarding the chaining of events. How can
I handle those in my code.

It will be great if you help in fixing this issue.

Regards,

Re: Issue with VConn close

Posted by deepak srinivasan <sd...@gmail.com>.
Hi Alan,

Thanks for the reply.

I guess by chunk you mean a request to origin server.
I dont get it why I will get two VConn close events due to chunks not
consistent in size. I think they will only impact performace of read/write.

Code Logic:-
I have created a thread function for read/write/remove from cache.(i.e
total 3 threads)
I have presented one of the function
threadcacheWrite(CacheHandler.cpp).This function runs in infinite loop.
In each loop I check if there is a data in queue, I pop the data. I then
create a cont and set the data retrieved from queue.
Then I make a call to TSCacheWrite.

Events for TS_EVENT_CACHE_OPEN_WRITE and TS_EVENT_VCONN_WRITE_COMPLETE are
getting called correctly as expected.
But for event TS_EVENT_IMMEDIATE generated by VConn Close goes to
null_transform instead of calling cacheHandler.
Also the cont data which i observe is of null_transform.

For populating the data for reading and writing, I perform the following
operations-
I get the queue(stl queue) using function getWriteCacheQueue. I then push
the cache data object using push function call(Line 30 in NullTransform)
After the object is pushed in the queue, I wait for the signal using
pthread_cond_wait. To wake the main thread, I send the signal from the
function
which I send from cacheHandler.

Similary are the calls for threadcacheRead and threadcacheRemove.

I didn't understand your comment regarding the chaining of events. How can
I handle those in my code.

It will be great if you help in fixing this issue.

Regards,

Re: Issue with VConn close

Posted by "Alan M. Carroll" <am...@network-geographics.com>.
I don't see where in the code the cacheHandler is called. I would also note that you are calling handle_transform for every chunk of data that passes through the null transform - hopefully you realize those chunks are not consistent in size, and non-reliably repeatable between runs.

The event system uses a lot of chaining, where events are passed from VC to VC in the flow chain. When the cache writer is closed, the event is passed on to the transform VC. Sometimes this is done via scheduling but it can also happen through direct calls so that it appears as if the null transform event handler is called from the cache writer VC, which although technically true is done through event system intermediaries.

Tuesday, March 12, 2013, 7:36:57 AM, you wrote:

> Hi All,


> I am trying to implement cache write using plugin cache.


> After the null transfrom has made a cont call for event TS_EVENT_VCONN_WRITE_COMPLETE, I try to
> do cache write.
> In order to handle these cases I create a queue of cache data. I check if the
> queue has data in a infinite running thread(threadcacheWrite), created using TSThreadCreate. If It has, I create a cont for cache write
> and perform cache write(TSCacheWrite).
> After the cache write is complete I close the VConn.
> However the the closed vconn instead of calling the same function(cacheHandler), it calls null_transform function.
> This function is again called when the null_transform vconn is also closed.
> Also the data passed to null_transform function is same in both the cases.


> Can anybody suggest me why the cache vconn is going to null transform handler.
> I checked this by using function (TSVConnClosedGet) and printing cont data.
> The cont data printed is same in both the cases.
> Due to this I am unable to free the Cont and it is resulting in memory leaks.


> I have also attached sample code in two files for the reference.


> Am I missing something


> Regards