diff options
Diffstat (limited to 'src/ipcpd')
-rw-r--r-- | src/ipcpd/common/connmgr.c | 22 | ||||
-rw-r--r-- | src/ipcpd/common/enroll.c | 18 |
2 files changed, 7 insertions, 33 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, diff --git a/src/ipcpd/common/enroll.c b/src/ipcpd/common/enroll.c index ade6db70..8e5384a5 100644 --- a/src/ipcpd/common/enroll.c +++ b/src/ipcpd/common/enroll.c @@ -52,15 +52,10 @@ #define ENROLL_WARN_TIME_OFFSET 20 #define ENROLL_BUF_LEN 1024 -enum enroll_state { - ENROLL_NULL = 0, - ENROLL_INIT, - ENROLL_RUNNING -}; struct { struct ipcp_config conf; - enum enroll_state state; + pthread_t listener; } enroll; @@ -309,16 +304,11 @@ int enroll_init(void) return -1; } - enroll.state = ENROLL_INIT; - return 0; } void enroll_fini(void) { - if (enroll.state == ENROLL_RUNNING) - pthread_join(enroll.listener, NULL); - connmgr_comp_fini(COMPID_ENROLL); } @@ -327,13 +317,11 @@ int enroll_start(void) if (pthread_create(&enroll.listener, NULL, enroll_handle, NULL)) return -1; - enroll.state = ENROLL_RUNNING; - return 0; } void enroll_stop(void) { - if (enroll.state == ENROLL_RUNNING) - pthread_cancel(enroll.listener); + pthread_cancel(enroll.listener); + pthread_join(enroll.listener, NULL); } |