]> git.ipfire.org Git - zone-sync.git/commitdiff
main: Create an event loop and launch it
authorMichael Tremer <michael.tremer@ipfire.org>
Mon, 11 May 2026 09:02:47 +0000 (09:02 +0000)
committerMichael Tremer <michael.tremer@ipfire.org>
Mon, 11 May 2026 09:02:47 +0000 (09:02 +0000)
Signed-off-by: Michael Tremer <michael.tremer@ipfire.org>
main.c

diff --git a/main.c b/main.c
index 443dd2875c962a5126ba0b6293d4f7de84b40ef9..beb9b5ac4af6eecdd2c63109f62270f8cc0f8db9 100644 (file)
--- a/main.c
+++ b/main.c
@@ -22,6 +22,9 @@
 #include <stdio.h>
 #include <syslog.h>
 
+#include <urcu/wfcqueue.h>
+
+#include <isc/loop.h>
 #include <isc/mem.h>
 
 typedef struct ctx {
@@ -29,6 +32,9 @@ typedef struct ctx {
 
        // Memory Context
        isc_mem_t* memctx;
+
+       // Loop Manager
+       isc_loopmgr_t* loopmgr;
 } ctx_t;
 
 static void logger(ctx_t* ctx, int priority, const char* format, ...) {
@@ -133,5 +139,17 @@ int main(int argc, char* argv[]) {
        // Allocate a new memory context
        isc_mem_create(&ctx.memctx);
 
+       // Initialize the loop manager
+       isc_loopmgr_create(ctx.memctx, 1, &ctx.loopmgr);
+
+       // Register a callback to be called when the loop starts
+       isc_loopmgr_setup(ctx.loopmgr, run_loop, &ctx);
+
+       // Run the event loop
+       isc_loopmgr_run(ctx.loopmgr);
+
+ERROR:
+       isc_loopmgr_destroy(&ctx.loopmgr);
+
        return 0;
 }