diff options
-rw-r--r-- | auto_tests/TCP_test.c | 6 | ||||
-rw-r--r-- | auto_tests/dht_test.c | 57 | ||||
-rw-r--r-- | auto_tests/onion_test.c | 6 | ||||
-rw-r--r-- | other/DHT_bootstrap.c | 4 | ||||
-rw-r--r-- | other/bootstrap_daemon/src/tox-bootstrapd.c | 4 | ||||
-rw-r--r-- | testing/DHT_test.c | 3 | ||||
-rw-r--r-- | testing/Messenger_test.c | 5 | ||||
-rw-r--r-- | toxcore/DHT.c | 9 | ||||
-rw-r--r-- | toxcore/Messenger.c | 2 | ||||
-rw-r--r-- | toxcore/TCP_client.c | 2 | ||||
-rw-r--r-- | toxcore/TCP_server.c | 2 | ||||
-rw-r--r-- | toxcore/net_crypto.c | 3 | ||||
-rw-r--r-- | toxcore/network.c | 2 | ||||
-rw-r--r-- | toxcore/tox.c | 5 |
14 files changed, 53 insertions, 57 deletions
diff --git a/auto_tests/TCP_test.c b/auto_tests/TCP_test.c index 07266543..52ecad77 100644 --- a/auto_tests/TCP_test.c +++ b/auto_tests/TCP_test.c | |||
@@ -39,6 +39,7 @@ static inline IP get_loopback() | |||
39 | static void do_TCP_server_delay(TCP_Server *tcp_s, int delay) | 39 | static void do_TCP_server_delay(TCP_Server *tcp_s, int delay) |
40 | { | 40 | { |
41 | c_sleep(delay); | 41 | c_sleep(delay); |
42 | unix_time_update(); | ||
42 | do_TCP_server(tcp_s); | 43 | do_TCP_server(tcp_s); |
43 | c_sleep(delay); | 44 | c_sleep(delay); |
44 | } | 45 | } |
@@ -141,6 +142,7 @@ START_TEST(test_basic) | |||
141 | i += msg_length; | 142 | i += msg_length; |
142 | 143 | ||
143 | c_sleep(50); | 144 | c_sleep(50); |
145 | unix_time_update(); | ||
144 | do_TCP_server(tcp_s); | 146 | do_TCP_server(tcp_s); |
145 | } | 147 | } |
146 | 148 | ||
@@ -477,6 +479,7 @@ START_TEST(test_client) | |||
477 | const uint8_t LOOP_SIZE = 3; | 479 | const uint8_t LOOP_SIZE = 3; |
478 | 480 | ||
479 | for (uint8_t i = 0; i < LOOP_SIZE; i++) { | 481 | for (uint8_t i = 0; i < LOOP_SIZE; i++) { |
482 | unix_time_update(); | ||
480 | do_TCP_connection(conn, nullptr); // Run the connection loop. | 483 | do_TCP_connection(conn, nullptr); // Run the connection loop. |
481 | 484 | ||
482 | // The status of the connection should continue to be TCP_CLIENT_CONFIRMED after multiple subsequent do_TCP_connection() calls. | 485 | // The status of the connection should continue to be TCP_CLIENT_CONFIRMED after multiple subsequent do_TCP_connection() calls. |
@@ -584,6 +587,7 @@ START_TEST(test_client_invalid) | |||
584 | TCP_Client_Connection *conn = new_TCP_connection(ip_port_tcp_s, self_public_key, f_public_key, f_secret_key, nullptr); | 587 | TCP_Client_Connection *conn = new_TCP_connection(ip_port_tcp_s, self_public_key, f_public_key, f_secret_key, nullptr); |
585 | 588 | ||
586 | // Run the client's main loop but not the server. | 589 | // Run the client's main loop but not the server. |
590 | unix_time_update(); | ||
587 | do_TCP_connection(conn, nullptr); | 591 | do_TCP_connection(conn, nullptr); |
588 | c_sleep(50); | 592 | c_sleep(50); |
589 | 593 | ||
@@ -592,11 +596,13 @@ START_TEST(test_client_invalid) | |||
592 | TCP_CLIENT_CONNECTING, tcp_con_status(conn)); | 596 | TCP_CLIENT_CONNECTING, tcp_con_status(conn)); |
593 | // After 5s... | 597 | // After 5s... |
594 | c_sleep(5000); | 598 | c_sleep(5000); |
599 | unix_time_update(); | ||
595 | do_TCP_connection(conn, nullptr); | 600 | do_TCP_connection(conn, nullptr); |
596 | ck_assert_msg(tcp_con_status(conn) == TCP_CLIENT_CONNECTING, "Wrong status. Expected: %d, is: %d.", | 601 | ck_assert_msg(tcp_con_status(conn) == TCP_CLIENT_CONNECTING, "Wrong status. Expected: %d, is: %d.", |
597 | TCP_CLIENT_CONNECTING, tcp_con_status(conn)); | 602 | TCP_CLIENT_CONNECTING, tcp_con_status(conn)); |
598 | // 11s... (Should wait for 10 before giving up.) | 603 | // 11s... (Should wait for 10 before giving up.) |
599 | c_sleep(6000); | 604 | c_sleep(6000); |
605 | unix_time_update(); | ||
600 | do_TCP_connection(conn, nullptr); | 606 | do_TCP_connection(conn, nullptr); |
601 | ck_assert_msg(tcp_con_status(conn) == TCP_CLIENT_DISCONNECTED, "Wrong status. Expected: %d, is: %d.", | 607 | ck_assert_msg(tcp_con_status(conn) == TCP_CLIENT_DISCONNECTED, "Wrong status. Expected: %d, is: %d.", |
602 | TCP_CLIENT_DISCONNECTED, tcp_con_status(conn)); | 608 | TCP_CLIENT_DISCONNECTED, tcp_con_status(conn)); |
diff --git a/auto_tests/dht_test.c b/auto_tests/dht_test.c index 8b96f09a..2f273727 100644 --- a/auto_tests/dht_test.c +++ b/auto_tests/dht_test.c | |||
@@ -389,21 +389,19 @@ static void test_addto_lists(IP ip) | |||
389 | logger_kill(log); | 389 | logger_kill(log); |
390 | } | 390 | } |
391 | 391 | ||
392 | START_TEST(test_addto_lists_ipv4) | 392 | static void test_addto_lists_ipv4(void) |
393 | { | 393 | { |
394 | IP ip; | 394 | IP ip; |
395 | ip_init(&ip, 0); | 395 | ip_init(&ip, 0); |
396 | test_addto_lists(ip); | 396 | test_addto_lists(ip); |
397 | } | 397 | } |
398 | END_TEST | ||
399 | 398 | ||
400 | START_TEST(test_addto_lists_ipv6) | 399 | static void test_addto_lists_ipv6(void) |
401 | { | 400 | { |
402 | IP ip; | 401 | IP ip; |
403 | ip_init(&ip, 1); | 402 | ip_init(&ip, 1); |
404 | test_addto_lists(ip); | 403 | test_addto_lists(ip); |
405 | } | 404 | } |
406 | END_TEST | ||
407 | 405 | ||
408 | #define DHT_DEFAULT_PORT (TOX_PORT_DEFAULT + 1000) | 406 | #define DHT_DEFAULT_PORT (TOX_PORT_DEFAULT + 1000) |
409 | 407 | ||
@@ -580,7 +578,7 @@ static void test_list_main(void) | |||
580 | } | 578 | } |
581 | 579 | ||
582 | 580 | ||
583 | START_TEST(test_list) | 581 | static void test_list(void) |
584 | { | 582 | { |
585 | uint8_t i; | 583 | uint8_t i; |
586 | 584 | ||
@@ -588,7 +586,6 @@ START_TEST(test_list) | |||
588 | test_list_main(); | 586 | test_list_main(); |
589 | } | 587 | } |
590 | } | 588 | } |
591 | END_TEST | ||
592 | 589 | ||
593 | static void ip_callback(void *data, int32_t number, IP_Port ip_port) | 590 | static void ip_callback(void *data, int32_t number, IP_Port ip_port) |
594 | { | 591 | { |
@@ -596,13 +593,15 @@ static void ip_callback(void *data, int32_t number, IP_Port ip_port) | |||
596 | 593 | ||
597 | #define NUM_DHT_FRIENDS 20 | 594 | #define NUM_DHT_FRIENDS 20 |
598 | 595 | ||
599 | START_TEST(test_DHT_test) | 596 | static void test_DHT_test(void) |
600 | { | 597 | { |
601 | uint32_t to_comp = 8394782; | 598 | uint32_t to_comp = 8394782; |
602 | DHT *dhts[NUM_DHT]; | 599 | DHT *dhts[NUM_DHT]; |
603 | Logger *logs[NUM_DHT]; | 600 | Logger *logs[NUM_DHT]; |
604 | uint32_t index[NUM_DHT]; | 601 | uint32_t index[NUM_DHT]; |
605 | 602 | ||
603 | unix_time_update(); | ||
604 | |||
606 | uint32_t i, j; | 605 | uint32_t i, j; |
607 | 606 | ||
608 | for (i = 0; i < NUM_DHT; ++i) { | 607 | for (i = 0; i < NUM_DHT; ++i) { |
@@ -664,6 +663,7 @@ loop_top: | |||
664 | } | 663 | } |
665 | 664 | ||
666 | for (i = 0; i < NUM_DHT; ++i) { | 665 | for (i = 0; i < NUM_DHT; ++i) { |
666 | unix_time_update(); | ||
667 | networking_poll(dhts[i]->net, nullptr); | 667 | networking_poll(dhts[i]->net, nullptr); |
668 | do_dht(dhts[i]); | 668 | do_dht(dhts[i]); |
669 | } | 669 | } |
@@ -678,9 +678,8 @@ loop_top: | |||
678 | logger_kill(logs[i]); | 678 | logger_kill(logs[i]); |
679 | } | 679 | } |
680 | } | 680 | } |
681 | END_TEST | ||
682 | 681 | ||
683 | START_TEST(test_dht_create_packet) | 682 | static void test_dht_create_packet(void) |
684 | { | 683 | { |
685 | uint8_t plain[100] = {0}; | 684 | uint8_t plain[100] = {0}; |
686 | uint8_t pkt[1 + CRYPTO_PUBLIC_KEY_SIZE + CRYPTO_NONCE_SIZE + sizeof(plain) + CRYPTO_MAC_SIZE]; | 685 | uint8_t pkt[1 + CRYPTO_PUBLIC_KEY_SIZE + CRYPTO_NONCE_SIZE + sizeof(plain) + CRYPTO_MAC_SIZE]; |
@@ -697,7 +696,6 @@ START_TEST(test_dht_create_packet) | |||
697 | 696 | ||
698 | printf("Create Packet Successful!\n"); | 697 | printf("Create Packet Successful!\n"); |
699 | } | 698 | } |
700 | END_TEST | ||
701 | 699 | ||
702 | #define MAX_COUNT 3 | 700 | #define MAX_COUNT 3 |
703 | 701 | ||
@@ -750,7 +748,7 @@ static void random_ip(IP_Port *ipp, int family) | |||
750 | 748 | ||
751 | #define PACKED_NODES_SIZE (SIZE_IPPORT + CRYPTO_PUBLIC_KEY_SIZE) | 749 | #define PACKED_NODES_SIZE (SIZE_IPPORT + CRYPTO_PUBLIC_KEY_SIZE) |
752 | 750 | ||
753 | START_TEST(test_dht_node_packing) | 751 | static void test_dht_node_packing(void) |
754 | { | 752 | { |
755 | const uint16_t length = MAX_COUNT * PACKED_NODES_SIZE; | 753 | const uint16_t length = MAX_COUNT * PACKED_NODES_SIZE; |
756 | uint8_t *data = (uint8_t *)malloc(length); | 754 | uint8_t *data = (uint8_t *)malloc(length); |
@@ -789,38 +787,23 @@ START_TEST(test_dht_node_packing) | |||
789 | 787 | ||
790 | free(data); | 788 | free(data); |
791 | } | 789 | } |
792 | END_TEST | ||
793 | |||
794 | static Suite *dht_suite(void) | ||
795 | { | ||
796 | Suite *s = suite_create("DHT"); | ||
797 | DEFTESTCASE(dht_create_packet); | ||
798 | DEFTESTCASE(dht_node_packing); | ||
799 | |||
800 | DEFTESTCASE_SLOW(list, 20); | ||
801 | DEFTESTCASE_SLOW(DHT_test, 50); | ||
802 | |||
803 | if (enable_broken_tests) { | ||
804 | DEFTESTCASE(addto_lists_ipv4); | ||
805 | DEFTESTCASE(addto_lists_ipv6); | ||
806 | } | ||
807 | |||
808 | return s; | ||
809 | } | ||
810 | 790 | ||
811 | int main(void) | 791 | int main(void) |
812 | { | 792 | { |
813 | setvbuf(stdout, nullptr, _IONBF, 0); | 793 | setvbuf(stdout, nullptr, _IONBF, 0); |
814 | 794 | ||
815 | Suite *dht = dht_suite(); | 795 | unix_time_update(); |
816 | SRunner *test_runner = srunner_create(dht); | ||
817 | 796 | ||
818 | uint8_t number_failed = 0; | 797 | test_dht_create_packet(); |
819 | //srunner_set_fork_status(test_runner, CK_NOFORK); | 798 | test_dht_node_packing(); |
820 | srunner_run_all(test_runner, CK_NORMAL); | ||
821 | number_failed = srunner_ntests_failed(test_runner); | ||
822 | 799 | ||
823 | srunner_free(test_runner); | 800 | test_list(); |
801 | test_DHT_test(); | ||
802 | |||
803 | if (enable_broken_tests) { | ||
804 | test_addto_lists_ipv4(); | ||
805 | test_addto_lists_ipv6(); | ||
806 | } | ||
824 | 807 | ||
825 | return number_failed; | 808 | return 0; |
826 | } | 809 | } |
diff --git a/auto_tests/onion_test.c b/auto_tests/onion_test.c index 18b7b523..0a9a0577 100644 --- a/auto_tests/onion_test.c +++ b/auto_tests/onion_test.c | |||
@@ -31,6 +31,8 @@ static inline IP get_loopback() | |||
31 | } | 31 | } |
32 | static void do_onion(Onion *onion) | 32 | static void do_onion(Onion *onion) |
33 | { | 33 | { |
34 | unix_time_update(); | ||
35 | |||
34 | networking_poll(onion->net, nullptr); | 36 | networking_poll(onion->net, nullptr); |
35 | do_dht(onion->dht); | 37 | do_dht(onion->dht); |
36 | } | 38 | } |
@@ -327,6 +329,8 @@ static Onions *new_onions(uint16_t port, uint32_t *index) | |||
327 | return nullptr; | 329 | return nullptr; |
328 | } | 330 | } |
329 | 331 | ||
332 | unix_time_update(); | ||
333 | |||
330 | logger_callback_log(on->log, (logger_cb *)print_debug_log, nullptr, index); | 334 | logger_callback_log(on->log, (logger_cb *)print_debug_log, nullptr, index); |
331 | 335 | ||
332 | Networking_Core *net = new_networking(on->log, ip, port); | 336 | Networking_Core *net = new_networking(on->log, ip, port); |
@@ -385,6 +389,8 @@ static Onions *new_onions(uint16_t port, uint32_t *index) | |||
385 | 389 | ||
386 | static void do_onions(Onions *on) | 390 | static void do_onions(Onions *on) |
387 | { | 391 | { |
392 | unix_time_update(); | ||
393 | |||
388 | networking_poll(on->onion->net, nullptr); | 394 | networking_poll(on->onion->net, nullptr); |
389 | do_dht(on->onion->dht); | 395 | do_dht(on->onion->dht); |
390 | do_onion_client(on->onion_c); | 396 | do_onion_client(on->onion_c); |
diff --git a/other/DHT_bootstrap.c b/other/DHT_bootstrap.c index 347e5c82..fc1bba47 100644 --- a/other/DHT_bootstrap.c +++ b/other/DHT_bootstrap.c | |||
@@ -115,6 +115,8 @@ int main(int argc, char *argv[]) | |||
115 | IP ip; | 115 | IP ip; |
116 | ip_init(&ip, ipv6enabled); | 116 | ip_init(&ip, ipv6enabled); |
117 | 117 | ||
118 | unix_time_update(); | ||
119 | |||
118 | Logger *logger = logger_new(); | 120 | Logger *logger = logger_new(); |
119 | DHT *dht = new_dht(logger, new_networking(logger, ip, PORT), true); | 121 | DHT *dht = new_dht(logger, new_networking(logger, ip, PORT), true); |
120 | Onion *onion = new_onion(dht); | 122 | Onion *onion = new_onion(dht); |
@@ -186,6 +188,8 @@ int main(int argc, char *argv[]) | |||
186 | lan_discovery_init(dht); | 188 | lan_discovery_init(dht); |
187 | 189 | ||
188 | while (1) { | 190 | while (1) { |
191 | unix_time_update(); | ||
192 | |||
189 | if (is_waiting_for_dht_connection && dht_isconnected(dht)) { | 193 | if (is_waiting_for_dht_connection && dht_isconnected(dht)) { |
190 | printf("Connected to other bootstrap node successfully.\n"); | 194 | printf("Connected to other bootstrap node successfully.\n"); |
191 | is_waiting_for_dht_connection = 0; | 195 | is_waiting_for_dht_connection = 0; |
diff --git a/other/bootstrap_daemon/src/tox-bootstrapd.c b/other/bootstrap_daemon/src/tox-bootstrapd.c index b17fc2ba..d75018d8 100644 --- a/other/bootstrap_daemon/src/tox-bootstrapd.c +++ b/other/bootstrap_daemon/src/tox-bootstrapd.c | |||
@@ -230,6 +230,8 @@ int main(int argc, char *argv[]) | |||
230 | IP ip; | 230 | IP ip; |
231 | ip_init(&ip, enable_ipv6); | 231 | ip_init(&ip, enable_ipv6); |
232 | 232 | ||
233 | unix_time_update(); | ||
234 | |||
233 | Logger *logger = logger_new(); | 235 | Logger *logger = logger_new(); |
234 | 236 | ||
235 | Networking_Core *net = new_networking(logger, ip, port); | 237 | Networking_Core *net = new_networking(logger, ip, port); |
@@ -336,6 +338,8 @@ int main(int argc, char *argv[]) | |||
336 | } | 338 | } |
337 | 339 | ||
338 | while (1) { | 340 | while (1) { |
341 | unix_time_update(); | ||
342 | |||
339 | do_dht(dht); | 343 | do_dht(dht); |
340 | 344 | ||
341 | if (enable_lan_discovery && is_timeout(last_LANdiscovery, LAN_DISCOVERY_INTERVAL)) { | 345 | if (enable_lan_discovery && is_timeout(last_LANdiscovery, LAN_DISCOVERY_INTERVAL)) { |
diff --git a/testing/DHT_test.c b/testing/DHT_test.c index c9372847..1d01f0a2 100644 --- a/testing/DHT_test.c +++ b/testing/DHT_test.c | |||
@@ -42,6 +42,7 @@ | |||
42 | 42 | ||
43 | #include "../toxcore/DHT.h" | 43 | #include "../toxcore/DHT.h" |
44 | #include "../toxcore/friend_requests.h" | 44 | #include "../toxcore/friend_requests.h" |
45 | #include "../toxcore/mono_time.h" | ||
45 | #include "misc_tools.h" | 46 | #include "misc_tools.h" |
46 | 47 | ||
47 | #define PORT 33445 | 48 | #define PORT 33445 |
@@ -237,6 +238,8 @@ int main(int argc, char *argv[]) | |||
237 | #endif | 238 | #endif |
238 | 239 | ||
239 | while (1) { | 240 | while (1) { |
241 | unix_time_update(); | ||
242 | |||
240 | do_dht(dht); | 243 | do_dht(dht); |
241 | 244 | ||
242 | #if 0 /* TODO(slvr): */ | 245 | #if 0 /* TODO(slvr): */ |
diff --git a/testing/Messenger_test.c b/testing/Messenger_test.c index c02681f8..a5abfda0 100644 --- a/testing/Messenger_test.c +++ b/testing/Messenger_test.c | |||
@@ -47,6 +47,7 @@ | |||
47 | #endif | 47 | #endif |
48 | 48 | ||
49 | #include "../toxcore/Messenger.h" | 49 | #include "../toxcore/Messenger.h" |
50 | #include "../toxcore/mono_time.h" | ||
50 | #include "misc_tools.h" | 51 | #include "misc_tools.h" |
51 | 52 | ||
52 | static void print_message(Messenger *m, uint32_t friendnumber, unsigned int type, const uint8_t *string, size_t length, | 53 | static void print_message(Messenger *m, uint32_t friendnumber, unsigned int type, const uint8_t *string, size_t length, |
@@ -106,6 +107,8 @@ int main(int argc, char *argv[]) | |||
106 | exit(0); | 107 | exit(0); |
107 | } | 108 | } |
108 | 109 | ||
110 | unix_time_update(); | ||
111 | |||
109 | Messenger_Options options = {0}; | 112 | Messenger_Options options = {0}; |
110 | options.ipv6enabled = ipv6enabled; | 113 | options.ipv6enabled = ipv6enabled; |
111 | m = new_messenger(&options, nullptr); | 114 | m = new_messenger(&options, nullptr); |
@@ -177,6 +180,8 @@ int main(int argc, char *argv[]) | |||
177 | perror("Initialization"); | 180 | perror("Initialization"); |
178 | 181 | ||
179 | while (1) { | 182 | while (1) { |
183 | unix_time_update(); | ||
184 | |||
180 | uint8_t name[128]; | 185 | uint8_t name[128]; |
181 | const char *const filename = "Save.bak"; | 186 | const char *const filename = "Save.bak"; |
182 | getname(m, num, name); | 187 | getname(m, num, name); |
diff --git a/toxcore/DHT.c b/toxcore/DHT.c index 37dd9385..94928b75 100644 --- a/toxcore/DHT.c +++ b/toxcore/DHT.c | |||
@@ -2690,9 +2690,6 @@ static int cryptopacket_handle(void *object, IP_Port source, const uint8_t *pack | |||
2690 | 2690 | ||
2691 | DHT *new_dht(const Logger *log, Networking_Core *net, bool holepunching_enabled) | 2691 | DHT *new_dht(const Logger *log, Networking_Core *net, bool holepunching_enabled) |
2692 | { | 2692 | { |
2693 | /* init time */ | ||
2694 | unix_time_update(); | ||
2695 | |||
2696 | if (net == nullptr) { | 2693 | if (net == nullptr) { |
2697 | return nullptr; | 2694 | return nullptr; |
2698 | } | 2695 | } |
@@ -2741,8 +2738,6 @@ DHT *new_dht(const Logger *log, Networking_Core *net, bool holepunching_enabled) | |||
2741 | 2738 | ||
2742 | void do_dht(DHT *dht) | 2739 | void do_dht(DHT *dht) |
2743 | { | 2740 | { |
2744 | unix_time_update(); | ||
2745 | |||
2746 | if (dht->last_run == unix_time()) { | 2741 | if (dht->last_run == unix_time()) { |
2747 | return; | 2742 | return; |
2748 | } | 2743 | } |
@@ -2963,8 +2958,6 @@ int dht_load(DHT *dht, const uint8_t *data, uint32_t length) | |||
2963 | */ | 2958 | */ |
2964 | bool dht_isconnected(const DHT *dht) | 2959 | bool dht_isconnected(const DHT *dht) |
2965 | { | 2960 | { |
2966 | unix_time_update(); | ||
2967 | |||
2968 | for (uint32_t i = 0; i < LCLIENT_LIST; ++i) { | 2961 | for (uint32_t i = 0; i < LCLIENT_LIST; ++i) { |
2969 | const Client_data *const client = &dht->close_clientlist[i]; | 2962 | const Client_data *const client = &dht->close_clientlist[i]; |
2970 | 2963 | ||
@@ -2982,8 +2975,6 @@ bool dht_isconnected(const DHT *dht) | |||
2982 | */ | 2975 | */ |
2983 | bool dht_non_lan_connected(const DHT *dht) | 2976 | bool dht_non_lan_connected(const DHT *dht) |
2984 | { | 2977 | { |
2985 | unix_time_update(); | ||
2986 | |||
2987 | for (uint32_t i = 0; i < LCLIENT_LIST; ++i) { | 2978 | for (uint32_t i = 0; i < LCLIENT_LIST; ++i) { |
2988 | const Client_data *const client = &dht->close_clientlist[i]; | 2979 | const Client_data *const client = &dht->close_clientlist[i]; |
2989 | 2980 | ||
diff --git a/toxcore/Messenger.c b/toxcore/Messenger.c index acf9f806..ab341e61 100644 --- a/toxcore/Messenger.c +++ b/toxcore/Messenger.c | |||
@@ -2603,8 +2603,6 @@ void do_messenger(Messenger *m, void *userdata) | |||
2603 | } | 2603 | } |
2604 | } | 2604 | } |
2605 | 2605 | ||
2606 | unix_time_update(); | ||
2607 | |||
2608 | if (!m->options.udp_disabled) { | 2606 | if (!m->options.udp_disabled) { |
2609 | networking_poll(m->net, userdata); | 2607 | networking_poll(m->net, userdata); |
2610 | do_dht(m->dht); | 2608 | do_dht(m->dht); |
diff --git a/toxcore/TCP_client.c b/toxcore/TCP_client.c index 381d9b80..d6a27c95 100644 --- a/toxcore/TCP_client.c +++ b/toxcore/TCP_client.c | |||
@@ -985,8 +985,6 @@ static int do_confirmed_TCP(TCP_Client_Connection *conn, void *userdata) | |||
985 | */ | 985 | */ |
986 | void do_TCP_connection(TCP_Client_Connection *tcp_connection, void *userdata) | 986 | void do_TCP_connection(TCP_Client_Connection *tcp_connection, void *userdata) |
987 | { | 987 | { |
988 | unix_time_update(); | ||
989 | |||
990 | if (tcp_connection->status == TCP_CLIENT_DISCONNECTED) { | 988 | if (tcp_connection->status == TCP_CLIENT_DISCONNECTED) { |
991 | return; | 989 | return; |
992 | } | 990 | } |
diff --git a/toxcore/TCP_server.c b/toxcore/TCP_server.c index cc59d088..207a5107 100644 --- a/toxcore/TCP_server.c +++ b/toxcore/TCP_server.c | |||
@@ -1424,8 +1424,6 @@ static void do_TCP_epoll(TCP_Server *tcp_server) | |||
1424 | 1424 | ||
1425 | void do_TCP_server(TCP_Server *tcp_server) | 1425 | void do_TCP_server(TCP_Server *tcp_server) |
1426 | { | 1426 | { |
1427 | unix_time_update(); | ||
1428 | |||
1429 | #ifdef TCP_SERVER_USE_EPOLL | 1427 | #ifdef TCP_SERVER_USE_EPOLL |
1430 | do_TCP_epoll(tcp_server); | 1428 | do_TCP_epoll(tcp_server); |
1431 | 1429 | ||
diff --git a/toxcore/net_crypto.c b/toxcore/net_crypto.c index 8f5fd507..bd214b91 100644 --- a/toxcore/net_crypto.c +++ b/toxcore/net_crypto.c | |||
@@ -2925,8 +2925,6 @@ void load_secret_key(Net_Crypto *c, const uint8_t *sk) | |||
2925 | */ | 2925 | */ |
2926 | Net_Crypto *new_net_crypto(const Logger *log, DHT *dht, TCP_Proxy_Info *proxy_info) | 2926 | Net_Crypto *new_net_crypto(const Logger *log, DHT *dht, TCP_Proxy_Info *proxy_info) |
2927 | { | 2927 | { |
2928 | unix_time_update(); | ||
2929 | |||
2930 | if (dht == nullptr) { | 2928 | if (dht == nullptr) { |
2931 | return nullptr; | 2929 | return nullptr; |
2932 | } | 2930 | } |
@@ -3016,7 +3014,6 @@ uint32_t crypto_run_interval(const Net_Crypto *c) | |||
3016 | /* Main loop. */ | 3014 | /* Main loop. */ |
3017 | void do_net_crypto(Net_Crypto *c, void *userdata) | 3015 | void do_net_crypto(Net_Crypto *c, void *userdata) |
3018 | { | 3016 | { |
3019 | unix_time_update(); | ||
3020 | kill_timedout(c, userdata); | 3017 | kill_timedout(c, userdata); |
3021 | do_tcp(c, userdata); | 3018 | do_tcp(c, userdata); |
3022 | send_crypto_packets(c); | 3019 | send_crypto_packets(c); |
diff --git a/toxcore/network.c b/toxcore/network.c index 68ca43e5..08bec13a 100644 --- a/toxcore/network.c +++ b/toxcore/network.c | |||
@@ -641,8 +641,6 @@ void networking_poll(Networking_Core *net, void *userdata) | |||
641 | return; | 641 | return; |
642 | } | 642 | } |
643 | 643 | ||
644 | unix_time_update(); | ||
645 | |||
646 | IP_Port ip_port; | 644 | IP_Port ip_port; |
647 | uint8_t data[MAX_UDP_PACKET_SIZE]; | 645 | uint8_t data[MAX_UDP_PACKET_SIZE]; |
648 | uint32_t length; | 646 | uint32_t length; |
diff --git a/toxcore/tox.c b/toxcore/tox.c index cd1b71f0..879b5c09 100644 --- a/toxcore/tox.c +++ b/toxcore/tox.c | |||
@@ -38,6 +38,7 @@ | |||
38 | #include "Messenger.h" | 38 | #include "Messenger.h" |
39 | #include "group.h" | 39 | #include "group.h" |
40 | #include "logger.h" | 40 | #include "logger.h" |
41 | #include "mono_time.h" | ||
41 | 42 | ||
42 | #include "../toxencryptsave/defines.h" | 43 | #include "../toxencryptsave/defines.h" |
43 | 44 | ||
@@ -335,6 +336,8 @@ Tox *tox_new(const struct Tox_Options *options, Tox_Err_New *error) | |||
335 | return nullptr; | 336 | return nullptr; |
336 | } | 337 | } |
337 | 338 | ||
339 | unix_time_update(); | ||
340 | |||
338 | Messenger_Options m_options = {0}; | 341 | Messenger_Options m_options = {0}; |
339 | 342 | ||
340 | bool load_savedata_sk = false, load_savedata_tox = false; | 343 | bool load_savedata_sk = false, load_savedata_tox = false; |
@@ -653,6 +656,8 @@ uint32_t tox_iteration_interval(const Tox *tox) | |||
653 | 656 | ||
654 | void tox_iterate(Tox *tox, void *user_data) | 657 | void tox_iterate(Tox *tox, void *user_data) |
655 | { | 658 | { |
659 | unix_time_update(); | ||
660 | |||
656 | Messenger *m = tox->m; | 661 | Messenger *m = tox->m; |
657 | struct Tox_Userdata tox_data = { tox, user_data }; | 662 | struct Tox_Userdata tox_data = { tox, user_data }; |
658 | do_messenger(m, &tox_data); | 663 | do_messenger(m, &tox_data); |