diff options
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 | ||