add isc_timer_gettype() (useful in debugging code) and a temporary hack of isc_timermgr_poke

This commit is contained in:
Michael Graff
2002-09-08 18:35:55 +00:00
parent 3e42be4026
commit 371147fdc5
2 changed files with 36 additions and 10 deletions

View File

@@ -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 <config.h>
@@ -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;