Why not cleanup directly in evhttp_detect_close_cb? Is there any danger in 
doing it there (just started to look at libevent yesterday so not sure if I am 
missing anything)?
Actually a cleaner would be probably to call evhttp_connection_fail() -

static void
evhttp_detect_close_cb(int fd, short what, void *arg)
{     
  printf("evhttp_detect_close_cb\n");
  struct evhttp_connection *evcon = arg;
  evhttp_connection_fail(evcon, EVCON_HTTP_EOF);                     <<<<<<<<
}

This seems to be working for me although I am not doing anything else other 
then bunch of POSTs to the server so not sure if this would be safe in general 
case.

Thx

Peter Vajgel


> -----Original Message-----
> From: majek04 [mailto:[EMAIL PROTECTED]
> Sent: Tuesday, December 09, 2008 4:09 PM
> To: Peter Vajgel
> Cc: libevent-users@monkey.org
> Subject: Re: [Libevent-users] http requests not freed by evhttp on
> client timeout
> 
> On Tue, Dec 9, 2008 at 21:53, Peter Vajgel <[EMAIL PROTECTED]> wrote:
> > The evhttp_write event never gets called and the requests on this
> connection
> > never get freed. What happens instead is that in a very short time we
> run
> > out of memory, the system starts to swap out and the server is
> unresponsive.
> 
> I have the same issue. There is definetely a memory leak at evhttp when
> connectins is broken. It's easy to spot it using valgrind.
> 
> As a workaround I free the structure by hand.
> 
> To acheive this in routine called by
>     libevent.evhttp_connection_set_closecb
> I schedule callback to be executed in 1ms.
> In this callback I run
>     libevent.evhttp_connection_free
> 
> Cheers
>   Marek Majkowski
_______________________________________________
Libevent-users mailing list
Libevent-users@monkey.org
http://monkeymail.org/mailman/listinfo/libevent-users

Reply via email to