]> git.rm.cloudns.org Git - xonotic/darkplaces.git/commitdiff
Crypto_LoadKeys: make the caller responsible for the mutex
authordivverent <divverent@d7cf8633-e32d-0410-b094-e92efae38249>
Tue, 1 Nov 2011 15:28:55 +0000 (15:28 +0000)
committerdivverent <divverent@d7cf8633-e32d-0410-b094-e92efae38249>
Tue, 1 Nov 2011 15:28:55 +0000 (15:28 +0000)
git-svn-id: svn://svn.icculus.org/twilight/trunk/darkplaces@11515 d7cf8633-e32d-0410-b094-e92efae38249

crypto.c
crypto.h
netconn.c

index ce1741822eee4e2504bc78f79da4b5f3bcdb84f4..09c164e2293240baf404a1138bc3759ae86ea4d6 100644 (file)
--- 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;
index 7b2b9921bca3c030b233834146beeeb0b2d60c87..7edfcd98a389af04ed25559a62de798ebb2fa851 100644 (file)
--- 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()
index 2e1e9adb47dab61c2d827d9afb8f9ca8776e43a9..843dc852d71fdadacfb8911ad63cfc4350101f3c 100755 (executable)
--- 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);