Commit 0d89afff authored by Brian Wellington's avatar Brian Wellington

Make sure #else and #endif for ISC_PLATFORM_USETHREADS are marked as such.

parent e79a7d19
......@@ -15,7 +15,7 @@
* WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*/
/* $Id: task.c,v 1.74 2000/08/30 23:47:14 bwelling Exp $ */
/* $Id: task.c,v 1.75 2000/09/28 21:31:04 bwelling Exp $ */
/*
* Principal Author: Bob Halley
......@@ -39,7 +39,7 @@
#ifndef ISC_PLATFORM_USETHREADS
#include "task_p.h"
#endif
#endif /* ISC_PLATFORM_USETHREADS */
#define ISC_TASK_NAMES 1
......@@ -107,18 +107,18 @@ struct isc_taskmgr {
unsigned int workers;
#ifdef ISC_PLATFORM_USETHREADS
isc_thread_t * threads;
#endif
#endif /* ISC_PLATFORM_USETHREADS */
/* Locked by task manager lock. */
unsigned int default_quantum;
LIST(isc_task_t) tasks;
LIST(isc_task_t) ready_tasks;
#ifdef ISC_PLATFORM_USETHREADS
isc_condition_t work_available;
#endif
#endif /* ISC_PLATFORM_USETHREADS */
isc_boolean_t exiting;
#ifndef ISC_PLATFORM_USETHREADS
unsigned int refs;
#endif
#endif /* ISC_PLATFORM_USETHREADS */
};
#define DEFAULT_TASKMGR_QUANTUM 10
......@@ -127,7 +127,7 @@ struct isc_taskmgr {
#ifndef ISC_PLATFORM_USETHREADS
static isc_taskmgr_t *taskmgr = NULL;
#endif
#endif /* ISC_PLATFORM_USETHREADS */
/***
*** Tasks.
......@@ -156,7 +156,7 @@ task_finished(isc_task_t *task) {
*/
BROADCAST(&manager->work_available);
}
#endif
#endif /* ISC_PLATFORM_USETHREADS */
UNLOCK(&manager->lock);
DESTROYLOCK(&task->lock);
......@@ -289,7 +289,7 @@ task_ready(isc_task_t *task) {
ENQUEUE(manager->ready_tasks, task, ready_link);
#ifdef ISC_PLATFORM_USETHREADS
SIGNAL(&manager->work_available);
#endif
#endif /* ISC_PLATFORM_USETHREADS */
UNLOCK(&manager->lock);
}
......@@ -720,7 +720,7 @@ dispatch(isc_taskmgr_t *manager) {
isc_task_t *task;
#ifndef ISC_PLATFORM_USETHREADS
unsigned int total_dispatch_count = 0;
#endif
#endif /* ISC_PLATFORM_USETHREADS */
REQUIRE(VALID_MANAGER(manager));
......@@ -789,11 +789,11 @@ dispatch(isc_taskmgr_t *manager) {
WAIT(&manager->work_available, &manager->lock);
XTHREADTRACE("awake");
}
#else
#else /* ISC_PLATFORM_USETHREADS */
if (total_dispatch_count >= DEFAULT_TASKMGR_QUANTUM ||
EMPTY(manager->ready_tasks))
break;
#endif
#endif /* ISC_PLATFORM_USETHREADS */
XTHREADTRACE("working");
task = HEAD(manager->ready_tasks);
......@@ -835,7 +835,7 @@ dispatch(isc_taskmgr_t *manager) {
dispatch_count++;
#ifndef ISC_PLATFORM_USETHREADS
total_dispatch_count++;
#endif
#endif /* ISC_PLATFORM_USETHREADS */
}
if (task->references == 0 &&
......@@ -953,7 +953,7 @@ run(void *uap) {
return ((isc_threadresult_t)0);
}
#endif
#endif /* ISC_PLATFORM_USETHREADS */
static void
manager_free(isc_taskmgr_t *manager) {
......@@ -963,7 +963,7 @@ manager_free(isc_taskmgr_t *manager) {
(void)isc_condition_destroy(&manager->work_available);
isc_mem_put(manager->mctx, manager->threads,
manager->workers * sizeof (isc_thread_t));
#endif
#endif /* ISC_PLATFORM_USETHREADS */
DESTROYLOCK(&manager->lock);
manager->magic = 0;
mctx = manager->mctx;
......@@ -994,7 +994,7 @@ isc_taskmgr_create(isc_mem_t *mctx, unsigned int workers,
*managerp = taskmgr;
return (ISC_R_SUCCESS);
}
#endif
#endif /* ISC_PLATFORM_USETHREADS */
manager = isc_mem_get(mctx, sizeof *manager);
if (manager == NULL)
......@@ -1024,7 +1024,7 @@ isc_taskmgr_create(isc_mem_t *mctx, unsigned int workers,
"isc_condition_init() failed");
return (ISC_R_UNEXPECTED);
}
#endif
#endif /* ISC_PLATFORM_USETHREADS */
if (default_quantum == 0)
default_quantum = DEFAULT_DEFAULT_QUANTUM;
manager->default_quantum = default_quantum;
......@@ -1054,10 +1054,10 @@ isc_taskmgr_create(isc_mem_t *mctx, unsigned int workers,
manager_free(manager);
return (ISC_R_NOTHREADS);
}
#else
#else /* ISC_PLATFORM_USETHREADS */
manager->refs = 0;
taskmgr = manager;
#endif
#endif /* ISC_PLATFORM_USETHREADS */
*managerp = manager;
......@@ -1086,7 +1086,7 @@ isc_taskmgr_destroy(isc_taskmgr_t **managerp) {
*managerp = NULL;
return;
}
#endif
#endif /* ISC_PLATFORM_USETHREADS */
XTHREADTRACE("isc_taskmgr_destroy");
/*
......@@ -1140,14 +1140,14 @@ isc_taskmgr_destroy(isc_taskmgr_t **managerp) {
*/
for (i = 0; i < manager->workers; i++)
(void)isc_thread_join(manager->threads[i], NULL);
#else
#else /* ISC_PLATFORM_USETHREADS */
/*
* Dispatch the shutdown events.
*/
UNLOCK(&manager->lock);
while (isc__taskmgr_ready())
(void)isc__taskmgr_dispatch();
#endif
#endif /* ISC_PLATFORM_USETHREADS */
manager_free(manager);
......@@ -1173,4 +1173,4 @@ isc__taskmgr_dispatch(void) {
return (ISC_R_SUCCESS);
}
#endif
#endif /* ISC_PLATFORM_USETHREADS */
......@@ -15,7 +15,7 @@
* WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*/
/* $Id: timer.c,v 1.56 2000/08/29 21:30:02 bwelling Exp $ */
/* $Id: timer.c,v 1.57 2000/09/28 21:31:06 bwelling Exp $ */
#include <config.h>
......@@ -31,7 +31,7 @@
#ifndef ISC_PLATFORM_USETHREADS
#include "timer_p.h"
#endif
#endif /* ISC_PLATFORM_USETHREADS */
#ifdef ISC_TIMER_TRACE
#define XTRACE(s) printf("%s\n", (s))
......@@ -88,9 +88,9 @@ struct isc_timermgr {
#ifdef ISC_PLATFORM_USETHREADS
isc_condition_t wakeup;
isc_thread_t thread;
#else
#else /* ISC_PLATFORM_USETHREADS */
unsigned int refs;
#endif
#endif /* ISC_PLATFORM_USETHREADS */
isc_heap_t * heap;
};
......@@ -99,7 +99,7 @@ struct isc_timermgr {
* If threads are not in use, there can be only one.
*/
static isc_timermgr_t *timermgr = NULL;
#endif
#endif /* ISC_PLATFORM_USETHREADS */
static inline isc_result_t
schedule(isc_timer_t *timer, isc_time_t *now, isc_boolean_t signal_ok) {
......@@ -116,7 +116,7 @@ schedule(isc_timer_t *timer, isc_time_t *now, isc_boolean_t signal_ok) {
#ifndef ISC_PLATFORM_USETHREADS
UNUSED(signal_ok);
#endif
#endif /* ISC_PLATFORM_USETHREADS */
/*
* Compute the new due time.
......@@ -180,11 +180,11 @@ schedule(isc_timer_t *timer, isc_time_t *now, isc_boolean_t signal_ok) {
XTRACE("signal (schedule)");
SIGNAL(&manager->wakeup);
}
#else
#else /* ISC_PLATFORM_USETHREADS */
if (timer->index == 1 &&
isc_time_compare(&timer->due, &manager->due) < 0)
manager->due = timer->due;
#endif
#endif /* ISC_PLATFORM_USETHREADS */
return (ISC_R_SUCCESS);
}
......@@ -211,7 +211,7 @@ deschedule(isc_timer_t *timer) {
XTRACE("signal (deschedule)");
SIGNAL(&manager->wakeup);
}
#endif
#endif /* ISC_PLATFORM_USETHREADS */
}
}
......@@ -631,7 +631,7 @@ run(void *uap) {
return ((isc_threadresult_t)0);
}
#endif
#endif /* ISC_PLATFORM_USETHREADS */
static isc_boolean_t
sooner(void *v1, void *v2) {
......@@ -674,7 +674,7 @@ isc_timermgr_create(isc_mem_t *mctx, isc_timermgr_t **managerp) {
*managerp = timermgr;
return (ISC_R_SUCCESS);
}
#endif
#endif /* ISC_PLATFORM_USETHREADS */
manager = isc_mem_get(mctx, sizeof *manager);
if (manager == NULL)
......@@ -722,10 +722,10 @@ isc_timermgr_create(isc_mem_t *mctx, isc_timermgr_t **managerp) {
"isc_thread_create() failed");
return (ISC_R_UNEXPECTED);
}
#else
#else /* ISC_PLATFORM_USETHREADS */
manager->refs = 1;
timermgr = manager;
#endif
#endif /* ISC_PLATFORM_USETHREADS */
*managerp = manager;
......@@ -756,7 +756,7 @@ isc_timermgr_destroy(isc_timermgr_t **managerp) {
}
isc__timermgr_dispatch();
#endif
#endif /* ISC_PLATFORM_USETHREADS */
REQUIRE(EMPTY(manager->timers));
manager->done = ISC_TRUE;
......@@ -764,7 +764,7 @@ isc_timermgr_destroy(isc_timermgr_t **managerp) {
#ifdef ISC_PLATFORM_USETHREADS
XTRACE("signal (destroy)");
SIGNAL(&manager->wakeup);
#endif
#endif /* ISC_PLATFORM_USETHREADS */
UNLOCK(&manager->lock);
......@@ -775,14 +775,14 @@ isc_timermgr_destroy(isc_timermgr_t **managerp) {
if (isc_thread_join(manager->thread, NULL) != ISC_R_SUCCESS)
UNEXPECTED_ERROR(__FILE__, __LINE__,
"isc_thread_join() failed");
#endif
#endif /* ISC_PLATFORM_USETHREADS */
/*
* Clean up.
*/
#ifdef ISC_PLATFORM_USETHREADS
(void)isc_condition_destroy(&manager->wakeup);
#endif
#endif /* ISC_PLATFORM_USETHREADS */
DESTROYLOCK(&manager->lock);
isc_heap_destroy(&manager->heap);
manager->magic = 0;
......@@ -811,4 +811,4 @@ isc__timermgr_dispatch(void) {
dispatch(timermgr, &now);
return (ISC_R_SUCCESS);
}
#endif
#endif /* ISC_PLATFORM_USETHREADS */
......@@ -15,7 +15,7 @@
* WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*/
/* $Id: app.c,v 1.29 2000/09/01 21:31:51 bwelling Exp $ */
/* $Id: app.c,v 1.30 2000/09/28 21:31:07 bwelling Exp $ */
#include <config.h>
......@@ -39,11 +39,11 @@
#ifdef ISC_PLATFORM_USETHREADS
#include <pthread.h>
#else
#else /* ISC_PLATFORM_USETHREADS */
#include "../timer_p.h"
#include "../task_p.h"
#include "socket_p.h"
#endif
#endif /* ISC_PLATFORM_USETHREADS */
static isc_eventlist_t on_run;
static isc_mutex_t lock;
......@@ -61,7 +61,7 @@ static isc_boolean_t want_reload = ISC_FALSE;
static isc_boolean_t blocked = ISC_FALSE;
#ifdef ISC_PLATFORM_USETHREADS
static pthread_t blockedthread;
#endif
#endif /* ISC_PLATFORM_USETHREADS */
#ifdef HAVE_LINUXTHREADS
/*
......@@ -115,7 +115,7 @@ isc_app_start(void) {
#ifdef ISC_PLATFORM_USETHREADS
int presult;
sigset_t sset;
#endif
#endif /* ISC_PLATFORM_USETHREADS */
/*
* Start an ISC library application.
......@@ -213,7 +213,7 @@ isc_app_start(void) {
strerror(presult));
return (ISC_R_UNEXPECTED);
}
#endif
#endif /* ISC_PLATFORM_USETHREADS */
ISC_LIST_INIT(on_run);
......@@ -268,7 +268,7 @@ isc_app_run(void) {
isc_task_t *task;
#ifdef ISC_PLATFORM_USETHREADS
sigset_t sset;
#endif
#endif /* ISC_PLATFORM_USETHREADS */
#ifdef HAVE_SIGWAIT
int sig;
#endif
......@@ -531,7 +531,7 @@ void
isc_app_block(void) {
#ifdef ISC_PLATFORM_USETHREADS
sigset_t sset;
#endif
#endif /* ISC_PLATFORM_USETHREADS */
REQUIRE(running);
REQUIRE(!blocked);
......@@ -542,14 +542,14 @@ isc_app_block(void) {
sigaddset(&sset, SIGINT) == 0 &&
sigaddset(&sset, SIGTERM) == 0);
RUNTIME_CHECK(pthread_sigmask(SIG_UNBLOCK, &sset, NULL) == 0);
#endif
#endif /* ISC_PLATFORM_USETHREADS */
}
void
isc_app_unblock(void) {
#ifdef ISC_PLATFORM_USETHREADS
sigset_t sset;
#endif
#endif /* ISC_PLATFORM_USETHREADS */
REQUIRE(running);
REQUIRE(blocked);
......@@ -563,6 +563,6 @@ isc_app_unblock(void) {
sigaddset(&sset, SIGINT) == 0 &&
sigaddset(&sset, SIGTERM) == 0);
RUNTIME_CHECK(pthread_sigmask(SIG_BLOCK, &sset, NULL) == 0);
#endif
#endif /* ISC_PLATFORM_USETHREADS */
}
......@@ -15,7 +15,7 @@
* WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*/
/* $Id: socket.c,v 1.167 2000/09/21 21:40:29 explorer Exp $ */
/* $Id: socket.c,v 1.168 2000/09/28 21:31:08 bwelling Exp $ */
#include <config.h>
......@@ -50,7 +50,7 @@
#ifndef ISC_PLATFORM_USETHREADS
#include "socket_p.h"
#endif
#endif /* ISC_PLATFORM_USETHREADS */
/*
* Some systems define the socket length argument as an int, some as size_t,
......@@ -193,14 +193,14 @@ struct isc_socketmgr {
isc_thread_t watcher;
isc_condition_t shutdown_ok;
int pipe_fds[2];
#else
#else /* ISC_PLATFORM_USETHREADS */
unsigned int refs;
#endif
#endif /* ISC_PLATFORM_USETHREADS */
};
#ifndef ISC_PLATFORM_USETHREADS
static isc_socketmgr_t *socketmgr = NULL;
#endif
#endif /* ISC_PLATFORM_USETHREADS */
#define CLOSED 0 /* this one must be zero */
#define MANAGED 1
......@@ -372,7 +372,7 @@ select_readmsg(isc_socketmgr_t *mgr) {
return (msg);
}
#else
#else /* ISC_PLATFORM_USETHREADS */
/*
* Update the state of the socketmgr when something changes.
*/
......@@ -384,7 +384,7 @@ select_poke(isc_socketmgr_t *manager, int msg) {
wakeup_socket(manager, msg);
return;
}
#endif
#endif /* ISC_PLATFORM_USETHREADS */
/*
* Make a fd non-blocking.
......@@ -1051,7 +1051,7 @@ destroy(isc_socket_t **sockp) {
#ifdef ISC_PLATFORM_USETHREADS
if (ISC_LIST_EMPTY(manager->socklist))
SIGNAL(&manager->shutdown_ok);
#endif
#endif /* ISC_PLATFORM_USETHREADS */
/*
* XXX should reset manager->maxfd here
......@@ -1841,7 +1841,7 @@ process_fds(isc_socketmgr_t *manager, int maxfd,
#ifdef ISC_PLATFORM_USETHREADS
if (i == manager->pipe_fds[0] || i == manager->pipe_fds[1])
continue;
#endif
#endif /* ISC_PLATFORM_USETHREADS */
if (manager->fdstate[i] == CLOSE_PENDING) {
manager->fdstate[i] = CLOSED;
......@@ -1986,7 +1986,7 @@ watcher(void *uap) {
UNLOCK(&manager->lock);
return ((isc_threadresult_t)0);
}
#endif
#endif /* ISC_PLATFORM_USETHREADS */
/*
* Create a new socket manager.
......@@ -2003,7 +2003,7 @@ isc_socketmgr_create(isc_mem_t *mctx, isc_socketmgr_t **managerp) {
*managerp = socketmgr;
return (ISC_R_SUCCESS);
}
#endif
#endif /* ISC_PLATFORM_USETHREADS */
manager = isc_mem_get(mctx, sizeof *manager);
if (manager == NULL)
......@@ -2046,9 +2046,9 @@ isc_socketmgr_create(isc_mem_t *mctx, isc_socketmgr_t **managerp) {
#if 0
RUNTIME_CHECK(make_nonblock(manager->pipe_fds[1]) == ISC_R_SUCCESS);
#endif
#else
#else /* ISC_PLATFORM_USETHREADS */
manager->refs = 1;
#endif
#endif /* ISC_PLATFORM_USETHREADS */
/*
* Set up initial state for the select loop
......@@ -2058,9 +2058,9 @@ isc_socketmgr_create(isc_mem_t *mctx, isc_socketmgr_t **managerp) {
#ifdef ISC_PLATFORM_USETHREADS
FD_SET(manager->pipe_fds[0], &manager->read_fds);
manager->maxfd = manager->pipe_fds[0];
#else
#else /* ISC_PLATFORM_USETHREADS */
manager->maxfd = 0;
#endif
#endif /* ISC_PLATFORM_USETHREADS */
memset(manager->fdstate, 0, sizeof(manager->fdstate));
#ifdef ISC_PLATFORM_USETHREADS
......@@ -2077,12 +2077,12 @@ isc_socketmgr_create(isc_mem_t *mctx, isc_socketmgr_t **managerp) {
close(manager->pipe_fds[1]);
return (ISC_R_UNEXPECTED);
}
#endif
#endif /* ISC_PLATFORM_USETHREADS */
isc_mem_attach(mctx, &manager->mctx);
#ifndef ISC_PLATFORM_USETHREADS
socketmgr = manager;
#endif
#endif /* ISC_PLATFORM_USETHREADS */
*managerp = manager;
return (ISC_R_SUCCESS);
......@@ -2108,7 +2108,7 @@ isc_socketmgr_destroy(isc_socketmgr_t **managerp) {
*managerp = NULL;
return;
}
#endif
#endif /* ISC_PLATFORM_USETHREADS */
LOCK(&manager->lock);
......@@ -2120,7 +2120,7 @@ isc_socketmgr_destroy(isc_socketmgr_t **managerp) {
manager_log(manager, CREATION, "sockets exist");
WAIT(&manager->shutdown_ok, &manager->lock);
}
#else
#else /* ISC_PLATFORM_USETHREADS */
/*
* Hope all sockets have been destroyed.
*/
......@@ -2128,7 +2128,7 @@ isc_socketmgr_destroy(isc_socketmgr_t **managerp) {
manager_log(manager, CREATION, "sockets exist");
INSIST(0);
}
#endif
#endif /* ISC_PLATFORM_USETHREADS */
UNLOCK(&manager->lock);
......@@ -2146,7 +2146,7 @@ isc_socketmgr_destroy(isc_socketmgr_t **managerp) {
if (isc_thread_join(manager->watcher, NULL) != ISC_R_SUCCESS)
UNEXPECTED_ERROR(__FILE__, __LINE__,
"isc_thread_join() failed");
#endif
#endif /* ISC_PLATFORM_USETHREADS */
/*
* Clean up.
......@@ -2155,7 +2155,7 @@ isc_socketmgr_destroy(isc_socketmgr_t **managerp) {
close(manager->pipe_fds[0]);
close(manager->pipe_fds[1]);
(void)isc_condition_destroy(&manager->shutdown_ok);
#endif
#endif /* ISC_PLATFORM_USETHREADS */
for (i = 0 ; i < FD_SETSIZE ; i++)
if (manager->fdstate[i] == CLOSE_PENDING)
......@@ -3256,4 +3256,4 @@ isc__socketmgr_dispatch(fd_set *readset, fd_set *writeset, int maxfd) {
process_fds(manager, maxfd, readset, writeset);
return (ISC_R_SUCCESS);
}
#endif
#endif /* ISC_PLATFORM_USETHREADS */
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment