summaryrefslogtreecommitdiff
path: root/ot_livesync.c
diff options
context:
space:
mode:
Diffstat (limited to 'ot_livesync.c')
-rw-r--r--ot_livesync.c10
1 files changed, 5 insertions, 5 deletions
diff --git a/ot_livesync.c b/ot_livesync.c
index 5a63f3c..fb0bef2 100644
--- a/ot_livesync.c
+++ b/ot_livesync.c
@@ -70,8 +70,8 @@ void livesync_init(void) {
70 g_v6_buf.fill = sizeof(g_tracker_id) + sizeof(uint32_t); 70 g_v6_buf.fill = sizeof(g_tracker_id) + sizeof(uint32_t);
71 g_v4_buf.fill = sizeof(g_tracker_id) + sizeof(uint32_t); 71 g_v4_buf.fill = sizeof(g_tracker_id) + sizeof(uint32_t);
72 72
73 g_v6_buf.next_packet_time = g_now_seconds + LIVESYNC_MAXDELAY; 73 g_v6_buf.next_packet_time = time_future_seconds(LIVESYNC_MAXDELAY);
74 g_v4_buf.next_packet_time = g_now_seconds + LIVESYNC_MAXDELAY; 74 g_v4_buf.next_packet_time = time_future_seconds(LIVESYNC_MAXDELAY);
75 75
76 pthread_create(&thread_id, NULL, livesync_worker, NULL); 76 pthread_create(&thread_id, NULL, livesync_worker, NULL);
77} 77}
@@ -106,7 +106,7 @@ static void livesync_issue_peersync(sync_buffer *buf) {
106 106
107 memcpy(mycopy, buf->data, fill); 107 memcpy(mycopy, buf->data, fill);
108 buf->fill = sizeof(g_tracker_id) + sizeof(uint32_t); 108 buf->fill = sizeof(g_tracker_id) + sizeof(uint32_t);
109 buf->next_packet_time = g_now_seconds + LIVESYNC_MAXDELAY; 109 buf->next_packet_time = time_future_seconds(LIVESYNC_MAXDELAY);
110 110
111 /* From now this thread has a local copy of the buffer and 111 /* From now this thread has a local copy of the buffer and
112 has modified the protected element */ 112 has modified the protected element */
@@ -152,13 +152,13 @@ static void livesync_handle_peersync(struct ot_workstruct *ws, size_t peer_size)
152void livesync_ticker(void) { 152void livesync_ticker(void) {
153 /* livesync_issue_peersync sets g_next_packet_time */ 153 /* livesync_issue_peersync sets g_next_packet_time */
154 pthread_mutex_lock(&g_outbuf_mutex); 154 pthread_mutex_lock(&g_outbuf_mutex);
155 if (g_now_seconds > g_v6_buf.next_packet_time && g_v6_buf.fill > sizeof(g_tracker_id) + sizeof(uint32_t)) 155 if (time_now_seconds() > g_v6_buf.next_packet_time && g_v6_buf.fill > sizeof(g_tracker_id) + sizeof(uint32_t))
156 livesync_issue_peersync(&g_v6_buf); 156 livesync_issue_peersync(&g_v6_buf);
157 else 157 else
158 pthread_mutex_unlock(&g_outbuf_mutex); 158 pthread_mutex_unlock(&g_outbuf_mutex);
159 159
160 pthread_mutex_lock(&g_outbuf_mutex); 160 pthread_mutex_lock(&g_outbuf_mutex);
161 if (g_now_seconds > g_v4_buf.next_packet_time && g_v4_buf.fill > sizeof(g_tracker_id) + sizeof(uint32_t)) 161 if (time_now_seconds() > g_v4_buf.next_packet_time && g_v4_buf.fill > sizeof(g_tracker_id) + sizeof(uint32_t))
162 livesync_issue_peersync(&g_v4_buf); 162 livesync_issue_peersync(&g_v4_buf);
163 else 163 else
164 pthread_mutex_unlock(&g_outbuf_mutex); 164 pthread_mutex_unlock(&g_outbuf_mutex);