From 371147fdc5e7982a0c37adad60c728eeeaf228cf Mon Sep 17 00:00:00 2001 From: Michael Graff Date: Sun, 8 Sep 2002 18:35:55 +0000 Subject: [PATCH] add isc_timer_gettype() (useful in debugging code) and a temporary hack of isc_timermgr_poke --- lib/isc/include/isc/timer.h | 7 ++++++- lib/isc/timer.c | 39 ++++++++++++++++++++++++++++--------- 2 files changed, 36 insertions(+), 10 deletions(-) diff --git a/lib/isc/include/isc/timer.h b/lib/isc/include/isc/timer.h index 111d4c6327..50aa85cd08 100644 --- a/lib/isc/include/isc/timer.h +++ b/lib/isc/include/isc/timer.h @@ -15,7 +15,7 @@ * WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */ -/* $Id: timer.h,v 1.29 2001/10/18 06:06:13 marka Exp $ */ +/* $Id: timer.h,v 1.30 2002/09/08 18:35:55 explorer Exp $ */ #ifndef ISC_TIMER_H #define ISC_TIMER_H 1 @@ -277,6 +277,9 @@ isc_timer_detach(isc_timer_t **timerp); * timer event callbacks will run after the call. */ +isc_result_t +isc_timer_gettype(isc_timer_t *timer); + isc_result_t isc_timermgr_create(isc_mem_t *mctx, isc_timermgr_t **managerp); /* @@ -326,6 +329,8 @@ isc_timermgr_destroy(isc_timermgr_t **managerp); * All resources used by the manager have been freed. */ +void isc_timermgr_poke(isc_timermgr_t *m); + ISC_LANG_ENDDECLS #endif /* ISC_TIMER_H */ diff --git a/lib/isc/timer.c b/lib/isc/timer.c index b6f4a95012..74f74389d1 100644 --- a/lib/isc/timer.c +++ b/lib/isc/timer.c @@ -15,7 +15,7 @@ * WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */ -/* $Id: timer.c,v 1.67 2001/11/30 01:59:36 gson Exp $ */ +/* $Id: timer.c,v 1.68 2002/09/08 18:35:55 explorer Exp $ */ #include @@ -36,16 +36,19 @@ #endif /* ISC_PLATFORM_USETHREADS */ #ifdef ISC_TIMER_TRACE -#define XTRACE(s) printf("%s\n", (s)) -#define XTRACEID(s, t) printf("%s %p\n", (s), (t)) -#define XTRACETIME(s, d) printf("%s %u.%09u\n", (s), \ +#define XTRACE(s) fprintf(stderr, "%s\n", (s)) +#define XTRACEID(s, t) fprintf(stderr, "%s %p\n", (s), (t)) +#define XTRACETIME(s, d) fprintf(stderr, "%s %u.%09u\n", (s), \ (d).seconds, (d).nanoseconds) -#define XTRACETIMER(s, t, d) printf("%s %p %u.%09u\n", (s), (t), \ +#define XTRACETIME2(s, d, n) fprintf(stderr, "%s %u.%09u %u.%09u\n", (s), \ + (d).seconds, (d).nanoseconds, (n).seconds, (n).nanoseconds) +#define XTRACETIMER(s, t, d) fprintf(stderr, "%s %p %u.%09u\n", (s), (t), \ (d).seconds, (d).nanoseconds) #else #define XTRACE(s) #define XTRACEID(s, t) #define XTRACETIME(s, d) +#define XTRACETIME2(s, d, n) #define XTRACETIMER(s, t, d) #endif /* ISC_TIMER_TRACE */ @@ -444,6 +447,19 @@ isc_timer_reset(isc_timer_t *timer, isc_timertype_t type, return (result); } +isc_result_t +isc_timer_gettype(isc_timer_t *timer) { + isc_timertype_t t; + + REQUIRE(VALID_TIMER(timer)); + + LOCK(&timer->lock); + t = timer->type; + UNLOCK(&timer->lock); + + return (t); +} + isc_result_t isc_timer_touch(isc_timer_t *timer) { isc_result_t result; @@ -642,18 +658,18 @@ run(void *uap) { dispatch(manager, &now); if (manager->nscheduled > 0) { - XTRACETIME(isc_msgcat_get(isc_msgcat, + XTRACETIME2(isc_msgcat_get(isc_msgcat, ISC_MSGSET_GENERAL, ISC_MSG_WAITUNTIL, "waituntil"), - manager->due); + manager->due, now); result = WAITUNTIL(&manager->wakeup, &manager->lock, &manager->due); INSIST(result == ISC_R_SUCCESS || result == ISC_R_TIMEDOUT); } else { - XTRACE(isc_msgcat_get(isc_msgcat, ISC_MSGSET_GENERAL, - ISC_MSG_WAIT, "wait")); + XTRACETIME(isc_msgcat_get(isc_msgcat, ISC_MSGSET_GENERAL, + ISC_MSG_WAIT, "wait"), now); WAIT(&manager->wakeup, &manager->lock); } XTRACE(isc_msgcat_get(isc_msgcat, ISC_MSGSET_TIMER, @@ -770,6 +786,11 @@ isc_timermgr_create(isc_mem_t *mctx, isc_timermgr_t **managerp) { return (ISC_R_SUCCESS); } +void +isc_timermgr_poke(isc_timermgr_t *manager) { + SIGNAL(&manager->wakeup); +} + void isc_timermgr_destroy(isc_timermgr_t **managerp) { isc_timermgr_t *manager;