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

Re: [Libevent-users] Event timeout after it has been freed



Am 27.06.2014 16:25, schrieb Nick Mathewson:
On Thu, Jun 26, 2014 at 11:18 AM, Robin <imer@xxxxxxx> wrote:
  [...]
Code..
You can find the Event timer thing here:
https://github.com/imermcmaps/m2t/tree/master/Server/shared/util
Basic Socket class:
https://github.com/imermcmaps/m2t/blob/master/Server/shared/net/Socket.cpp
The ping event is created here:
https://github.com/imermcmaps/m2t/blob/master/Server/game/net/socket/Client.cpp#L141
The codebase is still a bit messy, you should find everything related to the
network in either shared/net/ or game/net/

This is an odd thought -- but I believe it's possible for
Socket::OnEvent to get called with both BEV_EVENT_EOF and
BEV_EVENT_ERROR .  If that happens, your code will call
Socket::OnDisconnect twice, creating _two_ timer events for a
reconnect.  Could that be going on here?

Well, if it were called twice in a row the second time m_reconnect_event would be set
            if (m_reconnect_event) { // 2nd time
                if (m_reconnect_event->IsStarted()) { // will be started
                    sys_err("Reconnect event already running");
                    return; // and return
                } else {
                    m_reconnect_event->Start();
                }
            } else { // first run: create a new event ...
Not to mention the reconnect is only used for the connection to the cache, and I dont have any logs of that failing. Although, thanks for mentioning that, made me look over the code and improve some stuff. For one, the event would never get freed, so yeah. Thanks :)


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