summaryrefslogtreecommitdiff
path: root/src/ipcpd/shim-eth-llc/main.c
diff options
context:
space:
mode:
authorSander Vrijders <[email protected]>2016-10-31 10:44:55 +0000
committerSander Vrijders <[email protected]>2016-10-31 10:44:55 +0000
commit95ad15debb61e71561d9c6363bc6e8ae0927dce1 (patch)
tree4084ef29c666739372c1f7899b78cad21da91aa1 /src/ipcpd/shim-eth-llc/main.c
parent94044e99af295e9440d306719a5cf341645d1803 (diff)
parentadd7d5f1e59c661b431ba86ba80d62badc14e762 (diff)
downloadouroboros-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/shim-eth-llc/main.c')
-rw-r--r--src/ipcpd/shim-eth-llc/main.c25
1 files changed, 14 insertions, 11 deletions
diff --git a/src/ipcpd/shim-eth-llc/main.c b/src/ipcpd/shim-eth-llc/main.c
index b7b9f783..0d4c3903 100644
--- a/src/ipcpd/shim-eth-llc/main.c
+++ b/src/ipcpd/shim-eth-llc/main.c
@@ -31,7 +31,6 @@
#include <ouroboros/bitmap.h>
#include <ouroboros/dev.h>
#include <ouroboros/ipcp-dev.h>
-#include <ouroboros/fcntl.h>
#include <ouroboros/fqueue.h>
#include <ouroboros/logs.h>
@@ -673,7 +672,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);
}
@@ -702,9 +705,6 @@ static int eth_llc_ipcp_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);
-
if (conf->if_name == NULL) {
LOG_ERR("Interface name is NULL.");
return -1;
@@ -831,7 +831,6 @@ static int eth_llc_ipcp_bootstrap(struct dif_config * conf)
if (ipcp_get_state() != IPCP_INIT) {
pthread_rwlock_unlock(&ipcpi.state_lock);
LOG_ERR("IPCP in wrong state.");
- close(skfd);
return -1;
}
@@ -855,6 +854,9 @@ static int eth_llc_ipcp_bootstrap(struct dif_config * conf)
pthread_rwlock_unlock(&ipcpi.state_lock);
+ /* this IPCP doesn't need to maintain its dif_name */
+ free(conf->dif_name);
+
LOG_DBG("Bootstrapped shim IPCP over Ethernet with LLC with api %d.",
getpid());
@@ -1135,11 +1137,12 @@ int main(int argc, char * argv[])
ipcp_fini();
- pthread_cancel(eth_llc_data.sdu_reader);
- pthread_cancel(eth_llc_data.sdu_writer);
-
- pthread_join(eth_llc_data.sdu_writer, NULL);
- pthread_join(eth_llc_data.sdu_reader, NULL);
+ if (ipcp_get_state() == IPCP_SHUTDOWN) {
+ pthread_cancel(eth_llc_data.sdu_reader);
+ pthread_cancel(eth_llc_data.sdu_writer);
+ pthread_join(eth_llc_data.sdu_writer, NULL);
+ pthread_join(eth_llc_data.sdu_reader, NULL);
+ }
eth_llc_data_fini();