]> granicus.if.org Git - apache/blobdiff - server/mpm/prefork/prefork.c
Add a status value to ap_log_error and ap_log_rerror. This allows us to use
[apache] / server / mpm / prefork / prefork.c
index 8ffb390a3f06e52f7b2fadfa5df5a7900f8b13d5..bbe33303436ea209f2186ca7653a01300bd552a5 100644 (file)
@@ -87,6 +87,7 @@
 
 #define CORE_PRIVATE
 
+#include "apr_portable.h"
 #include "httpd.h"
 #include "mpm_default.h"
 #include "http_main.h"
@@ -115,7 +116,6 @@ static int ap_max_requests_per_child=0;
 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;
@@ -135,7 +135,7 @@ static char ap_coredump_dir[MAX_STRING_LEN];
 /* *Non*-shared http_main globals... */
 
 static server_rec *server_conf;
-static int sd;
+static ap_socket_t *sd;
 static fd_set listenfds;
 static int listenmaxfd;
 
@@ -485,7 +485,7 @@ static void accept_mutex_init(ap_context_t *p)
     }
     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;
@@ -528,7 +528,7 @@ static int lock_fd = -1;
  */
 static void accept_mutex_init(ap_context_t *p)
 {
-
+    ap_file_t *tempfile;
     lock_it.l_whence = SEEK_SET;       /* from current point */
     lock_it.l_start = 0;               /* -"- */
     lock_it.l_len = 0;                 /* until end of file */
@@ -541,7 +541,9 @@ static void accept_mutex_init(ap_context_t *p)
     unlock_it.l_pid = 0;               /* pid not actually interesting */
 
     expand_lock_fname(p);
-    lock_fd = ap_popenf(p, ap_lock_fname, O_CREAT | O_WRONLY | O_EXCL, 0644);
+    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);
@@ -559,7 +561,7 @@ static void accept_mutex_on(void)
     }
 
     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!");
@@ -575,7 +577,7 @@ static void accept_mutex_off(void)
        /* 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!");
@@ -587,9 +589,11 @@ static void accept_mutex_off(void)
 
 static int lock_fd = -1;
 
-static void accept_mutex_cleanup(void *foo)
+static ap_status_t accept_mutex_cleanup(void *foo)
 {
     unlink(ap_lock_fname);
+
+    return APR_SUCCESS;
 }
 
 /*
@@ -598,13 +602,15 @@ static void accept_mutex_cleanup(void *foo)
  */
 static void accept_mutex_child_init(ap_context_t *p)
 {
+    ap_file_t *tempfile;
 
-    lock_fd = ap_popenf(p, ap_lock_fname, O_WRONLY, 0600);
-    if (lock_fd == -1) {
+    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(&lock_fd, tempfile);
 }
 
 /*
@@ -613,14 +619,18 @@ static void accept_mutex_child_init(ap_context_t *p)
  */
 static void accept_mutex_init(ap_context_t *p)
 {
+    ap_file_t *tempfile;
+
     expand_lock_fname(p);
     unlink(ap_lock_fname);
-    lock_fd = ap_popenf(p, ap_lock_fname, O_CREAT | O_WRONLY | O_EXCL, 0600);
-    if (lock_fd == -1) {
+    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(&lock_fd, tempfile);
     ap_register_cleanup(p, NULL, accept_mutex_cleanup, ap_null_cleanup);
 }
 
@@ -1142,18 +1152,18 @@ static void setup_shared_mem(ap_context_t *p)
     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
@@ -1174,21 +1184,21 @@ static void setup_shared_mem(ap_context_t *p)
 
 #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);
            }
        }
@@ -1198,7 +1208,7 @@ static void setup_shared_mem(ap_context_t *p)
      * (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);
     }
@@ -1573,7 +1583,7 @@ static void reclaim_child_processes(int terminate)
            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);
@@ -1586,14 +1596,14 @@ static void reclaim_child_processes(int terminate)
            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);
@@ -1604,7 +1614,7 @@ static void reclaim_child_processes(int terminate)
                 * 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;
@@ -1783,46 +1793,46 @@ static void set_signals(void)
        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 */
@@ -1830,9 +1840,9 @@ static void set_signals(void)
     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);
@@ -1903,7 +1913,7 @@ static void sock_disable_nagle(int s)
  */
 
 static int srv;
-static int csd;
+static ap_socket_t *csd;
 static int requests_this_child;
 static fd_set main_fds;
 
@@ -1934,19 +1944,21 @@ static void child_main(int child_num_arg)
     ap_context_t *ptrans;
     conn_rec *current_conn;
     ap_iol *iol;
+    ap_status_t stat;
+    int sockdes;
 
     my_pid = getpid();
-    csd = -1;
+    csd = NULL;
     my_child_num = child_num_arg;
     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(pconf, NULL, &pchild);
+    ap_create_context(&pchild, pconf);
 
-    ap_create_context(pchild, NULL, &ptrans);
+    ap_create_context(&ptrans, pchild);
 
     /* needs to be done before we switch UIDs so we have permissions */
     reopen_scoreboard(pchild);
@@ -2015,7 +2027,7 @@ static void child_main(int child_num_arg)
                     * 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);
                }
 
