mirror of
https://github.com/isc-projects/bind9.git
synced 2026-06-11 07:40:00 -04:00
update
This commit is contained in:
parent
d740c17c9c
commit
2acf552661
3 changed files with 32 additions and 5 deletions
20
lib/isc/pthreads/condition.c
Normal file
20
lib/isc/pthreads/condition.c
Normal file
|
|
@ -0,0 +1,20 @@
|
|||
|
||||
#include <isc/condition.h>
|
||||
#include <errno.h>
|
||||
|
||||
boolean_t
|
||||
os_condition_waituntil(os_condition_t *c, os_mutex_t *m, struct timespec *ts,
|
||||
boolean_t *timeout)
|
||||
{
|
||||
int result;
|
||||
|
||||
result = pthread_cond_timedwait(c, m, ts);
|
||||
if (result == 0) {
|
||||
*timeout = FALSE;
|
||||
return (TRUE);
|
||||
} else if (result == ETIMEDOUT) {
|
||||
*timeout = TRUE;
|
||||
return (TRUE);
|
||||
}
|
||||
return (FALSE);
|
||||
}
|
||||
|
|
@ -3,9 +3,9 @@
|
|||
#define CONDITION_H 1
|
||||
|
||||
#include <pthread.h>
|
||||
#include <errno.h>
|
||||
|
||||
#include <isc/boolean.h>
|
||||
#include <isc/mutex.h>
|
||||
#include <isc/assertions.h>
|
||||
|
||||
typedef pthread_cond_t os_condition_t;
|
||||
|
|
@ -13,12 +13,13 @@ typedef pthread_cond_t os_condition_t;
|
|||
|
||||
#define os_condition_init(cp) (pthread_cond_init((cp), NULL) == 0)
|
||||
#define os_condition_wait(cp, mp) (pthread_cond_wait((cp), (mp)) == 0)
|
||||
#define os_condition_waituntil(cp, mp, tsp, top) \
|
||||
(pthread_cond_timedwait((cp), (mp), (tsp)) == 0 \
|
||||
? TRUE \
|
||||
: ((*(top) = (errno == ETIMEDOUT)), FALSE))
|
||||
#define os_condition_signal(cp) (pthread_cond_signal((cp)) == 0)
|
||||
#define os_condition_broadcast(cp) (pthread_cond_broadcast((cp)) == 0)
|
||||
#define os_condition_destroy(cp) (pthread_cond_destroy((cp)) == 0)
|
||||
|
||||
boolean_t os_condition_waituntil(os_condition_t *,
|
||||
os_mutex_t *,
|
||||
struct timespec *,
|
||||
boolean_t *);
|
||||
|
||||
#endif /* CONDITION_H */
|
||||
|
|
|
|||
|
|
@ -766,6 +766,12 @@ task_manager_destroy(task_manager_t *managerp) {
|
|||
|
||||
/*
|
||||
* Wait for all the worker threads to exit.
|
||||
*
|
||||
* XXX This will become a timed wait. If all the workers haven't
|
||||
* died after we've waited the specified interval, we will
|
||||
* kill the worker threads. Should we join with the worker
|
||||
* threads after killing them or just leave them detached and
|
||||
* hope they go away?
|
||||
*/
|
||||
while (manager->workers > 0)
|
||||
WAIT(&manager->no_workers, &manager->lock);
|
||||
|
|
|
|||
Loading…
Reference in a new issue