From 4f875bbd387f17ec5d0fd05f3c4346c5da8e048a Mon Sep 17 00:00:00 2001 From: Dimitri Staessens Date: Sat, 16 Aug 2025 16:36:10 +0200 Subject: ipcpd: Simplify enroll and connmgr startup/shutdown There's not need to keep these states as they always follow the init/start/stop/fini flow. Signed-off-by: Dimitri Staessens --- src/ipcpd/common/connmgr.c | 22 ++++------------------ 1 file changed, 4 insertions(+), 18 deletions(-) (limited to 'src/ipcpd/common/connmgr.c') diff --git a/src/ipcpd/common/connmgr.c b/src/ipcpd/common/connmgr.c index 6dd5fed0..1bb8c932 100644 --- a/src/ipcpd/common/connmgr.c +++ b/src/ipcpd/common/connmgr.c @@ -38,12 +38,6 @@ #include #include -enum connmgr_state { - CONNMGR_NULL = 0, - CONNMGR_INIT, - CONNMGR_RUNNING -}; - struct conn_el { struct list_head next; struct conn conn; @@ -61,7 +55,6 @@ struct comp { struct { struct comp comps[COMPID_MAX]; - enum connmgr_state state; pthread_t acceptor; } connmgr; @@ -228,8 +221,6 @@ static void handle_event(void * self, int connmgr_init(void) { - connmgr.state = CONNMGR_INIT; - if (notifier_reg(handle_event, NULL)) { log_err("Failed to register notifier."); return -1; @@ -242,13 +233,10 @@ void connmgr_fini(void) { int i; - notifier_unreg(handle_event); - - if (connmgr.state == CONNMGR_RUNNING) - pthread_join(connmgr.acceptor, NULL); - for (i = 0; i < COMPID_MAX; ++i) connmgr_comp_fini(i); + + notifier_unreg(handle_event); } int connmgr_start(void) @@ -258,15 +246,13 @@ int connmgr_start(void) return -1; } - connmgr.state = CONNMGR_RUNNING; - return 0; } void connmgr_stop(void) { - if (connmgr.state == CONNMGR_RUNNING) - pthread_cancel(connmgr.acceptor); + pthread_cancel(connmgr.acceptor); + pthread_join(connmgr.acceptor, NULL); } int connmgr_comp_init(enum comp_id id, -- cgit v1.2.3