httpd-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From David McCreedy <McCre...@us.ibm.com>
Subject [PATCH] TPF maintenance items for Apache 1.3
Date Thu, 01 Feb 2001 01:37:10 GMT
These patches are for several small TPF maintenance items mostly
relating to the start-up and shut-down of Apache on TPF.
These changes should not impact any other platforms since they only
affect TPF-specific code paths.
Below is a unified diff (-u3) using Apache 1.3.17 as the base.

Thank you.
David McCreedy
McCreedy@us.ibm.com

--- current/src/include/ap_config.h	Wed Jan 31 12:02:04 2001
+++ new/src/include/ap_config.h	Wed Jan 31 12:02:19 2001
@@ -948,7 +948,6 @@
 #define NEED_STRDUP
 #define NO_DBM_REWRITEMAP
 #define NO_GETTIMEOFDAY
-#define NO_KILLPG
 #define NO_LINGCLOSE
 #define NO_MMAP
 #define NO_OTHER_CHILD
@@ -959,11 +958,10 @@
 #define NO_TIMES
 #define NO_USE_SIGACTION
 #define USE_LONGJMP
-/*#define USE_SHMGET_SCOREBOARD*/
+#define USE_SHMGET_SCOREBOARD
+/*#define USE_TPF_SCOREBOARD*/
 #define USE_TPF_ACCEPT
 #define USE_TPF_CORE_SERIALIZED_ACCEPT
-/*#define USE_TPF_DAEMON*/
-#define USE_TPF_SCOREBOARD
 #define USE_TPF_SELECT
 #define S_IREAD S_IRUSR
 #define S_IWRITE S_IWUSR
--- current/src/main/http_main.c	Wed Jan 31 12:03:01 2001
+++ new/src/main/http_main.c	Wed Jan 31 12:02:44 2001
@@ -3665,8 +3665,8 @@
 #ifdef USE_TPF_SCOREBOARD
     printf(" -D USE_TPF_SCOREBOARD\n");
 #endif
-#ifdef USE_TPF_DAEMON
-    printf(" -D USE_TPF_DAEMON\n");
+#ifdef NO_SAWNC
+    printf(" -D NO_SAWNC\n");
 #endif
 #ifdef USE_OS2_SCOREBOARD
     printf(" -D USE_OS2_SCOREBOARD\n");
@@ -5006,13 +5006,14 @@
 	STANDALONE_MAIN(argc, argv);
     }
 #else
+    if (!tpf_child) {
+        memcpy(tpf_server_name, input_parms.parent.servname,
+               INETD_SERVNAME_LENGTH);
+        tpf_server_name[INETD_SERVNAME_LENGTH + 1] = '\0';
+        ap_open_logs(server_conf, pconf);
+        ap_tpf_zinet_checks(ap_standalone, tpf_server_name,
server_conf);
+    }
     if (ap_standalone) {
-        if(!tpf_child) {
-            memcpy(tpf_server_name, input_parms.parent.servname,
-                   INETD_SERVNAME_LENGTH);
-            tpf_server_name[INETD_SERVNAME_LENGTH+1] = '\0';
-            ap_open_logs(server_conf, pconf);
-        }
         ap_set_version();
         ap_init_modules(pconf, server_conf);
         version_locked++;
@@ -5071,12 +5072,7 @@
 	    exit(0);
 	}
 
