You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@trafficserver.apache.org by Dk Jack <dn...@gmail.com> on 2017/03/22 20:37:36 UTC

atscppapi: AsyncHttpFetch question

Hi,
In the file lib/atscppapi/examples/async_http_fetch/AsyncHttpFetch.cc,
there is this code:

-------------------------------------------------------------------------------------------------------
    // we'll add some custom headers for this request
    AsyncHttpFetch2 *provider2 = new AsyncHttpFetch2("http://127.0.0.1/");
    Headers &request_headers = provider2->getRequestHeaders();
    request_headers.set("Header1", "Value1");
    request_headers.set("Header2", "Value2");
    Async::execute<AsyncHttpFetch2>(this, provider2, getMutex());
---------------------------------------------------------------------------------------------------------

 what is the lifetime of 'provider2'? I am assuming plugin owner is
responsible for
freeing this object. If so, when can I destroy this object?

Is the handle return in handleAnyAsyncComplete the same as 'provider2'?
thanks.

Dk.

Re: atscppapi: AsyncHttpFetch question

Posted by Bryan Call <bc...@apache.org>.
Can you try putting a message in the destructor (as Alan suggested) or running it under gdb and setting a breakpoint?  Please file an issue if it is still a problem: https://github.com/apache/trafficserver/issues <https://github.com/apache/trafficserver/issues>

-Bryan

> On Mar 22, 2017, at 5:04 PM, Dk Jack <dn...@gmail.com> wrote:
> 
> Hi,
> The motivation for my question is because I am seeing a small leak in my
> module.
> My module periodically fetches data using the Async api. When I disable the
> periodic
> fetching I don't see a leak (I ensured there is none of my other code is
> running).
> I reduced my code base to fetch and forget. I still see the leak. The API
> documentation
> states that the memory would be freed and it doesn't seem to be happening.
> Any help is appreciated. Thanks.
> 
> Dk.
> 
> /**
> * @brief This class provides an implementation of AsyncProvider that
> * makes HTTP requests asynchronously. This provider automatically
> * self-destructs after the completion of the request.
> *
> * See example async_http_fetch{,_streaming} for sample usage.
> */
> class AsyncHttpFetch : public AsyncProvider
> {
> ...
> }
> 
> 
> On Wed, Mar 22, 2017 at 1:37 PM, Dk Jack <dn...@gmail.com> wrote:
> 
>> Hi,
>> In the file lib/atscppapi/examples/async_http_fetch/AsyncHttpFetch.cc,
>> there is this code:
>> 
>> ------------------------------------------------------------
>> -------------------------------------------
>>    // we'll add some custom headers for this request
>>    AsyncHttpFetch2 *provider2 = new AsyncHttpFetch2("http://127.0.0.1/");
>>    Headers &request_headers = provider2->getRequestHeaders();
>>    request_headers.set("Header1", "Value1");
>>    request_headers.set("Header2", "Value2");
>>    Async::execute<AsyncHttpFetch2>(this, provider2, getMutex());
>> ------------------------------------------------------------
>> ---------------------------------------------
>> 
>> what is the lifetime of 'provider2'? I am assuming plugin owner is
>> responsible for
>> freeing this object. If so, when can I destroy this object?
>> 
>> Is the handle return in handleAnyAsyncComplete the same as 'provider2'?
>> thanks.
>> 
>> Dk.
>> 
>> 
>> 


Re: atscppapi: AsyncHttpFetch question

Posted by "Alan M. Carroll" <am...@network-geographics.com>.
Yes, it looks like it should clean up after itself but apparently isn't. I'd try putting a debug message in the destructor and verify it at least is getting called. I haven't looked at that code myself unfortunately.

> Hi,
> The motivation for my question is because I am seeing a small leak in my
> module.
> My module periodically fetches data using the Async api. When I disable the
> periodic
> fetching I don't see a leak (I ensured there is none of my other code is
> running).
> I reduced my code base to fetch and forget. I still see the leak. The API
> documentation
> states that the memory would be freed and it doesn't seem to be happening.
> Any help is appreciated. Thanks.

> Dk.

> /**
>  * @brief This class provides an implementation of AsyncProvider that
>  * makes HTTP requests asynchronously. This provider automatically
>  * self-destructs after the completion of the request.
>  *
>  * See example async_http_fetch{,_streaming} for sample usage.
>  */
> class AsyncHttpFetch : public AsyncProvider
> {
> ...
> }


> On Wed, Mar 22, 2017 at 1:37 PM, Dk Jack <dn...@gmail.com> wrote:

>> Hi,
>> In the file lib/atscppapi/examples/async_http_fetch/AsyncHttpFetch.cc,
>> there is this code:
>>
>> ------------------------------------------------------------
>> -------------------------------------------
>>     // we'll add some custom headers for this request
>>     AsyncHttpFetch2 *provider2 = new AsyncHttpFetch2("http://127.0.0.1/");
>>     Headers &request_headers = provider2->getRequestHeaders();
>>     request_headers.set("Header1", "Value1");
>>     request_headers.set("Header2", "Value2");
>>     Async::execute<AsyncHttpFetch2>(this, provider2, getMutex());
>> ------------------------------------------------------------
>> ---------------------------------------------
>>
>>  what is the lifetime of 'provider2'? I am assuming plugin owner is
>> responsible for
>> freeing this object. If so, when can I destroy this object?
>>
>> Is the handle return in handleAnyAsyncComplete the same as 'provider2'?
>> thanks.
>>
>> Dk.
>>
>>
>>



Re: atscppapi: AsyncHttpFetch question

Posted by Dk Jack <dn...@gmail.com>.
Hi,
The motivation for my question is because I am seeing a small leak in my
module.
My module periodically fetches data using the Async api. When I disable the
periodic
fetching I don't see a leak (I ensured there is none of my other code is
running).
I reduced my code base to fetch and forget. I still see the leak. The API
documentation
states that the memory would be freed and it doesn't seem to be happening.
Any help is appreciated. Thanks.

Dk.

/**
 * @brief This class provides an implementation of AsyncProvider that
 * makes HTTP requests asynchronously. This provider automatically
 * self-destructs after the completion of the request.
 *
 * See example async_http_fetch{,_streaming} for sample usage.
 */
class AsyncHttpFetch : public AsyncProvider
{
...
}


On Wed, Mar 22, 2017 at 1:37 PM, Dk Jack <dn...@gmail.com> wrote:

> Hi,
> In the file lib/atscppapi/examples/async_http_fetch/AsyncHttpFetch.cc,
> there is this code:
>
> ------------------------------------------------------------
> -------------------------------------------
>     // we'll add some custom headers for this request
>     AsyncHttpFetch2 *provider2 = new AsyncHttpFetch2("http://127.0.0.1/");
>     Headers &request_headers = provider2->getRequestHeaders();
>     request_headers.set("Header1", "Value1");
>     request_headers.set("Header2", "Value2");
>     Async::execute<AsyncHttpFetch2>(this, provider2, getMutex());
> ------------------------------------------------------------
> ---------------------------------------------
>
>  what is the lifetime of 'provider2'? I am assuming plugin owner is
> responsible for
> freeing this object. If so, when can I destroy this object?
>
> Is the handle return in handleAnyAsyncComplete the same as 'provider2'?
> thanks.
>
> Dk.
>
>
>