mirror of
https://github.com/irungentoo/toxcore.git
synced 2024-03-22 13:30:51 +08:00
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).
This commit is contained in:
parent
2d0a21adb3
commit
461c8f51f5
|
@ -2450,15 +2450,15 @@ static void send_crypto_packets(Net_Crypto *c)
|
|||
Crypto_Connection *conn = get_crypto_connection(c, i);
|
||||
|
||||
if (conn == nullptr) {
|
||||
return;
|
||||
continue;
|
||||
}
|
||||
|
||||
if (CRYPTO_SEND_PACKET_INTERVAL + conn->temp_packet_sent_time < temp_time) {
|
||||
if ((CRYPTO_SEND_PACKET_INTERVAL + conn->temp_packet_sent_time) < temp_time) {
|
||||
send_temp_packet(c, i);
|
||||
}
|
||||
|
||||
if ((conn->status == CRYPTO_CONN_NOT_CONFIRMED || conn->status == CRYPTO_CONN_ESTABLISHED)
|
||||
&& ((CRYPTO_SEND_PACKET_INTERVAL) + conn->last_request_packet_sent) < temp_time) {
|
||||
&& (CRYPTO_SEND_PACKET_INTERVAL + conn->last_request_packet_sent) < temp_time) {
|
||||
if (send_request_packet(c, i) == 0) {
|
||||
conn->last_request_packet_sent = temp_time;
|
||||
}
|
||||
|
|
|
@ -62,7 +62,7 @@
|
|||
#define MAX_NUM_SENDPACKET_TRIES 8
|
||||
|
||||
/* The timeout of no received UDP packets before the direct UDP connection is considered dead. */
|
||||
#define UDP_DIRECT_TIMEOUT ((MAX_NUM_SENDPACKET_TRIES * CRYPTO_SEND_PACKET_INTERVAL) / 1000)
|
||||
#define UDP_DIRECT_TIMEOUT 8
|
||||
|
||||
#define PACKET_ID_PADDING 0 /* Denotes padding */
|
||||
#define PACKET_ID_REQUEST 1 /* Used to request unreceived packets */
|
||||
|
|
Loading…
Reference in New Issue
Block a user