diff options
author | notsecure <notsecure@marek.ca> | 2014-07-11 10:23:40 -0400 |
---|---|---|
committer | notsecure <notsecure@marek.ca> | 2014-07-11 10:23:40 -0400 |
commit | a5d2775c2570121c34a13d248662adb5c4770f9b (patch) | |
tree | 17161ec4bf940a538ed084a0cba1d551682e3714 /toxcore | |
parent | a754cb543733f3dddf2d7ff305fd9b1868e4b733 (diff) |
.
Diffstat (limited to 'toxcore')
-rw-r--r-- | toxcore/net_crypto.c | 17 |
1 files changed, 4 insertions, 13 deletions
diff --git a/toxcore/net_crypto.c b/toxcore/net_crypto.c index bc22a23e..7c0dd77b 100644 --- a/toxcore/net_crypto.c +++ b/toxcore/net_crypto.c | |||
@@ -2252,19 +2252,9 @@ static void send_crypto_packets(Net_Crypto *c) | |||
2252 | 2252 | ||
2253 | /* additional step: adjust the send rate based on the size change of the send queue */ | 2253 | /* additional step: adjust the send rate based on the size change of the send queue */ |
2254 | uint32_t queue_size = num_packets_array(&conn->send_array); | 2254 | uint32_t queue_size = num_packets_array(&conn->send_array); |
2255 | if(queue_size > conn->last_queue_size + 100) { | 2255 | if(queue_size > conn->packet_send_rate && queue_size > conn->last_queue_size) { |
2256 | double v1 = (double)(conn->packets_sent) / (double)(queue_size); | 2256 | conn->rate_increase = 0; |
2257 | double v2 = (double)(conn->last_packets_sent) / (double)(conn->last_queue_size == 0 ? 1 : conn->last_queue_size); | 2257 | conn->packets_resent = conn->packets_sent; |
2258 | if(v1 < v2) { | ||
2259 | conn->packets_resent = conn->packets_sent; | ||
2260 | conn->rate_increase = 0; | ||
2261 | } | ||
2262 | |||
2263 | conn->last_queue_size = queue_size; | ||
2264 | conn->last_packets_sent = conn->packets_sent; | ||
2265 | } else if(queue_size < conn->last_queue_size) { | ||
2266 | conn->last_queue_size = queue_size; | ||
2267 | conn->last_packets_sent = conn->packets_sent; | ||
2268 | } | 2258 | } |
2269 | 2259 | ||
2270 | 2260 | ||
@@ -2326,6 +2316,7 @@ static void send_crypto_packets(Net_Crypto *c) | |||
2326 | conn->dropped = dropped; | 2316 | conn->dropped = dropped; |
2327 | conn->drop_ignore = drop_ignore_new; | 2317 | conn->drop_ignore = drop_ignore_new; |
2328 | conn->packets_resent = 0; | 2318 | conn->packets_resent = 0; |
2319 | conn->last_queue_size = queue_size; | ||
2329 | 2320 | ||
2330 | if (conn->packet_send_rate < CRYPTO_PACKET_MIN_RATE || !conn->sending || !conn->packets_sent) { | 2321 | if (conn->packet_send_rate < CRYPTO_PACKET_MIN_RATE || !conn->sending || !conn->packets_sent) { |
2331 | conn->rate_increase = 0; | 2322 | conn->rate_increase = 0; |