-#ifdef TPF
-/* TPF's Internet Daemon passes the incoming socket nbr (inetd mode
only) */
-    sock_in = sock_out = input_parms.parent.socket;
-/* TPF also needs a signal set for alarm in inetd mode */
-    signal(SIGALRM, alrm_handler);
-#elif defined(MPE)
+#ifdef MPE
 /* HP MPE 5.5 inetd only passes the incoming socket as stdin (fd 0),
whereas
    HPUX inetd passes the incoming socket as stdin (fd 0) and stdout (fd
1).
    Go figure.  SR 5003355016 has been submitted to request that the
existing
--- current/src/modules/standard/mod_usertrack.c	Wed Jan 31 12:38:07
2001
+++ new/src/modules/standard/mod_usertrack.c	Wed Jan 31 12:29:44 2001
@@ -103,7 +103,7 @@
 #include "httpd.h"
 #include "http_config.h"
 #include "http_core.h"
-#if !defined(WIN32) && !defined(MPE)
+#if !defined(WIN32) && !defined(MPE) && !defined(TPF)
 #include <sys/time.h>
 #endif
 
--- current/src/os/tpf/os.c	Wed Jan 31 12:04:37 2001
+++ new/src/os/tpf/os.c	Wed Jan 31 12:45:38 2001
@@ -68,12 +68,13 @@
 #include "http_log.h"
 #include "http_conf_globals.h"
 #ifdef __PIPE_
-#include "ipc.h"
-#include "shm.h"
+#include <ipc.h>
+#include <shm.h>
 static TPF_FD_LIST *tpf_fds = NULL;
 #endif
 
 void *tpf_shm_static_ptr = NULL;
+unsigned short zinet_model;
 
 static FILE *sock_fp;
 
@@ -133,7 +134,7 @@
     int no_writes = 0;
     int no_excepts = 0;
     int timeout = 0;
-    int rv;
+    int rv = 0;
     
     if(maxfds) {
         if(tv)
@@ -145,7 +146,29 @@
         sockets[0] = 0;
         
     ap_check_signals();
-    rv = select(sockets, no_reads, no_writes, no_excepts, timeout);
+    if ((no_reads + no_writes + no_excepts == 0) &&
+        (tv) && (tv->tv_sec + tv->tv_usec != 0)) {
+        /* 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:
+        */
+#ifndef NO_SAWNC
+        struct ev0bk evnblock;
+
+        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);
+#endif
+    } else {
+        rv = select(sockets, no_reads, no_writes, no_excepts, timeout);
+    }
     ap_check_signals();
     
     return rv;
@@ -352,10 +375,10 @@
         ap_log_error(APLOG_MARK, APLOG_CRIT, s,
         "unable to replace stdout with sock device driver");
     input_parms.generation = ap_my_generation;
-#ifdef SCOREBOARD_FILE
-    input_parms.scoreboard_fd = scoreboard_fd;
-#else /* must be USE_TPF_SCOREBOARD or USE_SHMGET_SCOREBOARD */
+#if defined(USE_TPF_SCOREBOARD) || defined(USE_SHMGET_SCOREBOARD)
     input_parms.scoreboard_heap = ap_scoreboard_image;
+#else
+    input_parms.scoreboard_fd = scoreboard_fd;
 #endif
 
     lr = ap_listeners;
@@ -379,18 +402,69 @@
     return tpf_fork(&fork_input);
 }
 
+void ap_tpf_zinet_checks(int standalone,
+                        const char *servername,
+                        server_rec *s) {
+
+    INETD_IDCT_ENTRY_PTR idct;
+
+    /* explicitly disallow "ServerType inetd" on TPF */
+    if (!standalone) {
+        ap_log_error(APLOG_MARK, APLOG_ALERT|APLOG_NOERRNO, s,
+                     TPF_SERVERTYPE_MSG);
+        exit(1); /* abort start-up of server */
+    }
+
+    /* figure out zinet model for our server from the idct slot */
+    idct = inetd_getServer(servername);
+    if (idct) {
+        zinet_model = idct->model;
+        free(idct);
+    } else {
+        ap_log_error(APLOG_MARK, APLOG_ALERT|APLOG_NOERRNO, s,
+                     TPF_UNABLE_TO_DETERMINE_ZINET_MODEL);
+        exit(1); /* abort start-up of server */
+    }
+
+    /* check for valid zinet models */
+    if (zinet_model != INETD_IDCF_MODEL_DAEMON &&
+        zinet_model != INETD_IDCF_MODEL_NOLISTEN) {
+        ap_log_error(APLOG_MARK, APLOG_ALERT|APLOG_NOERRNO, s,
+                     TPF_STANDALONE_CONFLICT_MSG);
+        exit(1); /* abort start-up of server */
+    }
+
+#ifdef TPF_NOLISTEN_WARNING
+/* nag about switching to DAEMON model */
+    if (zinet_model == INETD_IDCF_MODEL_NOLISTEN) {
+        ap_log_error(APLOG_MARK, APLOG_WARNING|APLOG_NOERRNO, s,
+                     TPF_NOLISTEN_WARNING);
+    }
+#endif
+
+}
+
 int os_check_server(char *server) {
-    #ifndef USE_TPF_DAEMON
-    int rv;
     int *current_acn;
-    if((rv = inetd_getServerStatus(server)) ==
INETD_SERVER_STATUS_INACTIVE)
-        return 1;
-    else {
+
+    if (zinet_model == INETD_IDCF_MODEL_NOLISTEN) {
+        /* if NOLISTEN model, check with ZINET for status */
+        if (inetd_getServerStatus(server) ==
INETD_SERVER_STATUS_INACTIVE) {
+            return 1;
+        }
+        /* and check that program activation number hasn't changed */
         current_acn = (int *)cinfc_fast(CINFC_CMMACNUM);
-        if(ecbp2()->ce2acn != *current_acn)
+        if (ecbp2()->ce2acn != *current_acn) {
             return 1;
+        }
+
+    } else {
+        /* if DAEMON model, just make sure parent is still around */
+        if (getppid() == 1) {
+            return 1;
+        }
     }
-    #endif
+
     return 0;
 }
 
@@ -662,4 +736,26 @@
     }
     else
          return (0);
