summaryrefslogtreecommitdiff
path: root/src/ipcpd/common/connmgr.c
diff options
context:
space:
mode:
authorDimitri Staessens <dimitri@ouroboros.rocks>2025-08-16 16:36:10 +0200
committerDimitri Staessens <dimitri@ouroboros.rocks>2025-08-23 10:13:36 +0200
commit4f875bbd387f17ec5d0fd05f3c4346c5da8e048a (patch)
tree6ad92c424b45aa458cdb97b0af23d582b9fda932 /src/ipcpd/common/connmgr.c
parent5db139d2dc74f0d4450d3d7f45c3febc4b5dfc1f (diff)
downloadouroboros-4f875bbd387f17ec5d0fd05f3c4346c5da8e048a.tar.gz
ouroboros-4f875bbd387f17ec5d0fd05f3c4346c5da8e048a.zip
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 <dimitri@ouroboros.rocks>
Diffstat (limited to 'src/ipcpd/common/connmgr.c')
-rw-r--r--src/ipcpd/common/connmgr.c22
1 files changed, 4 insertions, 18 deletions
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 <stdlib.h>
#include <string.h>
-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,