[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]
[Libevent-users] Re: question about evhttp_connection_free
Sorry there was some mistake in the dummy code
The code should be
http_request_done_callback(struct evhttp_request *req, void *arg)
{
if (req->evcon != NULL)
evhttp_connection_free(req->evcon);
}
request_function()
{
struct evhttp_connection *evcon = NULL;
struct evhttp_request *req = NULL;
evcon = evhttp_connection_base_new (u->eb, NULL, server_name, server_port);
evhttp_connection_set_timeout (evcon, 30);
evhttp_connection_set_retries (evcon, 5);
req = evhttp_request_new (http_request_done_callback, NULL);
if (evhttp_make_request (evcon, req, EVHTTP_REQ_GET, uri) == -1)
{
evhttp_connection_free (hco->evcon);
}
}
2010/10/28 Han LIU <cn.liuhan@xxxxxxxxx>:
> hi mate
> I have a question on evhttp_connection_free function.
> Should i call evhttp_connection_free function manually in the
> http_request_done call back?
> here is some dummy code for this situation
>
> http_request_done_callback(struct evhttp_request *req, void *arg)
> {
> if (req->evcon != NULL)
> evhttp_connection_free(req->evcon);
> }
>
> request_function()
> {
> struct evhttp_connection *evcon = NULL;
> struct evhttp_request *req = NULL;
> evcon = evhttp_connection_base_new (u->eb, NULL, server_name, server_port);
>
> evhttp_connection_set_timeout (evcon, 30);
> evhttp_connection_set_retries (evcon, 5);
>
> req = evhttp_request_new (sendmessage_http_request_done, NULL);
>
> if (evhttp_make_request (evcon, req, EVHTTP_REQ_GET, uri) == -1)
> {
> evhttp_connection_free (hco->evcon);
> }
> }
>
> thanks in advance
>
***********************************************************************
To unsubscribe, send an e-mail to majordomo@xxxxxxxxxxxxx with
unsubscribe libevent-users in the body.