diff options
author | Kozlov Dmitry <dima@server> | 2011-05-24 10:58:40 +0400 |
---|---|---|
committer | Kozlov Dmitry <dima@server> | 2011-05-24 10:58:40 +0400 |
commit | 85b204590c8d2ed028405330ca67cbd8c6dd25f9 (patch) | |
tree | ccad19edd89d52602f092552451b6d948c85b5e2 /accel-pppd/triton | |
parent | 0e7dab14a5753a162f9643d78623a62d6c9f477b (diff) | |
download | accel-ppp-85b204590c8d2ed028405330ca67cbd8c6dd25f9.tar.gz accel-ppp-85b204590c8d2ed028405330ca67cbd8c6dd25f9.zip |
fixed segfault at daemon termination
Diffstat (limited to 'accel-pppd/triton')
-rw-r--r-- | accel-pppd/triton/triton.c | 18 |
1 files changed, 14 insertions, 4 deletions
diff --git a/accel-pppd/triton/triton.c b/accel-pppd/triton/triton.c index 63561d8..d2ed595 100644 --- a/accel-pppd/triton/triton.c +++ b/accel-pppd/triton/triton.c @@ -121,8 +121,12 @@ static void* triton_thread(struct _triton_thread_t *thread) } else spin_unlock(&threads_lock); - if (terminate) + if (terminate) { + spin_lock(&threads_lock); + list_del(&thread->entry); + spin_unlock(&threads_lock); return NULL; + } //printf("thread %p: enter sigwait\n", thread); sigwait(&set, &sig); @@ -588,7 +592,6 @@ void __export triton_run() void __export triton_terminate() { struct _triton_context_t *ctx; - struct _triton_thread_t *t; int r; need_terminate = 1; @@ -604,8 +607,15 @@ void __export triton_terminate() } spin_unlock(&ctx_list_lock); - list_for_each_entry(t, &threads, entry) - pthread_join(t->thread, NULL); + while (1) { + spin_lock(&threads_lock); + if (list_empty(&threads)) { + spin_unlock(&threads_lock); + break; + } + spin_unlock(&threads_lock); + sleep(1); + } md_terminate(); timer_terminate(); |