diff options
author | Dmitry Kozlov <xeb@mail.ru> | 2014-09-09 21:13:16 +0400 |
---|---|---|
committer | Dmitry Kozlov <xeb@mail.ru> | 2014-09-09 21:13:16 +0400 |
commit | fd4bd1031e6b9b0e99761036b2d4488cb1403c77 (patch) | |
tree | a4bcf6778faf2f138671c48aca79133c06ffa0c3 /accel-pppd/triton | |
parent | ec9968885ed2f273c4d2c18297986c463fb9cf9b (diff) | |
download | accel-ppp-fd4bd1031e6b9b0e99761036b2d4488cb1403c77.tar.gz accel-ppp-fd4bd1031e6b9b0e99761036b2d4488cb1403c77.zip |
triton: fixed race condition
Diffstat (limited to 'accel-pppd/triton')
-rw-r--r-- | accel-pppd/triton/triton.c | 9 |
1 files changed, 5 insertions, 4 deletions
diff --git a/accel-pppd/triton/triton.c b/accel-pppd/triton/triton.c index 05cbf210..cdcccdb8 100644 --- a/accel-pppd/triton/triton.c +++ b/accel-pppd/triton/triton.c @@ -80,7 +80,7 @@ static void ctx_thread(struct _triton_context_t *ctx); static void* triton_thread(struct _triton_thread_t *thread) { sigset_t set; - int sig; + int sig, need_free; sigfillset(&set); sigdelset(&set, SIGKILL); @@ -160,14 +160,15 @@ cont: log_debug2("thread %p: switch from %p %p\n", thread, thread->ctx, thread->ctx->thread); spin_lock(&threads_lock); - if (thread->ctx->pending) { + if (thread->ctx->pending && !thread->ctx->need_free) { spin_unlock(&threads_lock); goto cont; } thread->ctx->thread = NULL; + need_free = thread->ctx->need_free; spin_unlock(&threads_lock); - if (thread->ctx->need_free) { + if (need_free) { log_debug2("- context %p removed\n", thread->ctx); triton_context_release(thread->ctx); } @@ -283,7 +284,7 @@ int triton_queue_ctx(struct _triton_context_t *ctx) { spin_lock(&threads_lock); ctx->pending = 1; - if (ctx->thread || ctx->queued || ctx->init) { + if (ctx->thread || ctx->queued || ctx->init || ctx->need_free) { spin_unlock(&threads_lock); return 0; } |