[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]

Re: [Libevent-users] Event loop not exiting when freeing bufferevent



On Wed, Dec 23, 2009 at 03:13:02PM +0100, Bas Verhoeven wrote:
> Hi,
> 
> Me again!
> 
> I was wondering. The documentation says that the libevent loop exits 
> when there are no events left to process. For some reason my event loop 
> keeps running tho, even after I've disabled the bufferevent and have 
> freed it.
> 
> My bufferevent is created with the 'BEV_OPT_CLOSE_ON_FREE' flag.
> 
> I'm calling the following snippet of code when I receive an event with 
> the BEV_EVENT_EOF flag set:
> 
>  printf("Connection lost, freeing bufferevent..\n");
>  bufferevent_disable(client->event, EV_READ|EV_WRITE);
>  bufferevent_free(client->event);
> 
> That seems to work fine (no errors occur, bufferevent_disable() returns 
> 0 and I can see the printf), but libevent keeps looping. Shouldn't it 
> have stopped because I closed the last bufferevent? I've tried without 
> the '_disable' initially, but no changes there.

It's supposed to work like that, yes.  My guess would be that either
there's a bug in your code, or that you've found a bug in Libevent.

To narrow it down, can you write a short test program that displays
the problematic behavior?  I've tried to do one myself, but I can't
get the behavior you're seeing: for me, disabling the last bufferevent
does indeed exit the loop.

yrs,
-- 
Nick
***********************************************************************
To unsubscribe, send an e-mail to majordomo@xxxxxxxxxxxxx with
unsubscribe libevent-users    in the body.