@@ -2034,7 +2046,8 @@ static void child_main(int child_num_arg)
                }
                first_lr=lr;
                do {
-                   if (FD_ISSET(lr->fd, &main_fds))
+                    ap_get_os_sock(&sockdes, lr->sd);
+                   if (FD_ISSET(sockdes, &main_fds))
                        goto got_listener;
                    lr = lr->next;
                    if (!lr)
@@ -2047,11 +2060,11 @@ static void child_main(int child_num_arg)
                continue;
        got_listener:
                last_lr = lr;
-               sd = lr->fd;
+               sd = lr->sd;
            }
            else {
                /* only one socket, just pretend we did the other stuff */
-               sd = ap_listeners->fd;
+               sd = ap_listeners->sd;
            }
 
            /* if we accept() something we don't want to die, so we have to
@@ -2064,12 +2077,12 @@ static void child_main(int child_num_arg)
                    clean_child_exit(0);
                }
                clen = sizeof(sa_client);
-               csd = ap_accept(sd, &sa_client, &clen);
-               if (csd >= 0 || errno != EINTR)
+               stat = ap_accept(&csd, sd);
+               if (stat == APR_SUCCESS || stat != APR_EINTR)
                    break;
            }
 
-           if (csd >= 0)
+           if (stat == APR_SUCCESS)
                break;          /* We have a socket ready for reading */
            else {
 
@@ -2143,24 +2156,24 @@ static void child_main(int child_num_arg)
                      * 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
@@ -2192,28 +2205,30 @@ static void child_main(int child_num_arg)
         * socket options, file descriptors, and read/write buffers.
         */
 
+        ap_get_os_sock(&sockdes, csd);
+
        clen = sizeof(sa_server);
-       if (getsockname(csd, &sa_server, &clen) < 0) {
-           ap_log_error(APLOG_MARK, APLOG_ERR, server_conf, "getsockname");
-           close(csd);
+       if (getsockname(sockdes, &sa_server, &clen) < 0) {
+           ap_log_error(APLOG_MARK, APLOG_ERR, errno, server_conf, "getsockname");
+           ap_close_socket(csd);
            continue;
        }
 
-       sock_disable_nagle(csd);
+       sock_disable_nagle(sockdes);
 
-       iol = unix_attach_socket(csd);
+       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", csd, FD_SETSIZE);
+                   "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");
            }
-           close(csd);
+           ap_close_socket(csd);
            continue;
        }
 
@@ -2263,7 +2278,7 @@ static int make_child(server_rec *s, int slot, time_t now)
 #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
@@ -2416,7 +2431,7 @@ static void perform_idle_server_maintenance(void)
            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;
@@ -2425,7 +2440,7 @@ static void perform_idle_server_maintenance(void)
        }
        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 "
@@ -2469,7 +2484,7 @@ static void process_child_status(int pid, ap_wait_t status)
        */
     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);
@@ -2487,7 +2502,7 @@ static void process_child_status(int pid, ap_wait_t status)
 #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) ? "" : 
@@ -2497,7 +2512,7 @@ static void process_child_status(int pid, ap_wait_t status)
            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
@@ -2514,12 +2529,13 @@ static void process_child_status(int pid, ap_wait_t status)
 }
 
 
-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;
     }
@@ -2527,9 +2543,10 @@ static int setup_listeners(ap_context_t *p, server_rec *s)
     listenmaxfd = -1;
     FD_ZERO(&listenfds);
     for (lr = ap_listeners; lr; lr = lr->next) {
-       FD_SET(lr->fd, &listenfds);
-       if (lr->fd > listenmaxfd) {
-           listenmaxfd = lr->fd;
+        ap_get_os_sock(&sockdes, lr->sd);
+       FD_SET(sockdes, &listenfds);
+       if (sockdes > listenmaxfd) {
+           listenmaxfd = sockdes;
        }
     }
     return 0;
@@ -2547,10 +2564,10 @@ int ap_mpm_run(ap_context_t *_pconf, ap_context_t *plog, server_rec *s)
     pconf = _pconf;
 
     server_conf = s;
-
     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;
     }
@@ -2593,10 +2610,10 @@ int ap_mpm_run(ap_context_t *_pconf, ap_context_t *plog, server_rec *s)
        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;
 
@@ -2636,7 +2653,8 @@ int ap_mpm_run(ap_context_t *_pconf, ap_context_t *plog, server_rec *s)
                    * 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,
@@ -2673,7 +2691,7 @@ int ap_mpm_run(ap_context_t *_pconf, ap_context_t *plog, server_rec *s)
         * 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 */
 
@@ -2683,12 +2701,12 @@ int ap_mpm_run(ap_context_t *_pconf, ap_context_t *plog, server_rec *s)
            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;
     }
@@ -2714,12 +2732,12 @@ int ap_mpm_run(ap_context_t *_pconf, ap_context_t *plog, server_rec *s)
 #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
@@ -2738,10 +2756,10 @@ int ap_mpm_run(ap_context_t *_pconf, ap_context_t *plog, server_rec *s)
     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");
     }
 
@@ -2950,6 +2968,18 @@ API_EXPORT(void) ap_thread_mutex_destroy(ap_thread_mutex *mtx)
     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