diff options
author | Sander Vrijders <sander.vrijders@intec.ugent.be> | 2016-10-31 10:44:55 +0000 |
---|---|---|
committer | Sander Vrijders <sander.vrijders@intec.ugent.be> | 2016-10-31 10:44:55 +0000 |
commit | 95ad15debb61e71561d9c6363bc6e8ae0927dce1 (patch) | |
tree | 4084ef29c666739372c1f7899b78cad21da91aa1 /src/ipcpd/local/main.c | |
parent | 94044e99af295e9440d306719a5cf341645d1803 (diff) | |
parent | add7d5f1e59c661b431ba86ba80d62badc14e762 (diff) | |
download | ouroboros-95ad15debb61e71561d9c6363bc6e8ae0927dce1.tar.gz ouroboros-95ad15debb61e71561d9c6363bc6e8ae0927dce1.zip |
Merged in dstaesse/ouroboros/be-fixes (pull request #294)
ipcpd: Clean shutdown when bootstrap fails
Diffstat (limited to 'src/ipcpd/local/main.c')
-rw-r--r-- | src/ipcpd/local/main.c | 20 |
1 files changed, 12 insertions, 8 deletions
diff --git a/src/ipcpd/local/main.c b/src/ipcpd/local/main.c index 412795ec..f95eeae4 100644 --- a/src/ipcpd/local/main.c +++ b/src/ipcpd/local/main.c @@ -26,7 +26,6 @@ #include <ouroboros/logs.h> #include <ouroboros/errno.h> #include <ouroboros/dev.h> -#include <ouroboros/fcntl.h> #include <ouroboros/fqueue.h> #include <ouroboros/ipcp-dev.h> #include <ouroboros/local-dev.h> @@ -38,7 +37,6 @@ #include <stdlib.h> #include <pthread.h> #include <sys/wait.h> -#include <fcntl.h> #include <assert.h> #define EVENT_WAIT_TIMEOUT 100 /* us */ @@ -140,7 +138,11 @@ void ipcp_sig_handler(int sig, siginfo_t * info, void * c) pthread_rwlock_wrlock(&ipcpi.state_lock); - ipcp_set_state(IPCP_SHUTDOWN); + if (ipcp_get_state() == IPCP_INIT) + ipcp_set_state(IPCP_NULL); + + if (ipcp_get_state() == IPCP_ENROLLED) + ipcp_set_state(IPCP_SHUTDOWN); pthread_rwlock_unlock(&ipcpi.state_lock); } @@ -154,9 +156,6 @@ static int ipcp_local_bootstrap(struct dif_config * conf) assert(conf); assert(conf->type == THIS_TYPE); - /* this IPCP doesn't need to maintain its dif_name */ - free(conf->dif_name); - pthread_rwlock_wrlock(&ipcpi.state_lock); if (ipcp_get_state() != IPCP_INIT) { @@ -165,6 +164,9 @@ static int ipcp_local_bootstrap(struct dif_config * conf) return -1; } + /* this IPCP doesn't need to maintain its dif_name */ + free(conf->dif_name); + ipcp_set_state(IPCP_ENROLLED); pthread_create(&local_data.sduloop, NULL, ipcp_local_sdu_loop, NULL); @@ -382,8 +384,10 @@ int main(int argc, char * argv[]) ipcp_fini(); - pthread_cancel(local_data.sduloop); - pthread_join(local_data.sduloop, NULL); + if (ipcp_get_state() == IPCP_SHUTDOWN) { + pthread_cancel(local_data.sduloop); + pthread_join(local_data.sduloop, NULL); + } local_data_fini(); |