From: divverent Date: Tue, 1 Nov 2011 15:28:55 +0000 (+0000) Subject: Crypto_LoadKeys: make the caller responsible for the mutex X-Git-Tag: xonotic-v0.6.0~163^2~42 X-Git-Url: https://git.rm.cloudns.org/?a=commitdiff_plain;h=2bbd12d7ca9db1247e4f6e10f4b78ea693c2d64a;p=xonotic%2Fdarkplaces.git Crypto_LoadKeys: make the caller responsible for the mutex git-svn-id: svn://svn.icculus.org/twilight/trunk/darkplaces@11515 d7cf8633-e32d-0410-b094-e92efae38249 --- diff --git a/crypto.c b/crypto.c index ce174182..09c164e2 100644 --- a/crypto.c +++ b/crypto.c @@ -778,8 +778,6 @@ void Crypto_LoadKeys(void) Host_LockSession(); // we use the session ID here - SV_LockThreadMutex(); - // load keys // note: we are just a CLIENT // so we load: @@ -874,16 +872,12 @@ void Crypto_LoadKeys(void) } if(crypto_keyfp_recommended_length < 7) crypto_keyfp_recommended_length = 7; - - SV_UnlockThreadMutex(); } static void Crypto_UnloadKeys(void) { int i; - SV_LockThreadMutex(); - keygen_i = -1; for(i = 0; i < MAX_PUBKEYS; ++i) { @@ -896,8 +890,6 @@ static void Crypto_UnloadKeys(void) challenge_append_length = 0; } crypto_idstring = NULL; - - SV_UnlockThreadMutex(); } static mempool_t *cryptomempool; diff --git a/crypto.h b/crypto.h index 7b2b9921..7edfcd98 100644 --- a/crypto.h +++ b/crypto.h @@ -31,7 +31,7 @@ crypto_t; void Crypto_Init(void); void Crypto_Init_Commands(void); -void Crypto_LoadKeys(void); +void Crypto_LoadKeys(void); // NOTE: when this is called, the SV_LockThreadMutex MUST be active void Crypto_Shutdown(void); qboolean Crypto_Available(void); void sha256(unsigned char *out, const unsigned char *in, int n); // may ONLY be called if Crypto_Available() diff --git a/netconn.c b/netconn.c index 2e1e9adb..843dc852 100755 --- a/netconn.c +++ b/netconn.c @@ -923,7 +923,9 @@ void NetConn_OpenClientPorts(void) int port; NetConn_CloseClientPorts(); + SV_LockThreadMutex(); // FIXME recursive? Crypto_LoadKeys(); // client sockets + SV_UnlockThreadMutex(); port = bound(0, cl_netport.integer, 65535); if (cl_netport.integer != port) @@ -991,7 +993,9 @@ void NetConn_OpenServerPorts(int opennetports) int port; NetConn_CloseServerPorts(); + SV_LockThreadMutex(); // FIXME recursive? Crypto_LoadKeys(); // server sockets + CSV_UnlockThreadMutex(); NetConn_UpdateSockets(); port = bound(0, sv_netport.integer, 65535);