static char *ap_pid_fname=NULL;
static char *ap_scoreboard_fname=NULL;
static char *ap_lock_fname;
-static char *ap_server_argv0=NULL;
static int ap_daemons_to_start=0;
static int ap_daemons_min_free=0;
static int ap_daemons_max_free=0;
}
ap_register_cleanup(p, NULL, accept_mutex_cleanup, ap_null_cleanup);
- /* pre ap_context_t nitialize these */
+ /* preinitialize these */
op_on.sem_num = 0;
op_on.sem_op = -1;
op_on.sem_flg = SEM_UNDO;
unlock_it.l_pid = 0; /* pid not actually interesting */
expand_lock_fname(p);
- ap_open(&tempfile, p, ap_lock_fname, APR_CREATE | APR_WRITE | APR_EXCL,
- APR_UREAD | APR_UWRITE | APR_GREAD | APR_WREAD);
- ap_get_os_file(tempfile, &lock_fd);
+ ap_open(&tempfile, ap_lock_fname, APR_CREATE | APR_WRITE | APR_EXCL,
+ APR_UREAD | APR_UWRITE | APR_GREAD | APR_WREAD, p);
+ ap_get_os_file(&lock_fd, tempfile);
if (lock_fd == -1) {
perror("open");
fprintf(stderr, "Cannot open lock file: %s\n", ap_lock_fname);
}
if (ret < 0) {
- ap_log_error(APLOG_MARK, APLOG_EMERG, server_conf,
+ ap_log_error(APLOG_MARK, APLOG_EMERG, errno, server_conf,
"fcntl: F_SETLKW: Error getting accept lock, exiting! "
"Perhaps you need to use the LockFile directive to place "
"your lock file on a local disk!");
/* nop */
}
if (ret < 0) {
- ap_log_error(APLOG_MARK, APLOG_EMERG, server_conf,
+ ap_log_error(APLOG_MARK, APLOG_EMERG, errno, server_conf,
"fcntl: F_SETLKW: Error freeing accept lock, exiting! "
"Perhaps you need to use the LockFile directive to place "
"your lock file on a local disk!");
{
ap_file_t *tempfile;
- ap_open(&tempfile, p, ap_lock_fname, APR_WRITE, APR_UREAD|APR_UWRITE);
+ ap_open(&tempfile, ap_lock_fname, APR_WRITE, APR_UREAD|APR_UWRITE, p);
if (!tempfile) {
ap_log_error(APLOG_MARK, APLOG_EMERG, server_conf,
"Child cannot open lock file: %s", ap_lock_fname);
clean_child_exit(APEXIT_CHILDINIT);
}
- ap_get_os_file(tempfile, &lock_fd);
+ ap_get_os_file(&lock_fd, tempfile);
}
/*
expand_lock_fname(p);
unlink(ap_lock_fname);
- ap_open(p, ap_lock_fname, APR_CREATE|APR_WRITE|APR_EXCL,
- APR_UREAD|APR_UWRITE, &tempfile);
+ ap_open(&tempfile, ap_lock_fname, APR_CREATE|APR_WRITE|APR_EXCL,
+ APR_UREAD|APR_UWRITE, p);
if (!tempfile) {
ap_log_error(APLOG_MARK, APLOG_EMERG, server_conf,
"Parent cannot open lock file: %s", ap_lock_fname);
exit(APEXIT_INIT);
}
- ap_get_os_file(tempfile, &lock_fd);
+ ap_get_os_file(&lock_fd, tempfile);
ap_register_cleanup(p, NULL, accept_mutex_cleanup, ap_null_cleanup);
}
if ((shmid = shmget(shmkey, SCOREBOARD_SIZE, IPC_CREAT | SHM_R | SHM_W)) == -1) {
#ifdef LINUX
if (errno == ENOSYS) {
- ap_log_error(APLOG_MARK, APLOG_NOERRNO|APLOG_EMERG, server_conf,
+ ap_log_error(APLOG_MARK, APLOG_NOERRNO|APLOG_EMERG, 0, server_conf,
"Your kernel was built without CONFIG_SYSVIPC\n"
"%s: Please consult the Apache FAQ for details",
ap_server_argv0);
}
#endif
- ap_log_error(APLOG_MARK, APLOG_EMERG, server_conf,
+ ap_log_error(APLOG_MARK, APLOG_EMERG, errno, server_conf,
"could not call shmget");
exit(APEXIT_INIT);
}
- ap_log_error(APLOG_MARK, APLOG_NOERRNO|APLOG_INFO, server_conf,
+ ap_log_error(APLOG_MARK, APLOG_NOERRNO|APLOG_INFO, 0, server_conf,
"created shared memory segment #%d", shmid);
#ifdef MOVEBREAK
#define BADSHMAT ((scoreboard *)(-1))
if ((ap_scoreboard_image = (scoreboard *) shmat(shmid, 0, 0)) == BADSHMAT) {
- ap_log_error(APLOG_MARK, APLOG_EMERG, server_conf, "shmat error");
+ ap_log_error(APLOG_MARK, APLOG_EMERG, errno, server_conf, "shmat error");
/*
* We exit below, after we try to remove the segment
*/
}
else { /* only worry about permissions if we attached the segment */
if (shmctl(shmid, IPC_STAT, &shmbuf) != 0) {
- ap_log_error(APLOG_MARK, APLOG_ERR, server_conf,
+ ap_log_error(APLOG_MARK, APLOG_ERR, errno, server_conf,
"shmctl() could not stat segment #%d", shmid);
}
else {
shmbuf.shm_perm.uid = unixd_config.user_id;
shmbuf.shm_perm.gid = unixd_config.group_id;
if (shmctl(shmid, IPC_SET, &shmbuf) != 0) {
- ap_log_error(APLOG_MARK, APLOG_ERR, server_conf,
+ ap_log_error(APLOG_MARK, APLOG_ERR, errno, server_conf,
"shmctl() could not set segment #%d", shmid);
}
}
* (small) tables.
*/
if (shmctl(shmid, IPC_RMID, NULL) != 0) {
- ap_log_error(APLOG_MARK, APLOG_WARNING, server_conf,
+ ap_log_error(APLOG_MARK, APLOG_WARNING, errno, server_conf,
"shmctl: IPC_RMID: could not remove shared memory segment #%d",
shmid);
}
case 3: /* 344ms */
/* perhaps it missed the SIGHUP, lets try again */
ap_log_error(APLOG_MARK, APLOG_NOERRNO|APLOG_WARNING,
- server_conf,
+ 0, server_conf,
"child process %d did not exit, sending another SIGHUP",
pid);
kill(pid, SIGHUP);
case 7: /* 1.4sec */
/* ok, now it's being annoying */
ap_log_error(APLOG_MARK, APLOG_NOERRNO|APLOG_WARNING,
- server_conf,
+ 0, server_conf,
"child process %d still did not exit, sending a SIGTERM",
pid);
kill(pid, SIGTERM);
break;
case 8: /* 6 sec */
/* die child scum */
- ap_log_error(APLOG_MARK, APLOG_NOERRNO|APLOG_ERR, server_conf,
+ ap_log_error(APLOG_MARK, APLOG_NOERRNO|APLOG_ERR, 0, server_conf,
"child process %d still did not exit, sending a SIGKILL",
pid);
kill(pid, SIGKILL);
* exited, we will likely fail to bind to the port
* after the restart.
*/
- ap_log_error(APLOG_MARK, APLOG_NOERRNO|APLOG_ERR, server_conf,
+ ap_log_error(APLOG_MARK, APLOG_NOERRNO|APLOG_ERR, 0, server_conf,
"could not make child process %d exit, "
"attempting to continue anyway", pid);
break;
sa.sa_flags = SA_RESETHAND;
#endif
if (sigaction(SIGSEGV, &sa, NULL) < 0)
- ap_log_error(APLOG_MARK, APLOG_WARNING, server_conf, "sigaction(SIGSEGV)");
+ ap_log_error(APLOG_MARK, APLOG_WARNING, errno, server_conf, "sigaction(SIGSEGV)");
#ifdef SIGBUS
if (sigaction(SIGBUS, &sa, NULL) < 0)
- ap_log_error(APLOG_MARK, APLOG_WARNING, server_conf, "sigaction(SIGBUS)");
+ ap_log_error(APLOG_MARK, APLOG_WARNING, errno, server_conf, "sigaction(SIGBUS)");
#endif
#ifdef SIGABORT
if (sigaction(SIGABORT, &sa, NULL) < 0)
- ap_log_error(APLOG_MARK, APLOG_WARNING, server_conf, "sigaction(SIGABORT)");
+ ap_log_error(APLOG_MARK, APLOG_WARNING, errno, server_conf, "sigaction(SIGABORT)");
#endif
#ifdef SIGABRT
if (sigaction(SIGABRT, &sa, NULL) < 0)
- ap_log_error(APLOG_MARK, APLOG_WARNING, server_conf, "sigaction(SIGABRT)");
+ ap_log_error(APLOG_MARK, APLOG_WARNING, errno, server_conf, "sigaction(SIGABRT)");
#endif
#ifdef SIGILL
if (sigaction(SIGILL, &sa, NULL) < 0)
- ap_log_error(APLOG_MARK, APLOG_WARNING, server_conf, "sigaction(SIGILL)");
+ ap_log_error(APLOG_MARK, APLOG_WARNING, errno, server_conf, "sigaction(SIGILL)");
#endif
sa.sa_flags = 0;
}
sa.sa_handler = sig_term;
if (sigaction(SIGTERM, &sa, NULL) < 0)
- ap_log_error(APLOG_MARK, APLOG_WARNING, server_conf, "sigaction(SIGTERM)");
+ ap_log_error(APLOG_MARK, APLOG_WARNING, errno, server_conf, "sigaction(SIGTERM)");
#ifdef SIGINT
if (sigaction(SIGINT, &sa, NULL) < 0)
- ap_log_error(APLOG_MARK, APLOG_WARNING, server_conf, "sigaction(SIGINT)");
+ ap_log_error(APLOG_MARK, APLOG_WARNING, errno, server_conf, "sigaction(SIGINT)");
#endif
#ifdef SIGXCPU
sa.sa_handler = SIG_DFL;
if (sigaction(SIGXCPU, &sa, NULL) < 0)
- ap_log_error(APLOG_MARK, APLOG_WARNING, server_conf, "sigaction(SIGXCPU)");
+ ap_log_error(APLOG_MARK, APLOG_WARNING, errno, server_conf, "sigaction(SIGXCPU)");
#endif
#ifdef SIGXFSZ
sa.sa_handler = SIG_DFL;
if (sigaction(SIGXFSZ, &sa, NULL) < 0)
- ap_log_error(APLOG_MARK, APLOG_WARNING, server_conf, "sigaction(SIGXFSZ)");
+ ap_log_error(APLOG_MARK, APLOG_WARNING, errno, server_conf, "sigaction(SIGXFSZ)");
#endif
#ifdef SIGPIPE
sa.sa_handler = SIG_IGN;
if (sigaction(SIGPIPE, &sa, NULL) < 0)
- ap_log_error(APLOG_MARK, APLOG_WARNING, server_conf, "sigaction(SIGPIPE)");
+ ap_log_error(APLOG_MARK, APLOG_WARNING, errno, server_conf, "sigaction(SIGPIPE)");
#endif
/* we want to ignore HUPs and USR1 while we're busy processing one */
sigaddset(&sa.sa_mask, SIGUSR1);
sa.sa_handler = restart;
if (sigaction(SIGHUP, &sa, NULL) < 0)
- ap_log_error(APLOG_MARK, APLOG_WARNING, server_conf, "sigaction(SIGHUP)");
+ ap_log_error(APLOG_MARK, APLOG_WARNING, errno, server_conf, "sigaction(SIGHUP)");
if (sigaction(SIGUSR1, &sa, NULL) < 0)
- ap_log_error(APLOG_MARK, APLOG_WARNING, server_conf, "sigaction(SIGUSR1)");
+ ap_log_error(APLOG_MARK, APLOG_WARNING, errno, server_conf, "sigaction(SIGUSR1)");
#else
if (!one_process) {
signal(SIGSEGV, sig_coredump);
requests_this_child = 0;
last_lr = NULL;
- /* Get a sub ap_context_t for global allocations in this child, so that
+ /* Get a sub context for global allocations in this child, so that
* we can have cleanups occur when the child exits.
*/
ap_create_context(&pchild, pconf);
* on Linux 2.0.x we seem to end up with EFAULT
* occasionally, and we'd loop forever due to it.
*/
- ap_log_error(APLOG_MARK, APLOG_ERR, server_conf, "select: (listen)");
+ ap_log_error(APLOG_MARK, APLOG_ERR, errno, server_conf, "select: (listen)");
clean_child_exit(1);
}
}
first_lr=lr;
do {
- ap_get_os_sock(lr->sd, &sockdes);
+ ap_get_os_sock(&sockdes, lr->sd);
if (FD_ISSET(sockdes, &main_fds))
goto got_listener;
lr = lr->next;
* Ben Hyde noted that temporary ENETDOWN situations
* occur in mobile IP.
*/
- ap_log_error(APLOG_MARK, APLOG_EMERG, server_conf,
+ ap_log_error(APLOG_MARK, APLOG_EMERG, errno, server_conf,
"accept: giving up.");
clean_child_exit(APEXIT_CHILDFATAL);
#endif /*ENETDOWN*/
#ifdef TPF
case EINACT:
- ap_log_error(APLOG_MARK, APLOG_EMERG, server_conf,
+ ap_log_error(APLOG_MARK, APLOG_EMERG, errno, server_conf,
"offload device inactive");
clean_child_exit(APEXIT_CHILDFATAL);
break;
default:
- ap_log_error(APLOG_MARK, APLOG_NOERRNO|APLOG_ERR, server_conf,
+ ap_log_error(APLOG_MARK, APLOG_NOERRNO|APLOG_ERR, 0, server_conf,
"select/accept error (%u)", errno);
clean_child_exit(APEXIT_CHILDFATAL);
#else
default:
- ap_log_error(APLOG_MARK, APLOG_ERR, server_conf,
+ ap_log_error(APLOG_MARK, APLOG_ERR, errno, server_conf,
"accept: (client socket)");
clean_child_exit(1);
#endif
* socket options, file descriptors, and read/write buffers.
*/
- ap_get_os_sock(csd, &sockdes);
+ ap_get_os_sock(&sockdes, csd);
clen = sizeof(sa_server);
if (getsockname(sockdes, &sa_server, &clen) < 0) {
- ap_log_error(APLOG_MARK, APLOG_ERR, server_conf, "getsockname");
+ ap_log_error(APLOG_MARK, APLOG_ERR, errno, server_conf, "getsockname");
ap_close_socket(csd);
continue;
}
iol = unix_attach_socket(sockdes);
if (iol == NULL) {
if (errno == EBADF) {
- ap_log_error(APLOG_MARK, APLOG_NOERRNO|APLOG_WARNING, NULL,
+ ap_log_error(APLOG_MARK, APLOG_NOERRNO|APLOG_WARNING, 0, NULL,
"filedescriptor (%u) larger than FD_SETSIZE (%u) "
"found, you probably need to rebuild Apache with a "
"larger FD_SETSIZE", sockdes, FD_SETSIZE);
}
else {
- ap_log_error(APLOG_MARK, APLOG_WARNING, NULL,
+ ap_log_error(APLOG_MARK, APLOG_WARNING, errno, NULL,
"error attaching to socket");
}
ap_close_socket(csd);
#else
if ((pid = fork()) == -1) {
#endif
- ap_log_error(APLOG_MARK, APLOG_ERR, s, "fork: Unable to fork new process");
+ ap_log_error(APLOG_MARK, APLOG_ERR, errno, s, "fork: Unable to fork new process");
/* fork didn't succeed. Fix the scoreboard or else
* it will say SERVER_STARTING forever and ever
static int reported = 0;
if (!reported) {
- ap_log_error(APLOG_MARK, APLOG_NOERRNO|APLOG_ERR, server_conf,
+ ap_log_error(APLOG_MARK, APLOG_NOERRNO|APLOG_ERR, 0, server_conf,
"server reached MaxClients setting, consider"
" raising the MaxClients setting");
reported = 1;
}
else {
if (idle_spawn_rate >= 8) {
- ap_log_error(APLOG_MARK, APLOG_NOERRNO|APLOG_INFO, server_conf,
+ ap_log_error(APLOG_MARK, APLOG_NOERRNO|APLOG_INFO, 0, server_conf,
"server seems busy, (you may need "
"to increase StartServers, or Min/MaxSpareServers), "
"spawning %d children, there are %d idle, and "
*/
if ((WIFEXITED(status)) &&
WEXITSTATUS(status) == APEXIT_CHILDFATAL) {
- ap_log_error(APLOG_MARK, APLOG_ALERT|APLOG_NOERRNO, server_conf,
+ ap_log_error(APLOG_MARK, APLOG_ALERT|APLOG_NOERRNO, 0, server_conf,
"Child %d returned a Fatal error... \n"
"Apache is exiting!",
pid);
#ifdef WCOREDUMP
if (WCOREDUMP(status)) {
ap_log_error(APLOG_MARK, APLOG_NOERRNO|APLOG_NOTICE,
- server_conf,
+ 0, server_conf,
"child pid %d exit signal %s (%d), "
"possible coredump in %s",
pid, (WTERMSIG(status) >= NumSIG) ? "" :
else {
#endif
ap_log_error(APLOG_MARK, APLOG_NOERRNO|APLOG_NOTICE,
- server_conf,
+ 0, server_conf,
"child pid %d exit signal %s (%d)", pid,
SYS_SIGLIST[WTERMSIG(status)], WTERMSIG(status));
#ifdef WCOREDUMP
}
-static int setup_listeners(ap_context_t *p, server_rec *s)
+static int setup_listeners(server_rec *s)
{
ap_listen_rec *lr;
int sockdes;
- if (ap_listen_open(p, s->port)) {
- ap_log_error(APLOG_MARK, APLOG_NOERRNO|APLOG_ALERT, s,
+ if (ap_listen_open(s->process, s->port)) {
+ ap_log_error(APLOG_MARK, APLOG_NOERRNO|APLOG_ALERT, 0, s,
"no listening sockets available, shutting down");
return -1;
}
listenmaxfd = -1;
FD_ZERO(&listenfds);
for (lr = ap_listeners; lr; lr = lr->next) {
- ap_get_os_sock(lr->sd, &sockdes);
+ ap_get_os_sock(&sockdes, lr->sd);
FD_SET(sockdes, &listenfds);
if (sockdes > listenmaxfd) {
listenmaxfd = sockdes;
ap_log_pid(pconf, ap_pid_fname);
- if (setup_listeners(pconf, s)) {
+ if (setup_listeners(s)) {
/* XXX: hey, what's the right way for the mpm to indicate a fatal error? */
return 1;
}
hold_off_on_exponential_spawning = 10;
}
- ap_log_error(APLOG_MARK, APLOG_NOERRNO|APLOG_NOTICE, server_conf,
+ ap_log_error(APLOG_MARK, APLOG_NOERRNO|APLOG_NOTICE, 0, server_conf,
"%s configured -- resuming normal operations",
ap_get_server_version());
- ap_log_error(APLOG_MARK, APLOG_NOERRNO|APLOG_INFO, server_conf,
+ ap_log_error(APLOG_MARK, APLOG_NOERRNO|APLOG_INFO, 0, server_conf,
"Server built: %s", ap_get_server_built());
restart_pending = shutdown_pending = 0;
* scoreboard. Somehow we don't know about this
* child.
*/
- ap_log_error(APLOG_MARK, APLOG_NOERRNO|APLOG_WARNING, server_conf,
+ ap_log_error(APLOG_MARK, APLOG_NOERRNO|APLOG_WARNING,
+ 0, server_conf,
"long lost child came home! (pid %d)", pid);
}
/* Don't perform idle maintenance when a child dies,
* Kill child processes, tell them to call child_exit, etc...
*/
if (ap_killpg(getpgrp(), SIGTERM) < 0) {
- ap_log_error(APLOG_MARK, APLOG_WARNING, server_conf, "killpg SIGTERM");
+ ap_log_error(APLOG_MARK, APLOG_WARNING, errno, server_conf, "killpg SIGTERM");
}
reclaim_child_processes(1); /* Start with SIGTERM */
pidfile = ap_server_root_relative (pconf, ap_pid_fname);
if ( pidfile != NULL && unlink(pidfile) == 0)
ap_log_error(APLOG_MARK, APLOG_NOERRNO|APLOG_INFO,
- server_conf,
+ 0, server_conf,
"removed PID file %s (pid=%ld)",
pidfile, (long)getpid());
}
- ap_log_error(APLOG_MARK, APLOG_NOERRNO|APLOG_NOTICE, server_conf,
+ ap_log_error(APLOG_MARK, APLOG_NOERRNO|APLOG_NOTICE, 0, server_conf,
"caught SIGTERM, shutting down");
return 1;
}
#ifndef SCOREBOARD_FILE
int i;
#endif
- ap_log_error(APLOG_MARK, APLOG_NOERRNO|APLOG_NOTICE, server_conf,
+ ap_log_error(APLOG_MARK, APLOG_NOERRNO|APLOG_NOTICE, 0, server_conf,
"SIGUSR1 received. Doing graceful restart");
/* kill off the idle ones */
if (ap_killpg(getpgrp(), SIGUSR1) < 0) {
- ap_log_error(APLOG_MARK, APLOG_WARNING, server_conf, "killpg SIGUSR1");
+ ap_log_error(APLOG_MARK, APLOG_WARNING, errno, server_conf, "killpg SIGUSR1");
}
#ifndef SCOREBOARD_FILE
/* This is mostly for debugging... so that we know what is still
else {
/* Kill 'em off */
if (ap_killpg(getpgrp(), SIGHUP) < 0) {
- ap_log_error(APLOG_MARK, APLOG_WARNING, server_conf, "killpg SIGHUP");
+ ap_log_error(APLOG_MARK, APLOG_WARNING, errno, server_conf, "killpg SIGHUP");
}
reclaim_child_processes(0); /* Not when just starting up */
- ap_log_error(APLOG_MARK, APLOG_NOERRNO|APLOG_NOTICE, server_conf,
+ ap_log_error(APLOG_MARK, APLOG_NOERRNO|APLOG_NOTICE, 0, server_conf,
"SIGHUP received. Attempting to restart");
}
free(mtx);
}
+/* Stub functions until this MPM supports the connection status API */
+
+API_EXPORT(void) ap_update_connection_status(long conn_id, const char *key, \
+ const char *value)
+{
+ /* NOP */
+}
+
+API_EXPORT(void) ap_reset_connection_status(long conn_id)
+{
+ /* NOP */
+}
static const command_rec prefork_cmds[] = {
UNIX_DAEMON_COMMANDS