diff options
| author | Dirk Engling <erdgeist@erdgeist.org> | 2026-11-03 05:13:22 +0100 |
|---|---|---|
| committer | Dirk Engling <erdgeist@erdgeist.org> | 2026-11-03 05:13:22 +0100 |
| commit | d501bbc97aeb87e6e4aa50bb2fa10a157d5909e9 (patch) | |
| tree | 460846f5787dc8a94c4b3076eff3cc92370832e0 /src | |
| parent | 253432c918dacc8bfd5d9a6a46c45a9dc682c7ec (diff) | |
Let a tracker with live sync built in run without a cluster
Diffstat (limited to 'src')
| -rw-r--r-- | src/ot_livesync.c | 15 |
1 files changed, 12 insertions, 3 deletions
diff --git a/src/ot_livesync.c b/src/ot_livesync.c index 18dae0d..9770bbc 100644 --- a/src/ot_livesync.c +++ b/src/ot_livesync.c | |||
| @@ -60,7 +60,7 @@ void livesync_init(void) { | |||
| 60 | uint32_t packet_type4 = htonl(OT_SYNC_PEER4); | 60 | uint32_t packet_type4 = htonl(OT_SYNC_PEER4); |
| 61 | 61 | ||
| 62 | if (g_socket_in == -1) | 62 | if (g_socket_in == -1) |
| 63 | exerr("No socket address for live sync specified."); | 63 | return; |
| 64 | 64 | ||
| 65 | /* Prepare outgoing peers buffer */ | 65 | /* Prepare outgoing peers buffer */ |
| 66 | memcpy(g_v6_buf.data, &g_tracker_id, sizeof(g_tracker_id)); | 66 | memcpy(g_v6_buf.data, &g_tracker_id, sizeof(g_tracker_id)); |
| @@ -160,6 +160,9 @@ static void livesync_handle_peersync(struct ot_workstruct *ws, size_t peer_size) | |||
| 160 | stuck when there's not enough traffic to fill udp packets fast | 160 | stuck when there's not enough traffic to fill udp packets fast |
| 161 | enough */ | 161 | enough */ |
| 162 | void livesync_ticker(void) { | 162 | void livesync_ticker(void) { |
| 163 | if (g_socket_out == -1) | ||
| 164 | return; | ||
| 165 | |||
| 163 | /* livesync_issue_peersync sets g_next_packet_time */ | 166 | /* livesync_issue_peersync sets g_next_packet_time */ |
| 164 | pthread_mutex_lock(&g_outbuf_mutex); | 167 | pthread_mutex_lock(&g_outbuf_mutex); |
| 165 | if (time_now_seconds() > g_v6_buf.next_packet_time && g_v6_buf.fill > sizeof(g_tracker_id) + sizeof(uint32_t)) | 168 | if (time_now_seconds() > g_v6_buf.next_packet_time && g_v6_buf.fill > sizeof(g_tracker_id) + sizeof(uint32_t)) |
| @@ -177,8 +180,14 @@ void livesync_ticker(void) { | |||
| 177 | /* Inform live sync about whats going on. */ | 180 | /* Inform live sync about whats going on. */ |
| 178 | void livesync_tell(struct ot_workstruct *ws) { | 181 | void livesync_tell(struct ot_workstruct *ws) { |
| 179 | size_t peer_size; /* initialized in next line */ | 182 | size_t peer_size; /* initialized in next line */ |
| 180 | ot_peer *peer_src = peer_from_peer6(&ws->peer, &peer_size); | 183 | ot_peer *peer_src; |
| 181 | sync_buffer *dest_buf = peer_size == OT_PEER_SIZE6 ? &g_v6_buf : &g_v4_buf; | 184 | sync_buffer *dest_buf; |
| 185 | |||
| 186 | if (g_socket_out == -1) | ||
| 187 | return; | ||
| 188 | |||
| 189 | peer_src = peer_from_peer6(&ws->peer, &peer_size); | ||
| 190 | dest_buf = peer_size == OT_PEER_SIZE6 ? &g_v6_buf : &g_v4_buf; | ||
| 182 | 191 | ||
| 183 | pthread_mutex_lock(&g_outbuf_mutex); | 192 | pthread_mutex_lock(&g_outbuf_mutex); |
| 184 | 193 | ||
