httpd-cvs mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Dean Gaudet <dgau...@hyperreal.org>
Subject cvs commit: apachen/src/main http_main.c
Date Sun, 14 Sep 1997 11:06:54 GMT
dgaudet     97/09/14 04:06:53

  Modified:    src      INDENT
               src/main http_main.c
  Log:
  indent
  
  Revision  Changes    Path
  1.5       +2 -2      apachen/src/INDENT
  
  Index: INDENT
  ===================================================================
  RCS file: /export/home/cvs/apachen/src/INDENT,v
  retrieving revision 1.4
  retrieving revision 1.5
  diff -u -r1.4 -r1.5
  --- INDENT	1997/09/14 10:35:01	1.4
  +++ INDENT	1997/09/14 11:06:49	1.5
  @@ -21,8 +21,8 @@
      http_core.h
      http_log.c
      http_log.h
  -   http_main.c			RESERVED by Dean
  -   http_main.h
  +   http_main.c			DONE by Dean
  +   http_main.h			RESERVED by Dean
      http_protocol.c		DONE by Roy
      http_protocol.h		DONE by Roy
      http_request.c		RESERVED while Roy is working on it
  
  
  
  1.224     +1269 -1256apachen/src/main/http_main.c
  
  Index: http_main.c
  ===================================================================
  RCS file: /export/home/cvs/apachen/src/main/http_main.c,v
  retrieving revision 1.223
  retrieving revision 1.224
  diff -u -r1.223 -r1.224
  --- http_main.c	1997/09/14 10:30:56	1.223
  +++ http_main.c	1997/09/14 11:06:51	1.224
  @@ -61,9 +61,9 @@
    *   of processes
    *
    * 03-10-95  blong
  - * 	Added numerous speed hacks proposed by Robert S. Thau (rst@ai.mit.edu) 
  - *	including set group before fork, and call gettime before to fork
  - * 	to set up libraries.
  + *      Added numerous speed hacks proposed by Robert S. Thau (rst@ai.mit.edu) 
  + *      including set group before fork, and call gettime before to fork
  + *      to set up libraries.
    *
    * 04-14-95  rst / rh
    *      Brandon's code snarfed from NCSA 1.4, but tinkered to work with the
  @@ -82,7 +82,7 @@
   #include "http_protocol.h"	/* for read_request */
   #include "http_request.h"	/* for process_request */
   #include "http_conf_globals.h"
  -#include "http_core.h"          /* for get_remote_host */
  +#include "http_core.h"		/* for get_remote_host */
   #include "scoreboard.h"
   #include "multithread.h"
   #include <sys/stat.h>
  @@ -119,14 +119,14 @@
   
   #ifdef __EMX__
       /* Add MMAP style functionality to OS/2 */
  -    #ifdef HAVE_MMAP
  -        #define INCL_DOSMEMMGR
  -        #include <os2.h>
  -        #include <umalloc.h>
  -        #include <stdio.h>
  -        caddr_t create_shared_heap (const char *, size_t);
  -        caddr_t get_shared_heap (const char *);
  -    #endif
  +#ifdef HAVE_MMAP
  +#define INCL_DOSMEMMGR
  +#include <os2.h>
  +#include <umalloc.h>
  +#include <stdio.h>
  +caddr_t create_shared_heap(const char *, size_t);
  +caddr_t get_shared_heap(const char *);
  +#endif
   #endif
   
   DEF_Explain
  @@ -240,7 +240,7 @@
   struct other_child_rec {
       other_child_rec *next;
       int pid;
  -    void (*maintenance)(int, void *, int);
  +    void (*maintenance) (int, void *, int);
       void *data;
       int write_fd;
   };
  @@ -261,7 +261,7 @@
   
   #ifdef WIN32
   #define ap_killpg(x, y)
  -#else 
  +#else
   #ifdef NO_KILLPG
   #define ap_killpg(x, y)		(kill (-(x), (y)))
   #else
  @@ -274,8 +274,8 @@
   {
       char buf[20];
   
  -    ap_snprintf( buf, sizeof(buf), ".%u", getpid() );
  -    lock_fname = pstrcat (p, server_root_relative (p, lock_fname), buf, NULL);
  +    ap_snprintf(buf, sizeof(buf), ".%u", getpid());
  +    lock_fname = pstrcat(p, server_root_relative(p, lock_fname), buf, NULL);
   }
   #endif
   
  @@ -294,50 +294,50 @@
   
   
       /* default is 8, allocate enough for all the children plus the parent */
  -    if ((old = usconfig(CONF_INITUSERS, HARD_SERVER_LIMIT+1)) == -1) {
  -        perror("usconfig(CONF_INITUSERS)");
  -        exit(-1);
  +    if ((old = usconfig(CONF_INITUSERS, HARD_SERVER_LIMIT + 1)) == -1) {
  +	perror("usconfig(CONF_INITUSERS)");
  +	exit(-1);
       }
   
       if ((old = usconfig(CONF_LOCKTYPE, US_NODEBUG)) == -1) {
  -        perror("usconfig(CONF_LOCKTYPE)");
  -        exit(-1);
  +	perror("usconfig(CONF_LOCKTYPE)");
  +	exit(-1);
       }
       if ((old = usconfig(CONF_ARENATYPE, US_SHAREDONLY)) == -1) {
  -        perror("usconfig(CONF_ARENATYPE)");
  -        exit(-1);
  +	perror("usconfig(CONF_ARENATYPE)");
  +	exit(-1);
       }
       if ((us = usinit("/dev/zero")) == NULL) {
  -        perror("usinit");
  -        exit(-1);
  +	perror("usinit");
  +	exit(-1);
       }
   
       if ((uslock = usnewlock(us)) == NULL) {
  -        perror("usnewlock");
  -        exit(-1);
  +	perror("usnewlock");
  +	exit(-1);
       }
   }
   
   static void accept_mutex_on()
   {
  -    switch(ussetlock(uslock)) {
  -        case 1:
  -            /* got lock */
  -            break;
  -        case 0:
  -            fprintf(stderr, "didn't get lock\n");
  -            exit(-1);
  -        case -1:
  -            perror("ussetlock");
  -            exit(-1);
  +    switch (ussetlock(uslock)) {
  +    case 1:
  +	/* got lock */
  +	break;
  +    case 0:
  +	fprintf(stderr, "didn't get lock\n");
  +	exit(-1);
  +    case -1:
  +	perror("ussetlock");
  +	exit(-1);
       }
   }
   
   static void accept_mutex_off()
   {
       if (usunsetlock(uslock) == -1) {
  -        perror("usunsetlock");
  -        exit(-1);
  +	perror("usunsetlock");
  +	exit(-1);
       }
   }
   
  @@ -353,8 +353,8 @@
   
   static void accept_mutex_cleanup(void)
   {
  -    if (munmap ((caddr_t)accept_mutex, sizeof (*accept_mutex))) {
  -	perror ("munmap");
  +    if (munmap((caddr_t) accept_mutex, sizeof(*accept_mutex))) {
  +	perror("munmap");
       }
   }
   
  @@ -363,45 +363,45 @@
       pthread_mutexattr_t mattr;
       int fd;
   
  -    fd = open ("/dev/zero", O_RDWR);
  +    fd = open("/dev/zero", O_RDWR);
       if (fd == -1) {
  -        perror ("open(/dev/zero)");
  -        exit (1);
  +	perror("open(/dev/zero)");
  +	exit(1);
       }
  -    accept_mutex = (pthread_mutex_t *)mmap ((caddr_t)0, sizeof (*accept_mutex),
  -                    PROT_READ|PROT_WRITE, MAP_SHARED, fd, 0);
  -    if (accept_mutex == (void *)(caddr_t)-1) {
  -        perror ("mmap");
  -        exit (1);
  +    accept_mutex = (pthread_mutex_t *) mmap((caddr_t) 0, sizeof(*accept_mutex),
  +				 PROT_READ | PROT_WRITE, MAP_SHARED, fd, 0);
  +    if (accept_mutex == (void *) (caddr_t) - 1) {
  +	perror("mmap");
  +	exit(1);
       }
  -    close (fd);
  +    close(fd);
       if (pthread_mutexattr_init(&mattr)) {
  -        perror ("pthread_mutexattr_init");
  -        exit (1);
  +	perror("pthread_mutexattr_init");
  +	exit(1);
       }
       if (pthread_mutexattr_setpshared(&mattr, PTHREAD_PROCESS_SHARED)) {
  -        perror ("pthread_mutexattr_setpshared");
  -        exit (1);
  +	perror("pthread_mutexattr_setpshared");
  +	exit(1);
       }
       if (pthread_mutex_init(accept_mutex, &mattr)) {
  -        perror ("pthread_mutex_init");
  -        exit (1);
  +	perror("pthread_mutex_init");
  +	exit(1);
       }
   }
   
   static void accept_mutex_on()
   {
  -    if (pthread_mutex_lock (accept_mutex)) {
  -        perror ("pthread_mutex_lock");
  -        exit (1);
  +    if (pthread_mutex_lock(accept_mutex)) {
  +	perror("pthread_mutex_lock");
  +	exit(1);
       }
   }
   
   static void accept_mutex_off()
   {
  -    if (pthread_mutex_unlock (accept_mutex)) {
  -        perror ("pthread_mutex_unlock");
  -        exit (1);
  +    if (pthread_mutex_unlock(accept_mutex)) {
  +	perror("pthread_mutex_unlock");
  +	exit(1);
       }
   }
   
  @@ -418,6 +418,7 @@
       struct semid_ds *buf;
       ushort *array;
   };
  +
   #endif
   
   static int sem_cleanup_registered;
  @@ -432,15 +433,17 @@
    * do many things in here... especially nothing that would allocate
    * memory or use a FILE *.
    */
  -static void accept_mutex_cleanup (void)
  +static void accept_mutex_cleanup(void)
   {
       union semun ick;
   
  -    if (sem_id < 0) return;
  -    if (getpid() != sem_cleanup_pid) return;
  +    if (sem_id < 0)
  +	return;
  +    if (getpid() != sem_cleanup_pid)
  +	return;
       /* this is ignored anyhow */
       ick.val = 0;
  -    semctl (sem_id, 0, IPC_RMID, ick);
  +    semctl(sem_id, 0, IPC_RMID, ick);
   }
   
   
  @@ -452,22 +455,22 @@
       if (!sem_cleanup_registered) {
   	/* only the parent will try to do cleanup */
   	sem_cleanup_pid = getpid();
  -	if (atexit (accept_mutex_cleanup)) {
  -	    perror ("atexit");
  -	    exit (1);
  +	if (atexit(accept_mutex_cleanup)) {
  +	    perror("atexit");
  +	    exit(1);
   	}
   	sem_cleanup_registered = 1;
       }
       /* acquire the semaphore */
       sem_id = semget(IPC_PRIVATE, 1, IPC_CREAT | 0600);
       if (sem_id < 0) {
  -       perror ("semget");
  -       exit (1);
  +	perror("semget");
  +	exit(1);
       }
       ick.val = 1;
       if (semctl(sem_id, 0, SETVAL, ick) < 0) {
  -	perror ("semctl(SETVAL)");
  -        exit (1);
  +	perror("semctl(SETVAL)");
  +	exit(1);
       }
       if (!getuid()) {
   	/* restrict it to use only by the appropriate user_id ... not that this
  @@ -478,8 +481,8 @@
   	buf.sem_perm.mode = 0600;
   	ick.buf = &buf;
   	if (semctl(sem_id, 0, IPC_SET, ick) < 0) {
  -	    perror ("semctl(IPC_SET)");
  -	    exit (1);
  +	    perror("semctl(IPC_SET)");
  +	    exit(1);
   	}
       }
   
  @@ -495,16 +498,16 @@
   static void accept_mutex_on()
   {
       if (semop(sem_id, &op_on, 1) < 0) {
  -        perror ("accept_mutex_on");
  -        exit (1);
  +	perror("accept_mutex_on");
  +	exit(1);
       }
   }
   
   static void accept_mutex_off()
   {
       if (semop(sem_id, &op_off, 1) < 0) {
  -        perror ("accept_mutex_off");
  -        exit (1);
  +	perror("accept_mutex_off");
  +	exit(1);
       }
   }
   
  @@ -512,7 +515,7 @@
   static struct flock lock_it;
   static struct flock unlock_it;
   
  -static int lock_fd=-1;
  +static int lock_fd = -1;
   
   #define accept_mutex_cleanup()
   
  @@ -523,24 +526,23 @@
   static void accept_mutex_init(pool *p)
   {
   
  -    lock_it.l_whence = SEEK_SET;   /* from current point */
  -    lock_it.l_start  = 0;          /* -"- */
  -    lock_it.l_len    = 0;          /* until end of file */
  -    lock_it.l_type   = F_WRLCK;    /* set exclusive/write lock */
  -    lock_it.l_pid    = 0;          /* pid not actually interesting */
  -    unlock_it.l_whence = SEEK_SET; /* from current point */
  -    unlock_it.l_start  = 0;        /* -"- */
  -    unlock_it.l_len    = 0;        /* until end of file */
  -    unlock_it.l_type   = F_UNLCK;  /* set exclusive/write lock */
  -    unlock_it.l_pid    = 0;        /* pid not actually interesting */
  +    lock_it.l_whence = SEEK_SET;	/* from current point */
  +    lock_it.l_start = 0;		/* -"- */
  +    lock_it.l_len = 0;			/* until end of file */
  +    lock_it.l_type = F_WRLCK;		/* set exclusive/write lock */
  +    lock_it.l_pid = 0;			/* pid not actually interesting */
  +    unlock_it.l_whence = SEEK_SET;	/* from current point */
  +    unlock_it.l_start = 0;		/* -"- */
  +    unlock_it.l_len = 0;		/* until end of file */
  +    unlock_it.l_type = F_UNLCK;		/* set exclusive/write lock */
  +    unlock_it.l_pid = 0;		/* pid not actually interesting */
   
  -    expand_lock_fname (p);
  +    expand_lock_fname(p);
       lock_fd = popenf(p, lock_fname, O_CREAT | O_WRONLY | O_EXCL, 0644);
  -    if (lock_fd == -1)
  -    {
  -	perror ("open");
  -	fprintf (stderr, "Cannot open lock file: %s\n", lock_fname);
  -	exit (1);
  +    if (lock_fd == -1) {
  +	perror("open");
  +	fprintf(stderr, "Cannot open lock file: %s\n", lock_fname);
  +	exit(1);
       }
       unlink(lock_fname);
   }
  @@ -548,7 +550,7 @@
   static void accept_mutex_on(void)
   {
       int ret;
  -    
  +
       while ((ret = fcntl(lock_fd, F_SETLKW, &lock_it)) < 0 && errno == EINTR)
   	continue;
   
  @@ -561,8 +563,7 @@
   
   static void accept_mutex_off(void)
   {
  -    if (fcntl (lock_fd, F_SETLKW, &unlock_it) < 0)
  -    {
  +    if (fcntl(lock_fd, F_SETLKW, &unlock_it) < 0) {
   	aplog_error(APLOG_MARK, APLOG_EMERG, server_conf,
   		    "fcntl: F_SETLKW: Error freeing accept lock. Exiting!");
   	exit(1);
  @@ -571,7 +572,7 @@
   
   #elif defined(USE_FLOCK_SERIALIZED_ACCEPT)
   
  -static int lock_fd=-1;
  +static int lock_fd = -1;
   
   #define accept_mutex_cleanup()
   
  @@ -582,12 +583,12 @@
   static void accept_mutex_init(pool *p)
   {
   
  -    expand_lock_fname (p);
  +    expand_lock_fname(p);
       lock_fd = popenf(p, lock_fname, O_CREAT | O_WRONLY | O_EXCL, 0644);
       if (lock_fd == -1) {
   	aplog_error(APLOG_MARK, APLOG_EMERG, server_conf,
   		    "Cannot open lock file: %s\n", lock_fname);
  -	exit (1);
  +	exit(1);
       }
       unlink(lock_fname);
   }
  @@ -595,7 +596,7 @@
   static void accept_mutex_on(void)
   {
       int ret;
  -    
  +
       while ((ret = flock(lock_fd, LOCK_EX)) < 0 && errno == EINTR)
   	continue;
   
  @@ -608,8 +609,7 @@
   
   static void accept_mutex_off(void)
   {
  -    if (flock (lock_fd, LOCK_UN) < 0)
  -    {
  +    if (flock(lock_fd, LOCK_UN) < 0) {
   	aplog_error(APLOG_MARK, APLOG_EMERG, server_conf,
   		    "flock: LOCK_UN: Error freeing accept lock. Exiting!");
   	exit(1);
  @@ -639,12 +639,12 @@
   
   void usage(char *bin)
   {
  -    fprintf(stderr,"Usage: %s [-d directory] [-f file] [-v] [-h] [-l]\n",bin);
  -    fprintf(stderr,"-d directory : specify an alternate initial ServerRoot\n");
  -    fprintf(stderr,"-f file : specify an alternate ServerConfigFile\n");
  -    fprintf(stderr,"-v : show version number\n");
  -    fprintf(stderr,"-h : list directives\n");
  -    fprintf(stderr,"-l : list modules\n");
  +    fprintf(stderr, "Usage: %s [-d directory] [-f file] [-v] [-h] [-l]\n", bin);
  +    fprintf(stderr, "-d directory : specify an alternate initial ServerRoot\n");
  +    fprintf(stderr, "-f file : specify an alternate ServerConfigFile\n");
  +    fprintf(stderr, "-v : show version number\n");
  +    fprintf(stderr, "-h : list directives\n");
  +    fprintf(stderr, "-l : list modules\n");
       exit(1);
   }
   
  @@ -655,9 +655,9 @@
    * one timeout in progress at a time...
    */
   
  -static APACHE_TLS conn_rec * volatile current_conn;
  -static APACHE_TLS request_rec * volatile timeout_req;
  -static APACHE_TLS const char * volatile timeout_name = NULL;
  +static APACHE_TLS conn_rec *volatile current_conn;
  +static APACHE_TLS request_rec *volatile timeout_req;
  +static APACHE_TLS const char *volatile timeout_name = NULL;
   static APACHE_TLS int volatile alarms_blocked = 0;
   static APACHE_TLS int volatile alarm_pending = 0;
   static APACHE_TLS int volatile exit_after_unblock = 0;
  @@ -668,78 +668,84 @@
    * from W. Richard Stevens' "Advanced Programming in the UNIX Environment"
    * (the version that does not automatically restart system calls).
    */
  -Sigfunc *signal(int signo, Sigfunc *func)
  +Sigfunc *signal(int signo, Sigfunc * func)
   {
       struct sigaction act, oact;
   
       act.sa_handler = func;
       sigemptyset(&act.sa_mask);
       act.sa_flags = 0;
  -#ifdef  SA_INTERRUPT    /* SunOS */
  +#ifdef  SA_INTERRUPT		/* SunOS */
       act.sa_flags |= SA_INTERRUPT;
   #endif
       if (sigaction(signo, &act, &oact) < 0)
  -       return SIG_ERR;
  +	return SIG_ERR;
       return oact.sa_handler;
   }
   #endif
   
  -void timeout(int sig)			/* Also called on SIGPIPE */
  -{
  +void timeout(int sig)
  +{				/* Also called on SIGPIPE */
       char errstr[MAX_STRING_LEN];
       void *dirconf;
   
  -    signal(SIGPIPE, SIG_IGN);		/* Block SIGPIPE */
  +    signal(SIGPIPE, SIG_IGN);	/* Block SIGPIPE */
       if (alarms_blocked) {
   	alarm_pending = 1;
   	return;
       }
   
       if (!current_conn) {
  -	ap_longjmp (jmpbuffer, 1);
  +	ap_longjmp(jmpbuffer, 1);
       }
  -    
  -    if (timeout_req != NULL) dirconf = timeout_req->per_dir_config;
  -    else dirconf = current_conn->server->lookup_defaults;
  +
  +    if (timeout_req != NULL)
  +	dirconf = timeout_req->per_dir_config;
  +    else
  +	dirconf = current_conn->server->lookup_defaults;
       if (sig == SIGPIPE) {
  -        ap_snprintf(errstr, sizeof(errstr), "%s lost connection to %s",
  +	ap_snprintf(errstr, sizeof(errstr), "%s lost connection to %s",
   		    timeout_name ? timeout_name : "request",
   		    get_remote_host(current_conn, dirconf, REMOTE_NAME));
  -    } else {
  -        ap_snprintf(errstr, sizeof(errstr), "%s timed out for %s",
  +    }
  +    else {
  +	ap_snprintf(errstr, sizeof(errstr), "%s timed out for %s",
   		    timeout_name ? timeout_name : "request",
   		    get_remote_host(current_conn, dirconf, REMOTE_NAME));
       }
  -    
  -    if (!current_conn->keptalive) 
  +
  +    if (!current_conn->keptalive)
   	aplog_error(APLOG_MARK, APLOG_DEBUG, current_conn->server, errstr);
  -          
  +
       if (timeout_req) {
   	/* Someone has asked for this transaction to just be aborted
   	 * if it times out...
   	 */
  -	
  +
   	request_rec *log_req = timeout_req;
  -	
  +
   	while (log_req->main || log_req->prev) {
   	    /* Get back to original request... */
  -	    if (log_req->main) log_req = log_req->main;
  -	    else log_req = log_req->prev;
  +	    if (log_req->main)
  +		log_req = log_req->main;
  +	    else
  +		log_req = log_req->prev;
   	}
  -	
  -	if (!current_conn->keptalive) 
  -            log_transaction(log_req);
  +
  +	if (!current_conn->keptalive)
  +	    log_transaction(log_req);
   
   	bsetflag(timeout_req->connection->client, B_EOUT, 1);
   	bclose(timeout_req->connection->client);
  -    
  -	if (!standalone) exit(0);
   
  -	ap_longjmp (jmpbuffer, 1);
  +	if (!standalone)
  +	    exit(0);
  +
  +	ap_longjmp(jmpbuffer, 1);
       }
  -    else {   /* abort the connection */
  -        bsetflag(current_conn->client, B_EOUT, 1);
  -        current_conn->aborted = 1;
  +    else {			/* abort the connection */
  +	bsetflag(current_conn->client, B_EOUT, 1);
  +	current_conn->aborted = 1;
       }
   }
   
  @@ -749,11 +755,13 @@
    * which is itself being cleared); we have to support that here.
    */
   
  -API_EXPORT(void) block_alarms() {
  +API_EXPORT(void) block_alarms()
  +{
       ++alarms_blocked;
   }
   
  -API_EXPORT(void) unblock_alarms() {
  +API_EXPORT(void) unblock_alarms()
  +{
       --alarms_blocked;
       if (alarms_blocked == 0) {
   	if (exit_after_unblock) {
  @@ -769,41 +777,38 @@
   }
   
   
  -static APACHE_TLS void (* volatile alarm_fn)(int) = NULL;
  +static APACHE_TLS void (*volatile alarm_fn) (int) = NULL;
   #ifdef WIN32
   static APACHE_TLS unsigned int alarm_expiry_time = 0;
   #endif /* WIN32 */
   
   #ifndef WIN32
  -static void alrm_handler (int sig)
  +static void alrm_handler(int sig)
   {
       if (alarm_fn) {
  -	(*alarm_fn)(sig);
  +	(*alarm_fn) (sig);
       }
   }
   #endif
   
  -unsigned int
  -set_callback_and_alarm(void (*fn)(int), int x)
  +unsigned int set_callback_and_alarm(void (*fn) (int), int x)
   {
       unsigned int old;
   
   #ifdef WIN32
       old = alarm_expiry_time;
  -    if(old)
  -        old -= time(0);
  -    if(x == 0)
  -    {
  -        alarm_fn = NULL;
  -        alarm_expiry_time = 0;
  +    if (old)
  +	old -= time(0);
  +    if (x == 0) {
  +	alarm_fn = NULL;
  +	alarm_expiry_time = 0;
       }
  -    else
  -    {
  -        alarm_fn = fn;
  -        alarm_expiry_time = time(NULL) + x;
  +    else {
  +	alarm_fn = fn;
  +	alarm_expiry_time = time(NULL) + x;
       }
   #else
  -    if(x) {
  +    if (x) {
   	alarm_fn = fn;
       }
   #ifndef OPTIMIZE_TIMEOUTS
  @@ -817,34 +822,30 @@
       ++scoreboard_image->servers[my_child_num].cur_vtime;
   #endif
   #endif
  -    return(old);
  +    return (old);
   }
   
   
  -int
  -check_alarm(void)
  +int check_alarm(void)
   {
   #ifdef WIN32
  -    if(alarm_expiry_time)
  -    {
  -        unsigned int t;
  +    if (alarm_expiry_time) {
  +	unsigned int t;
   
  -        t = time(NULL);
  -        if(t >= alarm_expiry_time)
  -        {
  -            alarm_expiry_time = 0;
  -            (*alarm_fn)(0);
  -            return(-1);
  -        }
  -        else
  -        {
  -            return(alarm_expiry_time - t);
  -        }
  +	t = time(NULL);
  +	if (t >= alarm_expiry_time) {
  +	    alarm_expiry_time = 0;
  +	    (*alarm_fn) (0);
  +	    return (-1);
  +	}
  +	else {
  +	    return (alarm_expiry_time - t);
  +	}
       }
       else
  -        return(0);
  +	return (0);
   #else
  -    return(0);
  +    return (0);
   #endif /* WIN32 */
   }
   
  @@ -854,12 +855,13 @@
    * as long as it hasn't expired already.
    */
   
  -API_EXPORT(void) reset_timeout (request_rec *r) {
  +API_EXPORT(void) reset_timeout(request_rec *r)
  +{
       int i;
   
  -    if (timeout_name) { /* timeout has been set */
  -        i = set_callback_and_alarm(alarm_fn, r->server->timeout);
  -        if (i == 0) /* timeout already expired, so set it back to 0 */
  +    if (timeout_name) {		/* timeout has been set */
  +	i = set_callback_and_alarm(alarm_fn, r->server->timeout);
  +	if (i == 0)		/* timeout already expired, so set it back to 0 */
   	    set_callback_and_alarm(alarm_fn, 0);
       }
   }
  @@ -867,39 +869,40 @@
   
   
   
  -void keepalive_timeout (char *name, request_rec *r)
  +void keepalive_timeout(char *name, request_rec *r)
   {
       unsigned int to;
   
       timeout_req = r;
       timeout_name = name;
   
  -    if (r->connection->keptalive) 
  -       to = r->server->keep_alive_timeout;
  +    if (r->connection->keptalive)
  +	to = r->server->keep_alive_timeout;
       else
  -       to = r->server->timeout;
  +	to = r->server->timeout;
       set_callback_and_alarm(timeout, to);
   
   }
   
  -API_EXPORT(void) hard_timeout (char *name, request_rec *r)
  +API_EXPORT(void) hard_timeout(char *name, request_rec *r)
   {
       timeout_req = r;
       timeout_name = name;
  -    
  +
       set_callback_and_alarm(timeout, r->server->timeout);
   
   }
   
  -API_EXPORT(void) soft_timeout (char *name, request_rec *r)
  +API_EXPORT(void) soft_timeout(char *name, request_rec *r)
   {
       timeout_name = name;
  -    
  +
       set_callback_and_alarm(timeout, r->server->timeout);
   
   }
   
  -API_EXPORT(void) kill_timeout (request_rec *dummy) {
  +API_EXPORT(void) kill_timeout(request_rec *dummy)
  +{
       set_callback_and_alarm(NULL, 0);
       timeout_req = NULL;
       timeout_name = NULL;
  @@ -931,9 +934,9 @@
   #endif
   
   #ifdef USE_SO_LINGER
  -#define NO_LINGCLOSE    /* The two lingering options are exclusive */
  +#define NO_LINGCLOSE		/* The two lingering options are exclusive */
   
  -static void sock_enable_linger (int s)
  +static void sock_enable_linger(int s)
   {
       struct linger li;
   
  @@ -941,15 +944,15 @@
       li.l_linger = MAX_SECS_TO_LINGER;
   
       if (setsockopt(s, SOL_SOCKET, SO_LINGER,
  -                   (char *)&li, sizeof(struct linger)) < 0) {
  -        aplog_error(APLOG_MARK, APLOG_WARNING, server_conf, "setsockopt: (SO_LINGER)");
  -        /* not a fatal error */
  +		   (char *) &li, sizeof(struct linger)) < 0) {
  +	aplog_error(APLOG_MARK, APLOG_WARNING, server_conf, "setsockopt: (SO_LINGER)");
  +	/* not a fatal error */
       }
   }
   
   #else
  -#define sock_enable_linger(s) /* NOOP */
  -#endif  /* USE_SO_LINGER */
  +#define sock_enable_linger(s)	/* NOOP */
  +#endif /* USE_SO_LINGER */
   
   #ifndef NO_LINGCLOSE
   
  @@ -961,18 +964,18 @@
   	alarm_pending = 1;
   	return;
       }
  -    
  +
       if (!current_conn) {
  -	ap_longjmp (jmpbuffer, 1);
  +	ap_longjmp(jmpbuffer, 1);
       }
       bsetflag(current_conn->client, B_EOUT, 1);
       current_conn->aborted = 1;
   }
  -    
  -static void linger_timeout (void)
  +
  +static void linger_timeout(void)
   {
       timeout_name = "lingering close";
  -    
  +
       set_callback_and_alarm(lingerout, MAX_SECS_TO_LINGER);
   }
   
  @@ -982,7 +985,7 @@
    * distinguish between a dropped connection and something that might be
    * worth logging.
    */
  -static void lingering_close (request_rec *r)
  +static void lingering_close(request_rec *r)
   {
       int dummybuf[512];
       struct timeval tv;
  @@ -997,9 +1000,9 @@
       /* Send any leftover data to the client, but never try to again */
   
       if (bflush(r->connection->client) == -1) {
  -        kill_timeout(r);
  -        bclose(r->connection->client);
  -        return;
  +	kill_timeout(r);
  +	bclose(r->connection->client);
  +	return;
       }
       bsetflag(r->connection->client, B_EOUT, 1);
   
  @@ -1026,26 +1029,26 @@
        */
   
       do {
  -        /* We use a 2 second timeout because current (Feb 97) browsers
  -         * fail to close a connection after the server closes it.  Thus,
  -         * to avoid keeping the child busy, we are only lingering long enough
  -         * for a client that is actively sending data on a connection.
  -         * This should be sufficient unless the connection is massively
  -         * losing packets, in which case we might have missed the RST anyway.
  -         * These parameters are reset on each pass, since they might be
  -         * changed by select.
  -         */
  -        tv.tv_sec  = 2;
  -        tv.tv_usec = 0;
  -        read_rv    = 0;
  -        fds_read   = lfds;
  -        fds_err    = lfds;
  -    
  -        select_rv = ap_select(lsd+1, &fds_read, NULL, &fds_err, &tv);
  -    } while ((select_rv > 0) &&            /* Something to see on socket    */
  -             !FD_ISSET(lsd, &fds_err) &&   /* that isn't an error condition */
  -             FD_ISSET(lsd, &fds_read) &&   /* and is worth trying to read   */
  -             ((read_rv = read(lsd, dummybuf, sizeof dummybuf)) > 0));
  +	/* We use a 2 second timeout because current (Feb 97) browsers
  +	 * fail to close a connection after the server closes it.  Thus,
  +	 * to avoid keeping the child busy, we are only lingering long enough
  +	 * for a client that is actively sending data on a connection.
  +	 * This should be sufficient unless the connection is massively
  +	 * losing packets, in which case we might have missed the RST anyway.
  +	 * These parameters are reset on each pass, since they might be
  +	 * changed by select.
  +	 */
  +	tv.tv_sec = 2;
  +	tv.tv_usec = 0;
  +	read_rv = 0;
  +	fds_read = lfds;
  +	fds_err = lfds;
  +
  +	select_rv = ap_select(lsd + 1, &fds_read, NULL, &fds_err, &tv);
  +    } while ((select_rv > 0) &&	/* Something to see on socket    */
  +	     !FD_ISSET(lsd, &fds_err) &&	/* that isn't an error condition */
  +	     FD_ISSET(lsd, &fds_read) &&	/* and is worth trying to read   */
  +	     ((read_rv = read(lsd, dummybuf, sizeof dummybuf)) > 0));
   
       /* Should now have seen final ack.  Safe to finally kill socket */
   
  @@ -1060,13 +1063,13 @@
    */
   
   #ifndef NO_OTHER_CHILD
  -void register_other_child (int pid,
  -    void (*maintenance)(int reason, void *, int status),
  -    void *data, int write_fd)
  +void register_other_child(int pid,
  +		       void (*maintenance) (int reason, void *, int status),
  +			  void *data, int write_fd)
   {
       other_child_rec *ocr;
   
  -    ocr = palloc (pconf, sizeof (*ocr));
  +    ocr = palloc(pconf, sizeof(*ocr));
       ocr->pid = pid;
       ocr->maintenance = maintenance;
       ocr->data = data;
  @@ -1079,14 +1082,14 @@
    * scanning the other_children list, all scanners should protect themself
    * by loading ocr->next before calling any maintenance function.
    */
  -void unregister_other_child (void *data)
  +void unregister_other_child(void *data)
   {
       other_child_rec **pocr, *nocr;
   
       for (pocr = &other_children; *pocr; pocr = &(*pocr)->next) {
   	if ((*pocr)->data == data) {
   	    nocr = (*pocr)->next;
  -	    (*(*pocr)->maintenance)(OC_REASON_UNREGISTER, (*pocr)->data, -1);
  +	    (*(*pocr)->maintenance) (OC_REASON_UNREGISTER, (*pocr)->data, -1);
   	    *pocr = nocr;
   	    /* XXX: um, well we've just wasted some space in pconf ? */
   	    return;
  @@ -1096,7 +1099,7 @@
   
   /* test to ensure that the write_fds are all still writable, otherwise
    * invoke the maintenance functions as appropriate */
  -static void probe_writable_fds (void)
  +static void probe_writable_fds(void)
   {
       fd_set writable_fds;
       int fd_max;
  @@ -1104,52 +1107,59 @@
       struct timeval tv;
       int rc;
   
  -    if (other_children == NULL) return;
  +    if (other_children == NULL)
  +	return;
   
       fd_max = 0;
  -    FD_ZERO (&writable_fds);
  +    FD_ZERO(&writable_fds);
       for (ocr = other_children; ocr; ocr = ocr->next) {
  -	if (ocr->write_fd == -1) continue;
  -	FD_SET (ocr->write_fd, &writable_fds);
  +	if (ocr->write_fd == -1)
  +	    continue;
  +	FD_SET(ocr->write_fd, &writable_fds);
   	if (ocr->write_fd > fd_max) {
   	    fd_max = ocr->write_fd;
   	}
       }
  -    if (fd_max == 0) return;
  +    if (fd_max == 0)
  +	return;
   
       do {
   	tv.tv_sec = 0;
   	tv.tv_usec = 0;
  -	rc = ap_select (fd_max + 1, NULL, &writable_fds, NULL, &tv);
  +	rc = ap_select(fd_max + 1, NULL, &writable_fds, NULL, &tv);
       } while (rc == -1 && errno == EINTR);
   
       if (rc == -1) {
   	/* XXX: uhh this could be really bad, we could have a bad file
   	 * descriptor due to a bug in one of the maintenance routines */
  -	log_unixerr ("probe_writable_fds", "select", 
  -		     "could not probe writable fds", server_conf);
  +	log_unixerr("probe_writable_fds", "select",
  +		    "could not probe writable fds", server_conf);
   	return;
       }
  -    if (rc == 0) return;
  +    if (rc == 0)
  +	return;
   
       for (ocr = other_children; ocr; ocr = nocr) {
   	nocr = ocr->next;
  -	if (ocr->write_fd == -1) continue;
  -	if (FD_ISSET (ocr->write_fd, &writable_fds)) continue;
  -	(*ocr->maintenance)(OC_REASON_UNWRITABLE, ocr->data, -1);
  +	if (ocr->write_fd == -1)
  +	    continue;
  +	if (FD_ISSET(ocr->write_fd, &writable_fds))
  +	    continue;
  +	(*ocr->maintenance) (OC_REASON_UNWRITABLE, ocr->data, -1);
       }
   }
   
   /* possibly reap an other_child, return 0 if yes, -1 if not */
  -static int reap_other_child (int pid, int status)
  +static int reap_other_child(int pid, int status)
   {
       other_child_rec *ocr, *nocr;
   
       for (ocr = other_children; ocr; ocr = nocr) {
   	nocr = ocr->next;
  -	if (ocr->pid != pid) continue;
  +	if (ocr->pid != pid)
  +	    continue;
   	ocr->pid = -1;
  -	(*ocr->maintenance)(OC_REASON_DEATH, ocr->data, status);
  +	(*ocr->maintenance) (OC_REASON_DEATH, ocr->data, status);
   	return 0;
       }
       return -1;
  @@ -1175,21 +1185,22 @@
   #undef HAVE_MMAP
   #define HAVE_MMAP 1
   
  -void reinit_scoreboard (pool *p)
  +void reinit_scoreboard(pool *p)
   {
       ap_assert(!scoreboard_image);
  -    scoreboard_image = (scoreboard *)calloc(HARD_SERVER_LIMIT, sizeof(short_score));
  +    scoreboard_image = (scoreboard *) calloc(HARD_SERVER_LIMIT, sizeof(short_score));
   }
   
  -void cleanup_scoreboard ()
  +void cleanup_scoreboard()
   {
       ap_assert(scoreboard_image);
       free(scoreboard_image);
       scoreboard_image = NULL;
   }
   
  -API_EXPORT(void) sync_scoreboard_image ()
  -{}
  +API_EXPORT(void) sync_scoreboard_image()
  +{
  +}
   
   
   #else /* MULTITHREAD */
  @@ -1203,15 +1214,15 @@
       char errstr[MAX_STRING_LEN];
       int rc;
   
  -    m = (caddr_t)create_shared_heap("\\SHAREMEM\\SCOREBOARD", HARD_SERVER_LIMIT*sizeof(short_score));
  -    if(m == 0) {
  -       fprintf(stderr, "httpd: Could not create OS/2 Shared memory pool.\n");
  -       exit(1);
  +    m = (caddr_t) create_shared_heap("\\SHAREMEM\\SCOREBOARD", HARD_SERVER_LIMIT * sizeof(short_score));
  +    if (m == 0) {
  +	fprintf(stderr, "httpd: Could not create OS/2 Shared memory pool.\n");
  +	exit(1);
       }
   
  -    rc = _uopen((Heap_t)m);
  -    if(rc != 0) {
  -       fprintf(stderr, "httpd: Could not uopen() newly created OS/2 Shared memory pool.\n");
  +    rc = _uopen((Heap_t) m);
  +    if (rc != 0) {
  +	fprintf(stderr, "httpd: Could not uopen() newly created OS/2 Shared memory pool.\n");
       }
   
   #elif defined(QNX)
  @@ -1244,19 +1255,19 @@
    */
       int fd;
   
  -    fd = shm_open (scoreboard_fname, O_RDWR|O_CREAT, S_IRUSR|S_IWUSR);
  +    fd = shm_open(scoreboard_fname, O_RDWR | O_CREAT, S_IRUSR | S_IWUSR);
       if (fd == -1) {
   	perror("httpd: could not open(create) scoreboard");
   	exit(1);
       }
  -    if (ltrunc(fd, (off_t)SCOREBOARD_SIZE, SEEK_SET) == -1) {
  +    if (ltrunc(fd, (off_t) SCOREBOARD_SIZE, SEEK_SET) == -1) {
   	perror("httpd: could not ltrunc scoreboard");
   	shm_unlink(scoreboard_fname);
   	exit(1);
       }
  -    if ((m = (caddr_t)mmap((caddr_t)0,
  -		(size_t)SCOREBOARD_SIZE, PROT_READ|PROT_WRITE,
  -		MAP_SHARED, fd, (off_t)0)) == (caddr_t)-1) {
  +    if ((m = (caddr_t) mmap((caddr_t) 0,
  +			    (size_t) SCOREBOARD_SIZE, PROT_READ | PROT_WRITE,
  +			    MAP_SHARED, fd, (off_t) 0)) == (caddr_t) - 1) {
   	perror("httpd: cannot mmap scoreboard");
   	shm_unlink(scoreboard_fname);
   	exit(1);
  @@ -1278,16 +1289,15 @@
        */
       {
   	unsigned len = SCOREBOARD_SIZE;
  -	
  -	m = mmap((caddr_t)0xC0000000, &len,
  -		PROT_READ | PROT_WRITE, MAP_ANON | MAP_SHARED, NOFD, 0);
  +
  +	m = mmap((caddr_t) 0xC0000000, &len,
  +		 PROT_READ | PROT_WRITE, MAP_ANON | MAP_SHARED, NOFD, 0);
       }
   #else
  -    m = mmap((caddr_t)0, SCOREBOARD_SIZE,
  +    m = mmap((caddr_t) 0, SCOREBOARD_SIZE,
   	     PROT_READ | PROT_WRITE, MAP_ANON | MAP_SHARED, -1, 0);
   #endif
  -    if (m == (caddr_t)-1)
  -    {
  +    if (m == (caddr_t) - 1) {
   	perror("mmap");
   	fprintf(stderr, "httpd: Could not mmap memory\n");
   	exit(1);
  @@ -1297,24 +1307,22 @@
       int fd;
   
       fd = open("/dev/zero", O_RDWR);
  -    if (fd == -1)
  -    {
  +    if (fd == -1) {
   	perror("open");
   	fprintf(stderr, "httpd: Could not open /dev/zero\n");
   	exit(1);
       }
  -    m = mmap((caddr_t)0, SCOREBOARD_SIZE,
  +    m = mmap((caddr_t) 0, SCOREBOARD_SIZE,
   	     PROT_READ | PROT_WRITE, MAP_SHARED, fd, 0);
  -    if (m == (caddr_t)-1)
  -    {
  +    if (m == (caddr_t) - 1) {
   	perror("mmap");
   	fprintf(stderr, "httpd: Could not mmap /dev/zero\n");
   	exit(1);
       }
       close(fd);
   #endif
  -    scoreboard_image = (scoreboard *)m;
  -    scoreboard_image->global.exit_generation=0;
  +    scoreboard_image = (scoreboard *) m;
  +    scoreboard_image->global.exit_generation = 0;
   }
   
   #elif defined(HAVE_SHMGET)
  @@ -1329,13 +1337,12 @@
       char *obrk;
   #endif
   
  -    if ((shmid = shmget(shmkey, SCOREBOARD_SIZE, IPC_CREAT|SHM_R|SHM_W)) == -1)
  -    {
  +    if ((shmid = shmget(shmkey, SCOREBOARD_SIZE, IPC_CREAT | SHM_R | SHM_W)) == -1) {
   #ifdef LINUX
   	if (errno == ENOSYS) {
   	    fprintf(stderr,
  -		"httpd: Your kernel was built without CONFIG_SYSVIPC\n"
  -		"httpd: please consult the Apache FAQ for details\n");
  +		    "httpd: Your kernel was built without CONFIG_SYSVIPC\n"
  +		    "httpd: please consult the Apache FAQ for details\n");
   	}
   #endif
   	perror("shmget");
  @@ -1356,30 +1363,26 @@
        * To get around this, we move the break point "way up there",
        * attach the segment and then move break back down. Ugly
        */
  -    if ((obrk=sbrk(MOVEBREAK)) == (char *)-1)
  -    {
  +    if ((obrk = sbrk(MOVEBREAK)) == (char *) -1) {
   	perror("sbrk");
   	fprintf(stderr, "httpd: Could not move break\n");
       }
   #endif
   
   #define BADSHMAT	((scoreboard *)(-1))
  -    if ((scoreboard_image = (scoreboard *)shmat(shmid, 0, 0)) == BADSHMAT)
  -    {
  +    if ((scoreboard_image = (scoreboard *) shmat(shmid, 0, 0)) == BADSHMAT) {
   	perror("shmat");
   	fprintf(stderr, "httpd: Could not call shmat\n");
   	/*
   	 * We exit below, after we try to remove the segment
   	 */
       }
  -    else	/* only worry about permissions if we attached the segment */
  -    {
  +    else {			/* only worry about permissions if we attached the segment */
   	if (shmctl(shmid, IPC_STAT, &shmbuf) != 0) {
   	    perror("shmctl");
   	    fprintf(stderr, "httpd: Could not stat segment #%d\n", shmid);
   	}
  -	else
  -	{
  +	else {
   	    shmbuf.shm_perm.uid = user_id;
   	    shmbuf.shm_perm.gid = group_id;
   	    if (shmctl(shmid, IPC_SET, &shmbuf) != 0) {
  @@ -1404,15 +1407,14 @@
   	exit(1);
   
   #ifdef MOVEBREAK
  -    if (obrk == (char *)-1)
  -	return;		/* nothing else to do */
  -    if (sbrk(-(MOVEBREAK)) == (char *)-1)
  -    {
  +    if (obrk == (char *) -1)
  +	return;			/* nothing else to do */
  +    if (sbrk(-(MOVEBREAK)) == (char *) -1) {
   	perror("sbrk");
   	fprintf(stderr, "httpd: Could not move break back\n");
       }
   #endif
  -    scoreboard_image->global.exit_generation=0;
  +    scoreboard_image->global.exit_generation = 0;
   }
   
   #else
  @@ -1423,81 +1425,79 @@
   /* XXX: things are seriously screwed if we ever have to do a partial
    * read or write ... we could get a corrupted scoreboard
    */
  -static int force_write (int fd, void *buffer, int bufsz)
  +static int force_write(int fd, void *buffer, int bufsz)
   {
       int rv, orig_sz = bufsz;
  -    
  +
       do {
  -	rv = write (fd, buffer, bufsz);
  +	rv = write(fd, buffer, bufsz);
   	if (rv > 0) {
  -	    buffer = (char *)buffer + rv;
  +	    buffer = (char *) buffer + rv;
   	    bufsz -= rv;
   	}
       } while ((rv > 0 && bufsz > 0) || (rv == -1 && errno == EINTR));
   
  -    return rv < 0? rv : orig_sz - bufsz;
  +    return rv < 0 ? rv : orig_sz - bufsz;
   }
   
  -static int force_read (int fd, void *buffer, int bufsz)
  +static int force_read(int fd, void *buffer, int bufsz)
   {
       int rv, orig_sz = bufsz;
  -    
  +
       do {
  -	rv = read (fd, buffer, bufsz);
  +	rv = read(fd, buffer, bufsz);
   	if (rv > 0) {
  -	    buffer = (char *)buffer + rv;
  +	    buffer = (char *) buffer + rv;
   	    bufsz -= rv;
   	}
       } while ((rv > 0 && bufsz > 0) || (rv == -1 && errno == EINTR));
  -    
  -    return rv < 0? rv : orig_sz - bufsz;
  +
  +    return rv < 0 ? rv : orig_sz - bufsz;
   }
   #endif
   
   /* Called by parent process */
  -void reinit_scoreboard (pool *p)
  +void reinit_scoreboard(pool *p)
   {
  -    int exit_gen=0;
  -    if(scoreboard_image)
  -	exit_gen=scoreboard_image->global.exit_generation;
  -	
  +    int exit_gen = 0;
  +    if (scoreboard_image)
  +	exit_gen = scoreboard_image->global.exit_generation;
  +
   #ifndef SCOREBOARD_FILE
  -    if (scoreboard_image == NULL)
  -    {
  +    if (scoreboard_image == NULL) {
   	setup_shared_mem();
       }
       memset(scoreboard_image, 0, SCOREBOARD_SIZE);
  -    scoreboard_image->global.exit_generation=exit_gen;
  +    scoreboard_image->global.exit_generation = exit_gen;
   #else
  -    scoreboard_image=&_scoreboard_image;
  -    scoreboard_fname = server_root_relative (p, scoreboard_fname);
  +    scoreboard_image = &_scoreboard_image;
  +    scoreboard_fname = server_root_relative(p, scoreboard_fname);
   
  -    scoreboard_fd = popenf(p, scoreboard_fname, O_CREAT|O_BINARY|O_RDWR, 0644);
  -    if (scoreboard_fd == -1)
  -    {
  -	perror (scoreboard_fname);
  -	fprintf (stderr, "Cannot open scoreboard file:\n");
  -	exit (1);
  +    scoreboard_fd = popenf(p, scoreboard_fname, O_CREAT | O_BINARY | O_RDWR, 0644);
  +    if (scoreboard_fd == -1) {
  +	perror(scoreboard_fname);
  +	fprintf(stderr, "Cannot open scoreboard file:\n");
  +	exit(1);
       }
   
  -    memset ((char*)scoreboard_image, 0, sizeof(*scoreboard_image));
  -    scoreboard_image->global.exit_generation=exit_gen;
  -    force_write (scoreboard_fd, scoreboard_image, sizeof(*scoreboard_image));
  +    memset((char *) scoreboard_image, 0, sizeof(*scoreboard_image));
  +    scoreboard_image->global.exit_generation = exit_gen;
  +    force_write(scoreboard_fd, scoreboard_image, sizeof(*scoreboard_image));
   #endif
   }
   
   /* called by child */
  -void reopen_scoreboard (pool *p)
  +void reopen_scoreboard(pool *p)
   {
   #ifdef SCOREBOARD_FILE
  -    if (scoreboard_fd != -1) pclosef (p, scoreboard_fd);
  -    
  -    scoreboard_fd = popenf(p, scoreboard_fname, O_CREAT|O_BINARY|O_RDWR, 0666);
  -    if (scoreboard_fd == -1)
  -    {
  -	perror (scoreboard_fname);
  -	fprintf (stderr, "Cannot open scoreboard file:\n");
  -	exit (1);
  +    if (scoreboard_fd != -1)
  +	pclosef(p, scoreboard_fd);
  +
  +    scoreboard_fd = popenf(p, scoreboard_fname, O_CREAT | O_BINARY | O_RDWR, 0666);
  +    if (scoreboard_fd == -1) {
  +	perror(scoreboard_fname);
  +	fprintf(stderr, "Cannot open scoreboard file:\n");
  +	exit(1);
       }
   #else
   #ifdef __EMX__
  @@ -1505,23 +1505,23 @@
       caddr_t m;
       int rc;
   
  -    m = (caddr_t)get_shared_heap("\\SHAREMEM\\SCOREBOARD");
  -    if(m == 0) {
  -        fprintf(stderr, "httpd: Could not find existing OS/2 Shared memory pool.\n");
  -        exit(1);
  +    m = (caddr_t) get_shared_heap("\\SHAREMEM\\SCOREBOARD");
  +    if (m == 0) {
  +	fprintf(stderr, "httpd: Could not find existing OS/2 Shared memory pool.\n");
  +	exit(1);
       }
   
  -    rc = _uopen((Heap_t)m);
  -    scoreboard_image = (scoreboard *)m;
  +    rc = _uopen((Heap_t) m);
  +    scoreboard_image = (scoreboard *) m;
   #endif
   #endif
   #endif
   }
   
  -void cleanup_scoreboard (void)
  +void cleanup_scoreboard(void)
   {
   #ifdef SCOREBOARD_FILE
  -    unlink (scoreboard_fname);
  +    unlink(scoreboard_fname);
   #elif defined(QNX) && defined(HAVE_MMAP)
       shm_unlink(scoreboard_fname);
   #endif
  @@ -1538,38 +1538,38 @@
    * anyway.
    */
   
  -inline void sync_scoreboard_image (void)
  +inline void sync_scoreboard_image(void)
   {
   #ifdef SCOREBOARD_FILE
  -    lseek (scoreboard_fd, 0L, 0);
  -    force_read (scoreboard_fd, scoreboard_image, sizeof(*scoreboard_image));
  +    lseek(scoreboard_fd, 0L, 0);
  +    force_read(scoreboard_fd, scoreboard_image, sizeof(*scoreboard_image));
   #endif
   }
   
   #endif /* MULTITHREAD */
   
  -API_EXPORT(int) exists_scoreboard_image (void)
  +API_EXPORT(int) exists_scoreboard_image(void)
   {
       return (scoreboard_image ? 1 : 0);
   }
   
   static inline void put_scoreboard_info(int child_num,
  -    short_score *new_score_rec)
  -{ 
  +				       short_score *new_score_rec)
  +{
   #ifdef SCOREBOARD_FILE
  -    lseek(scoreboard_fd, (long)child_num * sizeof(short_score), 0);
  +    lseek(scoreboard_fd, (long) child_num * sizeof(short_score), 0);
       force_write(scoreboard_fd, new_score_rec, sizeof(short_score));
   #endif
   }
   
  -int update_child_status (int child_num, int status, request_rec *r)
  +int update_child_status(int child_num, int status, request_rec *r)
   {
       int old_status;
       short_score *ss;
   
       if (child_num < 0)
   	return -1;
  -    
  +
       sync_scoreboard_image();
       ss = &scoreboard_image->servers[child_num];
       old_status = ss->status;
  @@ -1590,22 +1590,22 @@
   	    ss->my_access_count = 0L;
   	    ss->my_bytes_served = 0L;
   	}
  -	ss->conn_count = (unsigned short)0;
  -	ss->conn_bytes = (unsigned long)0;
  +	ss->conn_count = (unsigned short) 0;
  +	ss->conn_bytes = (unsigned long) 0;
       }
       if (r) {
   	int slot_size;
   	conn_rec *c = r->connection;
   	slot_size = sizeof(ss->client) - 1;
   	strncpy(ss->client, get_remote_host(c, r->per_dir_config,
  -	 REMOTE_NOLOOKUP), slot_size);
  +					    REMOTE_NOLOOKUP), slot_size);
   	ss->client[slot_size] = '\0';
   	slot_size = sizeof(ss->request) - 1;
   	strncpy(ss->request, (r->the_request ? r->the_request :
  -	 "NULL"), slot_size);
  +			      "NULL"), slot_size);
   	ss->request[slot_size] = '\0';
   	slot_size = sizeof(ss->vhost) - 1;
  -	strncpy(ss->vhost,r->server->server_hostname, slot_size);
  +	strncpy(ss->vhost, r->server->server_hostname, slot_size);
   	ss->vhost[slot_size] = '\0';
       }
   #endif
  @@ -1619,14 +1619,14 @@
   {
   #ifdef SCOREBOARD_FILE
       lseek(scoreboard_fd,
  -	  (char *)&scoreboard_image->global-(char *)scoreboard_image,0);
  -    force_write(scoreboard_fd,&scoreboard_image->global,
  +	  (char *) &scoreboard_image->global -(char *) scoreboard_image, 0);
  +    force_write(scoreboard_fd, &scoreboard_image->global,
   		sizeof scoreboard_image->global);
   #endif
   }
   
   #if defined(STATUS)
  -void time_process_request (int child_num, int status)
  +void time_process_request(int child_num, int status)
   {
       short_score *ss;
   #if defined(NO_GETTIMEOFDAY) && !defined(NO_TIMES)
  @@ -1634,8 +1634,8 @@
   #endif
   
       if (child_num < 0)
  -	return ;
  -    
  +	return;
  +
       sync_scoreboard_image();
       ss = &scoreboard_image->servers[child_num];
   
  @@ -1644,11 +1644,11 @@
   #ifndef NO_TIMES
   	if ((ss->start_time = times(&tms_blk)) == -1)
   #endif /* NO_TIMES */
  -	    ss->start_time = (clock_t)0;
  +	    ss->start_time = (clock_t) 0;
   #else
  -	if (gettimeofday(&ss->start_time, (struct timezone *)0) < 0)
  +	if (gettimeofday(&ss->start_time, (struct timezone *) 0) < 0)
   	    ss->start_time.tv_sec =
  -	    ss->start_time.tv_usec = 0L;
  +		ss->start_time.tv_usec = 0L;
   #endif
       }
       else if (status == STOP_PREQUEST) {
  @@ -1656,13 +1656,13 @@
   #ifndef NO_TIMES
   	if ((ss->stop_time = times(&tms_blk)) == -1)
   #endif
  -	    ss->stop_time = ss->start_time = (clock_t)0;
  +	    ss->stop_time = ss->start_time = (clock_t) 0;
   #else
  -	if (gettimeofday(&ss->stop_time, (struct timezone *)0) < 0)
  +	if (gettimeofday(&ss->stop_time, (struct timezone *) 0) < 0)
   	    ss->stop_time.tv_sec =
  -	    ss->stop_time.tv_usec =
  -	    ss->start_time.tv_sec =
  -	    ss->start_time.tv_usec = 0L;
  +		ss->stop_time.tv_usec =
  +		ss->start_time.tv_sec =
  +		ss->start_time.tv_usec = 0L;
   #endif
   
       }
  @@ -1670,33 +1670,34 @@
       put_scoreboard_info(child_num, ss);
   }
   
  -static void increment_counts (int child_num, request_rec *r)
  +static void increment_counts(int child_num, request_rec *r)
   {
  -    long int bs=0;
  +    long int bs = 0;
       short_score *ss;
   
       sync_scoreboard_image();
       ss = &scoreboard_image->servers[child_num];
   
       if (r->sent_bodyct)
  -        bgetopt(r->connection->client, BO_BYTECT, &bs);
  +	bgetopt(r->connection->client, BO_BYTECT, &bs);
   
   #ifndef NO_TIMES
       times(&ss->times);
   #endif
  -    ss->access_count ++;
  -    ss->my_access_count ++;
  -    ss->conn_count ++;
  -    ss->bytes_served += (unsigned long)bs;
  -    ss->my_bytes_served += (unsigned long)bs;
  -    ss->conn_bytes += (unsigned long)bs;
  +    ss->access_count++;
  +    ss->my_access_count++;
  +    ss->conn_count++;
  +    ss->bytes_served += (unsigned long) bs;
  +    ss->my_bytes_served += (unsigned long) bs;
  +    ss->conn_bytes += (unsigned long) bs;
   
  -    put_scoreboard_info(child_num, ss); 
  +    put_scoreboard_info(child_num, ss);
   }
  +
   #endif
   
   
  -static int find_child_by_pid (int pid)
  +static int find_child_by_pid(int pid)
   {
       int i;
   
  @@ -1707,11 +1708,11 @@
       return -1;
   }
   
  -static void reclaim_child_processes (int start_tries)
  +static void reclaim_child_processes(int start_tries)
   {
   #ifndef MULTITHREAD
       int i, status;
  -    long int waittime = 4096; /* in usecs */
  +    long int waittime = 4096;	/* in usecs */
       struct timeval tv;
       int waitret, tries;
       int not_dead_yet;
  @@ -1722,13 +1723,13 @@
       sync_scoreboard_image();
   
       tries = 0;
  -    for(tries = start_tries; tries < 4; ++tries) {
  +    for (tries = start_tries; tries < 4; ++tries) {
   	/* don't want to hold up progress any more than 
  -	* necessary, but we need to allow children a few moments to exit.
  -	* delay with an exponential backoff.
  -	* Currently set for a maximum wait of a bit over
  -	* four seconds.
  -	*/
  +	 * necessary, but we need to allow children a few moments to exit.
  +	 * delay with an exponential backoff.
  +	 * Currently set for a maximum wait of a bit over
  +	 * four seconds.
  +	 */
   	tv.tv_sec = waittime / 1000000;
   	tv.tv_usec = waittime % 1000000;
   	waittime = waittime * 2;
  @@ -1739,9 +1740,10 @@
   	for (i = 0; i < max_daemons_limit; ++i) {
   	    int pid = scoreboard_image->parent[i].pid;
   
  -	    if (pid == my_pid || pid == 0) continue;
  +	    if (pid == my_pid || pid == 0)
  +		continue;
   
  -	    waitret = waitpid (pid, &status, WNOHANG);
  +	    waitret = waitpid(pid, &status, WNOHANG);
   	    if (waitret == pid || waitret == -1) {
   		scoreboard_image->parent[i].pid = 0;
   		continue;
  @@ -1752,51 +1754,54 @@
   		/* perhaps it missed the SIGHUP, lets try again */
   		aplog_error(APLOG_MARK, APLOG_ERR, server_conf,
   		    "child process %d did not exit, sending another SIGHUP",
  -		    pid);
  +			    pid);
   		kill(pid, SIGHUP);
   		break;
   	    case 2:
   		/* ok, now it's being annoying */
   		aplog_error(APLOG_MARK, APLOG_ERR, server_conf,
  -		    "child process %d still did not exit, sending a SIGTERM",
  -		    pid);
  +		   "child process %d still did not exit, sending a SIGTERM",
  +			    pid);
   		kill(pid, SIGTERM);
   		break;
   	    case 3:
   		/* die child scum */
   		aplog_error(APLOG_MARK, APLOG_ERR, server_conf,
  -		    "child process %d still did not exit, sending a SIGKILL",
  -		    pid);
  +		   "child process %d still did not exit, sending a SIGKILL",
  +			    pid);
   		kill(pid, SIGKILL);
   		break;
   	    case 4:
   		/* gave it our best shot, but alas...  If this really 
  -		    * is a child we are trying to kill and it really hasn't
  -		    * exited, we will likely fail to bind to the port
  -		    * after the restart.
  -		    */
  +		 * is a child we are trying to kill and it really hasn't
  +		 * exited, we will likely fail to bind to the port
  +		 * after the restart.
  +		 */
   		aplog_error(APLOG_MARK, APLOG_ERR, server_conf,
  -		    "could not make child process %d exit, "
  -		    "attempting to continue anyway", pid);
  +			    "could not make child process %d exit, "
  +			    "attempting to continue anyway", pid);
   		break;
   	    }
   	}
   #ifndef NO_OTHER_CHILD
   	for (ocr = other_children; ocr; ocr = nocr) {
   	    nocr = ocr->next;
  -	    if (ocr->pid == -1) continue;
  +	    if (ocr->pid == -1)
  +		continue;
   
  -	    waitret = waitpid (ocr->pid, &status, WNOHANG);
  +	    waitret = waitpid(ocr->pid, &status, WNOHANG);
   	    if (waitret == ocr->pid) {
   		ocr->pid = -1;
  -		(*ocr->maintenance)(OC_REASON_DEATH, ocr->data, status);
  -	    } else if (waitret == 0) {
  -		(*ocr->maintenance)(OC_REASON_RESTART, ocr->data, -1);
  +		(*ocr->maintenance) (OC_REASON_DEATH, ocr->data, status);
  +	    }
  +	    else if (waitret == 0) {
  +		(*ocr->maintenance) (OC_REASON_RESTART, ocr->data, -1);
   		++not_dead_yet;
  -	    } else if (waitret == -1) {
  +	    }
  +	    else if (waitret == -1) {
   		/* uh what the heck? they didn't call unregister? */
   		ocr->pid = -1;
  -		(*ocr->maintenance)(OC_REASON_LOST, ocr->data, -1);
  +		(*ocr->maintenance) (OC_REASON_LOST, ocr->data, -1);
   	    }
   	}
   #endif
  @@ -1811,23 +1816,23 @@
   
   #if defined(BROKEN_WAIT) || defined(NEED_WAITPID)
   /*
  -Some systems appear to fail to deliver dead children to wait() at times.
  -This sorts them out. In fact, this may have been caused by a race condition
  -in wait_or_timeout(). But this routine is still useful for systems with no
  -waitpid().
  -*/
  -int reap_children (void)
  +   Some systems appear to fail to deliver dead children to wait() at times.
  +   This sorts them out. In fact, this may have been caused by a race condition
  +   in wait_or_timeout(). But this routine is still useful for systems with no
  +   waitpid().
  + */
  +int reap_children(void)
   {
       int status, n;
       int ret = 0;
   
       for (n = 0; n < max_daemons_limit; ++n) {
   	if (scoreboard_image->servers[n].status != SERVER_DEAD
  -		&& waitpid (scoreboard_image->parent[n].pid, &status, WNOHANG)
  -		    == -1
  -		&& errno == ECHILD) {
  -	    sync_scoreboard_image ();
  -	    update_child_status (n, SERVER_DEAD, NULL);
  +	    && waitpid(scoreboard_image->parent[n].pid, &status, WNOHANG)
  +	    == -1
  +	    && errno == ECHILD) {
  +	    sync_scoreboard_image();
  +	    update_child_status(n, SERVER_DEAD, NULL);
   	    ret = 1;
   	}
       }
  @@ -1845,40 +1850,36 @@
   #endif
   static int wait_or_timeout_counter;
   
  -static int wait_or_timeout (int *status)
  +static int wait_or_timeout(int *status)
   {
   #ifdef WIN32
   #define MAXWAITOBJ MAXIMUM_WAIT_OBJECTS
       HANDLE h[MAXWAITOBJ];
       int e[MAXWAITOBJ];
       int round, pi, hi, rv, err;
  -    for(round=0; round<=(HARD_SERVER_LIMIT-1)/MAXWAITOBJ+1; round++)
  -    {
  -        hi = 0;
  -        for(pi=round*MAXWAITOBJ;
  -                (pi<(round+1)*MAXWAITOBJ) && (pi<HARD_SERVER_LIMIT);
  -                pi++)
  -        {
  -            if(scoreboard_image->servers[pi].status != SERVER_DEAD)
  -            {
  -                e[hi] = pi;
  -                h[hi++] = (HANDLE)scoreboard_image->parent[pi].pid;
  -            }
  -
  -        }
  -        if(hi > 0)
  -        {
  -            rv = WaitForMultipleObjects(hi, h, FALSE, 10000);
  -            if(rv == -1)
  -                err = GetLastError();
  -            if((WAIT_OBJECT_0 <= (unsigned int)rv) && ((unsigned int)rv < (WAIT_OBJECT_0 + hi)))
  -                return(scoreboard_image->parent[e[rv - WAIT_OBJECT_0]].pid);
  -            else if((WAIT_ABANDONED_0 <= (unsigned int)rv) && ((unsigned int)rv < (WAIT_ABANDONED_0 + hi)))
  -                return(scoreboard_image->parent[e[rv - WAIT_ABANDONED_0]].pid);
  +    for (round = 0; round <= (HARD_SERVER_LIMIT - 1) / MAXWAITOBJ + 1; round++) {
  +	hi = 0;
  +	for (pi = round * MAXWAITOBJ;
  +	     (pi < (round + 1) * MAXWAITOBJ) && (pi < HARD_SERVER_LIMIT);
  +	     pi++) {
  +	    if (scoreboard_image->servers[pi].status != SERVER_DEAD) {
  +		e[hi] = pi;
  +		h[hi++] = (HANDLE) scoreboard_image->parent[pi].pid;
  +	    }
  +
  +	}
  +	if (hi > 0) {
  +	    rv = WaitForMultipleObjects(hi, h, FALSE, 10000);
  +	    if (rv == -1)
  +		err = GetLastError();
  +	    if ((WAIT_OBJECT_0 <= (unsigned int) rv) && ((unsigned int) rv < (WAIT_OBJECT_0 + hi)))
  +		return (scoreboard_image->parent[e[rv - WAIT_OBJECT_0]].pid);
  +	    else if ((WAIT_ABANDONED_0 <= (unsigned int) rv) && ((unsigned int) rv < (WAIT_ABANDONED_0 + hi)))
  +		return (scoreboard_image->parent[e[rv - WAIT_ABANDONED_0]].pid);
   
  -        }
  +	}
       }
  -    return(-1);
  +    return (-1);
   
   #else /* WIN32 */
       struct timeval tv;
  @@ -1891,7 +1892,7 @@
   	probe_writable_fds();
   #endif
       }
  -    ret = waitpid (-1, status, WNOHANG);
  +    ret = waitpid(-1, status, WNOHANG);
       if (ret == -1 && errno == EINTR) {
   	return -1;
       }
  @@ -1906,22 +1907,24 @@
   }
   
   
  -void bus_error(int sig) {
  +void bus_error(int sig)
  +{
       char emsg[256];
   
  -    ap_snprintf(emsg, sizeof(emsg), 
  +    ap_snprintf(emsg, sizeof(emsg),
   		"httpd: caught SIGBUS, attempting to dump core in %s",
   		coredump_dir);
       aplog_error(APLOG_MARK, APLOG_INFO, server_conf, emsg);
       chdir(coredump_dir);
  -    abort();         
  +    abort();
       exit(1);
   }
   
  -void seg_fault(int sig) {
  +void seg_fault(int sig)
  +{
       char emsg[256];
   
  -    ap_snprintf(emsg, sizeof(emsg), 
  +    ap_snprintf(emsg, sizeof(emsg),
   		"httpd: caught SIGSEGV, attempting to dump core in %s",
   		coredump_dir);
       aplog_error(APLOG_MARK, APLOG_INFO, server_conf, emsg);
  @@ -1934,13 +1937,14 @@
    * Connection structures and accounting...
    */
   
  -void just_die(int sig)			/* SIGHUP to child process??? */
  -{
  +void just_die(int sig)
  +{				/* SIGHUP to child process??? */
       /* if alarms are blocked we have to wait to die otherwise we might
        * end up with corruption in alloc.c's internal structures */
       if (alarms_blocked) {
   	exit_after_unblock = 1;
  -    } else {
  +    }
  +    else {
   	child_exit_modules(pconf, server_conf);
   	destroy_pool(pconf);
   	exit(0);
  @@ -1950,10 +1954,10 @@
   static int volatile usr1_just_die = 1;
   static int volatile deferred_die;
   
  -static void usr1_handler (int sig)
  +static void usr1_handler(int sig)
   {
       if (usr1_just_die) {
  -	just_die (sig);
  +	just_die(sig);
       }
       deferred_die = 1;
   }
  @@ -1964,11 +1968,12 @@
   static int volatile is_graceful;
   static int volatile generation;
   
  -static void sig_term(int sig) {
  +static void sig_term(int sig)
  +{
       shutdown_pending = 1;
   }
   
  -static void restart (int sig)
  +static void restart(int sig)
   {
   #ifdef WIN32
       is_graceful = 0;
  @@ -2008,10 +2013,10 @@
       if (sigaction(SIGUSR1, &sa, NULL) < 0)
   	aplog_error(APLOG_MARK, APLOG_WARNING, server_conf, "sigaction(SIGUSR1)");
   #else
  -    if(!one_process) {
  +    if (!one_process) {
   	signal(SIGSEGV, seg_fault);
   #ifdef SIGBUS
  -    	signal(SIGBUS, bus_error);
  +	signal(SIGBUS, bus_error);
   #endif /* SIGBUS */
       }
   
  @@ -2039,39 +2044,39 @@
   #ifndef MPE
   /* Don't detach for MPE because child processes can't survive the death of
      the parent. */
  -    if((x = fork()) > 0)
  -        exit(0);
  -    else if(x == -1) {
  -        perror("fork");
  -        fprintf(stderr,"httpd: unable to fork new process\n");
  -        exit(1);
  +    if ((x = fork()) > 0)
  +	exit(0);
  +    else if (x == -1) {
  +	perror("fork");
  +	fprintf(stderr, "httpd: unable to fork new process\n");
  +	exit(1);
       }
   #endif
   #ifndef NO_SETSID
  -    if((pgrp=setsid()) == -1) {
  -        perror("setsid");
  -        fprintf(stderr,"httpd: setsid failed\n");
  -        exit(1);
  +    if ((pgrp = setsid()) == -1) {
  +	perror("setsid");
  +	fprintf(stderr, "httpd: setsid failed\n");
  +	exit(1);
       }
   #elif defined(NEXT) || defined(NEWSOS)
  -    if(setpgrp(0,getpid()) == -1 || (pgrp = getpgrp(0)) == -1) {
  -        perror("setpgrp");
  -        fprintf(stderr,"httpd: setpgrp or getpgrp failed\n");
  -        exit(1);
  +    if (setpgrp(0, getpid()) == -1 || (pgrp = getpgrp(0)) == -1) {
  +	perror("setpgrp");
  +	fprintf(stderr, "httpd: setpgrp or getpgrp failed\n");
  +	exit(1);
       }
   #elif defined(__EMX__)
       /* OS/2 don't support process group IDs */
  -    pgrp=-getpid();
  +    pgrp = -getpid();
   #elif defined(MPE)
       /* MPE uses negative pid for process group */
  -    pgrp=-getpid();
  +    pgrp = -getpid();
   #else
  -    if((pgrp=setpgrp(getpid(),0)) == -1) {
  -        perror("setpgrp");
  -        fprintf(stderr,"httpd: setpgrp failed\n");
  -        exit(1);
  +    if ((pgrp = setpgrp(getpid(), 0)) == -1) {
  +	perror("setpgrp");
  +	fprintf(stderr, "httpd: setpgrp failed\n");
  +	exit(1);
       }
  -#endif    
  +#endif
   #endif /* ndef WIN32 */
   }
   
  @@ -2086,67 +2091,69 @@
    * the lookup of to uid --- the same uid may have multiple passwd entries,
    * with different sets of groups for each.
    */
  -  
  +
   static void set_group_privs(void)
   {
   #ifndef WIN32
  -  if(!geteuid()) {
  -    char *name;
  -  
  -    /* Get username if passed as a uid */
  -    
  -    if (user_name[0] == '#') {
  -      struct passwd* ent;
  -      uid_t uid=atoi(&user_name[1]);
  -
  -      if ((ent = getpwuid(uid)) == NULL) {
  -	 aplog_error(APLOG_MARK, APLOG_ALERT, server_conf,
  -		     "getpwuid: couldn't determine user name from uid");
  -	 exit(1);
  -      }
  -      
  -      name = ent->pw_name;
  -    } else name = user_name;
  +    if (!geteuid()) {
  +	char *name;
  +
  +	/* Get username if passed as a uid */
  +
  +	if (user_name[0] == '#') {
  +	    struct passwd *ent;
  +	    uid_t uid = atoi(&user_name[1]);
  +
  +	    if ((ent = getpwuid(uid)) == NULL) {
  +		aplog_error(APLOG_MARK, APLOG_ALERT, server_conf,
  +			 "getpwuid: couldn't determine user name from uid");
  +		exit(1);
  +	    }
  +
  +	    name = ent->pw_name;
  +	}
  +	else
  +	    name = user_name;
   
   #ifndef __EMX__
  -    /* OS/2 dosen't support groups. */
  +	/* OS/2 dosen't support groups. */
   
  -    /* Reset `groups' attributes. */
  -    
  -    if (initgroups(name, group_id) == -1) {
  -	aplog_error(APLOG_MARK, APLOG_ALERT, server_conf,
  -		    "initgroups: unable to set groups");
  -	exit (1);
  -    }
  +	/* Reset `groups' attributes. */
  +
  +	if (initgroups(name, group_id) == -1) {
  +	    aplog_error(APLOG_MARK, APLOG_ALERT, server_conf,
  +			"initgroups: unable to set groups");
  +	    exit(1);
  +	}
   #ifdef MULTIPLE_GROUPS
  -    if (getgroups(NGROUPS_MAX, group_id_list) == -1) {
  -	aplog_error(APLOG_MARK, APLOG_ALERT, server_conf,
  -		    "getgroups: unable to get group list");
  -	exit (1);
  -    }
  +	if (getgroups(NGROUPS_MAX, group_id_list) == -1) {
  +	    aplog_error(APLOG_MARK, APLOG_ALERT, server_conf,
  +			"getgroups: unable to get group list");
  +	    exit(1);
  +	}
  +#endif
  +	if (setgid(group_id) == -1) {
  +	    aplog_error(APLOG_MARK, APLOG_ALERT, server_conf,
  +			"setgid: unable to set group id");
  +	    exit(1);
  +	}
   #endif
  -    if (setgid(group_id) == -1) {
  -	aplog_error(APLOG_MARK, APLOG_ALERT, server_conf,
  -		    "setgid: unable to set group id");
  -	exit (1);
       }
  -#endif 
  -  }
   #endif /* ndef WIN32 */
   }
   
   /* check to see if we have the 'suexec' setuid wrapper installed */
  -int init_suexec (void)
  +int init_suexec(void)
   {
   #ifndef WIN32
       struct stat wrapper;
  -    
  +
       if ((stat(SUEXEC_BIN, &wrapper)) != 0)
  -      return (suexec_enabled);
  -    
  +	return (suexec_enabled);
  +
       if ((wrapper.st_mode & S_ISUID) && wrapper.st_uid == 0) {
  -      suexec_enabled = 1;
  -      fprintf(stderr, "Configuring Apache for use with suexec wrapper.\n");
  +	suexec_enabled = 1;
  +	fprintf(stderr, "Configuring Apache for use with suexec wrapper.\n");
       }
   #endif /* ndef WIN32 */
       return (suexec_enabled);
  @@ -2163,21 +2170,21 @@
    *
    * Hash function provided by David Hankins.
    */
  -static inline unsigned hash_inaddr( unsigned key )
  +static inline unsigned hash_inaddr(unsigned key)
   {
       key ^= (key >> 16);
       return ((key >> 8) ^ key) % VHASH_TABLE_SIZE;
   }
   
  -static server_rec *find_virtual_server (struct in_addr server_ip,
  -				unsigned port, server_rec *server)
  +static server_rec *find_virtual_server(struct in_addr server_ip,
  +				       unsigned port, server_rec *server)
   {
       server_addr_rec *sar;
       server_rec_chain *trav;
       unsigned buk;
   
       /* scan the hash table for an exact match first */
  -    buk = hash_inaddr( server_ip.s_addr );
  +    buk = hash_inaddr(server_ip.s_addr);
       for (trav = vhash_table[buk]; trav; trav = trav->next) {
   	sar = trav->sar;
   	if ((sar->host_addr.s_addr == server_ip.s_addr)
  @@ -2197,12 +2204,12 @@
   }
   
   
  -static void add_to_vhash_bucket (unsigned buk, server_rec *s,
  -    server_addr_rec *sar)
  +static void add_to_vhash_bucket(unsigned buk, server_rec *s,
  +				server_addr_rec *sar)
   {
       server_rec_chain *hashme;
   
  -    hashme = palloc (pconf, sizeof (*hashme));
  +    hashme = palloc(pconf, sizeof(*hashme));
       hashme->server = s;
       hashme->sar = sar;
       hashme->next = vhash_table[buk];
  @@ -2215,12 +2222,12 @@
    */
   #define VHASH_STATISTICS
   #ifdef VHASH_STATISTICS
  -static int vhash_compare (const void *a, const void *b)
  +static int vhash_compare(const void *a, const void *b)
   {
  -    return (*(const int *)b - *(const int *)a);
  +    return (*(const int *) b - *(const int *) a);
   }
   
  -static void dump_vhash_statistics (void)
  +static void dump_vhash_statistics(void)
   {
       unsigned count[VHASH_TABLE_SIZE + VHASH_EXTRA_SLOP];
       int i;
  @@ -2240,24 +2247,25 @@
   	    }
   	}
       }
  -    qsort (count, VHASH_TABLE_SIZE, sizeof (count[0]), vhash_compare);
  -    p = buf + ap_snprintf (buf, sizeof (buf),
  -			   "vhash: total hashed = %u, avg chain = %u, #default = %u, "
  -			   "#name-vhost = %u, chain lengths (count x len):",
  -			   total, total / VHASH_TABLE_SIZE, count [VHASH_DEFAULT_BUCKET],
  -			   count [VHASH_MAIN_BUCKET]);
  +    qsort(count, VHASH_TABLE_SIZE, sizeof(count[0]), vhash_compare);
  +    p = buf + ap_snprintf(buf, sizeof(buf),
  +		 "vhash: total hashed = %u, avg chain = %u, #default = %u, "
  +			  "#name-vhost = %u, chain lengths (count x len):",
  +	       total, total / VHASH_TABLE_SIZE, count[VHASH_DEFAULT_BUCKET],
  +			  count[VHASH_MAIN_BUCKET]);
       total = 1;
       for (i = 1; i < VHASH_TABLE_SIZE; ++i) {
  -	if (count[i-1] != count[i]) {
  -	    p += ap_snprintf (p, sizeof (buf) - (p - buf), " %ux%u",
  -			      total, count[i-1]);
  +	if (count[i - 1] != count[i]) {
  +	    p += ap_snprintf(p, sizeof(buf) - (p - buf), " %ux%u",
  +			     total, count[i - 1]);
   	    total = 1;
  -	} else {
  +	}
  +	else {
   	    ++total;
   	}
       }
  -    p += ap_snprintf(p, sizeof (buf) - (p - buf), " %ux%u",
  -		     total, count[VHASH_TABLE_SIZE-1]);
  +    p += ap_snprintf(p, sizeof(buf) - (p - buf), " %ux%u",
  +		     total, count[VHASH_TABLE_SIZE - 1]);
       aplog_error(APLOG_MARK, APLOG_DEBUG, server_conf, buf);
   }
   #endif
  @@ -2271,7 +2279,7 @@
       server_addr_rec *sar;
       server_addr_rec *main_sar;
       int has_default_vhost_addr;
  -    int from_local=0;  
  +    int from_local = 0;
       server_rec *s;
       int is_namevhost;
   
  @@ -2285,14 +2293,15 @@
   
       def_hostname = s->server_hostname;
       h = gethostbyname(def_hostname);
  -    if( h == NULL ) {
  -	fprintf(stderr,"httpd: cannot determine the IP address of ");
  +    if (h == NULL) {
  +	fprintf(stderr, "httpd: cannot determine the IP address of ");
   	if (from_local) {
  -	   fprintf(stderr,"the local host (%s). Use ServerName to set it manually.\n",
  -		s->server_hostname ? s->server_hostname : "<NULL>");
  -	} else {
  -	   fprintf(stderr,"the specified ServerName (%s).\n",
  -		s->server_hostname ? s->server_hostname : "<NULL>");
  +	    fprintf(stderr, "the local host (%s). Use ServerName to set it manually.\n",
  +		    s->server_hostname ? s->server_hostname : "<NULL>");
  +	}
  +	else {
  +	    fprintf(stderr, "the specified ServerName (%s).\n",
  +		    s->server_hostname ? s->server_hostname : "<NULL>");
   	};
   	exit(1);
       }
  @@ -2303,14 +2312,14 @@
        * clobbered here if we didn't copy it somewhere. -djg
        */
       for (n = 0; h->h_addr_list[n] != NULL; n++) {
  -    	main_sar = pcalloc (pconf, sizeof (*main_sar));
  -	main_sar->host_addr = *(struct in_addr *)h->h_addr_list[n];
  +	main_sar = pcalloc(pconf, sizeof(*main_sar));
  +	main_sar->host_addr = *(struct in_addr *) h->h_addr_list[n];
   	main_sar->host_port = 0;	/* we want this to match all ports */
   	main_sar->virthost = s->server_hostname;
   	main_sar->next = s->addrs;
   	s->addrs = main_sar;
  -	add_to_vhash_bucket (hash_inaddr (main_sar->host_addr.s_addr),
  -	    s, main_sar);
  +	add_to_vhash_bucket(hash_inaddr(main_sar->host_addr.s_addr),
  +			    s, main_sar);
       }
   
       /* Then virtual hosts */
  @@ -2318,12 +2327,12 @@
       for (s = s->next; s; s = s->next) {
   	/* Check to see if we might be a HTTP/1.1 virtual host - same IP */
   	has_default_vhost_addr = 0;
  -	for(sar = s->addrs; sar; sar = sar->next) {
  -	    is_namevhost = 0; /* guess addr doesn't match main server */
  -	    for (main_sar = main_s->addrs; main_sar; main_sar=main_sar->next) {
  +	for (sar = s->addrs; sar; sar = sar->next) {
  +	    is_namevhost = 0;	/* guess addr doesn't match main server */
  +	    for (main_sar = main_s->addrs; main_sar; main_sar = main_sar->next) {
   		if (sar->host_addr.s_addr == main_sar->host_addr.s_addr
   		    && s->port == main_s->port) {
  -		    add_to_vhash_bucket (VHASH_MAIN_BUCKET, s, sar);
  +		    add_to_vhash_bucket(VHASH_MAIN_BUCKET, s, sar);
   		    /* XXX: only add it to the main bucket once since we're
   		     * not optimizing name-vhosts yet */
   		    s->is_virtual = 2;
  @@ -2338,84 +2347,89 @@
   		 * since we need to do a port test
   		 */
   		has_default_vhost_addr = 1;
  -		add_to_vhash_bucket (VHASH_DEFAULT_BUCKET, s, sar);
  -	    } else if (!is_namevhost) {
  -		add_to_vhash_bucket (hash_inaddr (sar->host_addr.s_addr),
  -		    s, sar);
  +		add_to_vhash_bucket(VHASH_DEFAULT_BUCKET, s, sar);
  +	    }
  +	    else if (!is_namevhost) {
  +		add_to_vhash_bucket(hash_inaddr(sar->host_addr.s_addr),
  +				    s, sar);
   	    }
   	}
   
   	/* FIXME: some of this decision doesn't make a lot of sense in
  -	    the presence of multiple addresses on the <VirtualHost>
  -	    directive.  It should issue warnings here perhaps. -djg */
  -        if (!s->server_hostname) {
  +	   the presence of multiple addresses on the <VirtualHost>
  +	   directive.  It should issue warnings here perhaps. -djg */
  +	if (!s->server_hostname) {
   	    if (s->is_virtual == 2) {
   		if (s->addrs) {
   		    s->server_hostname = s->addrs->virthost;
  -		} else {
  +		}
  +		else {
   		    /* what else can we do?  at this point this vhost has
  -			no configured name, probably because they used
  -			DNS in the VirtualHost statement.  It's disabled
  -			anyhow by the host matching code.  -djg */
  -		    s->server_hostname = 
  -			pstrdup (pconf, "bogus_host_without_forward_dns");
  +		       no configured name, probably because they used
  +		       DNS in the VirtualHost statement.  It's disabled
  +		       anyhow by the host matching code.  -djg */
  +		    s->server_hostname =
  +			pstrdup(pconf, "bogus_host_without_forward_dns");
   		}
  -	    } else if (has_default_vhost_addr) {
  +	    }
  +	    else if (has_default_vhost_addr) {
   		s->server_hostname = def_hostname;
  -	    } else {
  +	    }
  +	    else {
   		if (s->addrs
  -		    && (h = gethostbyaddr ((char *)&(s->addrs->host_addr),
  -				   sizeof (struct in_addr), AF_INET))) {
  -		    s->server_hostname = pstrdup (pconf, (char *)h->h_name);
  -		} else {
  +		    && (h = gethostbyaddr((char *) &(s->addrs->host_addr),
  +					sizeof(struct in_addr), AF_INET))) {
  +		    s->server_hostname = pstrdup(pconf, (char *) h->h_name);
  +		}
  +		else {
   		    /* again, what can we do?  They didn't specify a
  -			ServerName, and their DNS isn't working. -djg */
  +		       ServerName, and their DNS isn't working. -djg */
   		    if (s->addrs) {
   			fprintf(stderr, "Failed to resolve server name "
  -			    "for %s (check DNS)\n",
  -			    inet_ntoa(s->addrs->host_addr));
  +				"for %s (check DNS)\n",
  +				inet_ntoa(s->addrs->host_addr));
   		    }
   		    s->server_hostname =
  -			pstrdup (pconf, "bogus_host_without_reverse_dns");
  +			pstrdup(pconf, "bogus_host_without_reverse_dns");
   		}
   	    }
   	}
       }
   
   #ifdef VHASH_STATISTICS
  -    dump_vhash_statistics ();
  +    dump_vhash_statistics();
   #endif
   }
   
  -conn_rec *new_connection (pool *p, server_rec *server, BUFF *inout,
  -			  const struct sockaddr_in *remaddr,
  -			  const struct sockaddr_in *saddr,
  -			  int child_num)
  +conn_rec *new_connection(pool *p, server_rec *server, BUFF *inout,
  +			 const struct sockaddr_in *remaddr,
  +			 const struct sockaddr_in *saddr,
  +			 int child_num)
   {
  -    conn_rec *conn = (conn_rec *)pcalloc (p, sizeof(conn_rec));
  -    
  +    conn_rec *conn = (conn_rec *) pcalloc(p, sizeof(conn_rec));
  +
       /* Got a connection structure, so initialize what fields we can
        * (the rest are zeroed out by pcalloc).
        */
  -    
  +
       conn->child_num = child_num;
  -    
  +
       conn->pool = p;
       conn->local_addr = *saddr;
       conn->server = find_virtual_server(saddr->sin_addr, ntohs(saddr->sin_port),
   				       server);
       conn->base_server = conn->server;
       conn->client = inout;
  -    
  +
       conn->remote_addr = *remaddr;
  -    conn->remote_ip = pstrdup (conn->pool,
  -			       inet_ntoa(conn->remote_addr.sin_addr));
  +    conn->remote_ip = pstrdup(conn->pool,
  +			      inet_ntoa(conn->remote_addr.sin_addr));
   
       return conn;
   }
   
   #if defined(TCP_NODELAY) && !defined(MPE)
  -static void sock_disable_nagle (int s)
  +static void sock_disable_nagle(int s)
   {
       /* The Nagle algorithm says that we should delay sending partial
        * packets in hopes of getting more data.  We don't want to do
  @@ -2428,14 +2442,15 @@
        */
       int just_say_no = 1;
   
  -    if (setsockopt(s, IPPROTO_TCP, TCP_NODELAY, (char*)&just_say_no,
  -                   sizeof(int)) < 0) {
  -        aplog_error(APLOG_MARK, APLOG_WARNING, server_conf,
  +    if (setsockopt(s, IPPROTO_TCP, TCP_NODELAY, (char *) &just_say_no,
  +		   sizeof(int)) < 0) {
  +	aplog_error(APLOG_MARK, APLOG_WARNING, server_conf,
   		    "setsockopt: (TCP_NODELAY)");
       }
   }
  +
   #else
  -#define sock_disable_nagle(s) /* NOOP */
  +#define sock_disable_nagle(s)	/* NOOP */
   #endif
   
   
  @@ -2446,11 +2461,11 @@
   
       /* note that because we're about to slack we don't use psocket */
       block_alarms();
  -    if ((s = socket(AF_INET,SOCK_STREAM,IPPROTO_TCP)) == -1) {
  -        aplog_error(APLOG_MARK, APLOG_CRIT, server_conf,
  +    if ((s = socket(AF_INET, SOCK_STREAM, IPPROTO_TCP)) == -1) {
  +	aplog_error(APLOG_MARK, APLOG_CRIT, server_conf,
   		    "socket: Failed to get a socket, exiting child");
   	unblock_alarms();
  -        exit(1);
  +	exit(1);
       }
   
       /* Solaris (probably versions 2.4, 2.5, and 2.5.1 with various levels
  @@ -2465,31 +2480,31 @@
   #ifndef WORKAROUND_SOLARIS_BUG
       s = ap_slack(s, AP_SLACK_HIGH);
   
  -    note_cleanups_for_socket(p, s); /* arrange to close on exec or restart */
  +    note_cleanups_for_socket(p, s);	/* arrange to close on exec or restart */
       unblock_alarms();
   #endif
   
   #ifndef MPE
   /* MPE does not support SO_REUSEADDR and SO_KEEPALIVE */
  -    if (setsockopt(s, SOL_SOCKET, SO_REUSEADDR, (char *)&one, sizeof(int)) < 0) {
  -        aplog_error(APLOG_MARK, APLOG_CRIT, server_conf,
  +    if (setsockopt(s, SOL_SOCKET, SO_REUSEADDR, (char *) &one, sizeof(int)) < 0) {
  +	aplog_error(APLOG_MARK, APLOG_CRIT, server_conf,
   		    "setsockopt: (SO_REUSEADDR)");
  -        exit(1);
  +	exit(1);
       }
       one = 1;
   #ifndef BEOS
   /* BeOS does not support SO_KEEPALIVE */
  -    if (setsockopt(s, SOL_SOCKET,SO_KEEPALIVE,(char *)&one,sizeof(int)) < 0) {
  -        aplog_error(APLOG_MARK, APLOG_CRIT, server_conf,
  +    if (setsockopt(s, SOL_SOCKET, SO_KEEPALIVE, (char *) &one, sizeof(int)) < 0) {
  +	aplog_error(APLOG_MARK, APLOG_CRIT, server_conf,
   		    "setsockopt: (SO_KEEPALIVE)");
  -        exit(1);
  +	exit(1);
       }
   #endif
   #endif
   
       sock_disable_nagle(s);
       sock_enable_linger(s);
  -    
  +
       /*
        * To send data over high bandwidth-delay connections at full
        * speed we must force the TCP window to open wide enough to keep the
  @@ -2509,11 +2524,11 @@
        *
        * If no size is specified, use the kernel default.
        */
  -#ifndef BEOS	/* BeOS does not support SO_SNDBUF */
  +#ifndef BEOS			/* BeOS does not support SO_SNDBUF */
       if (server_conf->send_buffer_size) {
  -        if (setsockopt(s, SOL_SOCKET, SO_SNDBUF,
  -		       (char *)&server_conf->send_buffer_size, sizeof(int)) < 0) {
  -            aplog_error(APLOG_MARK, APLOG_WARNING, server_conf,
  +	if (setsockopt(s, SOL_SOCKET, SO_SNDBUF,
  +		(char *) &server_conf->send_buffer_size, sizeof(int)) < 0) {
  +	    aplog_error(APLOG_MARK, APLOG_WARNING, server_conf,
   			"setsockopt: (SO_SNDBUF): Failed to set SendBufferSize, using default");
   	    /* not a fatal error */
   	}
  @@ -2522,29 +2537,32 @@
   
   #ifdef MPE
   /* MPE requires CAP=PM and GETPRIVMODE to bind to ports less than 1024 */
  -    if (ntohs(server->sin_port) < 1024) GETPRIVMODE();
  +    if (ntohs(server->sin_port) < 1024)
  +	GETPRIVMODE();
   #endif
  -    if(bind(s, (struct sockaddr *)server,sizeof(struct sockaddr_in)) == -1) {
  -        perror("bind");
  +    if (bind(s, (struct sockaddr *) server, sizeof(struct sockaddr_in)) == -1) {
  +	perror("bind");
   #ifdef MPE
  -        if (ntohs(server->sin_port) < 1024) GETUSERMODE();
  +	if (ntohs(server->sin_port) < 1024)
  +	    GETUSERMODE();
   #endif
   	if (server->sin_addr.s_addr != htonl(INADDR_ANY))
  -	    fprintf(stderr,"httpd: could not bind to address %s port %d\n",
  +	    fprintf(stderr, "httpd: could not bind to address %s port %d\n",
   		    inet_ntoa(server->sin_addr), ntohs(server->sin_port));
   	else
  -	    fprintf(stderr,"httpd: could not bind to port %d\n",
  +	    fprintf(stderr, "httpd: could not bind to port %d\n",
   		    ntohs(server->sin_port));
  -        exit(1);
  +	exit(1);
       }
   #ifdef MPE
  -    if (ntohs(server->sin_port) < 1024) GETUSERMODE();
  +    if (ntohs(server->sin_port) < 1024)
  +	GETUSERMODE();
   #endif
   
       if (listen(s, listenbacklog) == -1) {
   	aplog_error(APLOG_MARK, APLOG_ERR, server_conf,
   		    "listen: unable to listen for connections");
  -	close (s);
  +	close(s);
   #ifdef WORKAROUND_SOLARIS_BUG
   	unblock_alarms();
   #endif
  @@ -2554,7 +2572,7 @@
   #ifdef WORKAROUND_SOLARIS_BUG
       s = ap_slack(s, AP_SLACK_HIGH);
   
  -    note_cleanups_for_socket(p, s); /* arrange to close on exec or restart */
  +    note_cleanups_for_socket(p, s);	/* arrange to close on exec or restart */
       unblock_alarms();
   #endif
       return s;
  @@ -2586,8 +2604,8 @@
       do {
   	listen_rec *nr = malloc(sizeof *nr);
   	if (nr == NULL) {
  -	    fprintf (stderr, "Ouch!  malloc failed in copy_listeners()\n");
  -	    exit (1);
  +	    fprintf(stderr, "Ouch!  malloc failed in copy_listeners()\n");
  +	    exit(1);
   	}
   	*nr = *lr;
   	kill_cleanups_for_socket(p, nr->fd);
  @@ -2634,25 +2652,27 @@
       int fd;
   
       listenmaxfd = -1;
  -    FD_ZERO (&listenfds);
  +    FD_ZERO(&listenfds);
       lr = listeners;
  -    for(;;) {
  -	fd = find_listener (lr);
  +    for (;;) {
  +	fd = find_listener(lr);
   	if (fd < 0) {
  -	    fd = make_sock (p, &lr->local_addr);
  +	    fd = make_sock(p, &lr->local_addr);
   	}
   	if (fd >= 0) {
  -	    FD_SET (fd, &listenfds);
  -	    if (fd > listenmaxfd) listenmaxfd = fd;
  +	    FD_SET(fd, &listenfds);
  +	    if (fd > listenmaxfd)
  +		listenmaxfd = fd;
   	}
   	lr->fd = fd;
  -	if (lr->next == NULL) break;
  +	if (lr->next == NULL)
  +	    break;
   	lr = lr->next;
       }
       /* turn the list into a ring */
       lr->next = listeners;
       head_listener = listeners;
  -    close_unused_listeners ();
  +    close_unused_listeners();
   }
   
   
  @@ -2660,10 +2680,10 @@
    * Find a listener which is ready for accept().  This advances the
    * head_listener global.
    */
  -static inline listen_rec *find_ready_listener(fd_set *main_fds)
  +static inline listen_rec *find_ready_listener(fd_set * main_fds)
   {
       listen_rec *lr;
  -    
  +
       lr = head_listener;
       do {
   	if (FD_ISSET(lr->fd, main_fds)) {
  @@ -2678,53 +2698,48 @@
   
   static int s_iInitCount = 0;
   
  -int
  -AMCSocketInitialize(void)
  +int AMCSocketInitialize(void)
   {
   #ifdef WIN32
       int iVersionRequested;
       WSADATA wsaData;
       int err;
  -    
  -    if(s_iInitCount > 0)
  -    {
  -        s_iInitCount++;
  -        return(0);
  +
  +    if (s_iInitCount > 0) {
  +	s_iInitCount++;
  +	return (0);
       }
  -    else if(s_iInitCount < 0)
  -        return(s_iInitCount);
  +    else if (s_iInitCount < 0)
  +	return (s_iInitCount);
   
       /* s_iInitCount == 0. Do the initailization */
       iVersionRequested = MAKEWORD(1, 1);
  -    err = WSAStartup((WORD)iVersionRequested, &wsaData);
  -    if(err)
  -    {
  -        s_iInitCount = -1;
  -        return(s_iInitCount);
  -    }
  -    if ( LOBYTE( wsaData.wVersion ) != 1 || 
  -        HIBYTE( wsaData.wVersion ) != 1 )
  -    { 
  -        s_iInitCount = -2; 
  -        WSACleanup(); 
  -        return(s_iInitCount); 
  +    err = WSAStartup((WORD) iVersionRequested, &wsaData);
  +    if (err) {
  +	s_iInitCount = -1;
  +	return (s_iInitCount);
  +    }
  +    if (LOBYTE(wsaData.wVersion) != 1 ||
  +	HIBYTE(wsaData.wVersion) != 1) {
  +	s_iInitCount = -2;
  +	WSACleanup();
  +	return (s_iInitCount);
       }
   #else
       signal(SIGPIPE, SIG_IGN);
   #endif /* WIN32 */
   
       s_iInitCount++;
  -    return(s_iInitCount);
  +    return (s_iInitCount);
   
   }
   
   
  -void
  -AMCSocketCleanup(void)
  +void AMCSocketCleanup(void)
   {
   #ifdef WIN32
  -    if(--s_iInitCount == 0)
  -        WSACleanup();
  +    if (--s_iInitCount == 0)
  +	WSACleanup();
   #else /* not WIN32 */
       s_iInitCount--;
   #endif /* WIN32 */
  @@ -2744,12 +2759,12 @@
   static int requests_this_child;
   static fd_set main_fds;
   
  -API_EXPORT(void) child_terminate (request_rec *r)
  +API_EXPORT(void) child_terminate(request_rec *r)
   {
       r->connection->keepalive = 0;
       requests_this_child = max_requests_per_child = 1;
   }
  -  
  +
   void child_main(int child_num_arg)
   {
       NET_SIZE_T clen;
  @@ -2769,108 +2784,111 @@
   #ifdef MPE
       /* Only try to switch if we're running as MANAGER.SYS */
       if (geteuid() == 1 && user_id > 1) {
  -        GETPRIVMODE();
  -        if (setuid(user_id) == -1) {
  -            GETUSERMODE();
  +	GETPRIVMODE();
  +	if (setuid(user_id) == -1) {
  +	    GETUSERMODE();
  +	    aplog_error(APLOG_MARK, APLOG_ALERT, server_conf,
  +			"setuid: unable to change uid");
  +	    exit(1);
  +	}
  +	GETUSERMODE();
  +    }
   #else
       /* Only try to switch if we're running as root */
       if (!geteuid() && setuid(user_id) == -1) {
  -#endif
  -        aplog_error(APLOG_MARK, APLOG_ALERT, server_conf,
  +	aplog_error(APLOG_MARK, APLOG_ALERT, server_conf,
   		    "setuid: unable to change uid");
  -	exit (1);
  -    }
  -#ifdef MPE
  -        GETUSERMODE();
  +	exit(1);
       }
   #endif
   
       child_init_modules(pconf, server_conf);
   
  -    (void)update_child_status(my_child_num, SERVER_READY, (request_rec*)NULL);
  +    (void) update_child_status(my_child_num, SERVER_READY, (request_rec *) NULL);
   
       /*
        * Setup the jump buffers so that we can return here after
        * a signal or a timeout (yeah, I know, same thing).
        */
  -    ap_setjmp (jmpbuffer);
  +    ap_setjmp(jmpbuffer);
   #ifndef __EMX__
       signal(SIGURG, timeout);
  -#endif    
  -    signal(SIGPIPE, timeout);  
  +#endif
  +    signal(SIGPIPE, timeout);
       signal(SIGALRM, alrm_handler);
   
       while (1) {
   	BUFF *conn_io;
   	request_rec *r;
  -      
  +
   	/* Prepare to receive a SIGUSR1 due to graceful restart so that
   	 * we can exit cleanly.  Since we're between connections right
   	 * now it's the right time to exit, but we might be blocked in a
   	 * system call when the graceful restart request is made. */
   	usr1_just_die = 1;
  -	signal (SIGUSR1, usr1_handler);
  +	signal(SIGUSR1, usr1_handler);
   
  -        /*
  -         * (Re)initialize this child to a pre-connection state.
  -         */
  +	/*
  +	 * (Re)initialize this child to a pre-connection state.
  +	 */
   
   	kill_timeout(0);	/* Cancel any outstanding alarms. */
  -        timeout_req = NULL;	/* No request in progress */
  +	timeout_req = NULL;	/* No request in progress */
   	current_conn = NULL;
  -    
  -	clear_pool (ptrans);
  -	
  +
  +	clear_pool(ptrans);
  +
   	sync_scoreboard_image();
   	if (scoreboard_image->global.exit_generation >= generation) {
   	    child_exit_modules(pconf, server_conf);
   	    destroy_pool(pconf);
   	    exit(0);
   	}
  -	
  +
   	if ((max_requests_per_child > 0
  -	        && ++requests_this_child >= max_requests_per_child))
  -	{
  +	     && ++requests_this_child >= max_requests_per_child)) {
   	    child_exit_modules(pconf, server_conf);
   	    destroy_pool(pconf);
   	    exit(0);
   	}
   
  -	(void)update_child_status(my_child_num, SERVER_READY, (request_rec*)NULL);
  +	(void) update_child_status(my_child_num, SERVER_READY, (request_rec *) NULL);
   
  -        /*
  -         * Wait for an acceptable connection to arrive.
  -         */
  +	/*
  +	 * Wait for an acceptable connection to arrive.
  +	 */
   
   	/* Lock around "accept", if necessary */
  -        SAFE_ACCEPT(accept_mutex_on());
  +	SAFE_ACCEPT(accept_mutex_on());
   
  -        for (;;) {
  +	for (;;) {
   	    if (listeners->next != listeners) {
   		/* more than one socket */
   		memcpy(&main_fds, &listenfds, sizeof(fd_set));
  -		srv = ap_select(listenmaxfd+1, &main_fds, NULL, NULL, NULL);
  +		srv = ap_select(listenmaxfd + 1, &main_fds, NULL, NULL, NULL);
   
   		if (srv < 0 && errno != EINTR) {
   #ifdef LINUX
   		    if (errno == EFAULT) {
   			aplog_error(APLOG_MARK, APLOG_ERR, server_conf,
  -			    "select: (listen) fatal, exiting");
  -			child_exit_modules (pconf, server_conf);
  +				    "select: (listen) fatal, exiting");
  +			child_exit_modules(pconf, server_conf);
   			destroy_pool(pconf);
   			exit(1);
   		    }
   #endif
   		    aplog_error(APLOG_MARK, APLOG_ERR, server_conf, "select: (listen)");
   		}
  -		
  +
   		if (srv <= 0)
   		    continue;
   
   		lr = find_ready_listener(&main_fds);
  -		if (lr == NULL) continue;
  +		if (lr == NULL)
  +		    continue;
   		sd = lr->fd;
  -	    } else {
  +	    }
  +	    else {
   		/* only one socket, just pretend we did the other stuff */
   		sd = listeners->fd;
   	    }
  @@ -2880,10 +2898,11 @@
   	     */
   	    deferred_die = 0;
   	    usr1_just_die = 0;
  -            for (;;) {
  -                clen = sizeof(sa_client);
  -                csd  = accept(sd, &sa_client, &clen);
  -		if (csd >= 0 || errno != EINTR) break;
  +	    for (;;) {
  +		clen = sizeof(sa_client);
  +		csd = accept(sd, &sa_client, &clen);
  +		if (csd >= 0 || errno != EINTR)
  +		    break;
   		if (deferred_die) {
   		    /* we didn't get a socket, and we were told to die */
   		    child_exit_modules(pconf, server_conf);
  @@ -2892,20 +2911,20 @@
   		}
   	    }
   
  -            if (csd >= 0)
  -                break;      /* We have a socket ready for reading */
  -            else {
  +	    if (csd >= 0)
  +		break;		/* We have a socket ready for reading */
  +	    else {
   
   #if defined(EPROTO) && defined(ECONNABORTED)
  -              if ((errno != EPROTO) && (errno != ECONNABORTED))
  +		if ((errno != EPROTO) && (errno != ECONNABORTED))
   #elif defined(EPROTO)
  -              if (errno != EPROTO)
  +		    if (errno != EPROTO)
   #elif defined(ECONNABORTED)
  -              if (errno != ECONNABORTED)
  +			if (errno != ECONNABORTED)
   #endif
  -		  aplog_error(APLOG_MARK, APLOG_ERR, server_conf,
  -			      "accept: (client socket)");
  -            }
  +			    aplog_error(APLOG_MARK, APLOG_ERR, server_conf,
  +					"accept: (client socket)");
  +	    }
   
   	    /* go around again, safe to die */
   	    usr1_just_die = 1;
  @@ -2924,21 +2943,21 @@
   		destroy_pool(pconf);
   		exit(0);
   	    }
  -        }
  +	}
   
  -        SAFE_ACCEPT(accept_mutex_off()); /* unlock after "accept" */
  +	SAFE_ACCEPT(accept_mutex_off());	/* unlock after "accept" */
   
   	/* We've got a socket, let's at least process one request off the
   	 * socket before we accept a graceful restart request.
   	 */
  -	signal (SIGUSR1, SIG_IGN);
  +	signal(SIGUSR1, SIG_IGN);
   
  -	note_cleanups_for_fd(ptrans,csd);
  +	note_cleanups_for_fd(ptrans, csd);
   
  -        /*
  -         * We now have a connection, so set it up with the appropriate
  -         * socket options, file descriptors, and read/write buffers.
  -         */
  +	/*
  +	 * We now have a connection, so set it up with the appropriate
  +	 * socket options, file descriptors, and read/write buffers.
  +	 */
   
   	clen = sizeof(sa_server);
   	if (getsockname(csd, &sa_server, &clen) < 0) {
  @@ -2948,70 +2967,70 @@
   
   	sock_disable_nagle(csd);
   
  -	(void)update_child_status(my_child_num, SERVER_BUSY_READ,
  -	                          (request_rec*)NULL);
  +	(void) update_child_status(my_child_num, SERVER_BUSY_READ,
  +				   (request_rec *) NULL);
   
   	conn_io = bcreate(ptrans, B_RDWR | B_SOCKET);
   
   #ifdef B_SFIO
  -	(void)sfdisc(conn_io->sf_in, SF_POPDISC);
  +	(void) sfdisc(conn_io->sf_in, SF_POPDISC);
   	sfdisc(conn_io->sf_in, bsfio_new(conn_io->pool, conn_io));
   	sfsetbuf(conn_io->sf_in, NULL, 0);
   
  -	(void)sfdisc(conn_io->sf_out, SF_POPDISC);
  +	(void) sfdisc(conn_io->sf_out, SF_POPDISC);
   	sfdisc(conn_io->sf_out, bsfio_new(conn_io->pool, conn_io));
   	sfsetbuf(conn_io->sf_out, NULL, 0);
   #endif
  -	
  +
   	dupped_csd = csd;
   #if defined(NEED_DUPPED_CSD)
   	if ((dupped_csd = dup(csd)) < 0) {
   	    aplog_error(APLOG_MARK, APLOG_ERR, server_conf,
   			"dup: couldn't duplicate csd");
  -	    dupped_csd = csd;   /* Oh well... */
  +	    dupped_csd = csd;	/* Oh well... */
   	}
  -	note_cleanups_for_fd(ptrans,dupped_csd);
  +	note_cleanups_for_fd(ptrans, dupped_csd);
   #endif
   	bpushfd(conn_io, csd, dupped_csd);
   
  -	current_conn = new_connection (ptrans, server_conf, conn_io,
  -				       (struct sockaddr_in *)&sa_client,
  -				       (struct sockaddr_in *)&sa_server,
  -				       my_child_num);
  -
  -        /*
  -         * Read and process each request found on our connection
  -         * until no requests are left or we decide to close.
  -         */
  +	current_conn = new_connection(ptrans, server_conf, conn_io,
  +				      (struct sockaddr_in *) &sa_client,
  +				      (struct sockaddr_in *) &sa_server,
  +				      my_child_num);
  +
  +	/*
  +	 * Read and process each request found on our connection
  +	 * until no requests are left or we decide to close.
  +	 */
   
  -        while ((r = read_request(current_conn)) != NULL) {
  +	while ((r = read_request(current_conn)) != NULL) {
   
   	    /* read_request_line has already done a
   	     * signal (SIGUSR1, SIG_IGN);
   	     */
   
  -            (void)update_child_status(my_child_num, SERVER_BUSY_WRITE, r);
  +	    (void) update_child_status(my_child_num, SERVER_BUSY_WRITE, r);
   
  -            process_request(r);
  +	    process_request(r);
   
   #if defined(STATUS)
  -            increment_counts(my_child_num, r);
  +	    increment_counts(my_child_num, r);
   #endif
   
  -            if (!current_conn->keepalive || current_conn->aborted) 
  -                break;
  +	    if (!current_conn->keepalive || current_conn->aborted)
  +		break;
   
  -            destroy_pool(r->pool);
  -            (void)update_child_status(my_child_num, SERVER_BUSY_KEEPALIVE,
  -                                      (request_rec*)NULL);
  +	    destroy_pool(r->pool);
  +	    (void) update_child_status(my_child_num, SERVER_BUSY_KEEPALIVE,
  +				       (request_rec *) NULL);
   
  -            sync_scoreboard_image();
  -            if (scoreboard_image->global.exit_generation >= generation) {
  -                bclose(conn_io);
  +	    sync_scoreboard_image();
  +	    if (scoreboard_image->global.exit_generation >= generation) {
  +		bclose(conn_io);
   		child_exit_modules(pconf, server_conf);
   		destroy_pool(pconf);
   		exit(0);
  -            }
  +	    }
   
   	    /* In case we get a graceful restart while we're blocked
   	     * waiting for the request.
  @@ -3027,31 +3046,31 @@
   	     * of network latencies and server timeouts.
   	     */
   	    usr1_just_die = 1;
  -	    signal (SIGUSR1, usr1_handler);
  -        }
  +	    signal(SIGUSR1, usr1_handler);
  +	}
   
  -        /*
  -         * Close the connection, being careful to send out whatever is still
  -         * in our buffers.  If possible, try to avoid a hard close until the
  -         * client has ACKed our FIN and/or has stopped sending us data.
  -         */
  +	/*
  +	 * Close the connection, being careful to send out whatever is still
  +	 * in our buffers.  If possible, try to avoid a hard close until the
  +	 * client has ACKed our FIN and/or has stopped sending us data.
  +	 */
   
   #ifdef NO_LINGCLOSE
  -        bclose(conn_io);        /* just close it */
  +	bclose(conn_io);	/* just close it */
   #else
  -        if (r &&  r->connection
  -              && !r->connection->aborted
  -              &&  r->connection->client
  -              && (r->connection->client->fd >= 0)) {
  -
  -            lingering_close(r);
  -        }
  -        else {
  -            bsetflag(conn_io, B_EOUT, 1);
  -            bclose(conn_io);
  -        }
  +	if (r && r->connection
  +	    && !r->connection->aborted
  +	    && r->connection->client
  +	    && (r->connection->client->fd >= 0)) {
  +
  +	    lingering_close(r);
  +	}
  +	else {
  +	    bsetflag(conn_io, B_EOUT, 1);
  +	    bclose(conn_io);
  +	}
   #endif
  -    }    
  +    }
   }
   
   static int make_child(server_rec *s, int slot, time_t now)
  @@ -3063,16 +3082,16 @@
       }
   
       if (one_process) {
  -	signal (SIGHUP, just_die);
  -	signal (SIGTERM, just_die);
  -	child_main (slot);
  +	signal(SIGHUP, just_die);
  +	signal(SIGTERM, just_die);
  +	child_main(slot);
       }
   
       /* avoid starvation */
       head_listener = head_listener->next;
   
  -    Explain1 ("Starting new child in slot %d", slot);
  -    (void)update_child_status (slot, SERVER_STARTING, (request_rec *)NULL);
  +    Explain1("Starting new child in slot %d", slot);
  +    (void) update_child_status(slot, SERVER_STARTING, (request_rec *) NULL);
   
       if ((pid = fork()) == -1) {
   	aplog_error(APLOG_MARK, APLOG_ERR, s, "fork: Unable to fork new process");
  @@ -3080,25 +3099,25 @@
   	/* fork didn't succeed. Fix the scoreboard or else
   	 * it will say SERVER_STARTING forever and ever
   	 */
  -	(void)update_child_status (slot, SERVER_DEAD, (request_rec*)NULL);
  +	(void) update_child_status(slot, SERVER_DEAD, (request_rec *) NULL);
   
   	/* In case system resources are maxxed out, we don't want
  -           Apache running away with the CPU trying to fork over and
  -           over and over again. */
  +	   Apache running away with the CPU trying to fork over and
  +	   over and over again. */
   	sleep(10);
   
   	return -1;
  -    } 
  -    
  +    }
  +
       if (!pid) {
   	/* Disable the restart signal handlers and enable the just_die stuff.
   	 * Note that since restart() just notes that a restart has been
   	 * requested there's no race condition here.
   	 */
  -	signal (SIGHUP, just_die);
  -	signal (SIGUSR1, just_die);
  -	signal (SIGTERM, just_die);
  -	child_main (slot);
  +	signal(SIGHUP, just_die);
  +	signal(SIGUSR1, just_die);
  +	signal(SIGTERM, just_die);
  +	child_main(slot);
       }
   
   #ifdef OPTIMIZE_TIMEOUTS
  @@ -3108,7 +3127,7 @@
   #ifdef SCOREBOARD_FILE
       lseek(scoreboard_fd, XtOffsetOf(scoreboard, parent[slot]), 0);
       force_write(scoreboard_fd, &scoreboard_image->parent[slot],
  -	sizeof(parent_score));
  +		sizeof(parent_score));
   #endif
   
       return 0;
  @@ -3116,16 +3135,16 @@
   
   
   /* start up a bunch of children */
  -static void startup_children (int number_to_start)
  +static void startup_children(int number_to_start)
   {
       int i;
       time_t now = time(0);
   
  -    for (i = 0; number_to_start && i < daemons_limit; ++i ) {
  +    for (i = 0; number_to_start && i < daemons_limit; ++i) {
   	if (scoreboard_image->servers[i].status != SERVER_DEAD) {
   	    continue;
   	}
  -	if (make_child (server_conf, i, now) < 0) {
  +	if (make_child(server_conf, i, now) < 0) {
   	    break;
   	}
   	--number_to_start;
  @@ -3145,7 +3164,7 @@
   #endif
   static int hold_off_on_exponential_spawning;
   
  -static void perform_idle_server_maintenance (void)
  +static void perform_idle_server_maintenance(void)
   {
       int i;
       int to_kill;
  @@ -3163,9 +3182,10 @@
       idle_count = 0;
       last_non_dead = -1;
   
  -    sync_scoreboard_image ();
  +    sync_scoreboard_image();
       for (i = 0; i < daemons_limit; ++i) {
  -	if (i >= max_daemons_limit && free_length == idle_spawn_rate) break;
  +	if (i >= max_daemons_limit && free_length == idle_spawn_rate)
  +	    break;
   	ss = &scoreboard_image->servers[i];
   	switch (ss->status) {
   	    /* We consider a starting server as idle because we started it
  @@ -3175,7 +3195,7 @@
   	     */
   	case SERVER_STARTING:
   	case SERVER_READY:
  -	    ++idle_count;
  +		++ idle_count;
   	    /* always kill the highest numbered child if we have to...
   	     * no really well thought out reason ... other than observing
   	     * the server behaviour under linux where lower numbered children
  @@ -3186,7 +3206,7 @@
   	    break;
   	case SERVER_DEAD:
   	    /* try to keep children numbers as low as possible */
  -	    if (free_length < idle_spawn_rate) {
  +		if (free_length < idle_spawn_rate) {
   		free_slots[free_length] = i;
   		++free_length;
   	    }
  @@ -3204,10 +3224,11 @@
   		     * last_vtime */
   		    ps->last_rtime = now;
   		    ps->last_vtime = ss->cur_vtime;
  -		} else if (ps->last_rtime + ss->timeout_len < now) {
  +		}
  +		else if (ps->last_rtime + ss->timeout_len < now) {
   		    /* no progress, and the timeout length has been exceeded */
   		    ss->timeout_len = 0;
  -		    kill (ps->pid, SIGALRM);
  +		    kill(ps->pid, SIGALRM);
   		}
   	    }
   #endif
  @@ -3219,9 +3240,10 @@
   	 * shut down gracefully, in case it happened to pick up a request
   	 * while we were counting
   	 */
  -	kill (scoreboard_image->parent[to_kill].pid, SIGUSR1);
  +	kill(scoreboard_image->parent[to_kill].pid, SIGUSR1);
   	idle_spawn_rate = 1;
  -    } else if (idle_count < daemons_min_free) {
  +    }
  +    else if (idle_count < daemons_min_free) {
   	/* terminate the free list */
   	if (free_length == 0) {
   	    /* only report this condition once */
  @@ -3234,26 +3256,29 @@
   		reported = 1;
   	    }
   	    idle_spawn_rate = 1;
  -	} else {
  +	}
  +	else {
   	    if (idle_spawn_rate >= 4) {
   		aplog_error(APLOG_MARK, APLOG_ERR, server_conf,
  -			    "server seems busy, spawning %d children (you may need "
  -			    "to increase StartServers, or Min/MaxSpareServers)",
  +		    "server seems busy, spawning %d children (you may need "
  +			"to increase StartServers, or Min/MaxSpareServers)",
   			    idle_spawn_rate);
   	    }
   	    for (i = 0; i < free_length; ++i) {
  -		make_child (server_conf, free_slots[i], now);
  +		make_child(server_conf, free_slots[i], now);
   	    }
   	    /* the next time around we want to spawn twice as many if this
   	     * wasn't good enough, but not if we've just done a graceful
   	     */
   	    if (hold_off_on_exponential_spawning) {
   		--hold_off_on_exponential_spawning;
  -	    } else if (idle_spawn_rate < MAX_SPAWN_RATE) {
  +	    }
  +	    else if (idle_spawn_rate < MAX_SPAWN_RATE) {
   		idle_spawn_rate *= 2;
   	    }
   	}
  -    } else {
  +    }
  +    else {
   	idle_spawn_rate = 1;
       }
   }
  @@ -3276,7 +3301,8 @@
       is_graceful = 0;
       ++generation;
   
  -    if (!one_process) detach (); 
  +    if (!one_process)
  +	detach();
   
       my_pid = getpid();
   
  @@ -3287,18 +3313,18 @@
   	}
   #ifdef SCOREBOARD_FILE
   	else {
  -	    kill_cleanups_for_fd (pconf, scoreboard_fd);
  +	    kill_cleanups_for_fd(pconf, scoreboard_fd);
   	}
   #endif
  -	clear_pool (pconf);
  -	ptrans = make_sub_pool (pconf);
  +	clear_pool(pconf);
  +	ptrans = make_sub_pool(pconf);
   
  -	server_conf = read_config (pconf, ptrans, server_confname); 
  -	setup_listeners (pconf);
  -	open_logs (server_conf, pconf);
  -	init_modules (pconf, server_conf);
  -	set_group_privs ();
  -	SAFE_ACCEPT(accept_mutex_init (pconf));
  +	server_conf = read_config(pconf, ptrans, server_confname);
  +	setup_listeners(pconf);
  +	open_logs(server_conf, pconf);
  +	init_modules(pconf, server_conf);
  +	set_group_privs();
  +	SAFE_ACCEPT(accept_mutex_init(pconf));
   	if (!is_graceful) {
   	    reinit_scoreboard(pconf);
   	}
  @@ -3308,12 +3334,12 @@
   	    note_cleanups_for_fd(pconf, scoreboard_fd);
   	}
   #endif
  -	default_server_hostnames (server_conf);
  +	default_server_hostnames(server_conf);
   
   	set_signals();
   	log_pid(pconf, pid_fname);
   
  -	if (daemons_max_free < daemons_min_free + 1) /* Don't thrash... */
  +	if (daemons_max_free < daemons_min_free + 1)	/* Don't thrash... */
   	    daemons_max_free = daemons_min_free + 1;
   
   	/* If we're doing a graceful_restart then we're going to see a lot
  @@ -3325,13 +3351,14 @@
   	 * supposed to start up without the 1 second penalty between each fork.
   	 */
   	remaining_children_to_start = daemons_to_start;
  -	if( remaining_children_to_start > daemons_limit ) {
  +	if (remaining_children_to_start > daemons_limit) {
   	    remaining_children_to_start = daemons_limit;
   	}
   	if (!is_graceful) {
  -	    startup_children (remaining_children_to_start);
  +	    startup_children(remaining_children_to_start);
   	    remaining_children_to_start = 0;
  -	} else {
  +	}
  +	else {
   	    /* give the system some time to recover before kicking into
   	     * exponential mode */
   	    hold_off_on_exponential_spawning = 10;
  @@ -3348,7 +3375,7 @@
   	while (!restart_pending && !shutdown_pending) {
   	    int child_slot;
   	    int status;
  -	    int pid = wait_or_timeout (&status);
  +	    int pid = wait_or_timeout(&status);
   
   	    /* XXX: if it takes longer than 1 second for all our children
   	     * to start up and get into IDLE state then we may spawn an
  @@ -3356,31 +3383,33 @@
   	     */
   	    if (pid >= 0) {
   		/* Child died... note that it's gone in the scoreboard. */
  -		sync_scoreboard_image ();
  -		child_slot = find_child_by_pid (pid);
  -		Explain2 ("Reaping child %d slot %d", pid, child_slot);
  +		sync_scoreboard_image();
  +		child_slot = find_child_by_pid(pid);
  +		Explain2("Reaping child %d slot %d", pid, child_slot);
   		if (child_slot >= 0) {
  -		    (void)update_child_status (child_slot, SERVER_DEAD,
  -			(request_rec *)NULL);
  +		    (void) update_child_status(child_slot, SERVER_DEAD,
  +					       (request_rec *) NULL);
   		    if (remaining_children_to_start
   			&& child_slot < daemons_limit) {
   			/* we're still doing a 1-for-1 replacement of dead
   			 * children with new children
   			 */
  -			make_child (server_conf, child_slot, time(0));
  +			make_child(server_conf, child_slot, time(0));
   			--remaining_children_to_start;
   		    }
   #ifndef NO_OTHER_CHILD
  -		} else if (reap_other_child (pid, status) == 0) {
  +		}
  +		else if (reap_other_child(pid, status) == 0) {
   		    /* handled */
   #endif
  -		} else if (is_graceful) {
  +		}
  +		else if (is_graceful) {
   		    /* Great, we've probably just lost a slot in the
   		     * scoreboard.  Somehow we don't know about this
   		     * child.
   		     */
   		    aplog_error(APLOG_MARK, APLOG_WARNING, server_conf,
  -				"long lost child came home! (pid %d)", pid );
  +				"long lost child came home! (pid %d)", pid);
   		}
   		/* Don't perform idle maintenance when a child dies,
   		 * only do it when there's a timeout.  Remember only a
  @@ -3388,12 +3417,13 @@
   		 * pathological for a lot to die suddenly.
   		 */
   		continue;
  -	    } else if (remaining_children_to_start) {
  +	    }
  +	    else if (remaining_children_to_start) {
   		/* we hit a 1 second timeout in which none of the previous
  -	 	 * generation of children needed to be reaped... so assume
  +		 * generation of children needed to be reaped... so assume
   		 * they're all done, and pick up the slack if any is left.
   		 */
  -		startup_children (remaining_children_to_start);
  +		startup_children(remaining_children_to_start);
   		remaining_children_to_start = 0;
   		/* In any event we really shouldn't do the code below because
   		 * few of the servers we just started are in the IDLE state
  @@ -3412,7 +3442,7 @@
   	    if (ap_killpg(pgrp, SIGTERM) < 0) {
   		aplog_error(APLOG_MARK, APLOG_WARNING, server_conf, "killpg SIGTERM");
   	    }
  -	    reclaim_child_processes(2); /* Start with SIGTERM */
  +	    reclaim_child_processes(2);		/* Start with SIGTERM */
   	    aplog_error(APLOG_MARK, APLOG_NOTICE, server_conf,
   			"httpd: caught SIGTERM, shutting down");
   
  @@ -3420,7 +3450,7 @@
   	    destroy_pool(pconf);
   	    cleanup_scoreboard();
   	    accept_mutex_cleanup();
  -	    
  +
   	    exit(0);
   	}
   
  @@ -3430,7 +3460,7 @@
   
   	if (one_process) {
   	    /* not worth thinking about */
  -	    exit (0);
  +	    exit(0);
   	}
   
   	if (is_graceful) {
  @@ -3439,13 +3469,13 @@
   #endif
   
   	    /* USE WITH CAUTION:  Graceful restarts are not known to work
  -	    * in various configurations on the architectures we support. */
  +	     * in various configurations on the architectures we support. */
   	    scoreboard_image->global.exit_generation = generation;
  -	    update_scoreboard_global ();
  +	    update_scoreboard_global();
   
   	    aplog_error(APLOG_MARK, APLOG_NOTICE, server_conf,
   			"SIGUSR1 received.  Doing graceful restart");
  -	    
  +
   	    /* kill off the idle ones */
   	    if (ap_killpg(pgrp, SIGUSR1) < 0) {
   		aplog_error(APLOG_MARK, APLOG_WARNING, server_conf, "killpg SIGUSR1");
  @@ -3457,7 +3487,7 @@
   	     * corruption too easily.
   	     */
   	    sync_scoreboard_image();
  -	    for (i = 0; i < daemons_limit; ++i ) {
  +	    for (i = 0; i < daemons_limit; ++i) {
   		if (scoreboard_image->servers[i].status != SERVER_DEAD) {
   		    scoreboard_image->servers[i].status = SERVER_GRACEFUL;
   		}
  @@ -3469,7 +3499,7 @@
   	    if (ap_killpg(pgrp, SIGHUP) < 0) {
   		aplog_error(APLOG_MARK, APLOG_WARNING, server_conf, "killpg SIGHUP");
   	    }
  -	    reclaim_child_processes(1); /* Not when just starting up */
  +	    reclaim_child_processes(1);		/* Not when just starting up */
   	    aplog_error(APLOG_MARK, APLOG_NOTICE, server_conf,
   			"SIGHUP received.  Attempting to restart");
   	}
  @@ -3479,7 +3509,7 @@
   
       } while (restart_pending);
   
  -} /* standalone_main */
  +}				/* standalone_main */
   #else
   /* prototype */
   void STANDALONE_MAIN(int argc, char **argv);
  @@ -3488,22 +3518,21 @@
   extern char *optarg;
   extern int optind;
   
  -int
  -main(int argc, char *argv[])
  +int main(int argc, char *argv[])
   {
       int c;
   
   #ifdef AUX
  -    (void)set42sig();
  +    (void) set42sig();
   #endif
   
   #ifdef SecureWare
  -    if(set_auth_parameters(argc,argv) < 0)
  -    	perror("set_auth_parameters");
  -    if(getluid() < 0)
  -	if(setluid(getuid()) < 0)
  +    if (set_auth_parameters(argc, argv) < 0)
  +	perror("set_auth_parameters");
  +    if (getluid() < 0)
  +	if (setluid(getuid()) < 0)
   	    perror("setluid");
  -    if(setreuid(0, 0) < 0)
  +    if (setreuid(0, 0) < 0)
   	perror("setreuid");
   #endif
   
  @@ -3512,102 +3541,103 @@
       ptrans = make_sub_pool(pconf);
   
       server_argv0 = argv[0];
  -    strncpy (server_root, HTTPD_ROOT, sizeof(server_root)-1);
  -    server_root[sizeof(server_root)-1] = '\0';
  -    strncpy (server_confname, SERVER_CONFIG_FILE, sizeof(server_root)-1);
  -    server_confname[sizeof(server_confname)-1] = '\0';
  +    strncpy(server_root, HTTPD_ROOT, sizeof(server_root) - 1);
  +    server_root[sizeof(server_root) - 1] = '\0';
  +    strncpy(server_confname, SERVER_CONFIG_FILE, sizeof(server_root) - 1);
  +    server_confname[sizeof(server_confname) - 1] = '\0';
   
       setup_prelinked_modules();
   
  -    while((c = getopt(argc,argv,"Xd:f:vhl")) != -1) {
  -        switch(c) {
  -          case 'd':
  -            strncpy (server_root, optarg, sizeof(server_root)-1);
  -            server_root[sizeof(server_root)-1] = '\0';
  -            break;
  -          case 'f':
  -            strncpy (server_confname, optarg, sizeof(server_confname)-1);
  -            server_confname[sizeof(server_confname)-1] = '\0';
  -            break;
  -          case 'v':
  -            printf("Server version %s.\n",SERVER_VERSION);
  -            exit(0);
  -          case 'h':
  +    while ((c = getopt(argc, argv, "Xd:f:vhl")) != -1) {
  +	switch (c) {
  +	case 'd':
  +	    strncpy(server_root, optarg, sizeof(server_root) - 1);
  +	    server_root[sizeof(server_root) - 1] = '\0';
  +	    break;
  +	case 'f':
  +	    strncpy(server_confname, optarg, sizeof(server_confname) - 1);
  +	    server_confname[sizeof(server_confname) - 1] = '\0';
  +	    break;
  +	case 'v':
  +	    printf("Server version %s.\n", SERVER_VERSION);
  +	    exit(0);
  +	case 'h':
   	    show_directives();
   	    exit(0);
  -	  case 'l':
  +	case 'l':
   	    show_modules();
   	    exit(0);
  -	  case 'X':
  +	case 'X':
   	    ++one_process;	/* Weird debugging mode. */
   	    break;
  -          case '?':
  -            usage(argv[0]);
  -        }
  +	case '?':
  +	    usage(argv[0]);
  +	}
       }
   
   #ifdef __EMX__
  -    printf("%s \n",SERVER_VERSION);
  +    printf("%s \n", SERVER_VERSION);
       printf("OS/2 port by Garey Smiley <garey@slink.com> \n");
   #endif
   
       suexec_enabled = init_suexec();
  -    server_conf = read_config (pconf, ptrans, server_confname);
  -    init_modules (pconf, server_conf);
  -    
  -    if(standalone) {
  -        clear_pool (pconf);	/* standalone_main rereads... */
  -        STANDALONE_MAIN(argc, argv);
  +    server_conf = read_config(pconf, ptrans, server_confname);
  +    init_modules(pconf, server_conf);
  +
  +    if (standalone) {
  +	clear_pool(pconf);	/* standalone_main rereads... */
  +	STANDALONE_MAIN(argc, argv);
       }
       else {
  -        conn_rec *conn;
  +	conn_rec *conn;
   	request_rec *r;
   	struct sockaddr sa_server, sa_client;
   	BUFF *cio;
   	NET_SIZE_T l;
  -      
  +
   	open_logs(server_conf, pconf);
  -	init_modules (pconf, server_conf);
  +	init_modules(pconf, server_conf);
   	set_group_privs();
  -	default_server_hostnames (server_conf);
  +	default_server_hostnames(server_conf);
   
   #ifdef MPE
  -      /* Only try to switch if we're running as MANAGER.SYS */
  -      if (geteuid() == 1 && user_id > 1) {
  -          GETPRIVMODE();
  -          if (setuid(user_id) == -1) {
  -              GETUSERMODE();
  +	/* Only try to switch if we're running as MANAGER.SYS */
  +	if (geteuid() == 1 && user_id > 1) {
  +	    GETPRIVMODE();
  +	    if (setuid(user_id) == -1) {
  +		GETUSERMODE();
  +		aplog_error(APLOG_MARK, APLOG_ALERT, server_conf,
  +			    "setuid: unable to change uid");
  +		exit(1);
  +	    }
  +	    GETUSERMODE();
  +	}
   #else
  -      /* Only try to switch if we're running as root */
  -      if(!geteuid() && setuid(user_id) == -1) {
  -#endif
  -          aplog_error(APLOG_MARK, APLOG_ALERT, server_conf,
  -		      "setuid: unable to change uid");
  -          exit (1);
  -      }
  -#ifdef MPE
  -          GETUSERMODE();
  -      }
  +	/* Only try to switch if we're running as root */
  +	if (!geteuid() && setuid(user_id) == -1) {
  +	    aplog_error(APLOG_MARK, APLOG_ALERT, server_conf,
  +			"setuid: unable to change uid");
  +	    exit(1);
  +	}
   #endif
  -	if (ap_setjmp (jmpbuffer)) {
  -	    exit (0);
  +	if (ap_setjmp(jmpbuffer)) {
  +	    exit(0);
   	}
   
   	l = sizeof(sa_client);
  -	if ((getpeername(fileno(stdin), &sa_client, &l)) < 0)
  -	{
  +	if ((getpeername(fileno(stdin), &sa_client, &l)) < 0) {
   /* get peername will fail if the input isn't a socket */
   	    perror("getpeername");
   	    memset(&sa_client, '\0', sizeof(sa_client));
   	}
   
   	l = sizeof(sa_server);
  -	if(getsockname(fileno(stdin), &sa_server, &l) < 0) {
  +	if (getsockname(fileno(stdin), &sa_server, &l) < 0) {
   	    perror("getsockname");
   	    fprintf(stderr, "Error getting local address\n");
   	    exit(1);
   	}
  -	server_conf->port =ntohs(((struct sockaddr_in *)&sa_server)->sin_port);
  +	server_conf->port = ntohs(((struct sockaddr_in *) &sa_server)->sin_port);
   	cio = bcreate(ptrans, B_RDWR | B_SOCKET);
   #ifdef MPE
   /* HP MPE 5.5 inetd only passes the incoming socket as stdin (fd 0), whereas
  @@ -3616,26 +3646,28 @@
      functionality be documented, and then to enhance the functionality to be
      like HPUX. */
   
  -        cio->fd = fileno(stdin);
  +	cio->fd = fileno(stdin);
   #else
   	cio->fd = fileno(stdout);
   #endif
   	cio->fd_in = fileno(stdin);
  -	conn = new_connection (ptrans, server_conf, cio,
  -			       (struct sockaddr_in *)&sa_client,
  -			       (struct sockaddr_in *)&sa_server,-1);
  -	r = read_request (conn);
  -	if (r) process_request (r); /* else premature EOF (ignore) */
  +	conn = new_connection(ptrans, server_conf, cio,
  +			      (struct sockaddr_in *) &sa_client,
  +			      (struct sockaddr_in *) &sa_server, -1);
  +	r = read_request(conn);
  +	if (r)
  +	    process_request(r);	/* else premature EOF (ignore) */
   
  -        while (r && conn->keepalive && !conn->aborted) {
  +	while (r && conn->keepalive && !conn->aborted) {
   	    destroy_pool(r->pool);
  -            r = read_request (conn);
  -            if (r) process_request (r);
  -        }
  +	    r = read_request(conn);
  +	    if (r)
  +		process_request(r);
  +	}
   
   	bclose(cio);
       }
  -    exit (0);
  +    exit(0);
   }
   
   #ifdef __EMX__
  @@ -3643,31 +3675,31 @@
   /* The next two routines are used to access shared memory under OS/2.  */
   /* This requires EMX v09c to be installed.                           */
   
  -caddr_t create_shared_heap (const char *name, size_t size)
  +caddr_t create_shared_heap(const char *name, size_t size)
   {
       ULONG rc;
       void *mem;
       Heap_t h;
   
  -    rc = DosAllocSharedMem (&mem, name, size,
  -                          PAG_COMMIT | PAG_READ | PAG_WRITE);
  +    rc = DosAllocSharedMem(&mem, name, size,
  +			   PAG_COMMIT | PAG_READ | PAG_WRITE);
       if (rc != 0)
  -        return NULL;
  -    h = _ucreate (mem, size, !_BLOCK_CLEAN, _HEAP_REGULAR | _HEAP_SHARED,
  -                NULL, NULL);
  +	return NULL;
  +    h = _ucreate(mem, size, !_BLOCK_CLEAN, _HEAP_REGULAR | _HEAP_SHARED,
  +		 NULL, NULL);
       if (h == NULL)
  -        DosFreeMem (mem);
  -    return (caddr_t)h;
  +	DosFreeMem(mem);
  +    return (caddr_t) h;
   }
   
  -caddr_t get_shared_heap (const char *Name)
  +caddr_t get_shared_heap(const char *Name)
   {
   
  -    PVOID    BaseAddress;     /* Pointer to the base address of
  -                              the shared memory object */
  -    ULONG    AttributeFlags;  /* Flags describing characteristics
  -                              of the shared memory object */
  -    APIRET   rc;              /* Return code */
  +    PVOID BaseAddress;		/* Pointer to the base address of
  +				   the shared memory object */
  +    ULONG AttributeFlags;	/* Flags describing characteristics
  +				   of the shared memory object */
  +    APIRET rc;			/* Return code */
   
       /* Request read and write access to */
       /*   the shared memory object       */
  @@ -3675,9 +3707,9 @@
   
       rc = DosGetNamedSharedMem(&BaseAddress, Name, AttributeFlags);
   
  -    if(rc != 0) {
  -        printf("DosGetNamedSharedMem error: return code = %ld", rc);
  -        return 0;
  +    if (rc != 0) {
  +	printf("DosGetNamedSharedMem error: return code = %ld", rc);
  +	return 0;
       }
   
       return BaseAddress;
  @@ -3690,14 +3722,12 @@
   
   
   
  -typedef struct joblist_s
  -{
  +typedef struct joblist_s {
       struct joblist_s *next;
       int sock;
   } joblist;
   
  -typedef struct globals_s
  -{
  +typedef struct globals_s {
       int exit_now;
       semaphore *jobsemaphore;
       joblist *jobhead;
  @@ -3707,60 +3737,58 @@
   } globals;
   
   
  -globals allowed_globals = { 0, NULL, NULL, NULL, 0 };
  +globals allowed_globals =
  +{0, NULL, NULL, NULL, 0};
   
   
  -void
  -add_job(int sock)
  +void add_job(int sock)
   {
       joblist *new_job;
  -    
  +
       ap_assert(allowed_globals.jobmutex);
       /* TODO: If too many jobs in queue, sleep, check for problems */
       acquire_mutex(allowed_globals.jobmutex);
  -    new_job = (joblist *)malloc(sizeof(joblist));
  +    new_job = (joblist *) malloc(sizeof(joblist));
       new_job->next = NULL;
       new_job->sock = sock;
  -    if(allowed_globals.jobtail != NULL)
  -        allowed_globals.jobtail->next = new_job;
  +    if (allowed_globals.jobtail != NULL)
  +	allowed_globals.jobtail->next = new_job;
       allowed_globals.jobtail = new_job;
  -    if(!allowed_globals.jobhead)
  -        allowed_globals.jobhead = new_job;
  +    if (!allowed_globals.jobhead)
  +	allowed_globals.jobhead = new_job;
       allowed_globals.jobcount++;
       release_semaphore(allowed_globals.jobsemaphore);
       release_mutex(allowed_globals.jobmutex);
   }
   
  -int
  -remove_job()
  +int remove_job()
   {
       joblist *job;
       int sock;
  -    
  +
       ap_assert(allowed_globals.jobmutex);
       acquire_semaphore(allowed_globals.jobsemaphore);
       acquire_mutex(allowed_globals.jobmutex);
  -    if(allowed_globals.exit_now && !allowed_globals.jobhead)
  -    {
  -        release_mutex(allowed_globals.jobmutex);
  -        return(-1);
  +    if (allowed_globals.exit_now && !allowed_globals.jobhead) {
  +	release_mutex(allowed_globals.jobmutex);
  +	return (-1);
       }
       job = allowed_globals.jobhead;
       ap_assert(job);
       allowed_globals.jobhead = job->next;
  -    if(allowed_globals.jobhead == NULL)
  -        allowed_globals.jobtail = NULL;
  +    if (allowed_globals.jobhead == NULL)
  +	allowed_globals.jobtail = NULL;
       release_mutex(allowed_globals.jobmutex);
       sock = job->sock;
       free(job);
  -    return(sock);
  +    return (sock);
   }
   
   
   
   void child_sub_main(int child_num, int srv,
  -                    int csd, int dupped_csd,
  -                    int requests_this_child, pool *pchild)
  +		    int csd, int dupped_csd,
  +		    int requests_this_child, pool *pchild)
   {
   #if defined(UW)
       size_t clen;
  @@ -3774,7 +3802,7 @@
       dupped_csd = -1;
       requests_this_child = 0;
   
  -    (void)update_child_status(child_num, SERVER_READY, (request_rec*)NULL);
  +    (void) update_child_status(child_num, SERVER_READY, (request_rec *) NULL);
   
       /*
        * Setup the jump buffers so that we can return here after
  @@ -3783,63 +3811,62 @@
   #if defined(USE_LONGJMP)
       setjmp(jmpbuffer);
   #else
  -    sigsetjmp(jmpbuffer,1);
  +    sigsetjmp(jmpbuffer, 1);
   #endif
   #ifdef SIGURG
       signal(SIGURG, timeout);
   #endif
  -    
  +
   
       pchild = make_sub_pool(NULL);
   
       while (1) {
   	BUFF *conn_io;
   	request_rec *r;
  -      
  -        /*
  -         * (Re)initialize this child to a pre-connection state.
  -         */
   
  -        set_callback_and_alarm(NULL, 0); /* Cancel any outstanding alarms. */
  -        timeout_req = NULL;	/* No request in progress */
  +	/*
  +	 * (Re)initialize this child to a pre-connection state.
  +	 */
  +
  +	set_callback_and_alarm(NULL, 0);	/* Cancel any outstanding alarms. */
  +	timeout_req = NULL;	/* No request in progress */
   	current_conn = NULL;
   #ifdef SIGPIPE
  -        signal(SIGPIPE, timeout);  
  +	signal(SIGPIPE, timeout);
   #endif
  -        
  -	clear_pool (pchild);
   
  -	(void)update_child_status(child_num, SERVER_READY, (request_rec*)NULL);
  +	clear_pool(pchild);
   
  -        csd = remove_job();
  -        if(csd == -1)
  -            break; /* time to exit */
  -        requests_this_child++;
  +	(void) update_child_status(child_num, SERVER_READY, (request_rec *) NULL);
   
  -	note_cleanups_for_socket(pchild,csd);
  +	csd = remove_job();
  +	if (csd == -1)
  +	    break;		/* time to exit */
  +	requests_this_child++;
   
  -        /*
  -         * We now have a connection, so set it up with the appropriate
  -         * socket options, file descriptors, and read/write buffers.
  -         */
  +	note_cleanups_for_socket(pchild, csd);
  +
  +	/*
  +	 * We now have a connection, so set it up with the appropriate
  +	 * socket options, file descriptors, and read/write buffers.
  +	 */
   
   	clen = sizeof(sa_server);
   	if (getsockname(csd, &sa_server, &clen) < 0) {
   	    aplog_error(APLOG_MARK, APLOG_WARNING, server_conf, "getsockname");
   	    continue;
   	}
  -        clen = sizeof(sa_client);
  -	if ((getpeername(csd, &sa_client, &clen)) < 0)
  -	{
  -            /* get peername will fail if the input isn't a socket */
  +	clen = sizeof(sa_client);
  +	if ((getpeername(csd, &sa_client, &clen)) < 0) {
  +	    /* get peername will fail if the input isn't a socket */
   	    perror("getpeername");
   	    memset(&sa_client, '\0', sizeof(sa_client));
   	}
   
   	sock_disable_nagle(csd);
   
  -	(void)update_child_status(child_num, SERVER_BUSY_READ,
  -	                          (request_rec*)NULL);
  +	(void) update_child_status(child_num, SERVER_BUSY_READ,
  +				   (request_rec *) NULL);
   
   	conn_io = bcreate(pchild, B_RDWR | B_SOCKET);
   	dupped_csd = csd;
  @@ -3847,73 +3874,72 @@
   	if ((dupped_csd = dup(csd)) < 0) {
   	    aplog_error(APLOG_MARK, APLOG_ERR, server_conf,
   			"dup: couldn't duplicate csd");
  -	    dupped_csd = csd;   /* Oh well... */
  +	    dupped_csd = csd;	/* Oh well... */
   	}
  -	note_cleanups_for_socket(pchild,dupped_csd);
  +	note_cleanups_for_socket(pchild, dupped_csd);
   #endif
   	bpushfd(conn_io, csd, dupped_csd);
   
  -	current_conn = new_connection (pchild, server_conf, conn_io,
  -				       (struct sockaddr_in *)&sa_client,
  -				       (struct sockaddr_in *)&sa_server,
  -				       child_num);
  -
  -        /*
  -         * Read and process each request found on our connection
  -         * until no requests are left or we decide to close.
  -         */
  +	current_conn = new_connection(pchild, server_conf, conn_io,
  +				      (struct sockaddr_in *) &sa_client,
  +				      (struct sockaddr_in *) &sa_server,
  +				      child_num);
   
  -        while ((r = read_request(current_conn)) != NULL) {
  -            (void)update_child_status(child_num, SERVER_BUSY_WRITE, r);
  +	/*
  +	 * Read and process each request found on our connection
  +	 * until no requests are left or we decide to close.
  +	 */
  +
  +	while ((r = read_request(current_conn)) != NULL) {
  +	    (void) update_child_status(child_num, SERVER_BUSY_WRITE, r);
   
  -            process_request(r);
  +	    process_request(r);
   
   #if defined(STATUS)
  -            increment_counts(child_num, r);
  +	    increment_counts(child_num, r);
   #endif
   
  -            if (!current_conn->keepalive || current_conn->aborted)
  -                break;
  +	    if (!current_conn->keepalive || current_conn->aborted)
  +		break;
   
  -            destroy_pool(r->pool);
  -            (void)update_child_status(child_num, SERVER_BUSY_KEEPALIVE,
  -                                      (request_rec*)NULL);
  +	    destroy_pool(r->pool);
  +	    (void) update_child_status(child_num, SERVER_BUSY_KEEPALIVE,
  +				       (request_rec *) NULL);
   
  -            sync_scoreboard_image();
  -        }
  +	    sync_scoreboard_image();
  +	}
   
  -        /*
  -         * Close the connection, being careful to send out whatever is still
  -         * in our buffers.  If possible, try to avoid a hard close until the
  -         * client has ACKed our FIN and/or has stopped sending us data.
  -         */
  -        kill_cleanups_for_socket(pchild,csd);
  +	/*
  +	 * Close the connection, being careful to send out whatever is still
  +	 * in our buffers.  If possible, try to avoid a hard close until the
  +	 * client has ACKed our FIN and/or has stopped sending us data.
  +	 */
  +	kill_cleanups_for_socket(pchild, csd);
   
   #ifdef NO_LINGCLOSE
  -        bclose(conn_io);        /* just close it */
  +	bclose(conn_io);	/* just close it */
   #else
  -        if (r &&  r->connection
  -            && !r->connection->aborted
  -            &&  r->connection->client
  -            && (r->connection->client->fd >= 0)) {
  -
  -            lingering_close(r);
  -        }
  -        else {
  -            bsetflag(conn_io, B_EOUT, 1);
  -            bclose(conn_io);
  -        }
  +	if (r && r->connection
  +	    && !r->connection->aborted
  +	    && r->connection->client
  +	    && (r->connection->client->fd >= 0)) {
  +
  +	    lingering_close(r);
  +	}
  +	else {
  +	    bsetflag(conn_io, B_EOUT, 1);
  +	    bclose(conn_io);
  +	}
   #endif
       }
       destroy_pool(pchild);
  -    (void)update_child_status(child_num,SERVER_DEAD, NULL);
  +    (void) update_child_status(child_num, SERVER_DEAD, NULL);
   }
   
   
  -void
  -child_main(int child_num_arg)
  +void child_main(int child_num_arg)
   {
  -    
  +
       int srv = 0;
       int csd = 0;
       int dupped_csd = 0;
  @@ -3930,21 +3956,20 @@
        * damn variables static/global
        */
       child_sub_main(child_num_arg, srv,
  -                        csd, dupped_csd,
  -                        requests_this_child, ppool);
  +		   csd, dupped_csd,
  +		   requests_this_child, ppool);
   
   }
   
   
   
  -void
  -cleanup_thread(thread **handles, int *thread_cnt, int thread_to_clean)
  +void cleanup_thread(thread **handles, int *thread_cnt, int thread_to_clean)
   {
       int i;
  -    
  +
       free_thread(handles[thread_to_clean]);
  -    for(i=thread_to_clean; i<((*thread_cnt)-1); i++)
  -        handles[i] = handles[i+1];
  +    for (i = thread_to_clean; i < ((*thread_cnt) - 1); i++)
  +	handles[i] = handles[i + 1];
       (*thread_cnt)--;
   }
   
  @@ -3989,18 +4014,19 @@
       max_jobs_after_exit_request = excess_requests_per_child;
       max_jobs_per_exe = max_requests_per_child;
       if (nthreads <= 0)
  -        nthreads = 40;
  +	nthreads = 40;
       if (max_jobs_per_exe <= 0)
  -        max_jobs_per_exe = 0;
  +	max_jobs_per_exe = 0;
       if (max_jobs_after_exit_request <= 0)
  -        max_jobs_after_exit_request = max_jobs_per_exe/10;
  -    
  -    if (!one_process) detach(); 
  +	max_jobs_after_exit_request = max_jobs_per_exe / 10;
  +
  +    if (!one_process)
  +	detach();
   
       my_pid = getpid();
  -    
  +
       ++generation;
  -  
  +
       copy_listeners(pconf);
       restart_time = time(NULL);
   
  @@ -4032,129 +4058,129 @@
       allowed_globals.jobmutex = create_mutex(NULL);
   
       /* spawn off the threads */
  -    child_handles = (thread *)alloca(nthreads * sizeof(int));
  +    child_handles = (thread *) alloca(nthreads * sizeof(int));
       {
  -        int i;
  +	int i;
   
  -        for (i = 0; i < nthreads; i++) {
  -            child_handles[i] = create_thread((void (*)(void *))child_main, (void *)i);
  -        }
  +	for (i = 0; i < nthreads; i++) {
  +	    child_handles[i] = create_thread((void (*)(void *)) child_main, (void *) i);
  +	}
   	if (nthreads > max_daemons_limit) {
   	    max_daemons_limit = nthreads;
   	}
       }
   
       /* main loop */
  -    for(;;) {
  -        if(max_jobs_per_exe && (total_jobs > max_jobs_per_exe) && !start_exit) {
  -            start_exit = 1;
  -            wait_time = 1;
  -            count_down = max_jobs_after_exit_request;
  -            release_mutex(start_mutex);
  -            start_mutex_released = 1;
  -        }
  -        if (!start_exit) {
  -            rv = WaitForSingleObject(exit_event, 0);
  -            ap_assert((rv == WAIT_TIMEOUT) || (rv == WAIT_OBJECT_0));
  -            if (rv == WAIT_OBJECT_0)
  -                break;
  -            rv = WaitForMultipleObjects(nthreads, child_handles, 0, 0);
  +    for (;;) {
  +	if (max_jobs_per_exe && (total_jobs > max_jobs_per_exe) && !start_exit) {
  +	    start_exit = 1;
  +	    wait_time = 1;
  +	    count_down = max_jobs_after_exit_request;
  +	    release_mutex(start_mutex);
  +	    start_mutex_released = 1;
  +	}
  +	if (!start_exit) {
  +	    rv = WaitForSingleObject(exit_event, 0);
  +	    ap_assert((rv == WAIT_TIMEOUT) || (rv == WAIT_OBJECT_0));
  +	    if (rv == WAIT_OBJECT_0)
  +		break;
  +	    rv = WaitForMultipleObjects(nthreads, child_handles, 0, 0);
   	    ap_assert(rv != WAIT_FAILED);
  -            if(rv != WAIT_TIMEOUT) {
  -                rv = rv - WAIT_OBJECT_0;
  -                ap_assert((rv >= 0) && (rv < nthreads));
  -                cleanup_thread(child_handles, &nthreads, rv);
  -                break;
  -            }
  -        }
  -        if (start_exit && max_jobs_after_exit_request && (count_down-- < 0))
  -            break;
  -        tv.tv_sec = wait_time;
  -        tv.tv_usec = 0;
  +	    if (rv != WAIT_TIMEOUT) {
  +		rv = rv - WAIT_OBJECT_0;
  +		ap_assert((rv >= 0) && (rv < nthreads));
  +		cleanup_thread(child_handles, &nthreads, rv);
  +		break;
  +	    }
  +	}
  +	if (start_exit && max_jobs_after_exit_request && (count_down-- < 0))
  +	    break;
  +	tv.tv_sec = wait_time;
  +	tv.tv_usec = 0;
   
  -        memcpy(&main_fds, &listenfds, sizeof(fd_set));
  -        srv = ap_select(listenmaxfd+1, &main_fds, NULL, NULL, &tv);
  +	memcpy(&main_fds, &listenfds, sizeof(fd_set));
  +	srv = ap_select(listenmaxfd + 1, &main_fds, NULL, NULL, &tv);
   #ifdef WIN32
  -        if (srv == SOCKET_ERROR)
  -            errno = WSAGetLastError() - WSABASEERR;
  +	if (srv == SOCKET_ERROR)
  +	    errno = WSAGetLastError() - WSABASEERR;
   #endif /* WIN32 */
   
  -        if (srv < 0 && errno != EINTR)
  -            aplog_error(APLOG_MARK, APLOG_ERR, server_conf, "select: (listen)");
  -	
  -        if (srv < 0)
  -            continue;
  -        if (srv == 0) {
  -            if (start_exit)
  -                break;
  -            else
  -                continue;
  -        }
  +	if (srv < 0 && errno != EINTR)
  +	    aplog_error(APLOG_MARK, APLOG_ERR, server_conf, "select: (listen)");
   
  -        {
  +	if (srv < 0)
  +	    continue;
  +	if (srv == 0) {
  +	    if (start_exit)
  +		break;
  +	    else
  +		continue;
  +	}
  +
  +	{
   	    listen_rec *lr;
   
  -	    lr = find_ready_listener (&main_fds);
  +	    lr = find_ready_listener(&main_fds);
   	    if (lr != NULL) {
   		sd = lr->fd;
   	    }
   	}
   
  -        do {
  -            clen = sizeof(sa_client);
  -            csd  = accept(sd, (struct sockaddr *)&sa_client, &clen);
  +	do {
  +	    clen = sizeof(sa_client);
  +	    csd = accept(sd, (struct sockaddr *) &sa_client, &clen);
   #ifdef WIN32
  -            if(csd == INVALID_SOCKET) {
  -                csd = -1;
  -                errno = WSAGetLastError() - WSABASEERR;
  -            }
  +	    if (csd == INVALID_SOCKET) {
  +		csd = -1;
  +		errno = WSAGetLastError() - WSABASEERR;
  +	    }
   #endif /* WIN32 */
  -        } while (csd < 0 && errno == EINTR);
  +	} while (csd < 0 && errno == EINTR);
   
  -        if (csd < 0) {
  +	if (csd < 0) {
   
   #if defined(EPROTO) && defined(ECONNABORTED)
  -            if ((errno != EPROTO) && (errno != ECONNABORTED))
  +	    if ((errno != EPROTO) && (errno != ECONNABORTED))
   #elif defined(EPROTO)
  -                if (errno != EPROTO)
  +		if (errno != EPROTO)
   #elif defined(ECONNABORTED)
  -                    if (errno != ECONNABORTED)
  +		    if (errno != ECONNABORTED)
   #endif
  -                        aplog_error(APLOG_MARK, APLOG_ERR, server_conf,
  +			aplog_error(APLOG_MARK, APLOG_ERR, server_conf,
   				    "accept: (client socket)");
  -        }
  -        else {
  -            add_job(csd);
  -            total_jobs++;
  -        }
  +	}
  +	else {
  +	    add_job(csd);
  +	    total_jobs++;
  +	}
       }
   
       /* Get ready to shutdown and exit */
       allowed_globals.exit_now = 1;
       if (!start_mutex_released) {
  -        release_mutex(start_mutex);
  +	release_mutex(start_mutex);
       }
   
       for (i = 0; i < nthreads; i++) {
  -        add_job(-1);
  +	add_job(-1);
       }
   
       /* Wait for all your children */
       end_time = time(NULL) + 180;
       while (nthreads) {
  -        rv = WaitForMultipleObjects(nthreads, child_handles, 0, (end_time-time(NULL))*1000);
  -        if (rv != WAIT_TIMEOUT) {
  -            rv = rv - WAIT_OBJECT_0;
  -            ap_assert((rv >= 0) && (rv < nthreads));
  -            cleanup_thread(child_handles, &nthreads, rv);
  -            continue;
  -        }
  -        break;
  +	rv = WaitForMultipleObjects(nthreads, child_handles, 0, (end_time - time(NULL)) * 1000);
  +	if (rv != WAIT_TIMEOUT) {
  +	    rv = rv - WAIT_OBJECT_0;
  +	    ap_assert((rv >= 0) && (rv < nthreads));
  +	    cleanup_thread(child_handles, &nthreads, rv);
  +	    continue;
  +	}
  +	break;
       }
   
       for (i = 0; i < nthreads; i++) {
  -        kill_thread(child_handles[i]);
  -        free_thread(child_handles[i]);
  +	kill_thread(child_handles[i]);
  +	free_thread(child_handles[i]);
       }
       destroy_semaphore(allowed_globals.jobsemaphore);
       destroy_mutex(allowed_globals.jobmutex);
  @@ -4165,16 +4191,15 @@
       exit(0);
   
   
  -} /* standalone_main */
  +}				/* standalone_main */
   
   
  -int
  -create_event_and_spawn(int argc, char **argv, event **ev, int *child_num, char* prefix)
  +int create_event_and_spawn(int argc, char **argv, event **ev, int *child_num, char *prefix)
   {
       int pid = getpid();
       char buf[40], mod[200];
       int i, rv;
  -    char **pass_argv = (char **)alloca(sizeof(char *)*(argc+3));
  +    char **pass_argv = (char **) alloca(sizeof(char *) * (argc + 3));
   
       sprintf(buf, "%s_%d", prefix, ++(*child_num));
       _flushall();
  @@ -4183,17 +4208,16 @@
       pass_argv[0] = argv[0];
       pass_argv[1] = "-c";
       pass_argv[2] = buf;
  -    for(i=1; i<argc; i++)
  -    {
  -        pass_argv[i+2] = argv[i];
  +    for (i = 1; i < argc; i++) {
  +	pass_argv[i + 2] = argv[i];
       }
  -    pass_argv[argc+2] = NULL;
  +    pass_argv[argc + 2] = NULL;
   
   
       GetModuleFileName(NULL, mod, 200);
       rv = spawnv(_P_NOWAIT, mod, pass_argv);
   
  -    return(rv);
  +    return (rv);
   }
   
   
  @@ -4201,8 +4225,7 @@
   static int service_stop = 0;
   
   
  -int
  -master_main(int argc, char **argv)
  +int master_main(int argc, char **argv)
   {
       /*
        * 1. Create exit events for children
  @@ -4223,69 +4246,64 @@
   
       sprintf(buf, "Apache%d", getpid());
       start_mutex = create_mutex(buf);
  -    ev = (event **)alloca(sizeof(event *)*nchild);
  -    child = (int *)alloca(sizeof(int)*nchild);
  -    for(i=0; i<nchild; i++)
  -    {
  -        service_set_status(SERVICE_START_PENDING);
  -        child[i] = create_event_and_spawn(argc, argv, &ev[i], &child_num, buf);
  -        ap_assert(child[i] >= 0);
  +    ev = (event **) alloca(sizeof(event *) * nchild);
  +    child = (int *) alloca(sizeof(int) * nchild);
  +    for (i = 0; i < nchild; i++) {
  +	service_set_status(SERVICE_START_PENDING);
  +	child[i] = create_event_and_spawn(argc, argv, &ev[i], &child_num, buf);
  +	ap_assert(child[i] >= 0);
       }
       service_set_status(SERVICE_RUNNING);
   
  -    for(;!service_stop;)
  -    {
  -        rv = WaitForMultipleObjects(nchild, (HANDLE *)child, FALSE, 2000);
  -        ap_assert(rv != WAIT_FAILED);
  -        if(rv == WAIT_TIMEOUT)
  -            continue;
  -        cld = rv - WAIT_OBJECT_0;
  -        ap_assert(rv < nchild);
  -        CloseHandle((HANDLE)child[rv]);
  -        CloseHandle(ev[rv]);
  -        child[rv] = create_event_and_spawn(argc, argv, &ev[rv], &child_num, buf);
  -        ap_assert(child[rv]);
  +    for (; !service_stop;) {
  +	rv = WaitForMultipleObjects(nchild, (HANDLE *) child, FALSE, 2000);
  +	ap_assert(rv != WAIT_FAILED);
  +	if (rv == WAIT_TIMEOUT)
  +	    continue;
  +	cld = rv - WAIT_OBJECT_0;
  +	ap_assert(rv < nchild);
  +	CloseHandle((HANDLE) child[rv]);
  +	CloseHandle(ev[rv]);
  +	child[rv] = create_event_and_spawn(argc, argv, &ev[rv], &child_num, buf);
  +	ap_assert(child[rv]);
       }
   
       /*
        * Tell all your kids to stop. Wait for them for some time
        * Kill those that haven't yet stopped
        */
  -    for(i=0; i<nchild; i++)
  -    {
  -        SetEvent(ev[i]);
  +    for (i = 0; i < nchild; i++) {
  +	SetEvent(ev[i]);
       }
   
  -    for(tmstart=time(NULL); nchild && (tmstart < (time(NULL) + 60));)
  -    {
  -        service_set_status(SERVICE_STOP_PENDING);
  -        rv = WaitForMultipleObjects(nchild, (HANDLE *)child, FALSE, 2000);
  -        ap_assert(rv != WAIT_FAILED);
  -        if(rv == WAIT_TIMEOUT)
  -            continue;
  -        cld = rv - WAIT_OBJECT_0;
  -        ap_assert(rv < nchild);
  -        CloseHandle((HANDLE)child[rv]);
  -        CloseHandle(ev[rv]);
  -        for(i=rv; i<(nchild-1); i++)
  -        {
  -            child[i] = child[i+1];
  -            ev[i] = ev[i+1];
  -        }
  -        nchild--;
  +    for (tmstart = time(NULL); nchild && (tmstart < (time(NULL) + 60));) {
  +	service_set_status(SERVICE_STOP_PENDING);
  +	rv = WaitForMultipleObjects(nchild, (HANDLE *) child, FALSE, 2000);
  +	ap_assert(rv != WAIT_FAILED);
  +	if (rv == WAIT_TIMEOUT)
  +	    continue;
  +	cld = rv - WAIT_OBJECT_0;
  +	ap_assert(rv < nchild);
  +	CloseHandle((HANDLE) child[rv]);
  +	CloseHandle(ev[rv]);
  +	for (i = rv; i < (nchild - 1); i++) {
  +	    child[i] = child[i + 1];
  +	    ev[i] = ev[i + 1];
  +	}
  +	nchild--;
       }
  -    for(i=0; i<nchild; i++)
  -    {
  -        TerminateProcess((HANDLE)child[i], 1);
  +    for (i = 0; i < nchild; i++) {
  +	TerminateProcess((HANDLE) child[i], 1);
       }
  -    service_set_status(SERVICE_STOPPED);          
  +    service_set_status(SERVICE_STOPPED);
   
   
       destroy_mutex(start_mutex);
  -    return(0);
  +    return (0);
   }
   
  -__declspec(dllexport) int main(int argc, char *argv[])
  +__declspec(dllexport)
  +     int main(int argc, char *argv[])
   {
       int c;
       int child = 0;
  @@ -4294,16 +4312,16 @@
       int install = 0;
   
   #ifdef AUX
  -    (void)set42sig();
  +    (void) set42sig();
   #endif
   
   #ifdef SecureWare
  -    if(set_auth_parameters(argc,argv) < 0)
  -    	perror("set_auth_parameters");
  -    if(getluid() < 0)
  -	if(setluid(getuid()) < 0)
  +    if (set_auth_parameters(argc, argv) < 0)
  +	perror("set_auth_parameters");
  +    if (getluid() < 0)
  +	if (setluid(getuid()) < 0)
   	    perror("setluid");
  -    if(setreuid(0, 0) < 0)
  +    if (setreuid(0, 0) < 0)
   	perror("setreuid");
   #endif
   
  @@ -4317,107 +4335,102 @@
       ptrans = make_sub_pool(pconf);
   
       server_argv0 = argv[0];
  -    strncpy (server_root, HTTPD_ROOT, sizeof(server_root)-1);
  -    server_root[sizeof(server_root)-1] = '\0';
  -    strncpy (server_confname, SERVER_CONFIG_FILE, sizeof(server_root)-1);
  -    server_confname[sizeof(server_confname)-1] = '\0';
  +    strncpy(server_root, HTTPD_ROOT, sizeof(server_root) - 1);
  +    server_root[sizeof(server_root) - 1] = '\0';
  +    strncpy(server_confname, SERVER_CONFIG_FILE, sizeof(server_root) - 1);
  +    server_confname[sizeof(server_confname) - 1] = '\0';
   
       setup_prelinked_modules();
   
  -    while((c = getopt(argc,argv,"Xd:f:vhlc:ius")) != -1) {
  -        switch(c) {
  +    while ((c = getopt(argc, argv, "Xd:f:vhlc:ius")) != -1) {
  +	switch (c) {
   #ifdef WIN32
  -        case 'c':
  -            exit_event = open_event(optarg);
  -            cp = strchr(optarg, '_');
  -            ap_assert(cp);
  -            *cp = 0;
  -            start_mutex = open_mutex(optarg);
  -            child = 1;
  -            break;
  -        case 'i':
  -            install = 1;
  -            break;
  -        case 'u':
  -            install = -1;
  -            break;
  -        case 's':
  -            run_as_service = 0;
  -            break;
  +	case 'c':
  +	    exit_event = open_event(optarg);
  +	    cp = strchr(optarg, '_');
  +	    ap_assert(cp);
  +	    *cp = 0;
  +	    start_mutex = open_mutex(optarg);
  +	    child = 1;
  +	    break;
  +	case 'i':
  +	    install = 1;
  +	    break;
  +	case 'u':
  +	    install = -1;
  +	    break;
  +	case 's':
  +	    run_as_service = 0;
  +	    break;
   #endif /* WIN32 */
  -          case 'd':
  -            strncpy (server_root, optarg, sizeof(server_root)-1);
  -            server_root[sizeof(server_root)-1] = '\0';
  -            break;
  -          case 'f':
  -            strncpy (server_confname, optarg, sizeof(server_confname)-1);
  -            server_confname[sizeof(server_confname)-1] = '\0';
  -            break;
  -          case 'v':
  -            printf("Server version %s.\n",SERVER_VERSION);
  -            exit(0);
  -          case 'h':
  +	case 'd':
  +	    strncpy(server_root, optarg, sizeof(server_root) - 1);
  +	    server_root[sizeof(server_root) - 1] = '\0';
  +	    break;
  +	case 'f':
  +	    strncpy(server_confname, optarg, sizeof(server_confname) - 1);
  +	    server_confname[sizeof(server_confname) - 1] = '\0';
  +	    break;
  +	case 'v':
  +	    printf("Server version %s.\n", SERVER_VERSION);
  +	    exit(0);
  +	case 'h':
   	    show_directives();
   	    exit(0);
  -	  case 'l':
  +	case 'l':
   	    show_modules();
   	    exit(0);
  -	  case 'X':
  +	case 'X':
   	    ++one_process;	/* Weird debugging mode. */
   	    break;
  -          case '?':
  -            usage(argv[0]);
  -        }
  +	case '?':
  +	    usage(argv[0]);
  +	}
       }
   
   #ifdef __EMX__
  -    printf("%s \n",SERVER_VERSION);
  +    printf("%s \n", SERVER_VERSION);
       printf("OS/2 port by Garey Smiley <garey@slink.com> \n");
   #endif
   #ifdef WIN32
  -    if(!child)
  -    {
  -        printf("%s \n",SERVER_VERSION);
  -        printf("WIN32 port by Ambarish Malpani <ambarish@valicert.com> and the Apache Group.\n");
  +    if (!child) {
  +	printf("%s \n", SERVER_VERSION);
  +	printf("WIN32 port by Ambarish Malpani <ambarish@valicert.com> and the Apache Group.\n");
       }
   #endif
  -    if(!child && run_as_service)
  -    {
  -        service_cd();
  +    if (!child && run_as_service) {
  +	service_cd();
       }
   
  -    server_conf = read_config (pconf, ptrans, server_confname);
  -    init_modules (pconf, server_conf);
  +    server_conf = read_config(pconf, ptrans, server_confname);
  +    init_modules(pconf, server_conf);
       suexec_enabled = init_suexec();
       open_logs(server_conf, pconf);
       set_group_privs();
   
  -    if(one_process && !exit_event)
  -        exit_event = create_event(0, 0, NULL);
  -    if(one_process && !start_mutex)
  -        start_mutex = create_mutex(NULL);
  +    if (one_process && !exit_event)
  +	exit_event = create_event(0, 0, NULL);
  +    if (one_process && !start_mutex)
  +	start_mutex = create_mutex(NULL);
       /*
        * In the future, the main will spawn off a couple
        * of children and monitor them. As soon as a child
        * exits, it spawns off a new one
        */
  -    if(child || one_process)
  -    {
  -        if(!exit_event || !start_mutex)
  -            exit(-1);
  -        worker_main();
  -        destroy_mutex(start_mutex);
  -        destroy_event(exit_event);
  +    if (child || one_process) {
  +	if (!exit_event || !start_mutex)
  +	    exit(-1);
  +	worker_main();
  +	destroy_mutex(start_mutex);
  +	destroy_event(exit_event);
  +    }
  +    else {
  +	service_main(master_main, argc, argv,
  +	  &service_pause, &service_stop, "Apache", install, run_as_service);
       }
  -    else
  -    {
  -        service_main(master_main, argc, argv,
  -                &service_pause, &service_stop, "Apache", install, run_as_service);
  -    }    
   
  -    return(0);
  +    return (0);
   }
   
   
   #endif /* ndef MULTITHREAD */
  -
  
  
  

Mime
View raw message