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:
sudden6 2019-09-07 01:57:51 +02:00
parent 6338cb46ad
commit 393a6be5c4
No known key found for this signature in database
GPG Key ID: 279509B499E032B9

View File

@ -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;
}