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

Re: [Libevent-users] Recommended way of notifying all active sessions



On Fri, Aug 10, 2012 at 11:42 AM, Chernyshev Vyacheslav <astellar@xxxxx> wrote:
> Hello. I bet that this question was already asked a couple of times, but… What is the right way to execute some action for all currently registered descriptors? Let imagine that I have a lot of active client sessions that must save some state to DB when socket is closed and that I use buffered events to handle network IO. Everything is fine when connection is closed from client side. In this case assigned event callback is called. But what should I do at application shutdown (for example due to received signal)?
>
> Currently I maintain a separate mapping from socket descriptor to connection specific data, that is properly updated when new connections are opened and/or current connections are closed. This way I have an up-to-date list of active sessions at application shutdown

Generally, if I'm going to need to iterate over all of the active
(sessions/events/whatever) in an application, I do in fact keep them
in a linked list of some kind.


>. But it does not seem right, as I'm essentially duplicating a part of information that is already stored by event_base. How would you solve this problem? Thanks in advance.

  Internally, libevent has the ability to iterate over all events, but
it doesn't have any list of buferevents it can iterate over.

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