From 25843bf141cedffefbf888034d6b50fbcba52319 Mon Sep 17 00:00:00 2001 From: irungentoo Date: Sat, 21 Nov 2015 10:05:39 -0500 Subject: [PATCH] More file transfer improvements. --- toxcore/net_crypto.c | 7 ++++++- toxcore/net_crypto.h | 2 +- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/toxcore/net_crypto.c b/toxcore/net_crypto.c index f29183ca..f08866aa 100644 --- a/toxcore/net_crypto.c +++ b/toxcore/net_crypto.c @@ -2235,7 +2235,12 @@ static void send_crypto_packets(Net_Crypto *c) total_resent += conn->last_num_packets_resent[ind]; } - total_sent -= sum; + if (sum > 0) { + total_sent -= sum; + } else { + if (total_resent > -sum) + total_resent = -sum; + } /* if queue is too big only allow resending packets. */ uint32_t npackets = num_packets_array(&conn->send_array); diff --git a/toxcore/net_crypto.h b/toxcore/net_crypto.h index 64caf9ad..715b6e3f 100644 --- a/toxcore/net_crypto.h +++ b/toxcore/net_crypto.h @@ -80,7 +80,7 @@ /* Base current transfer speed on last CONGESTION_QUEUE_ARRAY_SIZE number of points taken at the dT defined in net_crypto.c */ -#define CONGESTION_QUEUE_ARRAY_SIZE 24 +#define CONGESTION_QUEUE_ARRAY_SIZE 12 #define CONGESTION_LAST_SENT_ARRAY_SIZE (CONGESTION_QUEUE_ARRAY_SIZE * 2) /* Default connection ping in ms. */