1
0

Added network termination called at app exit.

This fixes a crash in MSVC runtime caused by joining a thread in a global var's destructor.
This commit is contained in:
Mattes D
2015-01-26 14:46:20 +01:00
parent 9a2200f8bb
commit 053362e604
6 changed files with 91 additions and 18 deletions

View File

@@ -4,7 +4,8 @@
// Declares the cNetworkSingleton class representing the storage for global data pertaining to network API
// such as a list of all connections, all listening sockets and the LibEvent dispatch thread.
// This is an internal header, no-one outside OSSupport should need to include it; use Network.h instead
// This is an internal header, no-one outside OSSupport should need to include it; use Network.h instead;
// the only exception being the main app entrypoint that needs to call Terminate before quitting.
@@ -48,6 +49,11 @@ public:
/** Returns the singleton instance of this class */
static cNetworkSingleton & Get(void);
/** Terminates all network-related threads.
To be used only on app shutdown.
MSVC runtime requires that the LibEvent networking be shut down before the main() function is exitted; this is the way to do it. */
void Terminate(void);
/** Returns the main LibEvent handle for event registering. */
event_base * GetEventBase(void) { return m_EventBase; }
@@ -113,6 +119,9 @@ protected:
/** Event that gets signalled when the event loop terminates. */
cEvent m_EventLoopTerminated;
/** Set to true if Terminate has been called. */
volatile bool m_HasTerminated;
/** Initializes the LibEvent internals. */
cNetworkSingleton(void);