From 888bc341ed6667d6c357f4f6b7936a9d0022bffd Mon Sep 17 00:00:00 2001 From: Thierry Bordaz Date: Jul 13 2018 09:45:25 +0000 Subject: Ticket 49848 - Nunc-stans event thread can be hanging shortly when a job is (re)armed Bug Description: When a nunc-stans job is rearmed, event_q_notify enqueue the job and notify the event thread. The first thing event thread does is to lock the job. But until internal_ns_job_rearm release the lock, event thread is hanging. This is also the case of a worker thread (work_q_notify) but has less negative impact Fix Description: Release the lock of the job before calling event_q_notify/work_q_notify https://pagure.io/389-ds-base/issue/49848 Reviewed by: ? Platforms tested: F27 Flag Day: no Doc impact: no --- diff --git a/src/nunc-stans/ns/ns_thrpool.c b/src/nunc-stans/ns/ns_thrpool.c index 774607c..2d2ea35 100644 --- a/src/nunc-stans/ns/ns_thrpool.c +++ b/src/nunc-stans/ns/ns_thrpool.c @@ -260,6 +260,15 @@ internal_ns_job_rearm(ns_job_t *job) /* I think we need to check about is_shutdown here? */ + /* + * weither it will wakeup a NS worker thread (work_q) or the NS event thread (event_q) + * This thread will acquire the job->monitor. + * To prevent the thread to wait just release the lock before waking it + * + * This is specifically important for the event thread + */ + pthread_mutex_unlock(&(job->monitor)); + if (NS_JOB_IS_IO(job->job_type) || NS_JOB_IS_TIMER(job->job_type) || NS_JOB_IS_SIGNAL(job->job_type)) { event_q_notify(job); } else { @@ -267,7 +276,6 @@ internal_ns_job_rearm(ns_job_t *job) /* Prevents an un-necessary queue / dequeue to the event_q */ work_q_notify(job); } - pthread_mutex_unlock(&(job->monitor)); } static void