diff --git a/lib/isc/task.c b/lib/isc/task.c index 23f91c125b..0ea4487b0f 100644 --- a/lib/isc/task.c +++ b/lib/isc/task.c @@ -28,6 +28,8 @@ INSIST(isc_mutex_unlock((lp)) == ISC_R_SUCCESS); #define BROADCAST(cvp) \ INSIST(isc_condition_broadcast((cvp)) == ISC_R_SUCCESS); +#define SIGNAL(cvp) \ + INSIST(isc_condition_signal((cvp)) == ISC_R_SUCCESS); #define WAIT(cvp, lp) \ INSIST(isc_condition_wait((cvp), (lp)) == ISC_R_SUCCESS); #define WAITUNTIL(cvp, lp, tp, bp) \ @@ -303,7 +305,6 @@ isc_task_send(isc_task_t task, isc_event_t *eventp) { } if (was_idle) { - isc_boolean_t need_wakeup = ISC_FALSE; isc_taskmgr_t manager; /* @@ -328,18 +329,9 @@ isc_task_send(isc_task_t task, isc_event_t *eventp) { manager = task->manager; INSIST(VALID_MANAGER(manager)); LOCK(&manager->lock); - if (EMPTY(manager->ready_tasks)) - need_wakeup = ISC_TRUE; ENQUEUE(manager->ready_tasks, task, ready_link); + SIGNAL(&manager->work_available); UNLOCK(&manager->lock); - - /* - * If the runnable queue is empty, the worker threads could - * either be executing tasks or waiting for something to do. - * We wakeup anyone who is sleeping. - */ - if (need_wakeup) - BROADCAST(&manager->work_available); } *eventp = NULL; @@ -416,19 +408,14 @@ isc_task_shutdown(isc_task_t task) { return; if (was_idle) { - isc_boolean_t need_wakeup = ISC_FALSE; isc_taskmgr_t manager; manager = task->manager; INSIST(VALID_MANAGER(manager)); LOCK(&manager->lock); - if (EMPTY(manager->ready_tasks)) - need_wakeup = ISC_TRUE; ENQUEUE(manager->ready_tasks, task, ready_link); + SIGNAL(&manager->work_available); UNLOCK(&manager->lock); - - if (need_wakeup) - BROADCAST(&manager->work_available); } } diff --git a/lib/isc/timer.c b/lib/isc/timer.c index f68ab46881..575c8da453 100644 --- a/lib/isc/timer.c +++ b/lib/isc/timer.c @@ -26,6 +26,8 @@ INSIST(isc_mutex_unlock((lp)) == ISC_R_SUCCESS); #define BROADCAST(cvp) \ INSIST(isc_condition_broadcast((cvp)) == ISC_R_SUCCESS); +#define SIGNAL(cvp) \ + INSIST(isc_condition_signal((cvp)) == ISC_R_SUCCESS); #define WAIT(cvp, lp) \ INSIST(isc_condition_wait((cvp), (lp)) == ISC_R_SUCCESS); #define WAITUNTIL(cvp, lp, tp) \ @@ -91,7 +93,7 @@ struct isc_timermgr { }; static inline isc_result -schedule(isc_timer_t timer, isc_time_t now, isc_boolean_t broadcast_ok) { +schedule(isc_timer_t timer, isc_time_t now, isc_boolean_t signal_ok) { isc_result result; isc_timermgr_t manager; struct isc_time due; @@ -156,9 +158,9 @@ schedule(isc_timer_t timer, isc_time_t now, isc_boolean_t broadcast_ok) { * due time than the one the run thread is sleeping on, and we don't * want it to oversleep. */ - if (timer->index == 1 && broadcast_ok) { - XTRACE("broadcast (schedule)"); - BROADCAST(&manager->wakeup); + if (timer->index == 1 && signal_ok) { + XTRACE("signal (schedule)"); + SIGNAL(&manager->wakeup); } return (ISC_R_SUCCESS); @@ -182,8 +184,8 @@ deschedule(isc_timer_t timer) { INSIST(manager->nscheduled > 0); manager->nscheduled--; if (need_wakeup) { - XTRACE("broadcast (deschedule)"); - BROADCAST(&manager->wakeup); + XTRACE("signal (deschedule)"); + SIGNAL(&manager->wakeup); } } } @@ -620,8 +622,8 @@ isc_timermgr_destroy(isc_timermgr_t *managerp) { UNLOCK(&manager->lock); - XTRACE("broadcast (destroy)"); - BROADCAST(&manager->wakeup); + XTRACE("signal (destroy)"); + SIGNAL(&manager->wakeup); /* * Wait for thread to exit.