summaryrefslogtreecommitdiff
path: root/src/ipcpd/local/main.c
diff options
context:
space:
mode:
authorSander Vrijders <sander.vrijders@intec.ugent.be>2016-05-28 21:09:13 +0200
committerSander Vrijders <sander.vrijders@intec.ugent.be>2016-05-28 21:09:13 +0200
commit06549f99edb0e25575487c3f76a6c76efa6e4017 (patch)
tree1cc71310374a522ab3bf0141abd0f65e00eb7e39 /src/ipcpd/local/main.c
parentc2e21a6a8cdbc72dc7d6af5ecfe0ed42f4b18cf7 (diff)
parent6aea30b730381af91300397a02e684a462bf55a7 (diff)
downloadouroboros-06549f99edb0e25575487c3f76a6c76efa6e4017.tar.gz
ouroboros-06549f99edb0e25575487c3f76a6c76efa6e4017.zip
Merged in dstaesse/ouroboros/be-ipcpd-cleanup (pull request #119)
ipcpd: cleanup of IPC processes
Diffstat (limited to 'src/ipcpd/local/main.c')
-rw-r--r--src/ipcpd/local/main.c12
1 files changed, 8 insertions, 4 deletions
diff --git a/src/ipcpd/local/main.c b/src/ipcpd/local/main.c
index f3224de0..b07b0a52 100644
--- a/src/ipcpd/local/main.c
+++ b/src/ipcpd/local/main.c
@@ -246,20 +246,24 @@ void ipcp_sig_handler(int sig, siginfo_t * info, void * c)
case SIGHUP:
case SIGQUIT:
if (info->si_pid == irmd_pid) {
+ bool clean_threads = false;
LOG_DBG("Terminating by order of %d. Bye.",
info->si_pid);
rw_lock_wrlock(&_ipcp->state_lock);
- if (_ipcp->state == IPCP_ENROLLED) {
- pthread_cancel(_ap_instance->sduloop);
- pthread_join(_ap_instance->sduloop, NULL);
- }
+ if (_ipcp->state == IPCP_ENROLLED)
+ clean_threads = true;
_ipcp->state = IPCP_SHUTDOWN;
rw_lock_unlock(&_ipcp->state_lock);
+ if (clean_threads) {
+ pthread_cancel(_ap_instance->sduloop);
+ pthread_join(_ap_instance->sduloop, NULL);
+ }
+
pthread_cancel(_ap_instance->mainloop);
}
default: