diff options
Diffstat (limited to 'toxcore/net_crypto.c')
-rw-r--r-- | toxcore/net_crypto.c | 10 |
1 files changed, 7 insertions, 3 deletions
diff --git a/toxcore/net_crypto.c b/toxcore/net_crypto.c index 43468b73..707b675d 100644 --- a/toxcore/net_crypto.c +++ b/toxcore/net_crypto.c | |||
@@ -936,7 +936,7 @@ static int send_request_packet(Net_Crypto *c, int crypt_connection_id) | |||
936 | * return -1 on failure. | 936 | * return -1 on failure. |
937 | * return number of packets sent on success. | 937 | * return number of packets sent on success. |
938 | */ | 938 | */ |
939 | static int send_requested_packets(Net_Crypto *c, int crypt_connection_id, uint16_t max_num) | 939 | static int send_requested_packets(Net_Crypto *c, int crypt_connection_id, uint32_t max_num) |
940 | { | 940 | { |
941 | if (max_num == 0) | 941 | if (max_num == 0) |
942 | return -1; | 942 | return -1; |
@@ -2094,10 +2094,14 @@ static void send_crypto_packets(Net_Crypto *c) | |||
2094 | conn->last_packets_left_set = temp_time; | 2094 | conn->last_packets_left_set = temp_time; |
2095 | } | 2095 | } |
2096 | 2096 | ||
2097 | int ret = send_requested_packets(c, i, conn->packets_left); | 2097 | int ret = send_requested_packets(c, i, ~0); |
2098 | 2098 | ||
2099 | if (ret != -1) { | 2099 | if (ret != -1) { |
2100 | conn->packets_left -= ret; | 2100 | if (ret < conn->packets_left) { |
2101 | conn->packets_left -= ret; | ||
2102 | } else { | ||
2103 | conn->packets_left = 0; | ||
2104 | } | ||
2101 | } | 2105 | } |
2102 | 2106 | ||
2103 | if (conn->packet_send_rate > CRYPTO_PACKET_MIN_RATE * 1.5) { | 2107 | if (conn->packet_send_rate > CRYPTO_PACKET_MIN_RATE * 1.5) { |