+}
+
+/*
+   This function serves as an interim killpg for Apache shutdown
purposes.
+   TPF won't have an actual killpg for a very long time, if ever.
+   (And kill with a negative pid doesn't work on TPF either.)
+*/
+int killpg(pid_t pgrp, int sig)
+{
+    int i;
+
+    ap_sync_scoreboard_image();
+
+    for (i = 0; i < HARD_SERVER_LIMIT; ++i) {
+        int pid = ap_scoreboard_image->parent[i].pid;
+        /* the pgrp check is so that we don't kill ourself: */
+        if (pid && pid != pgrp) {
+            kill(pid, sig);
+        }
+    }
+
+    return(0);
 }
--- current/src/os/tpf/os.h	Wed Jan 31 12:05:13 2001
+++ new/src/os/tpf/os.h	Wed Jan 31 12:05:25 2001
@@ -11,7 +11,7 @@
 #endif
 
 /*
- * This file in included in all Apache source code. It contains
definitions
+ * This file is included in all Apache source code. It contains
definitions
  * of facilities available on _this_ operating system (HAVE_* macros),
  * and prototypes of OS specific functions defined in os.c or
os-inline.c
  */
@@ -124,8 +124,12 @@
 
 struct server_rec;
 pid_t os_fork(struct server_rec *s, int slot);
+void ap_tpf_zinet_checks(int standalone,
+                         const char *servername,
+                         struct server_rec *s);
 int os_check_server(char *server);
 char *getpass(const char *prompt);
+int killpg(pid_t pgrp, int sig);
 extern char *ap_server_argv0;
 extern int scoreboard_fd;
 #include <signal.h>
@@ -135,4 +139,28 @@
 #ifdef NSIG
 #undef NSIG
 #endif
+
+/* various #defines for ServerType/ZINET model checks: */
+
+#define TPF_SERVERTYPE_MSG \
+        "ServerType inetd is not supported on TPF" \
+        " -- Apache startup aborted"
+
+#ifdef INETD_IDCF_MODEL_DAEMON
+#define TPF_STANDALONE_CONFLICT_MSG \
+        "ServerType standalone requires ZINET model DAEMON or NOLISTEN"
\
+        " -- Apache startup aborted"
+#define TPF_NOLISTEN_WARNING \
+        "ZINET model DAEMON is preferred over model NOLISTEN"
+#else
+#define INETD_IDCF_MODEL_DAEMON -1
+#define TPF_STANDALONE_CONFLICT_MSG \
+        "ServerType standalone requires ZINET model NOLISTEN" \
+        " -- Apache startup aborted"
+#endif
+
+#define TPF_UNABLE_TO_DETERMINE_ZINET_MODEL \
+        "Unable to determine ZINET model: inetd_getServer call failed"
\
+        " -- Apache startup aborted"
+
 #endif /*! APACHE_OS_H*/
--- current/src/os/tpf/TPFExport	Wed Jan 31 12:08:09 2001
+++ new/src/os/tpf/TPFExport	Wed Jan 31 12:12:05 2001
@@ -2,8 +2,9 @@
 echo " Setting TPF/c89 environment variables"
 export _C89_CCMODE=1
 # replace the following with the location of your TPF include files
-export _C89_INCDIRS="/u/tpf41/currentmaint/include
/u/tpf41/currentmaint/include/oco" 
+export _C89_INCDIRS="/u/tpf41/currentmaint/include" 
 export TPF=YES
 export _C89_INCLIBS=""
 export _C89_CSYSLIB=""
+export _C89_OPTIONS="-W 0,langlvl(extended)"
 echo "Done"

Mime
View raw message