timer.c revision 823ca3c14f1596341bdd50707c01f3b529b75b4a
bf8267aa453e5d2a735ed732a043b77a0b355b20Mark Andrews * Copyright (C) 2004, 2005, 2007-2009 Internet Systems Consortium, Inc. ("ISC")
bf8267aa453e5d2a735ed732a043b77a0b355b20Mark Andrews * Copyright (C) 1998-2002 Internet Software Consortium.
bf8267aa453e5d2a735ed732a043b77a0b355b20Mark Andrews * Permission to use, copy, modify, and/or distribute this software for any
bf8267aa453e5d2a735ed732a043b77a0b355b20Mark Andrews * purpose with or without fee is hereby granted, provided that the above
bf8267aa453e5d2a735ed732a043b77a0b355b20Mark Andrews * copyright notice and this permission notice appear in all copies.
bf8267aa453e5d2a735ed732a043b77a0b355b20Mark Andrews * THE SOFTWARE IS PROVIDED "AS IS" AND ISC DISCLAIMS ALL WARRANTIES WITH
bf8267aa453e5d2a735ed732a043b77a0b355b20Mark Andrews * REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
bf8267aa453e5d2a735ed732a043b77a0b355b20Mark Andrews * AND FITNESS. IN NO EVENT SHALL ISC BE LIABLE FOR ANY SPECIAL, DIRECT,
bf8267aa453e5d2a735ed732a043b77a0b355b20Mark Andrews * INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
bf8267aa453e5d2a735ed732a043b77a0b355b20Mark Andrews * LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE
bf8267aa453e5d2a735ed732a043b77a0b355b20Mark Andrews * OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
dafcb997e390efa4423883dafd100c975c4095d6Mark Andrews * PERFORMANCE OF THIS SOFTWARE.
be7f27304337afbf078e8bd8db0f951a33abe33bAndreas Gustafsson/* $Id: timer.c,v 1.92 2009/09/01 23:47:44 tbox Exp $ */
be7f27304337afbf078e8bd8db0f951a33abe33bAndreas Gustafsson/* See task.c about the following definition: */
be7f27304337afbf078e8bd8db0f951a33abe33bAndreas Gustafsson#endif /* ISC_PLATFORM_USETHREADS */
be7f27304337afbf078e8bd8db0f951a33abe33bAndreas Gustafsson#endif /* BIND9 */
be7f27304337afbf078e8bd8db0f951a33abe33bAndreas Gustafsson#endif /* USE_TIMER_THREAD */
be7f27304337afbf078e8bd8db0f951a33abe33bAndreas Gustafsson#define XTRACEID(s, t) fprintf(stderr, "%s %p\n", (s), (t))
be7f27304337afbf078e8bd8db0f951a33abe33bAndreas Gustafsson#define XTRACETIME(s, d) fprintf(stderr, "%s %u.%09u\n", (s), \
be7f27304337afbf078e8bd8db0f951a33abe33bAndreas Gustafsson#define XTRACETIME2(s, d, n) fprintf(stderr, "%s %u.%09u %u.%09u\n", (s), \
be7f27304337afbf078e8bd8db0f951a33abe33bAndreas Gustafsson (d).seconds, (d).nanoseconds, (n).seconds, (n).nanoseconds)
a8f94d29b38872fbc6cf9a1a8223ff8453357da1Andreas Gustafsson#define XTRACETIMER(s, t, d) fprintf(stderr, "%s %p %u.%09u\n", (s), (t), \
be7f27304337afbf078e8bd8db0f951a33abe33bAndreas Gustafsson#endif /* ISC_TIMER_TRACE */
be7f27304337afbf078e8bd8db0f951a33abe33bAndreas Gustafsson#define TIMER_MAGIC ISC_MAGIC('T', 'I', 'M', 'R')
be7f27304337afbf078e8bd8db0f951a33abe33bAndreas Gustafsson#define VALID_TIMER(t) ISC_MAGIC_VALID(t, TIMER_MAGIC)
965605e238d96eb685b94df4d46d7185d1b6f121Mark Andrews /*! Not locked. */
be7f27304337afbf078e8bd8db0f951a33abe33bAndreas Gustafsson /*! Locked by timer lock. */
be7f27304337afbf078e8bd8db0f951a33abe33bAndreas Gustafsson /*! Locked by manager lock. */
void * arg;
unsigned int index;
struct isc__timermgr {
unsigned int nscheduled;
#ifdef USE_TIMER_THREAD
#ifdef USE_SHARED_MANAGER
unsigned int refs;
#ifdef BIND9
#define ISC_TIMERFUNC_SCOPE
#define ISC_TIMERFUNC_SCOPE static
ISC_TIMERFUNC_SCOPE void
ISC_TIMERFUNC_SCOPE void
ISC_TIMERFUNC_SCOPE void
ISC_TIMERFUNC_SCOPE void
static struct isc__timermethods {
void *gettype;
} timermethods = {
static struct isc__timermgrmethods {
} timermgrmethods = {
#ifdef USE_SHARED_MANAGER
static inline isc_result_t
int cmp;
#ifdef USE_TIMER_THREAD
#ifndef USE_TIMER_THREAD
#ifdef USE_TIMER_THREAD
return (result);
switch (cmp) {
return (ISC_R_NOMEMORY);
#ifdef USE_TIMER_THREAD
return (ISC_R_SUCCESS);
#ifdef USE_TIMER_THREAD
if (need_wakeup) {
NULL);
return (ISC_R_NOMEMORY);
return (result);
return (result);
return (result);
return (ISC_R_SUCCESS);
if (purge)
NULL);
return (result);
return (result);
ISC_TIMERFUNC_SCOPE void
ISC_TIMERFUNC_SCOPE void
if (free_timer)
int cmp;
if (cmp >= 0) {
if (idle) {
timer);
if (post_event) {
type,
sizeof(*event));
if (need_schedule) {
result);
#ifdef USE_TIMER_THREAD
static isc_threadresult_t
return ((isc_threadresult_t)0);
static isc_boolean_t
return (ISC_TRUE);
return (ISC_FALSE);
#ifdef USE_SHARED_MANAGER
return (ISC_R_SUCCESS);
return (ISC_R_NOMEMORY);
return (ISC_R_NOMEMORY);
return (result);
#ifdef USE_TIMER_THREAD
return (ISC_R_UNEXPECTED);
return (ISC_R_UNEXPECTED);
#ifdef USE_SHARED_MANAGER
return (ISC_R_SUCCESS);
ISC_TIMERFUNC_SCOPE void
#ifdef USE_TIMER_THREAD
ISC_TIMERFUNC_SCOPE void
#ifdef USE_SHARED_MANAGER
#ifndef USE_TIMER_THREAD
#ifdef USE_TIMER_THREAD
#ifdef USE_TIMER_THREAD
#ifdef USE_TIMER_THREAD
#ifdef USE_SHARED_MANAGER
#ifndef USE_TIMER_THREAD
#ifdef USE_SHARED_MANAGER
return (ISC_R_NOTFOUND);
return (ISC_R_SUCCESS);
#ifdef USE_SHARED_MANAGER
#ifdef USE_TIMERIMPREGISTER