You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Please correct me if I'm wrong, but if I stop my Client's connection to a server and switch to another server very quickly essentially calling Client.Stop() and then Client.Start() right after the OnPeerDisconnect Event is fired I will receive an error on line 919 that the _netEventsQueue is already equal to zero.
I haven't fully figured it out, but I'm guessing that I still have some events in the queue, thus I'm in that while loop. Then another thread of mine is calling Start() since I've processed the Disconnect event. Now the _netEventsQueue has been cleared while being processed since I called Start().
Currently my trigger for switching servers is having a thread wait for the client to receive the disconnected event and then connect to the next server, but it seems like I may in fact need to wait until all events have been processed, not just the disconnect. Either that, or their should be a lock around _netEventsQueue.Clear() in Start().
Any suggestions?
The text was updated successfully, but these errors were encountered:
GitFlip
changed the title
Clearing _netEventsQueue in Start not entirely safe
Clearing _netEventsQueue in NetManager.Start() not entirely threadsafe
Jan 12, 2018
LiteNetLib/LiteNetLib/NetManager.cs
Line 919 in 438e1cb
Please correct me if I'm wrong, but if I stop my Client's connection to a server and switch to another server very quickly essentially calling Client.Stop() and then Client.Start() right after the OnPeerDisconnect Event is fired I will receive an error on line 919 that the _netEventsQueue is already equal to zero.
I haven't fully figured it out, but I'm guessing that I still have some events in the queue, thus I'm in that while loop. Then another thread of mine is calling Start() since I've processed the Disconnect event. Now the _netEventsQueue has been cleared while being processed since I called Start().
Currently my trigger for switching servers is having a thread wait for the client to receive the disconnected event and then connect to the next server, but it seems like I may in fact need to wait until all events have been processed, not just the disconnect. Either that, or their should be a lock around _netEventsQueue.Clear() in Start().
Any suggestions?
The text was updated successfully, but these errors were encountered: