summaryrefslogtreecommitdiff
path: root/toxcore/group.c
diff options
context:
space:
mode:
authoriphydf <iphydf@users.noreply.github.com>2018-08-01 23:02:13 +0000
committeriphydf <iphydf@users.noreply.github.com>2018-08-16 21:01:43 +0000
commitd6d305feeb76735ee4b4e14c6bca737a5482bc19 (patch)
tree99005c635a452245006b3b5de44f1dd80da9f77f /toxcore/group.c
parent54066f338f185f2fbd6694d9a4877f42cbfa21c8 (diff)
Use per-instance `Mono_Time` for Messenger and onion.
Diffstat (limited to 'toxcore/group.c')
-rw-r--r--toxcore/group.c14
1 files changed, 8 insertions, 6 deletions
diff --git a/toxcore/group.c b/toxcore/group.c
index 20075c8b..11467605 100644
--- a/toxcore/group.c
+++ b/toxcore/group.c
@@ -497,7 +497,7 @@ static int addpeer(Group_Chats *g_c, uint32_t groupnumber, const uint8_t *real_p
497 id_copy(g->group[g->numpeers].temp_pk, temp_pk); 497 id_copy(g->group[g->numpeers].temp_pk, temp_pk);
498 g->group[g->numpeers].peer_number = peer_number; 498 g->group[g->numpeers].peer_number = peer_number;
499 499
500 g->group[g->numpeers].last_recv = unix_time(); 500 g->group[g->numpeers].last_recv = mono_time_get(g_c->mono_time);
501 ++g->numpeers; 501 ++g->numpeers;
502 502
503 add_to_closest(g_c, groupnumber, real_pk, temp_pk); 503 add_to_closest(g_c, groupnumber, real_pk, temp_pk);
@@ -2158,7 +2158,7 @@ static void handle_message_packet_group(Group_Chats *g_c, uint32_t groupnumber,
2158 return; 2158 return;
2159 } 2159 }
2160 2160
2161 g->group[index].last_recv = unix_time(); 2161 g->group[index].last_recv = mono_time_get(g_c->mono_time);
2162 } 2162 }
2163 break; 2163 break;
2164 2164
@@ -2508,9 +2508,9 @@ static int ping_groupchat(Group_Chats *g_c, uint32_t groupnumber)
2508 return -1; 2508 return -1;
2509 } 2509 }
2510 2510
2511 if (is_timeout(g->last_sent_ping, GROUP_PING_INTERVAL)) { 2511 if (mono_time_is_timeout(g_c->mono_time, g->last_sent_ping, GROUP_PING_INTERVAL)) {
2512 if (group_ping_send(g_c, groupnumber) != -1) { /* Ping */ 2512 if (group_ping_send(g_c, groupnumber) != -1) { /* Ping */
2513 g->last_sent_ping = unix_time(); 2513 g->last_sent_ping = mono_time_get(g_c->mono_time);
2514 } 2514 }
2515 } 2515 }
2516 2516
@@ -2526,7 +2526,8 @@ static int groupchat_clear_timedout(Group_Chats *g_c, uint32_t groupnumber, void
2526 } 2526 }
2527 2527
2528 for (uint32_t i = 0; i < g->numpeers; ++i) { 2528 for (uint32_t i = 0; i < g->numpeers; ++i) {
2529 if (g->peer_number != g->group[i].peer_number && is_timeout(g->group[i].last_recv, GROUP_PING_INTERVAL * 3)) { 2529 if (g->peer_number != g->group[i].peer_number
2530 && mono_time_is_timeout(g_c->mono_time, g->group[i].last_recv, GROUP_PING_INTERVAL * 3)) {
2530 delpeer(g_c, groupnumber, i, userdata); 2531 delpeer(g_c, groupnumber, i, userdata);
2531 } 2532 }
2532 2533
@@ -2556,7 +2557,7 @@ void send_name_all_groups(Group_Chats *g_c)
2556} 2557}
2557 2558
2558/* Create new groupchat instance. */ 2559/* Create new groupchat instance. */
2559Group_Chats *new_groupchats(Messenger *m) 2560Group_Chats *new_groupchats(Mono_Time *mono_time, Messenger *m)
2560{ 2561{
2561 if (!m) { 2562 if (!m) {
2562 return nullptr; 2563 return nullptr;
@@ -2568,6 +2569,7 @@ Group_Chats *new_groupchats(Messenger *m)
2568 return nullptr; 2569 return nullptr;
2569 } 2570 }
2570 2571
2572 temp->mono_time = mono_time;
2571 temp->m = m; 2573 temp->m = m;
2572 temp->fr_c = m->fr_c; 2574 temp->fr_c = m->fr_c;
2573 m->conferences_object = temp; 2575 m->conferences_object = temp;