diff options
author | Pavel Karelin <hkarel@yandex.ru> | 2018-05-15 09:57:07 +0300 |
---|---|---|
committer | Pavel Karelin <hkarel@yandex.ru> | 2018-05-23 17:32:18 +0300 |
commit | 461c8f51f5c7165884cb556443ba8950532b46eb (patch) | |
tree | 21988da8b9fe4001d8991b9fa881f1929830ba84 /toxcore | |
parent | 2d0a21adb3069140da5009d2caa41cc837e23202 (diff) |
Fix the often call of event tox_friend_connection_status
Fixes #868
Is made by:
1. Fix enumeration mechanism of Crypto_Connection instances in function send_crypto_packets()
(this item solves the main problem);
2. Disruption of correlation between parameters of different dimensions
(the parameters MAX_NUM_SENDPACKET_TRIES and UDP_DIRECT_TIMEOUT have different dimensions).
Diffstat (limited to 'toxcore')
-rw-r--r-- | toxcore/net_crypto.c | 6 | ||||
-rw-r--r-- | toxcore/net_crypto.h | 2 |
2 files changed, 4 insertions, 4 deletions
diff --git a/toxcore/net_crypto.c b/toxcore/net_crypto.c index 5477fea7..d8e0d459 100644 --- a/toxcore/net_crypto.c +++ b/toxcore/net_crypto.c | |||
@@ -2450,15 +2450,15 @@ static void send_crypto_packets(Net_Crypto *c) | |||
2450 | Crypto_Connection *conn = get_crypto_connection(c, i); | 2450 | Crypto_Connection *conn = get_crypto_connection(c, i); |
2451 | 2451 | ||
2452 | if (conn == nullptr) { | 2452 | if (conn == nullptr) { |
2453 | return; | 2453 | continue; |
2454 | } | 2454 | } |
2455 | 2455 | ||
2456 | if (CRYPTO_SEND_PACKET_INTERVAL + conn->temp_packet_sent_time < temp_time) { | 2456 | if ((CRYPTO_SEND_PACKET_INTERVAL + conn->temp_packet_sent_time) < temp_time) { |
2457 | send_temp_packet(c, i); | 2457 | send_temp_packet(c, i); |
2458 | } | 2458 | } |
2459 | 2459 | ||
2460 | if ((conn->status == CRYPTO_CONN_NOT_CONFIRMED || conn->status == CRYPTO_CONN_ESTABLISHED) | 2460 | if ((conn->status == CRYPTO_CONN_NOT_CONFIRMED || conn->status == CRYPTO_CONN_ESTABLISHED) |
2461 | && ((CRYPTO_SEND_PACKET_INTERVAL) + conn->last_request_packet_sent) < temp_time) { | 2461 | && (CRYPTO_SEND_PACKET_INTERVAL + conn->last_request_packet_sent) < temp_time) { |
2462 | if (send_request_packet(c, i) == 0) { | 2462 | if (send_request_packet(c, i) == 0) { |
2463 | conn->last_request_packet_sent = temp_time; | 2463 | conn->last_request_packet_sent = temp_time; |
2464 | } | 2464 | } |
diff --git a/toxcore/net_crypto.h b/toxcore/net_crypto.h index bd00a3fe..ec55bf6f 100644 --- a/toxcore/net_crypto.h +++ b/toxcore/net_crypto.h | |||
@@ -62,7 +62,7 @@ | |||
62 | #define MAX_NUM_SENDPACKET_TRIES 8 | 62 | #define MAX_NUM_SENDPACKET_TRIES 8 |
63 | 63 | ||
64 | /* The timeout of no received UDP packets before the direct UDP connection is considered dead. */ | 64 | /* The timeout of no received UDP packets before the direct UDP connection is considered dead. */ |
65 | #define UDP_DIRECT_TIMEOUT ((MAX_NUM_SENDPACKET_TRIES * CRYPTO_SEND_PACKET_INTERVAL) / 1000) | 65 | #define UDP_DIRECT_TIMEOUT 8 |
66 | 66 | ||
67 | #define PACKET_ID_PADDING 0 /* Denotes padding */ | 67 | #define PACKET_ID_PADDING 0 /* Denotes padding */ |
68 | #define PACKET_ID_REQUEST 1 /* Used to request unreceived packets */ | 68 | #define PACKET_ID_REQUEST 1 /* Used to request unreceived packets */ |