summaryrefslogtreecommitdiff
path: root/toxcore/net_crypto.c
diff options
context:
space:
mode:
Diffstat (limited to 'toxcore/net_crypto.c')
-rw-r--r--toxcore/net_crypto.c15
1 files changed, 9 insertions, 6 deletions
diff --git a/toxcore/net_crypto.c b/toxcore/net_crypto.c
index f57886a8..3ed46a99 100644
--- a/toxcore/net_crypto.c
+++ b/toxcore/net_crypto.c
@@ -617,7 +617,8 @@ static IP_Port return_ip_port_connection(Net_Crypto *c, int crypt_connection_id)
617 } 617 }
618 618
619 const uint64_t current_time = mono_time_get(c->mono_time); 619 const uint64_t current_time = mono_time_get(c->mono_time);
620 bool v6 = 0, v4 = 0; 620 bool v6 = 0;
621 bool v4 = 0;
621 622
622 if ((UDP_DIRECT_TIMEOUT + conn->direct_lastrecv_timev4) > current_time) { 623 if ((UDP_DIRECT_TIMEOUT + conn->direct_lastrecv_timev4) > current_time) {
623 v4 = 1; 624 v4 = 1;
@@ -932,9 +933,9 @@ static int generate_request_packet(const Logger *log, uint8_t *data, uint16_t le
932 return cur_len; 933 return cur_len;
933 } 934 }
934 935
935 uint32_t i, n = 1; 936 uint32_t n = 1;
936 937
937 for (i = recv_array->buffer_start; i != recv_array->buffer_end; ++i) { 938 for (uint32_t i = recv_array->buffer_start; i != recv_array->buffer_end; ++i) {
938 uint32_t num = i % CRYPTO_PACKET_BUFFER_SIZE; 939 uint32_t num = i % CRYPTO_PACKET_BUFFER_SIZE;
939 940
940 if (!recv_array->buffer[num]) { 941 if (!recv_array->buffer[num]) {
@@ -1290,9 +1291,10 @@ static int send_requested_packets(Net_Crypto *c, int crypt_connection_id, uint32
1290 } 1291 }
1291 1292
1292 const uint64_t temp_time = current_time_monotonic(c->mono_time); 1293 const uint64_t temp_time = current_time_monotonic(c->mono_time);
1293 uint32_t i, num_sent = 0, array_size = num_packets_array(&conn->send_array); 1294 const uint32_t array_size = num_packets_array(&conn->send_array);
1295 uint32_t num_sent = 0;
1294 1296
1295 for (i = 0; i < array_size; ++i) { 1297 for (uint32_t i = 0; i < array_size; ++i) {
1296 Packet_Data *dt; 1298 Packet_Data *dt;
1297 const uint32_t packet_num = i + conn->send_array.buffer_start; 1299 const uint32_t packet_num = i + conn->send_array.buffer_start;
1298 const int ret = get_data_pointer(c->log, &conn->send_array, &dt, packet_num); 1300 const int ret = get_data_pointer(c->log, &conn->send_array, &dt, packet_num);
@@ -2586,7 +2588,8 @@ static void send_crypto_packets(Net_Crypto *c)
2586 2588
2587 /* When switching from TCP to UDP, don't change the packet send rate for CONGESTION_EVENT_TIMEOUT ms. */ 2589 /* When switching from TCP to UDP, don't change the packet send rate for CONGESTION_EVENT_TIMEOUT ms. */
2588 if (!(direct_connected && conn->last_tcp_sent + CONGESTION_EVENT_TIMEOUT > temp_time)) { 2590 if (!(direct_connected && conn->last_tcp_sent + CONGESTION_EVENT_TIMEOUT > temp_time)) {
2589 long signed int total_sent = 0, total_resent = 0; 2591 long signed int total_sent = 0;
2592 long signed int total_resent = 0;
2590 2593
2591 // TODO(irungentoo): use real delay 2594 // TODO(irungentoo): use real delay
2592 unsigned int delay = (unsigned int)((conn->rtt_time / PACKET_COUNTER_AVERAGE_INTERVAL) + 0.5); 2595 unsigned int delay = (unsigned int)((conn->rtt_time / PACKET_COUNTER_AVERAGE_INTERVAL) + 0.5);