diff options
author | Florian Obser <florian@cvs.openbsd.org> | 2020-02-16 08:06:38 +0000 |
---|---|---|
committer | Florian Obser <florian@cvs.openbsd.org> | 2020-02-16 08:06:38 +0000 |
commit | 2cd26457d696b252618618426b29f7790bc3e9b1 (patch) | |
tree | 10cafa98ca949ea71ec2af3438d89914f0c08263 /usr.bin | |
parent | 5af1c7c7f9f2a87d089e85d539bd94c6f0c16698 (diff) |
Now we are only using one timer type (once) and expires is always NULL
so remove those struct members.
OK millert
Diffstat (limited to 'usr.bin')
-rw-r--r-- | usr.bin/dig/dighost.c | 6 | ||||
-rw-r--r-- | usr.bin/dig/lib/isc/include/isc/timer.h | 19 | ||||
-rw-r--r-- | usr.bin/dig/lib/isc/timer.c | 109 | ||||
-rw-r--r-- | usr.bin/dig/lib/isc/unix/include/isc/time.h | 4 | ||||
-rw-r--r-- | usr.bin/dig/lib/isc/unix/time.c | 5 |
5 files changed, 36 insertions, 107 deletions
diff --git a/usr.bin/dig/dighost.c b/usr.bin/dig/dighost.c index c4bf27f22ab..631099fdb17 100644 --- a/usr.bin/dig/dighost.c +++ b/usr.bin/dig/dighost.c @@ -14,7 +14,7 @@ * PERFORMANCE OF THIS SOFTWARE. */ -/* $Id: dighost.c,v 1.6 2020/02/15 10:58:14 florian Exp $ */ +/* $Id: dighost.c,v 1.7 2020/02/16 08:06:37 florian Exp $ */ /*! \file * \note @@ -2546,7 +2546,7 @@ bringup_timer(dig_query_t *query, unsigned int default_timeout) { interval_set(&l->interval, local_timeout, 0); if (query->timer != NULL) isc_timer_detach(&query->timer); - result = isc_timer_create(timermgr, isc_timertype_once, NULL, + result = isc_timer_create(timermgr, &l->interval, global_task, connect_timeout, query, &query->timer); check_result(result, "isc_timer_create"); @@ -3664,8 +3664,6 @@ recv_done(isc_task_t *task, isc_event_t *event) { debug("have local timeout of %d", local_timeout); interval_set(&l->interval, local_timeout, 0); result = isc_timer_reset(query->timer, - isc_timertype_once, - NULL, &l->interval, ISC_FALSE); check_result(result, "isc_timer_reset"); diff --git a/usr.bin/dig/lib/isc/include/isc/timer.h b/usr.bin/dig/lib/isc/include/isc/timer.h index 4e96bb5bd17..e6c2d0b87c2 100644 --- a/usr.bin/dig/lib/isc/include/isc/timer.h +++ b/usr.bin/dig/lib/isc/include/isc/timer.h @@ -14,7 +14,7 @@ * PERFORMANCE OF THIS SOFTWARE. */ -/* $Id: timer.h,v 1.6 2020/02/16 08:05:41 florian Exp $ */ +/* $Id: timer.h,v 1.7 2020/02/16 08:06:37 florian Exp $ */ #ifndef ISC_TIMER_H #define ISC_TIMER_H 1 @@ -81,9 +81,6 @@ ***/ /*% Timer Type */ -typedef enum { - isc_timertype_once = 1 /*%< Once */ -} isc_timertype_t; typedef struct isc_timerevent { struct isc_event common; @@ -136,8 +133,6 @@ struct isc_timer { isc_result_t isc_timer_create(isc_timermgr_t *manager, - isc_timertype_t type, - const isc_time_t *expires, const interval_t *interval, isc_task_t *task, isc_taskaction_t action, @@ -200,8 +195,6 @@ isc_timer_create(isc_timermgr_t *manager, isc_result_t isc_timer_reset(isc_timer_t *timer, - isc_timertype_t type, - const isc_time_t *expires, const interval_t *interval, isc_boolean_t purge); /*%< @@ -286,16 +279,6 @@ isc_timer_detach(isc_timer_t **timerp); *\endcode */ -isc_timertype_t -isc_timer_gettype(isc_timer_t *timer); -/*%< - * Return the timer type. - * - * Requires: - * - *\li 'timer' to be a valid timer. - */ - isc_result_t isc_timermgr_create(isc_timermgr_t **managerp); /*%< diff --git a/usr.bin/dig/lib/isc/timer.c b/usr.bin/dig/lib/isc/timer.c index 44c5c31debe..722bb28d163 100644 --- a/usr.bin/dig/lib/isc/timer.c +++ b/usr.bin/dig/lib/isc/timer.c @@ -14,7 +14,7 @@ * PERFORMANCE OF THIS SOFTWARE. */ -/* $Id: timer.c,v 1.9 2020/02/16 08:05:41 florian Exp $ */ +/* $Id: timer.c,v 1.10 2020/02/16 08:06:37 florian Exp $ */ /*! \file */ @@ -43,8 +43,6 @@ struct isc__timer { unsigned int references; isc_time_t idle; /*! Locked by manager lock. */ - isc_timertype_t type; - isc_time_t expires; interval_t interval; isc_task_t * task; isc_taskaction_t action; @@ -76,16 +74,12 @@ struct isc__timermgr { */ isc_result_t -isc__timer_create(isc_timermgr_t *manager, isc_timertype_t type, - const isc_time_t *expires, const interval_t *interval, +isc__timer_create(isc_timermgr_t *manager, const interval_t *interval, isc_task_t *task, isc_taskaction_t action, void *arg, isc_timer_t **timerp); isc_result_t -isc__timer_reset(isc_timer_t *timer, isc_timertype_t type, - const isc_time_t *expires, const interval_t *interval, +isc__timer_reset(isc_timer_t *timer, const interval_t *interval, isc_boolean_t purge); -isc_timertype_t -isc_timer_gettype(isc_timer_t *timer); isc_result_t isc__timer_touch(isc_timer_t *timer); void @@ -120,14 +114,7 @@ schedule(isc__timer_t *timer, isc_time_t *now, isc_boolean_t signal_ok) { /* * Compute the new due time. */ - if (isc_time_isepoch(&timer->idle)) - due = timer->expires; - else if (isc_time_isepoch(&timer->expires)) - due = timer->idle; - else if (isc_time_compare(&timer->idle, &timer->expires) < 0) - due = timer->idle; - else - due = timer->expires; + due = timer->idle; /* * Schedule the timer. @@ -213,8 +200,7 @@ destroy(isc__timer_t *timer) { } isc_result_t -isc__timer_create(isc_timermgr_t *manager0, isc_timertype_t type, - const isc_time_t *expires, const interval_t *interval, +isc__timer_create(isc_timermgr_t *manager0, const interval_t *interval, isc_task_t *task, isc_taskaction_t action, void *arg, isc_timer_t **timerp) { @@ -225,7 +211,7 @@ isc__timer_create(isc_timermgr_t *manager0, isc_timertype_t type, /* * Create a new 'type' timer managed by 'manager'. The timers - * parameters are specified by 'expires' and 'interval'. Events + * parameters are specified by 'interval'. Events * will be posted to 'task' and when dispatched 'action' will be * called with 'arg' as the arg value. The new timer is returned * in 'timerp'. @@ -234,13 +220,10 @@ isc__timer_create(isc_timermgr_t *manager0, isc_timertype_t type, REQUIRE(VALID_MANAGER(manager)); REQUIRE(task != NULL); REQUIRE(action != NULL); - if (expires == NULL) - expires = isc_time_epoch; if (interval == NULL) interval = interval_zero; - REQUIRE(!(isc_time_isepoch(expires) && interval_iszero(interval))); + REQUIRE(!(interval_iszero(interval))); REQUIRE(timerp != NULL && *timerp == NULL); - REQUIRE(!(isc_time_isepoch(expires) || interval_iszero(interval))); /* * Get current time. @@ -254,7 +237,7 @@ isc__timer_create(isc_timermgr_t *manager0, isc_timertype_t type, timer->manager = manager; timer->references = 1; - if (type == isc_timertype_once && !interval_iszero(interval)) { + if (!interval_iszero(interval)) { result = isc_time_add(&now, interval, &timer->idle); if (result != ISC_R_SUCCESS) { free(timer); @@ -262,8 +245,6 @@ isc__timer_create(isc_timermgr_t *manager0, isc_timertype_t type, } } - timer->type = type; - timer->expires = *expires; timer->interval = *interval; timer->task = NULL; isc_task_attach(task, &timer->task); @@ -302,8 +283,7 @@ isc__timer_create(isc_timermgr_t *manager0, isc_timertype_t type, } isc_result_t -isc__timer_reset(isc_timer_t *timer0, isc_timertype_t type, - const isc_time_t *expires, const interval_t *interval, +isc__timer_reset(isc_timer_t *timer0, const interval_t *interval, isc_boolean_t purge) { isc__timer_t *timer = (isc__timer_t *)timer0; @@ -321,12 +301,10 @@ isc__timer_reset(isc_timer_t *timer0, isc_timertype_t type, manager = timer->manager; REQUIRE(VALID_MANAGER(manager)); - if (expires == NULL) - expires = isc_time_epoch; if (interval == NULL) interval = interval_zero; - REQUIRE(!(isc_time_isepoch(expires) && interval_iszero(interval))); - REQUIRE(!(isc_time_isepoch(expires) || interval_iszero(interval))); + + REQUIRE(!(interval_iszero(interval))); /* * Get current time. @@ -339,10 +317,8 @@ isc__timer_reset(isc_timer_t *timer0, isc_timertype_t type, ISC_TIMEREVENT_FIRSTEVENT, ISC_TIMEREVENT_LASTEVENT, NULL); - timer->type = type; - timer->expires = *expires; timer->interval = *interval; - if (type == isc_timertype_once && !interval_iszero(interval)) { + if (!interval_iszero(interval)) { result = isc_time_add(&now, interval, &timer->idle); } else { isc_time_settoepoch(&timer->idle); @@ -356,18 +332,6 @@ isc__timer_reset(isc_timer_t *timer0, isc_timertype_t type, return (result); } -isc_timertype_t -isc_timer_gettype(isc_timer_t *timer0) { - isc__timer_t *timer = (isc__timer_t *)timer0; - isc_timertype_t t; - - REQUIRE(VALID_TIMER(timer)); - - t = timer->type; - - return (t); -} - isc_result_t isc__timer_touch(isc_timer_t *timer0) { isc__timer_t *timer = (isc__timer_t *)timer0; @@ -443,32 +407,24 @@ dispatch(isc__timermgr_t *manager, isc_time_t *now) { timer = isc_heap_element(manager->heap, 1); INSIST(timer != NULL); if (isc_time_compare(now, &timer->due) >= 0) { - if (!isc_time_isepoch(&timer->expires) && - isc_time_compare(now, - &timer->expires) >= 0) { - type = ISC_TIMEREVENT_LIFE; + idle = ISC_FALSE; + + if (!isc_time_isepoch(&timer->idle) && + isc_time_compare(now, + &timer->idle) >= 0) { + idle = ISC_TRUE; + } + if (idle) { + type = ISC_TIMEREVENT_IDLE; post_event = ISC_TRUE; need_schedule = ISC_FALSE; } else { - idle = ISC_FALSE; - - if (!isc_time_isepoch(&timer->idle) && - isc_time_compare(now, - &timer->idle) >= 0) { - idle = ISC_TRUE; - } - if (idle) { - type = ISC_TIMEREVENT_IDLE; - post_event = ISC_TRUE; - need_schedule = ISC_FALSE; - } else { - /* - * Idle timer has been touched; - * reschedule. - */ - post_event = ISC_FALSE; - need_schedule = ISC_TRUE; - } + /* + * Idle timer has been touched; + * reschedule. + */ + post_event = ISC_FALSE; + need_schedule = ISC_TRUE; } if (post_event) { @@ -653,14 +609,13 @@ isc_timermgr_destroy(isc_timermgr_t **managerp) { } isc_result_t -isc_timer_create(isc_timermgr_t *manager, isc_timertype_t type, - const isc_time_t *expires, const interval_t *interval, +isc_timer_create(isc_timermgr_t *manager, const interval_t *interval, isc_task_t *task, isc_taskaction_t action, void *arg, isc_timer_t **timerp) { REQUIRE(ISCAPI_TIMERMGR_VALID(manager)); - return (isc__timer_create(manager, type, expires, interval, + return (isc__timer_create(manager, interval, task, action, arg, timerp)); } @@ -674,14 +629,12 @@ isc_timer_detach(isc_timer_t **timerp) { } isc_result_t -isc_timer_reset(isc_timer_t *timer, isc_timertype_t type, - const isc_time_t *expires, const interval_t *interval, +isc_timer_reset(isc_timer_t *timer, const interval_t *interval, isc_boolean_t purge) { REQUIRE(ISCAPI_TIMER_VALID(timer)); - return (isc__timer_reset(timer, type, expires, - interval, purge)); + return (isc__timer_reset(timer, interval, purge)); } isc_result_t diff --git a/usr.bin/dig/lib/isc/unix/include/isc/time.h b/usr.bin/dig/lib/isc/unix/include/isc/time.h index 288b3d058f9..5110031e414 100644 --- a/usr.bin/dig/lib/isc/unix/include/isc/time.h +++ b/usr.bin/dig/lib/isc/unix/include/isc/time.h @@ -14,7 +14,7 @@ * PERFORMANCE OF THIS SOFTWARE. */ -/* $Id: time.h,v 1.3 2020/02/13 13:53:01 jsg Exp $ */ +/* $Id: time.h,v 1.4 2020/02/16 08:06:37 florian Exp $ */ #ifndef ISC_TIME_H #define ISC_TIME_H 1 @@ -88,8 +88,6 @@ struct isc_time { unsigned int nanoseconds; }; -extern const isc_time_t * const isc_time_epoch; - void isc_time_set(isc_time_t *t, unsigned int seconds, unsigned int nanoseconds); /*%< diff --git a/usr.bin/dig/lib/isc/unix/time.c b/usr.bin/dig/lib/isc/unix/time.c index c9b8c34c07f..c6de5cc82d4 100644 --- a/usr.bin/dig/lib/isc/unix/time.c +++ b/usr.bin/dig/lib/isc/unix/time.c @@ -14,7 +14,7 @@ * PERFORMANCE OF THIS SOFTWARE. */ -/* $Id: time.c,v 1.6 2020/02/13 21:34:06 jung Exp $ */ +/* $Id: time.c,v 1.7 2020/02/16 08:06:37 florian Exp $ */ /*! \file */ @@ -77,9 +77,6 @@ interval_iszero(const interval_t *i) { *** Absolute Times ***/ -static const isc_time_t epoch = { 0, 0 }; -const isc_time_t * const isc_time_epoch = &epoch; - void isc_time_set(isc_time_t *t, unsigned int seconds, unsigned int nanoseconds) { REQUIRE(t != NULL); |