atproto relay implementation in zig zlay.waow.tech
9
fork

Configure Feed

Select the types of activity you want to include in your feed.

fix GC thread teardown race: join instead of detach, mark DB success from gc()

- keep gc_thread handle and join it during shutdown before dp.deinit() runs —
dp is stack-owned, detaching left a use-after-free window
- add markDbSuccess() call at end of gc() so the health signal isn't solely
dependent on uidForDid (event ingestion path)

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>

+5 -2
+2
src/event_log.zig
··· 835 835 if (self.max_dir_bytes > 0) { 836 836 try self.gcBySize(); 837 837 } 838 + 839 + self.markDbSuccess(); 838 840 } 839 841 840 842 /// delete oldest event files until total directory size is under max_dir_bytes
+3 -2
src/main.zig
··· 297 297 log.err("failed to start GC thread: {s}", .{@errorName(err)}); 298 298 return err; 299 299 }; 300 - gc_thread.detach(); 301 300 302 301 // wire HTTP fallback into broadcaster (all API endpoints served on WS port) 303 302 var http_context = api.HttpContext{ ··· 366 365 ws_listener.deinit(io); 367 366 server_future.cancel(io); 368 367 369 - // GC thread is detached and checks shutdown_flag — no cancel needed 368 + // join GC thread — it checks shutdown_flag and will exit its sleep loop. 369 + // must complete before dp.deinit() runs (dp is stack-owned). 370 + gc_thread.join(); 370 371 371 372 // cancel broadcaster fiber (shutdown flag already set, it will drain remaining) 372 373 broadcast_future.cancel(io);