01-24-2015, 05:08 AM
I've run into a nasty race condition.
Say there's a network server listening, and it has active connections. Suddenly the server is stopped and deleted by the app. The connections are still alive, so it's possible that the sockets' callbacks will still be called in a second thread, while the first thread is destroying both the server and its attached links. Unfortunately LibEvent seems to provide very little to prevent this behavior - there is no way to wait for a reasonable "no event executing" state.
Say there's a network server listening, and it has active connections. Suddenly the server is stopped and deleted by the app. The connections are still alive, so it's possible that the sockets' callbacks will still be called in a second thread, while the first thread is destroying both the server and its attached links. Unfortunately LibEvent seems to provide very little to prevent this behavior - there is no way to wait for a reasonable "no event executing" state.