mirror of
https://github.com/irungentoo/toxcore.git
synced 2024-03-22 13:30:51 +08:00
don't wait for connection when killing Tox
When tox_kill is called no other thread should be running anymore so this locking is not needed there.
This commit is contained in:
parent
6338cb46ad
commit
393a6be5c4
|
@ -1486,7 +1486,18 @@ static void connection_kill(Net_Crypto *c, int crypt_connection_id, void *userda
|
|||
userdata);
|
||||
}
|
||||
|
||||
while (1) { /* TODO(irungentoo): is this really the best way to do this? */
|
||||
pthread_mutex_lock(&c->connections_mutex);
|
||||
|
||||
if (!c->connection_use_counter) {
|
||||
break;
|
||||
}
|
||||
|
||||
pthread_mutex_unlock(&c->connections_mutex);
|
||||
}
|
||||
|
||||
crypto_kill(c, crypt_connection_id);
|
||||
pthread_mutex_unlock(&c->connections_mutex);
|
||||
}
|
||||
|
||||
/* Handle a received data packet.
|
||||
|
@ -2889,16 +2900,6 @@ int send_lossy_cryptpacket(Net_Crypto *c, int crypt_connection_id, const uint8_t
|
|||
*/
|
||||
int crypto_kill(Net_Crypto *c, int crypt_connection_id)
|
||||
{
|
||||
while (1) { /* TODO(irungentoo): is this really the best way to do this? */
|
||||
pthread_mutex_lock(&c->connections_mutex);
|
||||
|
||||
if (!c->connection_use_counter) {
|
||||
break;
|
||||
}
|
||||
|
||||
pthread_mutex_unlock(&c->connections_mutex);
|
||||
}
|
||||
|
||||
Crypto_Connection *conn = get_crypto_connection(c, crypt_connection_id);
|
||||
|
||||
int ret = -1;
|
||||
|
@ -2920,8 +2921,6 @@ int crypto_kill(Net_Crypto *c, int crypt_connection_id)
|
|||
ret = wipe_crypto_connection(c, crypt_connection_id);
|
||||
}
|
||||
|
||||
pthread_mutex_unlock(&c->connections_mutex);
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue
Block a user