From 2fd016776bca60e0a2bff69a9f130e4c3415bb4c Mon Sep 17 00:00:00 2001 From: Dimitri Staessens Date: Sun, 10 Aug 2025 10:25:34 +0200 Subject: ipcpd: Fix shutdown of link-state routing The link_state component tried to unregister from the notifier while it had threads running. The deadlock happens when notifier_event had a rdlock trying to delete a neighbour, while notifier_unreg tries to take the write lock. And the delete can't complete in the notifier. https://tree.taiga.io/project/dstaesse-ouroboros/us/113 We need to make sure that all threads are stopped before unregistering from the notifier. Updated link_state to use the start/stop() paradigm and not create/cancel threads within init/fini(). Signed-off-by: Dimitri Staessens Signed-off-by: Sander Vrijders --- src/ipcpd/unicast/dt.c | 10 ++++++++++ 1 file changed, 10 insertions(+) (limited to 'src/ipcpd/unicast/dt.c') diff --git a/src/ipcpd/unicast/dt.c b/src/ipcpd/unicast/dt.c index 39b0025f..38cee75d 100644 --- a/src/ipcpd/unicast/dt.c +++ b/src/ipcpd/unicast/dt.c @@ -726,8 +726,16 @@ int dt_start(void) goto fail_listener; } + if (routing_start() < 0) { + log_err("Failed to start routing."); + goto fail_routing; + } + return 0; + fail_routing: + pthread_cancel(dt.listener); + pthread_join(dt.listener, NULL); fail_listener: notifier_unreg(&handle_event); fail_notifier_reg: @@ -738,6 +746,8 @@ int dt_start(void) void dt_stop(void) { + routing_stop(); + pthread_cancel(dt.listener); pthread_join(dt.listener, NULL); -- cgit v1.2.3