From d501bbc97aeb87e6e4aa50bb2fa10a157d5909e9 Mon Sep 17 00:00:00 2001 From: Dirk Engling Date: Tue, 3 Nov 2026 05:13:22 +0100 Subject: Let a tracker with live sync built in run without a cluster --- src/ot_livesync.c | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) (limited to 'src/ot_livesync.c') 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) { uint32_t packet_type4 = htonl(OT_SYNC_PEER4); if (g_socket_in == -1) - exerr("No socket address for live sync specified."); + return; /* Prepare outgoing peers buffer */ 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) stuck when there's not enough traffic to fill udp packets fast enough */ void livesync_ticker(void) { + if (g_socket_out == -1) + return; + /* livesync_issue_peersync sets g_next_packet_time */ pthread_mutex_lock(&g_outbuf_mutex); 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) { /* Inform live sync about whats going on. */ void livesync_tell(struct ot_workstruct *ws) { size_t peer_size; /* initialized in next line */ - ot_peer *peer_src = peer_from_peer6(&ws->peer, &peer_size); - sync_buffer *dest_buf = peer_size == OT_PEER_SIZE6 ? &g_v6_buf : &g_v4_buf; + ot_peer *peer_src; + sync_buffer *dest_buf; + + if (g_socket_out == -1) + return; + + peer_src = peer_from_peer6(&ws->peer, &peer_size); + dest_buf = peer_size == OT_PEER_SIZE6 ? &g_v6_buf : &g_v4_buf; pthread_mutex_lock(&g_outbuf_mutex); -- cgit v1.3