task.c revision 7aba1a9660630ab7d16792b7388d9b8f56d7bf0f
8b835581b42a6b822026cc5e2eac9785db82b571Automatic Updater * Copyright (C) 2004-2013 Internet Systems Consortium, Inc. ("ISC")
73eb75dc212911e4da58a3ce0a4672d3910193ebBrian Wellington * Copyright (C) 1998-2003 Internet Software Consortium.
ec5347e2c775f027573ce5648b910361aa926c01Automatic Updater * Permission to use, copy, modify, and/or distribute this software for any
73eb75dc212911e4da58a3ce0a4672d3910193ebBrian Wellington * purpose with or without fee is hereby granted, provided that the above
73eb75dc212911e4da58a3ce0a4672d3910193ebBrian Wellington * copyright notice and this permission notice appear in all copies.
dafcb997e390efa4423883dafd100c975c4095d6Mark Andrews * THE SOFTWARE IS PROVIDED "AS IS" AND ISC DISCLAIMS ALL WARRANTIES WITH
dafcb997e390efa4423883dafd100c975c4095d6Mark Andrews * REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
dafcb997e390efa4423883dafd100c975c4095d6Mark Andrews * AND FITNESS. IN NO EVENT SHALL ISC BE LIABLE FOR ANY SPECIAL, DIRECT,
dafcb997e390efa4423883dafd100c975c4095d6Mark Andrews * INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
dafcb997e390efa4423883dafd100c975c4095d6Mark Andrews * LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE
dafcb997e390efa4423883dafd100c975c4095d6Mark Andrews * OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
dafcb997e390efa4423883dafd100c975c4095d6Mark Andrews * PERFORMANCE OF THIS SOFTWARE.
73eb75dc212911e4da58a3ce0a4672d3910193ebBrian Wellington * \author Principal Author: Bob Halley
2f9db90bf69b4cdbabe2e574cd174ef2d3a2f12bBrian Wellington * XXXRTH Need to document the states a task can be in, and the rules
2f9db90bf69b4cdbabe2e574cd174ef2d3a2f12bBrian Wellington * for changing states.
#ifdef ISC_PLATFORM_USETHREADS
#define USE_WORKER_THREADS
#define USE_SHARED_MANAGER
#include "task_p.h"
#ifdef ISC_TASK_TRACE
(t), isc_thread_self(), (m))
isc_thread_self(), (m))
#define XTRACE(m)
#define XTTRACE(t, m)
#define XTHREADTRACE(m)
} task_state_t;
static const char *statenames[] = {
struct isc__task {
unsigned int references;
unsigned int nevents;
unsigned int quantum;
unsigned int flags;
void * tag;
struct isc__taskmgr {
#ifdef ISC_PLATFORM_USETHREADS
unsigned int workers;
unsigned int default_quantum;
#ifdef ISC_PLATFORM_USETHREADS
unsigned int tasks_running;
unsigned int tasks_ready;
#ifdef USE_SHARED_MANAGER
unsigned int refs;
#ifdef USE_SHARED_MANAGER
void *tag);
const void *arg);
static inline isc_boolean_t
static inline isc__task_t *
static struct isc__taskmethods {
} taskmethods = {
(void *)isc_task_purgeevent,
(void *)isc__task_unsendrange,
(void *)isc__task_getname,
(void *)isc__task_gettag,
(void *)isc__task_getcurrenttime
#ifdef USE_WORKER_THREADS
return (ISC_R_NOMEMORY);
return (result);
if (exiting) {
return (ISC_R_SHUTTINGDOWN);
return (ISC_R_SUCCESS);
static inline isc_boolean_t
return (was_idle);
#ifdef USE_WORKER_THREADS
#ifdef USE_WORKER_THREADS
static inline isc_boolean_t
return (ISC_TRUE);
return (ISC_FALSE);
if (was_idle)
static inline isc_boolean_t
return (was_idle);
if (was_idle) {
unsigned int count = 0;
count++;
return (count);
unsigned int count;
ISC_TRUE);
return (count);
void *tag)
return (ISC_FALSE);
return (ISC_TRUE);
const void *arg)
NULL,
arg,
sizeof(*event));
return (ISC_R_NOMEMORY);
if (disallowed)
return (result);
if (was_idle)
static inline isc_boolean_t
static inline isc__task_t *
return (task);
#ifndef USE_WORKER_THREADS
unsigned int total_dispatch_count = 0;
unsigned int tasks_ready = 0;
#ifndef USE_WORKER_THREADS
#ifdef USE_WORKER_THREADS
unsigned int dispatch_count = 0;
event);
#ifndef USE_WORKER_THREADS
} while (!done);
if (finished)
#ifdef USE_WORKER_THREADS
if (requeue) {
#ifdef USE_WORKER_THREADS
tasks_ready++;
#ifdef USE_WORKER_THREADS
#ifndef USE_WORKER_THREADS
#ifdef USE_WORKER_THREADS
static isc_threadresult_t
#ifdef _WIN32
#ifdef OPENSSL_LEAKS
ERR_remove_state(0);
return ((isc_threadresult_t)0);
#ifdef USE_WORKER_THREADS
#ifdef USE_SHARED_MANAGER
unsigned int i, started = 0;
#ifndef USE_WORKER_THREADS
UNUSED(i);
#ifdef USE_SHARED_MANAGER
return (ISC_R_SHUTTINGDOWN);
return (ISC_R_SUCCESS);
return (ISC_R_NOMEMORY);
goto cleanup_mgr;
#ifdef USE_WORKER_THREADS
goto cleanup_lock;
goto cleanup_threads;
goto cleanup_workavailable;
goto cleanup_exclusivegranted;
if (default_quantum == 0)
#ifdef USE_WORKER_THREADS
for (i = 0; i < workers; i++) {
started++;
if (started == 0) {
return (ISC_R_NOTHREADS);
#ifdef USE_SHARED_MANAGER
return (ISC_R_SUCCESS);
#ifdef USE_WORKER_THREADS
return (result);
#ifndef USE_WORKER_THREADS
UNUSED(i);
#ifdef USE_SHARED_MANAGER
#ifdef USE_WORKER_THREADS
#ifdef USE_SHARED_MANAGER
return (mode);
#ifndef USE_WORKER_THREADS
#ifdef USE_SHARED_MANAGER
return (ISC_FALSE);
return (is_ready);
#ifdef USE_SHARED_MANAGER
return (ISC_R_NOTFOUND);
return (ISC_R_SUCCESS);
return (ISC_R_NOTFOUND);
return (ISC_R_SUCCESS);
#ifdef USE_WORKER_THREADS
return (ISC_R_LOCKBUSY);
return (ISC_R_SUCCESS);
#ifdef USE_WORKER_THREADS
if (priv)
return (priv);
#ifdef HAVE_LIBXML2
int xmlrc;
#ifdef ISC_PLATFORM_USETHREADS
return (xmlrc);
#ifdef HAVE_JSON
#define CHECKMEM(m) do { \
if (m == NULL) { \
goto error;\
#ifdef ISC_PLATFORM_USETHREADS
return (result);
initialize(void) {
return (result);
managerp);
return (result);
if (isc_bind9)
managerp);
return (result);
if (isc_bind9)
if (isc_bind9)
if (isc_bind9)
if (isc_bind9)
if (isc_bind9)
if (isc_bind9)
if (isc_bind9)
if (isc_bind9)
if (isc_bind9)
if (isc_bind9)
if (isc_bind9)
if (!isc_bind9)
if (isc_bind9)
if (isc_bind9)
if (isc_bind9)
if (isc_bind9)
if (isc_bind9)
if (isc_bind9)
if (!isc_bind9)
if (isc_bind9)