summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--toxcore/Lossless_UDP.c16
-rw-r--r--toxcore/network.c4
2 files changed, 10 insertions, 10 deletions
diff --git a/toxcore/Lossless_UDP.c b/toxcore/Lossless_UDP.c
index 79ee32c3..ca8ba8e0 100644
--- a/toxcore/Lossless_UDP.c
+++ b/toxcore/Lossless_UDP.c
@@ -275,7 +275,7 @@ static int new_inconnection(Lossless_UDP *ludp, IP_Port ip_port)
275 .timeout = timeout, 275 .timeout = timeout,
276 276
277 /* If this connection isn't handled within the timeout kill it. */ 277 /* If this connection isn't handled within the timeout kill it. */
278 .killat = current_time() + 1000000UL * timeout, 278 .killat = current_time() + 1000000ULL * timeout,
279 .confirmed = 0 279 .confirmed = 0
280 }; 280 };
281 connection->sendbuffer_length = resize_queue(&connection->sendbuffer, 0, DEFAULT_QUEUE_NUM, 0, 0); 281 connection->sendbuffer_length = resize_queue(&connection->sendbuffer, 0, DEFAULT_QUEUE_NUM, 0, 0);
@@ -356,7 +356,7 @@ int timeout_connection_in(Lossless_UDP *ludp, int connection_id, uint32_t second
356 Connection *connection = &tox_array_get(&ludp->connections, connection_id, Connection); 356 Connection *connection = &tox_array_get(&ludp->connections, connection_id, Connection);
357 357
358 if (connection->status != LUDP_NO_CONNECTION) { 358 if (connection->status != LUDP_NO_CONNECTION) {
359 connection->killat = current_time() + 1000000UL * seconds; 359 connection->killat = current_time() + 1000000ULL * seconds;
360 return 0; 360 return 0;
361 } 361 }
362 } 362 }
@@ -1069,13 +1069,13 @@ static void do_new(Lossless_UDP *ludp)
1069 uint64_t temp_time = current_time(); 1069 uint64_t temp_time = current_time();
1070 1070
1071 tox_array_for_each(&ludp->connections, Connection, tmp) { 1071 tox_array_for_each(&ludp->connections, Connection, tmp) {
1072 if (tmp->status == LUDP_HANDSHAKE_SENDING && (tmp->last_sent + (1000000UL / tmp->SYNC_rate)) <= temp_time) { 1072 if (tmp->status == LUDP_HANDSHAKE_SENDING && (tmp->last_sent + (1000000ULL / tmp->SYNC_rate)) <= temp_time) {
1073 send_handshake(ludp, tmp->ip_port, tmp->handshake_id1, 0); 1073 send_handshake(ludp, tmp->ip_port, tmp->handshake_id1, 0);
1074 tmp->last_sent = temp_time; 1074 tmp->last_sent = temp_time;
1075 } 1075 }
1076 1076
1077 /* kill all timed out connections */ 1077 /* kill all timed out connections */
1078 if (tmp->status != LUDP_NO_CONNECTION && (tmp->last_recvSYNC + tmp->timeout * 1000000UL) < temp_time 1078 if (tmp->status != LUDP_NO_CONNECTION && (tmp->last_recvSYNC + tmp->timeout * 1000000ULL) < temp_time
1079 && tmp->status != LUDP_TIMED_OUT) { 1079 && tmp->status != LUDP_TIMED_OUT) {
1080 tmp->status = LUDP_TIMED_OUT; 1080 tmp->status = LUDP_TIMED_OUT;
1081 /* kill_connection(i); */ 1081 /* kill_connection(i); */
@@ -1092,7 +1092,7 @@ static void do_SYNC(Lossless_UDP *ludp)
1092 1092
1093 tox_array_for_each(&ludp->connections, Connection, tmp) { 1093 tox_array_for_each(&ludp->connections, Connection, tmp) {
1094 if (tmp->status == LUDP_NOT_CONFIRMED || tmp->status == LUDP_ESTABLISHED) 1094 if (tmp->status == LUDP_NOT_CONFIRMED || tmp->status == LUDP_ESTABLISHED)
1095 if ((tmp->last_SYNC + (1000000UL / tmp->SYNC_rate)) <= temp_time) { 1095 if ((tmp->last_SYNC + (1000000ULL / tmp->SYNC_rate)) <= temp_time) {
1096 send_SYNC(ludp, tmp_i); 1096 send_SYNC(ludp, tmp_i);
1097 tmp->last_SYNC = temp_time; 1097 tmp->last_SYNC = temp_time;
1098 } 1098 }
@@ -1106,8 +1106,8 @@ static void do_data(Lossless_UDP *ludp)
1106 1106
1107 tox_array_for_each(&ludp->connections, Connection, tmp) { 1107 tox_array_for_each(&ludp->connections, Connection, tmp) {
1108 if (tmp->status == LUDP_ESTABLISHED && sendqueue(ludp, tmp_i) != 0 && 1108 if (tmp->status == LUDP_ESTABLISHED && sendqueue(ludp, tmp_i) != 0 &&
1109 (tmp->last_sent + (1000000UL / tmp->data_rate)) <= temp_time) { 1109 (tmp->last_sent + (1000000ULL / tmp->data_rate)) <= temp_time) {
1110 for (j = tmp->last_sent; j < temp_time; j += (1000000UL / tmp->data_rate)) 1110 for (j = tmp->last_sent; j < temp_time; j += (1000000ULL / tmp->data_rate))
1111 if (send_DATA(ludp, tmp_i) <= 0) 1111 if (send_DATA(ludp, tmp_i) <= 0)
1112 break; 1112 break;
1113 1113
@@ -1135,7 +1135,7 @@ static void adjust_rates(Lossless_UDP *ludp)
1135 if (tmp->status == LUDP_ESTABLISHED) { 1135 if (tmp->status == LUDP_ESTABLISHED) {
1136 if (sendqueue(ludp, tmp_i) != 0) { 1136 if (sendqueue(ludp, tmp_i) != 0) {
1137 tmp->SYNC_rate = MAX_SYNC_RATE; 1137 tmp->SYNC_rate = MAX_SYNC_RATE;
1138 } else if (tmp->last_recvdata + 200000UL > temp_time) { /* 200 ms */ 1138 } else if (tmp->last_recvdata + 200000ULL > temp_time) { /* 200 ms */
1139 tmp->SYNC_rate = MAX_SYNC_RATE; 1139 tmp->SYNC_rate = MAX_SYNC_RATE;
1140 } else { 1140 } else {
1141 tmp->SYNC_rate = SYNC_RATE; 1141 tmp->SYNC_rate = SYNC_RATE;
diff --git a/toxcore/network.c b/toxcore/network.c
index 951475f8..2088cce2 100644
--- a/toxcore/network.c
+++ b/toxcore/network.c
@@ -119,12 +119,12 @@ uint64_t current_time(void)
119 time = ft.dwHighDateTime; 119 time = ft.dwHighDateTime;
120 time <<= 32; 120 time <<= 32;
121 time |= ft.dwLowDateTime; 121 time |= ft.dwLowDateTime;
122 time -= 116444736000000000UL; 122 time -= 116444736000000000ULL;
123 return time / 10; 123 return time / 10;
124#else 124#else
125 struct timeval a; 125 struct timeval a;
126 gettimeofday(&a, NULL); 126 gettimeofday(&a, NULL);
127 time = 1000000UL * a.tv_sec + a.tv_usec; 127 time = 1000000ULL * a.tv_sec + a.tv_usec;
128 return time; 128 return time;
129#endif 129#endif
130} 130}