You are viewing a plain text version of this content. The canonical link for it is here.
Posted to cvs@httpd.apache.org by mc...@apache.org on 2002/12/17 20:06:10 UTC

cvs commit: apache-1.3/src/os/tpf os.c os.h

mccreedy    2002/12/17 11:06:10

  Modified:    src/include ap_config.h scoreboard.h
               src/main http_main.c
               src/modules/standard mod_status.c
               src/os/tpf os.c os.h
  Log:
  Removed TPF-specific USE_TPF_SCOREBOARD in favor of shared memory.
  Also improved shutdown/restart of the server on TPF.
  
  Revision  Changes    Path
  1.327     +2 -1      apache-1.3/src/include/ap_config.h
  
  Index: ap_config.h
  ===================================================================
  RCS file: /home/cvs/apache-1.3/src/include/ap_config.h,v
  retrieving revision 1.326
  retrieving revision 1.327
  diff -u -r1.326 -r1.327
  --- ap_config.h	3 Oct 2002 19:58:09 -0000	1.326
  +++ ap_config.h	17 Dec 2002 19:06:08 -0000	1.327
  @@ -968,10 +968,11 @@
   #define NO_SETSID
   #define NO_SLACK
   #define NO_TIMES
  +#ifndef TPF_HAVE_SIGACTION
   #define NO_USE_SIGACTION
  +#endif
   #define USE_LONGJMP
   #define USE_SHMGET_SCOREBOARD
  -/*#define USE_TPF_SCOREBOARD*/
   #define USE_TPF_ACCEPT
   #define HAVE_TPF_CORE_SERIALIZED_ACCEPT
   #define USE_TPF_SELECT
  
  
  
  1.55      +0 -4      apache-1.3/src/include/scoreboard.h
  
  Index: scoreboard.h
  ===================================================================
  RCS file: /home/cvs/apache-1.3/src/include/scoreboard.h,v
  retrieving revision 1.54
  retrieving revision 1.55
  diff -u -r1.54 -r1.55
  --- scoreboard.h	13 Mar 2002 21:05:29 -0000	1.54
  +++ scoreboard.h	17 Dec 2002 19:06:08 -0000	1.55
  @@ -185,10 +185,6 @@
   } scoreboard;
   
   #define SCOREBOARD_SIZE		sizeof(scoreboard)
  -#ifdef TPF
  -#define SCOREBOARD_NAME		"SCOREBRD"
  -#define SCOREBOARD_FRAMES		SCOREBOARD_SIZE/4095 + 1
  -#endif
   
   API_EXPORT(void) ap_sync_scoreboard_image(void);
   API_EXPORT(int) ap_exists_scoreboard_image(void);
  
  
  
  1.598     +22 -49    apache-1.3/src/main/http_main.c
  
  Index: http_main.c
  ===================================================================
  RCS file: /home/cvs/apache-1.3/src/main/http_main.c,v
  retrieving revision 1.597
  retrieving revision 1.598
  diff -u -r1.597 -r1.598
  --- http_main.c	12 Dec 2002 16:09:50 -0000	1.597
  +++ http_main.c	17 Dec 2002 19:06:08 -0000	1.598
  @@ -382,6 +382,7 @@
   #endif
   
   #ifdef TPF
  +pid_t tpf_parent_pid;
   int tpf_child = 0;
   char tpf_server_name[INETD_SERVNAME_LENGTH+1];
   char tpf_mutex_key[TPF_MUTEX_KEY_SIZE];
  @@ -2375,37 +2376,6 @@
   {
   }
   
  -#elif defined(USE_TPF_SCOREBOARD)
  -
  -static void cleanup_scoreboard_heap()
  -{
  -    int rv;
  -    rv = rsysc(ap_scoreboard_image, SCOREBOARD_FRAMES, SCOREBOARD_NAME);
  -    if(rv == RSYSC_ERROR) {
  -        ap_log_error(APLOG_MARK, APLOG_ERR, server_conf,
  -            "rsysc() could not release scoreboard system heap");
  -    }
  -}
  -
  -static void setup_shared_mem(pool *p)
  -{
  -    cinfc(CINFC_WRITE, CINFC_CMMCTK2);
  -    ap_scoreboard_image = (scoreboard *) gsysc(SCOREBOARD_FRAMES, SCOREBOARD_NAME);
  -
  -    if (!ap_scoreboard_image) {
  -        fprintf(stderr, "httpd: Could not create scoreboard system heap storage.\n");
  -        exit(APEXIT_INIT);
  -    }
  -
  -    ap_register_cleanup(p, NULL, cleanup_scoreboard_heap, ap_null_cleanup);
  -    ap_scoreboard_image->global.running_generation = 0;
  -}
  -
  -static void reopen_scoreboard(pool *p)
  -{
  -    cinfc(CINFC_WRITE, CINFC_CMMCTK2);
  -}
  -
   #else
   #define SCOREBOARD_FILE
   static scoreboard _scoreboard_image;
  @@ -3260,6 +3230,9 @@
   
   static void restart(int sig)
   {
  +#ifdef TPF
  +    signal(sig, restart);
  +#endif
   #if !defined (WIN32) && !defined(NETWARE)
       ap_start_restart(sig == SIGUSR1);
   #else
  @@ -4473,13 +4446,16 @@
   
   #ifdef TPF
   		case EINACT:
  -		    ap_log_error(APLOG_MARK, APLOG_EMERG, server_conf,
  -			"offload device inactive");
  -		    clean_child_exit(APEXIT_CHILDFATAL);
  +                    ap_log_error(APLOG_MARK, APLOG_ALERT|APLOG_NOERRNO,
  +                                 server_conf, "offload device inactive");
  +                    clean_child_exit(APEXIT_CHILDFATAL); 
   		    break;
   		default:
  -		    ap_log_error(APLOG_MARK, APLOG_NOERRNO|APLOG_ERR, server_conf,
  -			"select/accept error (%u)", errno);
  +                    if (getppid() != 1) {
  +                        ap_log_error(APLOG_MARK, APLOG_ALERT|APLOG_NOERRNO,
  +                                     server_conf, "select/accept error (%u)",
  +                                     errno);
  +                    }
   		    clean_child_exit(APEXIT_CHILDFATAL);
   #else
   		default:
  @@ -4919,6 +4895,9 @@
   	 */
   	kill(ap_scoreboard_image->parent[to_kill].pid, SIG_IDLE_KILL);
   	idle_spawn_rate = 1;
  +#ifdef TPF
  +        ap_update_child_status(to_kill, SERVER_DEAD, (request_rec *)NULL);
  +#endif
       }
       else if (idle_count < ap_daemons_min_free) {
   	/* terminate the free list */
  @@ -5146,6 +5125,11 @@
   	     * to start up and get into IDLE state then we may spawn an
   	     * extra child
   	     */
  +#ifdef TPF
  +            if (shutdown_pending += os_check_server(tpf_server_name)) {
  +                break;
  +            }
  +#endif
   	    if (pid >= 0) {
   		process_child_status(pid, status);
   		/* non-fatal death... note that it's gone in the scoreboard. */
  @@ -5199,17 +5183,6 @@
   	    }
   
   	    perform_idle_server_maintenance();
  -#ifdef TPF
  -            ap_check_signals();
  -            if (!shutdown_pending) {
  -                if (os_check_server(tpf_server_name)) {
  -                    shutdown_pending++;
  -                } else {
  -                    sleep(1);
  -                    ap_check_signals();
  -                }
  -            }
  -#endif /*TPF */
   	}
   
   	if (shutdown_pending) {
  @@ -5470,6 +5443,7 @@
                  INETD_SERVNAME_LENGTH);
           tpf_server_name[INETD_SERVNAME_LENGTH + 1] = '\0';
           sprintf(tpf_mutex_key, "%.*x", TPF_MUTEX_KEY_SIZE - 1, getpid());
  +        tpf_parent_pid = getppid();
           ap_open_logs(server_conf, plog);
           ap_tpf_zinet_checks(ap_standalone, tpf_server_name, server_conf);
           ap_tpf_save_argv(argc, argv);    /* save argv parms for children */
  @@ -5490,9 +5464,8 @@
               copy_listeners(pconf);
               reset_tpf_listeners(&input_parms.child);
   #ifdef SCOREBOARD_FILE
  -            scoreboard_fd = input_parms.child.scoreboard_fd;
               ap_scoreboard_image = &_scoreboard_image;
  -#else /* must be USE_TPF_SCOREBOARD or USE_SHMGET_SCOREBOARD */
  +#else /* must be USE_SHMGET_SCOREBOARD */
               ap_scoreboard_image =
                   (scoreboard *)input_parms.child.scoreboard_heap;
   #endif
  
  
  
  1.123     +20 -0     apache-1.3/src/modules/standard/mod_status.c
  
  Index: mod_status.c
  ===================================================================
  RCS file: /home/cvs/apache-1.3/src/modules/standard/mod_status.c,v
  retrieving revision 1.122
  retrieving revision 1.123
  diff -u -r1.122 -r1.123
  --- mod_status.c	13 Mar 2002 21:05:34 -0000	1.122
  +++ mod_status.c	17 Dec 2002 19:06:09 -0000	1.123
  @@ -534,6 +534,16 @@
   		if (!short_report) {
   		    if (no_table_report) {
   			if (score_record.status == SERVER_DEAD)
  +#ifdef TPF
  +                            if (kill(ps_record.pid, 0) == 0) {
  +                                /* on TPF show PIDs of the living dead */
  +                                ap_rprintf(r,
  +                                "<b>Server %d-%d</b> (%d): %d|%lu|%lu [",
  +                                i, (int) ps_record.generation,
  +                                (int)ps_record.pid, (int) conn_lres,
  +                                my_lres, lres);
  +                            } else
  +#endif /* TPF */
   			    ap_rprintf(r,
   				"<b>Server %d-%d</b> (-): %d|%lu|%lu [",
   				i, (int) ps_record.generation, (int) conn_lres,
  @@ -608,6 +618,16 @@
   		    }
   		    else {		/* !no_table_report */
   			if (score_record.status == SERVER_DEAD)
  +#ifdef TPF
  +                            if (kill(ps_record.pid, 0) == 0) {
  +                                /* on TPF show PIDs of the living dead */
  +                                ap_rprintf(r,
  +                                    "<tr><td><b>%d-%d</b><td>%d<td>%d/%lu/%lu",
  +                                    i, (int) ps_record.generation,
  +                                    (int) ps_record.pid,
  +                                    (int) conn_lres, my_lres, lres);
  +                            } else
  +#endif /* TPF */
   			    ap_rprintf(r,
   				"<tr><td><b>%d-%d</b><td>-<td>%d/%lu/%lu",
   				i, (int) ps_record.generation,
  
  
  
  1.20      +59 -21    apache-1.3/src/os/tpf/os.c
  
  Index: os.c
  ===================================================================
  RCS file: /home/cvs/apache-1.3/src/os/tpf/os.c,v
  retrieving revision 1.19
  retrieving revision 1.20
  diff -u -r1.19 -r1.20
  --- os.c	10 Sep 2002 22:51:15 -0000	1.19
  +++ os.c	17 Dec 2002 19:06:09 -0000	1.20
  @@ -78,12 +78,15 @@
   char *argv_ptr = NULL;
   
   static FILE *sock_fp;
  +static int   sock_sd;
   
  -int tpf_select(int maxfds, fd_set *reads, fd_set *writes, fd_set *excepts, struct timeval *tv)
  +int tpf_select(int maxfds, fd_set *reads, fd_set *writes, fd_set *excepts,
  +               struct timeval *tv)
   {
  -/* We're going to force our way through select.  We're only interested reads and TPF allows
  -   2billion+ socket descriptors for we don't want an fd_set that big.  Just assume that maxfds-1
  -   contains the socket descriptor we're interested in.  If it's 0, leave it alone. */
  +/* We're going to force our way through select.  We're only interested reads
  +   and TPF allows 2billion+ socket descriptors for we don't want an fd_set
  +   that big.  Just assume that maxfds-1 contains the socket descriptor we're
  +   interested in.  If it's 0, leave it alone. */
   
       int sockets[1];
       int no_reads = 0;
  @@ -104,25 +107,31 @@
       ap_check_signals();
       if ((no_reads + no_writes + no_excepts == 0) &&
           (tv) && (tv->tv_sec + tv->tv_usec != 0)) {
  -#ifdef TPF_HAVE_SAWNC
           /* TPF's select immediately returns if the sum of
              no_reads, no_writes, and no_excepts is zero.
  -           This means that the select calls in http_main.c
  -           for shutdown don't actually wait while killing children.
              The following code makes TPF's select work a little closer
              to everyone else's select:
           */
  +#ifdef TPF_HAVE_SAWNC
           struct ev0bk evnblock;
  -
  +#endif
           timeout = tv->tv_sec;
           if (tv->tv_usec) {
               timeout++; /* round up to seconds (like TPF's select does) */
           }
  -        evnblock.evnpstinf.evnbkc1 = 1; /* nbr of posts needed */
  -        evntc(&evnblock, EVENT_CNT, 'N', timeout, EVNTC_1052);
  -        tpf_sawnc(&evnblock, EVENT_CNT);
  +        if (timeout > 0) { /* paranoid check for valid timeout */
  +#ifdef TPF_HAVE_SAWNC
  +            evnblock.evnpstinf.evnbkc1 = 1; /* nbr of posts needed */
  +            evntc(&evnblock, EVENT_CNT, 'N', timeout, EVNTC_1052);
  +            tpf_sawnc(&evnblock, EVENT_CNT);
  +#else
  +            sleep(timeout);
   #endif
  +        }
       } else {
  +        if (timeout < 0) { /* paranoid check for valid timeout */
  +            timeout = 0;
  +        }
           rv = select(sockets, no_reads, no_writes, no_excepts, timeout);
       }
       ap_check_signals();
  @@ -138,13 +147,13 @@
   
       ap_check_signals();
       socks[0] = sockfd;
  -    rv = select(socks, 1, 0, 0, 1000);
  +    rv = select(socks, 1, 0, 0, TPF_ACCEPT_SECS_TO_BLOCK * 1000);
       errno = sock_errno();
       if(rv>0) {
  -        ap_check_signals();
           rv = accept(sockfd, peer, paddrlen);
           errno = sock_errno();
       }    
  +    ap_check_signals();
       return rv;
   }
      
  @@ -372,10 +381,8 @@
           ap_log_error(APLOG_MARK, APLOG_CRIT, s,
           "unable to replace stdout with sock device driver");
       input_parms.generation = ap_my_generation;
  -#if defined(USE_TPF_SCOREBOARD) || defined(USE_SHMGET_SCOREBOARD)
  +#ifdef USE_SHMGET_SCOREBOARD
       input_parms.scoreboard_heap = ap_scoreboard_image;
  -#else
  -    input_parms.scoreboard_fd = scoreboard_fd;
   #endif
   
       lr = ap_listeners;
  @@ -448,6 +455,8 @@
   int os_check_server(char *server) {
       int *current_acn;
   
  +    ap_check_signals();
  +
       /* check that the program activation number hasn't changed */
           current_acn = (int *)cinfc_fast(CINFC_CMMACNUM);
           if (ecbp2()->ce2acn != *current_acn) {
  @@ -476,8 +485,8 @@
       sprintf(sockfilename, "/dev/tpf.socket.file/%.8X", sd);
       sock_fp = fopen(sockfilename, "r+");
       /* arrange to close on exec or restart */
  -    ap_note_cleanups_for_file(p, sock_fp);
  -    fcntl(sd,F_SETFD,FD_CLOEXEC);
  +    ap_note_cleanups_for_file_ex(p, sock_fp, 1);
  +    sock_sd = sd;
   }
   
   void ap_tpf_save_argv(int argc, char **argv) {
  @@ -498,6 +507,7 @@
   }
   
   void os_tpf_child(APACHE_TPF_INPUT *input_parms) {
  +    extern pid_t tpf_parent_pid;
       extern char tpf_mutex_key[TPF_MUTEX_KEY_SIZE];
   
       tpf_child = 1;
  @@ -505,7 +515,8 @@
       ap_restart_time = input_parms->restart_time;
       tpf_fds = input_parms->tpf_fds;
       tpf_shm_static_ptr = input_parms->shm_static_ptr;
  -    sprintf(tpf_mutex_key, "%.*x", TPF_MUTEX_KEY_SIZE - 1, getppid());
  +    tpf_parent_pid = getppid();
  +    sprintf(tpf_mutex_key, "%.*x", TPF_MUTEX_KEY_SIZE - 1, tpf_parent_pid);
   }
   
   #ifndef __PIPE_
  @@ -540,7 +551,7 @@
       void *result;
   
       if ((shmid = shmget(shmkey, size, IPC_CREAT | SHM_R | SHM_W)) == -1) {
  -        perror("shmget failed in ap_tpf_get_shared_mem funciton");
  +        perror("shmget failed in ap_tpf_get_shared_mem function");
           exit(1);
       }
   #define BADSHMAT ((void *)(-1))
  @@ -777,6 +788,11 @@
               kill(pid, sig);
           }
       }
  +    /* allow time for the signals to get to the children */
  +    sleep(1);
  +    /* get idle children's attention by closing the socket */
  +    closesocket(sock_sd);
  +    sleep(1);
   
       return(0);
   }
  @@ -788,9 +804,14 @@
   */
   void show_os_specific_compile_settings(void)
   {
  +int i;
   
   #ifdef USE_TPF_SCOREBOARD
  -    printf(" -D USE_TPF_SCOREBOARD\n");
  +   #error "USE_TPF_SCOREBOARD (system heap scoreboard)"
  +   #error "is no longer supported."
  +   #error "Replace with USE_SHMGET_SCOREBOARD to use"
  +   #error "shared memory or remove entirely to use"
  +   #error "scoreboard on file for pre-PUT10 systems"
   #endif
   
   #ifdef TPF_FORK_EXTENDED
  @@ -819,6 +840,23 @@
    
   #ifdef HAVE_SYSLOG
       printf(" -D HAVE_SYSLOG\n");
  +#endif
  +
  +    printf(" -D TPF_ACCEPT_SECS_TO_BLOCK=%i\n", TPF_ACCEPT_SECS_TO_BLOCK);
  +    /* round SCOREBOARD_MAINTENANCE_INTERVAL up to seconds */
  +    i = (SCOREBOARD_MAINTENANCE_INTERVAL + 999999) / 1000000;
  +    if (i == 1) {
  +        printf(" -D SCOREBOARD_MAINTENANCE_INTERVAL=1 SECOND\n");
  +    } else {
  +        printf(" -D SCOREBOARD_MAINTENANCE_INTERVAL=%i SECONDS\n", i); 
  +    }
  +
  +#ifdef TPF_HAVE_SIGACTION
  +    printf(" -D TPF_HAVE_SIGACTION\n");
  +#endif
  +
  +#ifdef NO_USE_SIGACTION
  +    printf(" -D NO_USE_SIGACTION\n");
   #endif
   
   }
  
  
  
  1.17      +8 -2      apache-1.3/src/os/tpf/os.h
  
  Index: os.h
  ===================================================================
  RCS file: /home/cvs/apache-1.3/src/os/tpf/os.h,v
  retrieving revision 1.16
  retrieving revision 1.17
  diff -u -r1.16 -r1.17
  --- os.h	10 Sep 2002 22:51:15 -0000	1.16
  +++ os.h	17 Dec 2002 19:06:10 -0000	1.17
  @@ -72,6 +72,14 @@
   #include <sysapi.h>  
   #include "ap_config.h"
   
  +#define WUNTRACED 0 /* TPF's waitpid() doesn't support WUNTRACED */
  +
  +/* TPF_ACCEPT_SECS_TO_BLOCK is the number of seconds to block while
  +   waiting to accept a new request in the ap_accept/tpf_accept function */
  +#ifndef TPF_ACCEPT_SECS_TO_BLOCK
  +#define TPF_ACCEPT_SECS_TO_BLOCK 1
  +#endif
  +
   #ifdef HAVE_ISNAN
   #undef HAVE_ISNAN
   #endif
  @@ -151,7 +159,6 @@
   #include <i$netd.h>
   typedef struct apache_input {
       void                *scoreboard_heap;   /* scoreboard system heap address */
  -    int                 scoreboard_fd;      /* scoreboard file descriptor */
       int                 slot;               /* child number */
       int                 generation;         /* server generation number */
       int                 listeners[10];
  @@ -189,7 +196,6 @@
   char *getpass(const char *prompt);
   int killpg(pid_t pgrp, int sig);
   extern char *ap_server_argv0;
  -extern int scoreboard_fd;
   #include <signal.h>
   #ifndef SIGPIPE
   #define SIGPIPE 14