From 4eecaf3ee623c2c16567212e8767752ca868d28f Mon Sep 17 00:00:00 2001 From: irungentoo Date: Mon, 2 Jun 2014 19:35:49 -0400 Subject: [PATCH] Increased some timeouts to try to prevent disconnections when transferring files on wireless networks. --- toxcore/Messenger.h | 2 +- toxcore/net_crypto.c | 2 +- toxcore/net_crypto.h | 3 +++ 3 files changed, 5 insertions(+), 2 deletions(-) diff --git a/toxcore/Messenger.h b/toxcore/Messenger.h index 222bf3e49..51d5c73b8 100644 --- a/toxcore/Messenger.h +++ b/toxcore/Messenger.h @@ -96,7 +96,7 @@ enum { #define FRIEND_SHARE_RELAYS_INTERVAL (5 * 60) /* If no packets are received from friend in this time interval, kill the connection. */ -#define FRIEND_CONNECTION_TIMEOUT (FRIEND_PING_INTERVAL * 2) +#define FRIEND_CONNECTION_TIMEOUT (FRIEND_PING_INTERVAL * 3) /* USERSTATUS - diff --git a/toxcore/net_crypto.c b/toxcore/net_crypto.c index b29184e25..033f494b4 100644 --- a/toxcore/net_crypto.c +++ b/toxcore/net_crypto.c @@ -2427,7 +2427,7 @@ unsigned int crypto_connection_status(Net_Crypto *c, int crypt_connection_id, ui *direct_connected = 0; - if ((CRYPTO_SEND_PACKET_INTERVAL * MAX_NUM_SENDPACKET_TRIES + conn->direct_lastrecv_time) > current_time_monotonic()) + if ((UDP_DIRECT_TIMEOUT + conn->direct_lastrecv_time) > current_time_monotonic()) *direct_connected = 1; return conn->status; diff --git a/toxcore/net_crypto.h b/toxcore/net_crypto.h index 054dbb5dd..ebbfb8d30 100644 --- a/toxcore/net_crypto.h +++ b/toxcore/net_crypto.h @@ -55,6 +55,9 @@ before giving up. */ #define MAX_NUM_SENDPACKET_TRIES 8 +/* The timeout of no recieved UDP packets before the direct UDP connection is considered dead. */ +#define UDP_DIRECT_TIMEOUT (MAX_NUM_SENDPACKET_TRIES * CRYPTO_SEND_PACKET_INTERVAL * 2) + #define PACKET_ID_PADDING 0 #define PACKET_ID_REQUEST 1 #define PACKET_ID_KILL 2