mirror of
https://github.com/isc-projects/bind9.git
synced 2026-04-24 07:41:10 -04:00
130. [cleanup] <isc/condition.h> does not need <pthread.h> or
<isc/boolean.h>, and now includes <isc/types.h>
instead of <isc/time.h>.
(does not need pthread.h because it *does* need isc/mutex.h, which
will be guaranteed to provide pthread.h)
This commit is contained in:
parent
63d56ac555
commit
c403d3f7d6
6 changed files with 54 additions and 57 deletions
4
CHANGES
4
CHANGES
|
|
@ -1,3 +1,7 @@
|
|||
130. [cleanup] <isc/condition.h> does not need <pthread.h> or
|
||||
<isc/boolean.h>, and now includes <isc/types.h>
|
||||
instead of <isc/time.h>.
|
||||
|
||||
129. [bug] The 'default_debug' log channel was not set up when
|
||||
'category default' was present in the config file
|
||||
|
||||
|
|
|
|||
|
|
@ -21,14 +21,12 @@
|
|||
#include <stdlib.h>
|
||||
#include <unistd.h>
|
||||
|
||||
#include <isc/assertions.h>
|
||||
#include <isc/condition.h>
|
||||
#include <isc/mutex.h>
|
||||
#include <isc/error.h>
|
||||
#include <isc/mem.h>
|
||||
#include <isc/task.h>
|
||||
#include <isc/thread.h>
|
||||
#include <isc/result.h>
|
||||
#include <isc/time.h>
|
||||
#include <isc/timer.h>
|
||||
|
||||
#include <tests/t_api.h>
|
||||
|
|
@ -56,8 +54,7 @@ static int t_tasks13(void);
|
|||
isc_mem_t *mctx = NULL;
|
||||
|
||||
static void
|
||||
t1_callback(isc_task_t *task, isc_event_t *event)
|
||||
{
|
||||
t1_callback(isc_task_t *task, isc_event_t *event) {
|
||||
int i;
|
||||
int j;
|
||||
|
||||
|
|
@ -79,8 +76,7 @@ t1_shutdown(isc_task_t *task, isc_event_t *event) {
|
|||
}
|
||||
|
||||
static void
|
||||
my_tick(isc_task_t *task, isc_event_t *event)
|
||||
{
|
||||
my_tick(isc_task_t *task, isc_event_t *event) {
|
||||
task = task;
|
||||
t_info("%s\n", event->ev_arg);
|
||||
isc_event_free(&event);
|
||||
|
|
|
|||
|
|
@ -25,22 +25,21 @@
|
|||
#include <sys/time.h>
|
||||
#include <unistd.h>
|
||||
|
||||
#include <isc/assertions.h>
|
||||
#include <isc/boolean.h>
|
||||
#include <isc/condition.h>
|
||||
#include <isc/error.h>
|
||||
#include <isc/event.h>
|
||||
#include <isc/mem.h>
|
||||
#include <isc/mutex.h>
|
||||
#include <isc/task.h>
|
||||
#include <isc/thread.h>
|
||||
#include <isc/result.h>
|
||||
#include <isc/time.h>
|
||||
#include <isc/timer.h>
|
||||
|
||||
#include <tests/t_api.h>
|
||||
|
||||
#define Tx_FUDGE_SECONDS 0 /* in absence of clock_getres() */
|
||||
#define Tx_FUDGE_NANOSECONDS 500000000 /* in absence of clock_getres() */
|
||||
#define Tx_FUDGE_SECONDS 0 /* in absence of clock_getres() */
|
||||
#define Tx_FUDGE_NANOSECONDS 500000000 /* in absence of clock_getres() */
|
||||
|
||||
static isc_time_t Tx_endtime;
|
||||
static isc_time_t Tx_lasttime;
|
||||
|
|
@ -51,7 +50,7 @@ static isc_mutex_t Tx_mx;
|
|||
static isc_condition_t Tx_cv;
|
||||
static int Tx_nfails;
|
||||
static int Tx_nprobs;
|
||||
static isc_timer_t *Tx_timer;
|
||||
static isc_timer_t *Tx_timer;
|
||||
static int Tx_seconds;
|
||||
static int Tx_nanoseconds;
|
||||
|
||||
|
|
@ -329,9 +328,9 @@ t_timers_x(isc_timertype_t timertype, isc_time_t *expires,
|
|||
#define T1_NANOSECONDS 500000000
|
||||
|
||||
static char *a1 =
|
||||
"When type is isc_timertype_ticker, a call to isc_timer_create() creates "
|
||||
"a timer that posts an ISC_TIMEREVENT_TICK event to the specified "
|
||||
"task every 'interval' seconds and returns ISC_R_SUCCESS.";
|
||||
"When type is isc_timertype_ticker, a call to isc_timer_create() "
|
||||
"creates a timer that posts an ISC_TIMEREVENT_TICK event to the "
|
||||
"specified task every 'interval' seconds and returns ISC_R_SUCCESS.";
|
||||
|
||||
static void
|
||||
t1() {
|
||||
|
|
@ -365,9 +364,10 @@ t1() {
|
|||
#define T2_NANOSECONDS 300000000;
|
||||
|
||||
static char *a2 =
|
||||
"When type is isc_timertype_once, a call to isc_timer_create() creates "
|
||||
"a timer that posts an ISC_TIMEEVENT_LIFE event to the specified "
|
||||
"task when the current time reaches or exceeds the time specified by 'expires'.";
|
||||
"When type is isc_timertype_once, a call to isc_timer_create() "
|
||||
"creates a timer that posts an ISC_TIMEEVENT_LIFE event to the "
|
||||
"specified task when the current time reaches or exceeds the time "
|
||||
"specified by 'expires'.";
|
||||
|
||||
static void
|
||||
t2() {
|
||||
|
|
@ -459,9 +459,9 @@ t3_te(isc_task_t *task, isc_event_t *event) {
|
|||
#define T3_NANOSECONDS 400000000
|
||||
|
||||
static char *a3 =
|
||||
"When type is isc_timertype_once, a call to isc_timer_create() creates "
|
||||
"a timer that posts an ISC_TIMEEVENT_IDLE event to the specified "
|
||||
"task when the timer has been idle for 'interval' seconds.";
|
||||
"When type is isc_timertype_once, a call to isc_timer_create() "
|
||||
"creates a timer that posts an ISC_TIMEEVENT_IDLE event to the "
|
||||
"specified task when the timer has been idle for 'interval' seconds.";
|
||||
|
||||
static void
|
||||
t3() {
|
||||
|
|
@ -551,21 +551,26 @@ t4_te(isc_task_t *task, isc_event_t *event) {
|
|||
++Tx_nfails;
|
||||
}
|
||||
if (Tx_eventcnt == 2) {
|
||||
isc_interval_set(&interval, T4_SECONDS, T4_NANOSECONDS);
|
||||
isc_result = isc_time_nowplusinterval(&expires, &interval);
|
||||
isc_interval_set(&interval, T4_SECONDS,
|
||||
T4_NANOSECONDS);
|
||||
isc_result = isc_time_nowplusinterval(&expires,
|
||||
&interval);
|
||||
if (isc_result == ISC_R_SUCCESS) {
|
||||
isc_interval_set(&interval, 0, 0);
|
||||
isc_result = isc_timer_reset(Tx_timer, isc_timertype_once,
|
||||
&expires, &interval, ISC_FALSE);
|
||||
isc_result =
|
||||
isc_timer_reset(Tx_timer,
|
||||
isc_timertype_once,
|
||||
&expires, &interval,
|
||||
ISC_FALSE);
|
||||
if (isc_result != ISC_R_SUCCESS) {
|
||||
t_info("isc_timer_reset failed %s\n",
|
||||
isc_result_totext(isc_result));
|
||||
isc_result_totext(isc_result));
|
||||
++Tx_nfails;
|
||||
}
|
||||
}
|
||||
else {
|
||||
t_info("isc_time_nowplusinterval failed %s\n",
|
||||
isc_result_totext(isc_result));
|
||||
isc_result_totext(isc_result));
|
||||
++Tx_nprobs;
|
||||
}
|
||||
}
|
||||
|
|
@ -682,8 +687,9 @@ t5_tick_event(isc_task_t *task, isc_event_t *event) {
|
|||
if (T5_eventcnt == 1) {
|
||||
isc_time_settoepoch(&expires);
|
||||
isc_interval_set(&interval, T5_SECONDS, 0);
|
||||
isc_result = isc_timer_reset(T5_tickertimer, isc_timertype_ticker,
|
||||
&expires, &interval, ISC_TRUE);
|
||||
isc_result = isc_timer_reset(T5_tickertimer,
|
||||
isc_timertype_ticker, &expires,
|
||||
&interval, ISC_TRUE);
|
||||
if (isc_result != ISC_R_SUCCESS) {
|
||||
t_info("isc_timer_reset failed %d\n",
|
||||
isc_result_totext(isc_result));
|
||||
|
|
@ -892,7 +898,8 @@ t_timers5() {
|
|||
return(T_UNRESOLVED);
|
||||
}
|
||||
|
||||
event = isc_event_allocate(mctx, (void *) 1 , (isc_eventtype_t) 1, t5_start_event, NULL, sizeof(*event));
|
||||
event = isc_event_allocate(mctx, (void *)1 , (isc_eventtype_t)1,
|
||||
t5_start_event, NULL, sizeof(*event));
|
||||
isc_task_send(T5_task1, &event);
|
||||
|
||||
isc_time_settoepoch(&expires);
|
||||
|
|
@ -927,8 +934,8 @@ t_timers5() {
|
|||
if (isc_result != ISC_R_SUCCESS) {
|
||||
isc_timer_detach(&T5_tickertimer);
|
||||
isc_timermgr_destroy(&timermgr);
|
||||
(void) isc_condition_signal(&T5_cv);
|
||||
(void) isc_mutex_unlock(&T5_mx);
|
||||
(void)isc_condition_signal(&T5_cv);
|
||||
(void)isc_mutex_unlock(&T5_mx);
|
||||
isc_task_destroy(&T5_task1);
|
||||
isc_task_destroy(&T5_task2);
|
||||
isc_taskmgr_destroy(&tmgr);
|
||||
|
|
@ -939,14 +946,9 @@ t_timers5() {
|
|||
}
|
||||
|
||||
isc_interval_set(&interval, 0, 0);
|
||||
isc_result = isc_timer_create( timermgr,
|
||||
isc_timertype_once,
|
||||
&expires,
|
||||
&interval,
|
||||
T5_task2,
|
||||
t5_once_event,
|
||||
NULL,
|
||||
&T5_oncetimer);
|
||||
isc_result = isc_timer_create(timermgr, isc_timertype_once,
|
||||
&expires, &interval, T5_task2,
|
||||
t5_once_event, NULL, &T5_oncetimer);
|
||||
|
||||
if (isc_result != ISC_R_SUCCESS) {
|
||||
isc_timer_detach(&T5_tickertimer);
|
||||
|
|
|
|||
|
|
@ -20,21 +20,20 @@
|
|||
#include <errno.h>
|
||||
#include <string.h>
|
||||
|
||||
#include <isc/assertions.h>
|
||||
#include <isc/condition.h>
|
||||
#include <isc/error.h>
|
||||
#include <isc/time.h>
|
||||
#include <isc/util.h>
|
||||
|
||||
isc_result_t
|
||||
isc_condition_waituntil(isc_condition_t *c, isc_mutex_t *m, isc_time_t *t)
|
||||
{
|
||||
isc_condition_waituntil(isc_condition_t *c, isc_mutex_t *m, isc_time_t *t) {
|
||||
int presult;
|
||||
struct timespec ts;
|
||||
|
||||
REQUIRE(c != NULL && m != NULL && t != NULL);
|
||||
|
||||
ts.tv_sec = t->seconds;
|
||||
ts.tv_nsec = t->nanoseconds;
|
||||
ts.tv_sec = isc_time_seconds(t);
|
||||
ts.tv_nsec = isc_time_nanoseconds(t);
|
||||
do {
|
||||
presult = pthread_cond_timedwait(c, m, &ts);
|
||||
if (presult == 0)
|
||||
|
|
|
|||
|
|
@ -18,15 +18,10 @@
|
|||
#ifndef ISC_CONDITION_H
|
||||
#define ISC_CONDITION_H 1
|
||||
|
||||
#include <pthread.h>
|
||||
|
||||
#include <isc/boolean.h>
|
||||
#include <isc/result.h>
|
||||
#include <isc/mutex.h>
|
||||
#include <isc/time.h>
|
||||
#include <isc/lang.h>
|
||||
|
||||
ISC_LANG_BEGINDECLS
|
||||
#include <isc/mutex.h>
|
||||
#include <isc/result.h>
|
||||
#include <isc/types.h>
|
||||
|
||||
typedef pthread_cond_t isc_condition_t;
|
||||
|
||||
|
|
@ -50,8 +45,10 @@ typedef pthread_cond_t isc_condition_t;
|
|||
((pthread_cond_destroy((cp)) == 0) ? \
|
||||
ISC_R_SUCCESS : ISC_R_UNEXPECTED)
|
||||
|
||||
isc_result_t isc_condition_waituntil(isc_condition_t *, isc_mutex_t *,
|
||||
isc_time_t *);
|
||||
ISC_LANG_BEGINDECLS
|
||||
|
||||
isc_result_t
|
||||
isc_condition_waituntil(isc_condition_t *, isc_mutex_t *, isc_time_t *);
|
||||
|
||||
ISC_LANG_ENDDECLS
|
||||
|
||||
|
|
|
|||
|
|
@ -20,14 +20,13 @@
|
|||
#include <stddef.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
#include <isc/assertions.h>
|
||||
#include <isc/condition.h>
|
||||
#include <isc/error.h>
|
||||
#include <isc/heap.h>
|
||||
#include <isc/mem.h>
|
||||
#include <isc/mutex.h>
|
||||
#include <isc/task.h>
|
||||
#include <isc/thread.h>
|
||||
#include <isc/time.h>
|
||||
#include <isc/timer.h>
|
||||
#include <isc/util.h>
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue