[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]
Re: [Libevent-users] event shutdown/cleanup
On Wed, Jan 30, 2013 at 7:38 PM, John Dunn <John_Dunn@xxxxxxxxxxxx> wrote:
> I have a socket server which allocates memory for each connection. If there's an error on the socket it's easy for me to delete any memory associated with the connection. I also need to shutdown the eventbase from another thread which needs to close the listener socket, close all currently open connections and delete all memory associated with each connection.
>
> If I call event_base_loopbreak and event_base_free to shutdown my event loop the loop breaks but it doesn't close any outstanding connections or give me a chance to delete memory associated with each connection. I am setting BEV_OPT_CLOSE_ON_FREE so I assume that the issue is that the bufferedevents are not getting freed when the event_base is. Is there any libevent functionality that would help or do I need to maintain a parallel data structure of current connections so I can call event_free() on each of them? event_base_foreach_event seems almost like the correct thing but the documentation explicitly says to not modify the events - I'm guessing that includes calling event_free().
>
Right; there is no global list of all allocated bufferevents. If you
need a way to walk over all bufferevents, you'll need to implement one
yourself. It's generally not hard -- just create a linked list of
them in whatever associated data structure you're giving them.
--
Nick
***********************************************************************
To unsubscribe, send an e-mail to majordomo@xxxxxxxxxxxxx with
unsubscribe libevent-users in the body.