diff options
author | sudden6 <sudden6@gmx.at> | 2019-09-07 01:57:51 +0200 |
---|---|---|
committer | sudden6 <sudden6@gmx.at> | 2019-12-25 14:56:43 +0100 |
commit | 393a6be5c401e8e788d51f4c6e25f9937428360e (patch) | |
tree | 4aa726ce3e07e68983f1a8132e939d53362419b6 /toxcore | |
parent | 6338cb46ad99dbc2806976aefabbf2e98476ebda (diff) |
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.
Diffstat (limited to 'toxcore')
-rw-r--r-- | toxcore/net_crypto.c | 23 |
1 files changed, 11 insertions, 12 deletions
diff --git a/toxcore/net_crypto.c b/toxcore/net_crypto.c index da525a1f..01dd680e 100644 --- a/toxcore/net_crypto.c +++ b/toxcore/net_crypto.c | |||
@@ -1486,7 +1486,18 @@ static void connection_kill(Net_Crypto *c, int crypt_connection_id, void *userda | |||
1486 | userdata); | 1486 | userdata); |
1487 | } | 1487 | } |
1488 | 1488 | ||
1489 | while (1) { /* TODO(irungentoo): is this really the best way to do this? */ | ||
1490 | pthread_mutex_lock(&c->connections_mutex); | ||
1491 | |||
1492 | if (!c->connection_use_counter) { | ||
1493 | break; | ||
1494 | } | ||
1495 | |||
1496 | pthread_mutex_unlock(&c->connections_mutex); | ||
1497 | } | ||
1498 | |||
1489 | crypto_kill(c, crypt_connection_id); | 1499 | crypto_kill(c, crypt_connection_id); |
1500 | pthread_mutex_unlock(&c->connections_mutex); | ||
1490 | } | 1501 | } |
1491 | 1502 | ||
1492 | /* Handle a received data packet. | 1503 | /* Handle a received data packet. |
@@ -2889,16 +2900,6 @@ int send_lossy_cryptpacket(Net_Crypto *c, int crypt_connection_id, const uint8_t | |||
2889 | */ | 2900 | */ |
2890 | int crypto_kill(Net_Crypto *c, int crypt_connection_id) | 2901 | int crypto_kill(Net_Crypto *c, int crypt_connection_id) |
2891 | { | 2902 | { |
2892 | while (1) { /* TODO(irungentoo): is this really the best way to do this? */ | ||
2893 | pthread_mutex_lock(&c->connections_mutex); | ||
2894 | |||
2895 | if (!c->connection_use_counter) { | ||
2896 | break; | ||
2897 | } | ||
2898 | |||
2899 | pthread_mutex_unlock(&c->connections_mutex); | ||
2900 | } | ||
2901 | |||
2902 | Crypto_Connection *conn = get_crypto_connection(c, crypt_connection_id); | 2903 | Crypto_Connection *conn = get_crypto_connection(c, crypt_connection_id); |
2903 | 2904 | ||
2904 | int ret = -1; | 2905 | int ret = -1; |
@@ -2920,8 +2921,6 @@ int crypto_kill(Net_Crypto *c, int crypt_connection_id) | |||
2920 | ret = wipe_crypto_connection(c, crypt_connection_id); | 2921 | ret = wipe_crypto_connection(c, crypt_connection_id); |
2921 | } | 2922 | } |
2922 | 2923 | ||
2923 | pthread_mutex_unlock(&c->connections_mutex); | ||
2924 | |||
2925 | return ret; | 2924 | return ret; |
2926 | } | 2925 | } |
2927 | 2926 | ||