manoj 99/04/27 13:36:39
Modified: htdocs/manual install-tpf.html readme-tpf.html src CHANGES src/ap ap_md5c.c src/include ap_config.h scoreboard.h src/main alloc.c buff.c http_log.c http_main.c http_protocol.c src/modules/proxy proxy_connect.c src/modules/standard mod_cgi.c mod_include.c src/os/tpf Makefile.tmpl os.c os.h Added: src/os/tpf cgetop.c Log: Submitted by: Joe Moenich <[EMAIL PROTECTED]> Reviewed by: Dean Gaudet, Martin Kraemer, Manoj Kasichainula Add support for standalone mode in TPF Revision Changes Path 1.6 +3 -5 apache-1.3/htdocs/manual/install-tpf.html Index: install-tpf.html =================================================================== RCS file: /home/cvs/apache-1.3/htdocs/manual/install-tpf.html,v retrieving revision 1.5 retrieving revision 1.6 diff -u -u -r1.5 -r1.6 --- install-tpf.html 1999/01/08 23:24:46 1.5 +++ install-tpf.html 1999/04/27 20:36:24 1.6 @@ -53,8 +53,6 @@ If you are using a product such as WinZip on your PC, verify that the <EM>"TAR File Smart CR/LF Conversion"</EM> option is NOT checked. You can find this in WinZip under Options, Configuration. -Since you had to tar and unzip the file to read this document, -you need to re-tar and -unzip if the CR/LF option was checked. This will save you lots of headaches later on. </P> <P> @@ -212,8 +210,7 @@ Apache requires a configuration file to initialize itself during activation. (Previously three configuration files were used.) Copy the distribution version, /conf/httpd.conf-dist, to /conf/httpd.conf and then - edit the /conf/httpd.conf copy with your site specific information. This first release - of Apache for TPF only runs under the "inetd" model so you + edit the /conf/httpd.conf copy with your site specific information. If your system is pre-PUT09 you <font color=red><STRONG>must</STRONG></FONT> change <TT>ServerType</TT> from <TT>standalone</TT> to <TT>inetd</TT>. <BR><BR> @@ -226,7 +223,8 @@ <BR><BR> <PRE> ZINET ADD S-TFTP PGM-CTFT PORT-69 PROTOCOL-UDP MODEL-NOWAIT - ZINET ADD S-APACHE PGM-<EM>pppp</EM> PORT-80 PROTOCOL-TCP MODEL-NOWAIT</PRE> + ZINET ADD S-APACHE PGM-<EM>pppp</EM> PROTOCOL-TCP MODEL-NOWAIT PORT-80 (if inetd mode) + ZINET ADD S-APACHE PGM-<EM>pppp</EM> PROTOCOL-TCP MODEL-NOLISTEN (if standalone mode)</PRE> Please refer to <EM>IBM Transaction Processing Facility Transmission Control Protocol/Internet Protocol Version 4 Release 1</EM> for more information on ZCLAW, INETD, and TFTP. 1.5 +31 -32 apache-1.3/htdocs/manual/readme-tpf.html Index: readme-tpf.html =================================================================== RCS file: /home/cvs/apache-1.3/htdocs/manual/readme-tpf.html,v retrieving revision 1.4 retrieving revision 1.5 diff -u -u -r1.4 -r1.5 --- readme-tpf.html 1999/01/08 23:13:27 1.4 +++ readme-tpf.html 1999/04/27 20:36:25 1.5 @@ -8,7 +8,6 @@ <H1 align="center">Overview of the Apache TPF Port</H1> <HR> <CENTER>[ <A HREF="#configuration_files">Configuration Files</A> - | <A HREF="#auto_generated_files">Auto Generated Files</A> | <A HREF="#whats_available">What's Available</A> | <A HREF="#porting_notes">Porting Notes</A> ] </CENTER> @@ -41,8 +40,7 @@ work on TPF with only a couple of operating system specific changes to httpd.conf:<BR> <UL> - <LI>ServerType needs to be "inetd" since TPF does not yet support - "standalone" mode. + <LI>ServerType needs to be "inetd" on pre-PUT09 systems. <LI>Performance considerations may dictate setting KeepAlive to "Off" (the default is "On") or lowering the Timeout value from the default 300 seconds (5 minutes) in order to reduce the number of active ECBs on your system. @@ -68,64 +66,75 @@ <LI>buff.c <LI>buildmark.c <LI>ebcdic.c + <LI>gen_test.char.c + <LI>gen_uri_delims.c <LI>http_config.c <LI>http_core.c <LI>http_log.c - <LI>http_main.c + <LI>http_main.c <A HREF="#note_1"> <i><small>(see note 1)</small></i></A> <LI>http_protocol.c <LI>http_request.c - <LI>http_vhost.c <A HREF="#note_2">*</A> - <LI>mod_access.c + <LI>http_vhost.c <i><small>(requires PUT9)</small></i> + <LI>logresolve.c <i><small>(requires PUT10)</small></i> + <LI>mod_access.c <A HREF="#note_2"> <i><small>(see note 2)</small></i></A> + <LI>mod_actions.c <LI>mod_alias.c <LI>mod_asis.c + <LI>mod_auth_anon.c <LI>mod_autoindex.c <LI>mod_cern_meta.c + <LI>mod_cgi.c <i><small>(requires PUT10)</small></i> <LI>mod_dir.c + <LI>mod_env.c <LI>mod_example.c <LI>mod_expires.c <LI>mod_headers.c <LI>mod_imap.c + <LI>mod_include.c <A HREF="#note_3"> <i><small>(see note 3)</small></i></A> <LI>mod_info.c <LI>mod_log_agent.c <LI>mod_log_config.c <LI>mod_log_referer.c <LI>mod_mime.c + <LI>mod_mime_magic.c <LI>mod_negotiation.c + <LI><A HREF="http://hpwww.ec-lyon.fr/~vincent/apache/mod_put.html">mod_put.c</A> <LI>mod_setenvif.c <LI>mod_speling.c + <LI>mod_status.c + <LI>mod_unique_id.c <i><small>(requires PUT10)</small></i> <LI>mod_userdir.c <LI>mod_usertrack.c <LI>os.c <LI>os-inline.c <LI>regular expression parser + <LI>rotatelogs.c <i><small>(requires PUT10)</small></i> <LI>util.c <LI>util_date.c + <LI>util_script.c <LI>util_uri.c </UL></MULTICOL> - Please keep in mind that some major pieces are not yet in place including - standalone mode, pipes, password/group files, CGI scripts, and MD5 support. - <BR> + <br><b>Notes:</b> + <A NAME="note_1"> </A> + <ol> + <li>"Standalone" mode requires TPF version 4.1 PUT09 <A NAME="note_2"> </A> - <BR> - * virtual hosting requires TPF version 4.1 PUT09 + <li>Use of mod_access directives "<tt>allow from</tt>" & "<tt>deny from</tt>" + with host <i>names</i> (verses ip addresses) requires TPF version 4.1 PUT10 + <A NAME="note_3"> </A> + <li>CGI execution requires TPF version 4.1 PUT10 + </ol> -<H3>Components/modules not (yet?) supported on TPF:</H3> +<H3>Components/modules not yet supported on TPF:</H3> <multicol COLS=3><UL> + <LI>ap_md5c.c <LI>htpasswd.c - <LI>md5c.c - <LI>mod_actions.c <LI>mod_auth.c - <LI>mod_auth_anon.c - <LI>mod_cgi.c <LI>mod_digest.c - <LI>mod_env.c - <LI>mod_include.c - <LI>mod_mime_magic.c + <LI>mod_mmap_static.c <LI>mod_proxy.c <LI>mod_rewrite.c - <LI>mod_status.c - <LI>mod_unique_id.c <LI>proxy_cache.c <LI>proxy_connect.c <LI>proxy_ftp.c @@ -133,19 +142,16 @@ <LI>proxy_util.c <LI>rfc1413.c <LI>util_md5.c - <LI>util_script.c </UL></MULTICOL> <H3>Components/modules that don't apply or that probably won't ever be available on TPF:</H3> <multicol COLS=3><UL> - <LI>gen_test.char.c - <LI>gen_uri_delims.c <LI>mod_auth_db.c <LI>mod_auth_dbm.c <LI>mod_auth_db.module - <LI>mod_mmap_static.c <LI>mod_so.c + <LI>suexec.c </UL></MULTICOL> <A NAME="porting_notes"> </A> @@ -188,16 +194,9 @@ differences in how some functions are implemented on TPF. </P> - <H3>Temporary changes:</H3> - <P>Lastly, we needed to bypass sections of Apache processing - since this first cut for TPF doesn't include - Standalone mode, pipes, forking, et cetera. - </P> - <HR> <CENTER>[ <A HREF="#top">top</A> | <A HREF="#configuration_files">Configuration Files</A> - | <A HREF="#auto_generated_files">Auto Generated Files</A> | <A HREF="#whats_available">What's Available</A> | <A HREF="#porting_notes">Porting Notes</A> ] </CENTER> 1.1327 +3 -0 apache-1.3/src/CHANGES Index: CHANGES =================================================================== RCS file: /home/cvs/apache-1.3/src/CHANGES,v retrieving revision 1.1326 retrieving revision 1.1327 diff -u -u -r1.1326 -r1.1327 --- CHANGES 1999/04/22 11:06:45 1.1326 +++ CHANGES 1999/04/27 20:36:26 1.1327 @@ -1,5 +1,8 @@ Changes with Apache 1.3.7 + *) Add support for standalone mode in TPF + [Joe Moenich <[EMAIL PROTECTED]>] + *) Fix number of bytes copied by read_connection() in src/support/ab.c [Jim Cox <[EMAIL PROTECTED]>] PR#4271 1.27 +1 -1 apache-1.3/src/ap/ap_md5c.c Index: ap_md5c.c =================================================================== RCS file: /home/cvs/apache-1.3/src/ap/ap_md5c.c,v retrieving revision 1.26 retrieving revision 1.27 diff -u -u -r1.26 -r1.27 --- ap_md5c.c 1999/04/08 21:34:00 1.26 +++ ap_md5c.c 1999/04/27 20:36:28 1.27 @@ -611,7 +611,7 @@ /* * It's not our algorithm, so feed it to crypt() if possible. */ -#ifdef WIN32 +#if defined(WIN32) || defined(TPF) /* * On Windows, the only alternative to our MD5 algorithm is plain * text. 1.255 +42 -6 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.254 retrieving revision 1.255 diff -u -u -r1.254 -r1.255 --- ap_config.h 1999/04/20 19:42:59 1.254 +++ ap_config.h 1999/04/27 20:36:29 1.255 @@ -849,10 +849,16 @@ #include <sysgtime.h> #define PRIMECRAS 0x010000 #define JMP_BUF jmp_buf +#define HAVE_SHMGET +#undef HAVE_SYS_RESOURCE_H #define NEED_INITGROUPS +#define NEED_SIGNAL_INTERRUPT +#include <strings.h> +#ifndef __strings_h #define NEED_STRCASECMP -#define NEED_STRDUP #define NEED_STRNCASECMP +#endif +#define NEED_STRDUP #define NO_DBM_REWRITEMAP #define NO_GETTIMEOFDAY #define NO_KILLPG @@ -861,12 +867,16 @@ #define NO_OTHER_CHILD #define NO_RELIABLE_PIPED_LOGS #define NO_SETSID -#define NO_SHMGET #define NO_SLACK #define NO_TIMES #define NO_USE_SIGACTION #define NO_WRITEV #define USE_LONGJMP +/*#define USE_SHMGET_SCOREBOARD*/ +#define USE_TPF_ACCEPT +#define USE_TPF_CORE_SERIALIZED_ACCEPT +/*#define USE_TPF_DAEMON*/ +#define USE_TPF_SCOREBOARD #define USE_TPF_SELECT #undef offsetof #define offsetof(s_type,field) ((size_t)&(((s_type*)0)->field)) @@ -993,6 +1003,9 @@ #define strftime(s,max,format,tm) os_strftime(s,max,format,tm) #endif #include <signal.h> +#if defined(TPF) && defined(NSIG) +#undef NSIG +#endif #include <errno.h> #if !defined(QNX) && !defined(CONVEXOS11) && !defined(NEXT) && !defined(TPF) #include <memory.h> @@ -1094,14 +1107,37 @@ #define JMP_BUF sigjmp_buf #endif #endif + +/* Majority of os's want to verify FD_SETSIZE */ +#if !defined(WIN32) && !defined(TPF) +#define CHECK_FD_SETSIZE +#endif +/* and for client sockets */ +#if !defined(TPF) +#define CHECK_CSD_SETSIZE +#endif -#ifdef SELECT_NEEDS_CAST +#ifdef USE_TPF_SELECT #define ap_select(_a, _b, _c, _d, _e) \ + tpf_select(_a, _b, _c, _d, _e) +#elif defined(SELECT_NEEDS_CAST) +#define ap_select(_a, _b, _c, _d, _e) \ select((_a), (int *)(_b), (int *)(_c), (int *)(_d), (_e)) -#elif defined(USE_TPF_SELECT) -#define ap_select tpf_select +#else +#define ap_select(_a, _b, _c, _d, _e) \ + select(_a, _b, _c, _d, _e) +#endif + +#ifdef USE_TPF_ACCEPT +#define ap_accept(_fd, _sa, _ln) tpf_accept(_fd, _sa, _ln) +#else +#define ap_accept(_fd, _sa, _ln) accept(_fd, _sa, _ln) +#endif + +#ifdef NEED_SIGNAL_INTERRUPT +#define ap_check_signals() tpf_process_signals() #else -#define ap_select select +#define ap_check_signals() #endif #ifdef ULTRIX_BRAIN_DEATH 1.47 +4 -0 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.46 retrieving revision 1.47 diff -u -u -r1.46 -r1.47 --- scoreboard.h 1999/01/01 19:04:41 1.46 +++ scoreboard.h 1999/04/27 20:36:29 1.47 @@ -183,6 +183,10 @@ } 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.109 +3 -0 apache-1.3/src/main/alloc.c Index: alloc.c =================================================================== RCS file: /home/cvs/apache-1.3/src/main/alloc.c,v retrieving revision 1.108 retrieving revision 1.109 diff -u -u -r1.108 -r1.109 --- alloc.c 1999/04/20 16:28:46 1.108 +++ alloc.c 1999/04/27 20:36:30 1.109 @@ -2240,6 +2240,9 @@ *pipe_err = err_fds[0]; } } +#elif defined(TPF) + return (pid = ap_tpf_spawn_child(p, func, data, kill_how, + pipe_in, pipe_out, pipe_err, out_fds, in_fds, err_fds)); #else if ((pid = fork()) < 0) { 1.87 +4 -5 apache-1.3/src/main/buff.c Index: buff.c =================================================================== RCS file: /home/cvs/apache-1.3/src/main/buff.c,v retrieving revision 1.86 retrieving revision 1.87 diff -u -u -r1.86 -r1.87 --- buff.c 1999/02/20 18:12:34 1.86 +++ buff.c 1999/04/27 20:36:30 1.87 @@ -263,7 +263,7 @@ fd_set fds; struct timeval tv; - tpf_process_signals(); + ap_check_signals(); if (fb->flags & B_SOCKET) { alarm(rv = alarm(0)); FD_ZERO(&fds); @@ -271,11 +271,10 @@ tv.tv_sec = rv+1; tv.tv_usec = 0; rv = ap_select(fb->fd_in + 1, &fds, NULL, NULL, &tv); - if (rv < 1) { - tpf_process_signals(); - return(rv); - } + if (rv > 0) + rv = ap_read(fb, buf, nbyte); } + else rv = ap_read(fb, buf, nbyte); #else rv = ap_read(fb, buf, nbyte); 1.77 +34 -1 apache-1.3/src/main/http_log.c Index: http_log.c =================================================================== RCS file: /home/cvs/apache-1.3/src/main/http_log.c,v retrieving revision 1.76 retrieving revision 1.77 diff -u -u -r1.76 -r1.77 --- http_log.c 1999/03/11 16:52:38 1.76 +++ http_log.c 1999/04/27 20:36:31 1.77 @@ -188,9 +188,17 @@ if (*s->error_fname == '|') { FILE *dummy; - +#ifdef TPF + TPF_FORK_CHILD cld; + cld.filename = s->error_fname+1; + cld.subprocess_env = NULL; + cld.prog_type = FORK_NAME; + if (!ap_spawn_child(p, NULL, &cld, + kill_after_timeout, &dummy, NULL, NULL)) { +#else if (!ap_spawn_child(p, error_log_child, (void *)(s->error_fname+1), kill_after_timeout, &dummy, NULL, NULL)) { +#endif /* TPF */ perror("ap_spawn_child"); fprintf(stderr, "Couldn't fork child for ErrorLog process\n"); exit(1); @@ -311,6 +319,18 @@ return; logf = s->error_log; } +#ifdef TPF + else if (tpf_child) { + /* + * If we are doing normal logging, don't log messages that are + * above the server log level unless it is a startup/shutdown notice + */ + if (((level & APLOG_LEVELMASK) != APLOG_NOTICE) && + ((level & APLOG_LEVELMASK) > s->loglevel)) + return; + logf = stderr; + } +#endif /* TPF */ else { /* * If we are doing syslog logging, don't log messages that are @@ -330,6 +350,7 @@ len += ap_snprintf(errstr + len, sizeof(errstr) - len, "[%s] ", priorities[level & APLOG_LEVELMASK].t_name); +#ifndef TPF if (file && (level & APLOG_LEVELMASK) == APLOG_DEBUG) { #ifdef _OSD_POSIX char tmp[256]; @@ -352,6 +373,7 @@ len += ap_snprintf(errstr + len, sizeof(errstr) - len, "%s(%d): ", file, line); } +#endif /* TPF */ if (r) { /* XXX: TODO: add a method of selecting whether logged client * addresses are in dotted quad or resolved form... dotted @@ -455,6 +477,8 @@ * something, even an empty string, into the "error-notes" cell * before calling this routine. */ + va_end(args); + va_start(args,fmt); if (((level & APLOG_LEVELMASK) <= APLOG_WARNING) && (ap_table_get(r->notes, "error-notes") == NULL)) { ap_table_setn(r->notes, "error-notes", @@ -718,9 +742,18 @@ { piped_log *pl; FILE *dummy; +#ifdef TPF + TPF_FORK_CHILD cld; + cld.filename = (char *)program; + cld.subprocess_env = NULL; + cld.prog_type = FORK_NAME; + if (!ap_spawn_child (p, NULL, &cld, + kill_after_timeout, &dummy, NULL, NULL)){ +#else if (!ap_spawn_child(p, piped_log_child, (void *)program, kill_after_timeout, &dummy, NULL, NULL)) { +#endif /* TPF */ perror("ap_spawn_child"); fprintf(stderr, "Couldn't fork child for piped log process\n"); exit (1); 1.432 +196 -21 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.431 retrieving revision 1.432 diff -u -u -r1.431 -r1.432 --- http_main.c 1999/04/21 18:08:05 1.431 +++ http_main.c 1999/04/27 20:36:31 1.432 @@ -343,6 +343,11 @@ static int my_child_num; #endif +#ifdef TPF +int tpf_child = 0; +char tpf_server_name[INETD_SERVNAME_LENGTH+1]; +#endif /* TPF */ + scoreboard *ap_scoreboard_image = NULL; /* @@ -947,6 +952,38 @@ } } +#elif defined(USE_TPF_CORE_SERIALIZED_ACCEPT) + +static int tpf_core_held; + +static void accept_mutex_cleanup(void *foo) +{ + if(tpf_core_held) + coruc(RESOURCE_KEY); +} + +#define accept_mutex_init(x) + +static void accept_mutex_child_init(pool *p) +{ + ap_register_cleanup(p, NULL, accept_mutex_cleanup, ap_null_cleanup); + tpf_core_held = 0; +} + +static void accept_mutex_on(void) +{ + corhc(RESOURCE_KEY); + tpf_core_held = 1; + ap_check_signals(); +} + +static void accept_mutex_off(void) +{ + coruc(RESOURCE_KEY); + tpf_core_held = 0; + ap_check_signals(); +} + #else /* Default --- no serialization. Other methods *could* go here, * as #elifs... @@ -1184,6 +1221,7 @@ /* Just note the timeout in our scoreboard, no need to call the system. * We also note that the virtual time has gone forward. */ + ap_check_signals(); old = ap_scoreboard_image->servers[my_child_num].timeout_len; ap_scoreboard_image->servers[my_child_num].timeout_len = x; ++ap_scoreboard_image->servers[my_child_num].cur_vtime; @@ -1269,6 +1307,7 @@ API_EXPORT(void) ap_kill_timeout(request_rec *dummy) { + ap_check_signals(); ap_set_callback_and_alarm(NULL, 0); timeout_req = NULL; timeout_name = NULL; @@ -1899,6 +1938,37 @@ { } +#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; @@ -1947,6 +2017,9 @@ if (scoreboard_fd != -1) ap_pclosef(p, scoreboard_fd); +#ifdef TPF + ap_scoreboard_fname = ap_server_root_relative(p, ap_scoreboard_fname); +#endif /* TPF */ scoreboard_fd = ap_popenf(p, ap_scoreboard_fname, O_CREAT | O_BINARY | O_RDWR, 0666); if (scoreboard_fd == -1) { perror(ap_scoreboard_fname); @@ -2039,6 +2112,8 @@ if (child_num < 0) return -1; + ap_check_signals(); + ap_sync_scoreboard_image(); ss = &ap_scoreboard_image->servers[child_num]; old_status = ss->status; @@ -2849,7 +2924,7 @@ exit(1); } #elif defined(OS2) || defined(TPF) - /* OS/2 don't support process group IDs */ + /* OS/2 and TPF don't support process group IDs */ pgrp = getpid(); #elif defined(MPE) /* MPE uses negative pid for process group */ @@ -2915,8 +2990,8 @@ else name = ap_user_name; -#ifndef OS2 - /* OS/2 dosen't support groups. */ +#if !defined(OS2) && !defined(TPF) + /* OS/2 and TPF don't support groups. */ /* Reset `groups' attributes. */ @@ -2992,7 +3067,7 @@ return conn; } -#if defined(TCP_NODELAY) && !defined(MPE) +#if defined(TCP_NODELAY) && !defined(MPE) && !defined(TPF) static void sock_disable_nagle(int s) { /* The Nagle algorithm says that we should delay sending partial @@ -3062,6 +3137,9 @@ s = ap_slack(s, AP_SLACK_HIGH); ap_note_cleanups_for_socket(p, s); /* arrange to close on exec or restart */ +#ifdef TPF + os_note_additional_cleanups(p, s); +#endif /* TPF */ #endif #ifndef MPE @@ -3076,8 +3154,7 @@ } #endif /*_OSD_POSIX*/ one = 1; -#ifndef BEOS -/* BeOS does not support SO_KEEPALIVE */ +#ifdef SO_KEEPALIVE if (setsockopt(s, SOL_SOCKET, SO_KEEPALIVE, (char *) &one, sizeof(int)) < 0) { ap_log_error(APLOG_MARK, APLOG_CRIT, server_conf, "make_sock: for %s, setsockopt: (SO_KEEPALIVE)", addr); @@ -3158,7 +3235,7 @@ #endif ap_unblock_alarms(); -#ifndef WIN32 +#ifdef CHECK_FD_SETSIZE /* protect various fd_sets */ if (s >= FD_SETSIZE) { ap_log_error(APLOG_MARK, APLOG_NOERRNO|APLOG_WARNING, NULL, @@ -3601,6 +3678,11 @@ #endif #endif signal(SIGALRM, alrm_handler); +#ifdef TPF + signal(SIGHUP, just_die); + signal(SIGTERM, just_die); + signal(SIGUSR1, just_die); +#endif /* TPF */ #ifdef OS2 /* Stop Ctrl-C/Ctrl-Break signals going to child processes */ @@ -3690,7 +3772,7 @@ usr1_just_die = 0; for (;;) { clen = sizeof(sa_client); - csd = accept(sd, &sa_client, &clen); + csd = ap_accept(sd, &sa_client, &clen); if (csd >= 0 || errno != EINTR) break; if (deferred_die) { @@ -3754,11 +3836,22 @@ case ENETUNREACH: #endif break; - +#ifdef TPF + case EINACT: + ap_log_error(APLOG_MARK, APLOG_EMERG, 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); + clean_child_exit(APEXIT_CHILDFATAL); +#else + default: ap_log_error(APLOG_MARK, APLOG_ERR, server_conf, "accept: (client socket)"); clean_child_exit(1); +#endif } } @@ -3779,6 +3872,11 @@ SAFE_ACCEPT(accept_mutex_off()); /* unlock after "accept" */ +#ifdef TPF + if (csd == 0) /* 0 is invalid socket for TPF */ + continue; +#endif + /* We've got a socket, let's at least process one request off the * socket before we accept a graceful restart request. */ @@ -3787,6 +3885,7 @@ ap_note_cleanups_for_fd(ptrans, csd); /* protect various fd_sets */ +#ifdef CHECK_CSD_SETSIZE if (csd >= FD_SETSIZE) { ap_log_error(APLOG_MARK, APLOG_NOERRNO|APLOG_WARNING, NULL, "[csd] filedescriptor (%u) larger than FD_SETSIZE (%u) " @@ -3794,6 +3893,7 @@ "larger FD_SETSIZE", csd, FD_SETSIZE); continue; } +#endif /* * We now have a connection, so set it up with the appropriate @@ -3833,6 +3933,7 @@ ap_note_cleanups_for_fd(ptrans, dupped_csd); /* protect various fd_sets */ +#ifdef CHECK_CSD_SETSIZE if (dupped_csd >= FD_SETSIZE) { ap_log_error(APLOG_MARK, APLOG_NOERRNO|APLOG_WARNING, NULL, "[dupped_csd] filedescriptor (%u) larger than FD_SETSIZE (%u) " @@ -3841,6 +3942,7 @@ continue; } #endif +#endif ap_bpushfd(conn_io, csd, dupped_csd); current_conn = new_connection(ptrans, server_conf, conn_io, @@ -3923,6 +4025,36 @@ } } +#ifdef TPF +static void reset_tpf_listeners(APACHE_TPF_INPUT *input_parms) +{ + int count; + listen_rec *lr; + + count = 0; + listenmaxfd = -1; + FD_ZERO(&listenfds); + lr = ap_listeners; + + for(;;) { + lr->fd = input_parms->listeners[count]; + if(lr->fd >= 0) { + FD_SET(lr->fd, &listenfds); + if(lr->fd > listenmaxfd) + listenmaxfd = lr->fd; + } + if(lr->next == NULL) + break; + lr = lr->next; + count++; + } + lr->next = ap_listeners; + head_listener = ap_listeners; + close_unused_listeners(); +} + +#endif /* TPF */ + static int make_child(server_rec *s, int slot, time_t now) { int pid; @@ -3934,7 +4066,9 @@ if (one_process) { signal(SIGHUP, just_die); signal(SIGINT, just_die); +#ifdef SIGQUIT signal(SIGQUIT, SIG_DFL); +#endif signal(SIGTERM, just_die); child_main(slot); } @@ -3946,12 +4080,14 @@ (void) ap_update_child_status(slot, SERVER_STARTING, (request_rec *) NULL); -#ifndef _OSD_POSIX - if ((pid = fork()) == -1) { -#else /*_OSD_POSIX*/ +#ifdef _OSD_POSIX /* BS2000 requires a "special" version of fork() before a setuid() call */ if ((pid = os_fork(ap_user_name)) == -1) { -#endif /*_OSD_POSIX*/ +#elif defined(TPF) + if ((pid = os_fork(s, slot)) == -1) { +#else + if ((pid = fork()) == -1) { +#endif ap_log_error(APLOG_MARK, APLOG_ERR, s, "fork: Unable to fork new process"); /* fork didn't succeed. Fix the scoreboard or else @@ -4385,6 +4521,11 @@ } perform_idle_server_maintenance(); +#ifdef TPF + shutdown_pending = os_check_server(tpf_server_name); + ap_check_signals(); + sleep(1); +#endif /*TPF */ } if (shutdown_pending) { @@ -4497,6 +4638,12 @@ SOCKSinit(argv[0]); #endif +#ifdef TPF + APACHE_TPF_INPUT input_parms; + ecbptr()->ebrout = PRIMECRAS; + input_parms = * (APACHE_TPF_INPUT *)(&(ecbptr()->ebw000)); +#endif + MONCONTROL(0); common_init(); @@ -4513,9 +4660,8 @@ ap_setup_prelinked_modules(); -#ifndef TPF while ((c = getopt(argc, argv, - "D:C:c:Xd:f:vVlLR:Sth" + "D:C:c:xXd:f:vVlLR:Sth" #ifdef DEBUG_SIGSTOP "Z:" #endif @@ -4558,6 +4704,12 @@ case 'X': ++one_process; /* Weird debugging mode. */ break; +#ifdef TPF + case 'x': + os_tpf_child(&input_parms); + set_signals(); + break; +#endif #ifdef DEBUG_SIGSTOP case 'Z': raise_sigstop_flags = atoi(optarg); @@ -4584,7 +4736,6 @@ usage(argv[0]); } } -#endif /* TPF */ ap_suexec_enabled = init_suexec(); server_conf = ap_read_config(pconf, ptrans, ap_server_confname); @@ -4599,6 +4750,7 @@ child_timeouts = !ap_standalone || one_process; +#ifndef TPF if (ap_standalone) { ap_open_logs(server_conf, pconf); ap_set_version(); @@ -4606,6 +4758,32 @@ version_locked++; STANDALONE_MAIN(argc, argv); } +#else + if (ap_standalone) { + if(!tpf_child) { + memcpy(tpf_server_name, input_parms.inetd_server.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++; + if(tpf_child) { + copy_listeners(pconf); + reset_tpf_listeners(&input_parms); + server_conf->error_log = NULL; +#ifdef SCOREBOARD_FILE + scoreboard_fd = input_parms.scoreboard_fd; + ap_scoreboard_image = &_scoreboard_image; +#else /* must be USE_TPF_SCOREBOARD or USE_SHMGET_SCOREBOARD */ + ap_scoreboard_image = (scoreboard *)input_parms.scoreboard_heap; +#endif + child_main(input_parms.slot); + } + else + STANDALONE_MAIN(argc, argv); + } +#endif else { conn_rec *conn; request_rec *r; @@ -4646,15 +4824,12 @@ } #ifdef TPF - signal(SIGALRM, alrm_handler); - ecbptr()->ebrout = PRIMECRAS; -#endif /* TPF */ - -#ifdef TPF /* TPF only passes the incoming socket number from the internet daemon in ebw000 */ sock_in = * (int*)(&(ecbptr()->ebw000)); sock_out = * (int*)(&(ecbptr()->ebw000)); +/* TPF also needs a signal set for alarm in inetd mode */ + signal(SIGALRM, alrm_handler); #elif defined(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). 1.265 +3 -1 apache-1.3/src/main/http_protocol.c Index: http_protocol.c =================================================================== RCS file: /home/cvs/apache-1.3/src/main/http_protocol.c,v retrieving revision 1.264 retrieving revision 1.265 diff -u -u -r1.264 -r1.265 --- http_protocol.c 1999/04/20 19:15:41 1.264 +++ http_protocol.c 1999/04/27 20:36:31 1.265 @@ -1972,9 +1972,11 @@ /* Make fb unbuffered and non-blocking */ ap_bsetflag(fb, B_RD, 0); +#ifndef TPF ap_bnonblock(fb, B_RD); +#endif fd = ap_bfileno(fb, B_RD); -#ifndef WIN32 +#ifdef CHECK_FD_SETSIZE if (fd >= FD_SETSIZE) { ap_log_error(APLOG_MARK, APLOG_NOERRNO|APLOG_WARNING, NULL, "send body: filedescriptor (%u) larger than FD_SETSIZE (%u) " 1.38 +1 -1 apache-1.3/src/modules/proxy/proxy_connect.c Index: proxy_connect.c =================================================================== RCS file: /home/cvs/apache-1.3/src/modules/proxy/proxy_connect.c,v retrieving revision 1.37 retrieving revision 1.38 diff -u -u -r1.37 -r1.38 --- proxy_connect.c 1999/02/07 20:48:31 1.37 +++ proxy_connect.c 1999/04/27 20:36:34 1.38 @@ -187,7 +187,7 @@ return HTTP_INTERNAL_SERVER_ERROR; } -#ifndef WIN32 +#ifdef CHECK_FD_SETSIZE if (sock >= FD_SETSIZE) { ap_log_error(APLOG_MARK, APLOG_NOERRNO|APLOG_WARNING, NULL, "proxy_connect_handler: filedescriptor (%u) " 1.91 +12 -0 apache-1.3/src/modules/standard/mod_cgi.c Index: mod_cgi.c =================================================================== RCS file: /home/cvs/apache-1.3/src/modules/standard/mod_cgi.c,v retrieving revision 1.90 retrieving revision 1.91 diff -u -u -r1.90 -r1.91 --- mod_cgi.c 1999/04/08 11:36:34 1.90 +++ mod_cgi.c 1999/04/27 20:36:35 1.91 @@ -275,6 +275,9 @@ struct cgi_child_stuff { +#ifdef TPF + TPF_FORK_CHILD t; +#endif request_rec *r; int nph; int debug; @@ -325,6 +328,9 @@ * NB only ISINDEX scripts get decoded arguments. */ +#ifdef TPF + return (0); +#else ap_cleanup_for_exec(); child_pid = ap_call_exec(r, pinfo, argv0, env, 0); @@ -346,6 +352,7 @@ /* NOT REACHED */ return (0); #endif +#endif /* TPF */ } static int cgi_handler(request_rec *r) @@ -419,6 +426,11 @@ cld.r = r; cld.nph = nph; cld.debug = conf->logname ? 1 : 0; +#ifdef TPF + cld.t.filename = r->filename; + cld.t.subprocess_env = r->subprocess_env; + cld.t.prog_type = FORK_FILE; +#endif /* TPF */ #ifdef CHARSET_EBCDIC /* XXX:@@@ Is the generated/included output ALWAYS in text/ebcdic format? */ 1.113 +12 -0 apache-1.3/src/modules/standard/mod_include.c Index: mod_include.c =================================================================== RCS file: /home/cvs/apache-1.3/src/modules/standard/mod_include.c,v retrieving revision 1.112 retrieving revision 1.113 diff -u -u -r1.112 -r1.113 --- mod_include.c 1999/04/08 11:36:36 1.112 +++ mod_include.c 1999/04/27 20:36:35 1.113 @@ -765,6 +765,9 @@ } typedef struct { +#ifdef TPF + TPF_FORK_CHILD t; +#endif request_rec *r; char *s; } include_cmd_arg; @@ -818,6 +821,9 @@ #ifdef DEBUG_INCLUDE_CMD fprintf(dbg, "Attempting to exec '%s'\n", s); #endif +#ifdef TPF + return (0); +#else ap_cleanup_for_exec(); /* set shellcmd flag to pass arg to SHELL_PATH */ child_pid = ap_call_exec(r, pinfo, s, ap_create_environment(r->pool, env), @@ -840,6 +846,7 @@ /* NOT REACHED */ return (child_pid); #endif /* WIN32 */ +#endif /* TPF */ } static int include_cmd(char *s, request_rec *r) @@ -849,6 +856,11 @@ arg.r = r; arg.s = s; +#ifdef TPF + arg.t.filename = r->filename; + arg.t.subprocess_env = r->subprocess_env; + arg.t.prog_type = FORK_FILE; +#endif if (!ap_bspawn_child(r->pool, include_cmd_child, &arg, kill_after_timeout, NULL, &script_in, NULL)) { 1.2 +3 -2 apache-1.3/src/os/tpf/Makefile.tmpl Index: Makefile.tmpl =================================================================== RCS file: /home/cvs/apache-1.3/src/os/tpf/Makefile.tmpl,v retrieving revision 1.1 retrieving revision 1.2 diff -u -u -r1.1 -r1.2 --- Makefile.tmpl 1998/11/03 22:06:30 1.1 +++ Makefile.tmpl 1999/04/27 20:36:37 1.2 @@ -3,7 +3,7 @@ INCLUDES=$(INCLUDES1) $(INCLUDES0) $(EXTRA_INCLUDES) LDFLAGS=$(LDFLAGS1) $(EXTRA_LDFLAGS) -OBJS= os.o os-inline.o ebcdic.o +OBJS= os.o os-inline.o ebcdic.o cgetop.o LIB= libos.a @@ -35,7 +35,8 @@ && rm Makefile.new $(OBJS): Makefile -os.o: os.c os-inline.c +os.o: os.c os-inline.c $(INCDIR)/ap_config.h ebcdic.o: ebcdic.c +cgetop.o: cgetop.c # DO NOT REMOVE os.o: os.c 1.3 +260 -30 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.2 retrieving revision 1.3 diff -u -u -r1.2 -r1.3 --- os.c 1999/01/01 19:05:29 1.2 +++ os.c 1999/04/27 20:36:38 1.3 @@ -63,7 +63,12 @@ #include "httpd.h" #include "http_core.h" #include "os.h" +#include "scoreboard.h" +#include "http_log.h" +#include "http_conf_globals.h" +static FILE *sock_fp; + /* Check the Content-Type to decide if conversion is needed */ int ap_checkconv(struct request_rec *r) { @@ -87,14 +92,22 @@ if (type && (strncasecmp(type, "text/", 5) == 0 || strncasecmp(type, "message/", 8) == 0)) { if (strncasecmp(type, ASCIITEXT_MAGIC_TYPE_PREFIX, - sizeof(ASCIITEXT_MAGIC_TYPE_PREFIX)-1) == 0) + sizeof(ASCIITEXT_MAGIC_TYPE_PREFIX)-1) == 0){ r->content_type = ap_pstrcat(r->pool, "text/", - type+sizeof(ASCIITEXT_MAGIC_TYPE_PREFIX)-1, - NULL); + type+sizeof(ASCIITEXT_MAGIC_TYPE_PREFIX)-1, NULL); + if (r->method_number == M_PUT) + ap_bsetflag(r->connection->client, B_ASCII2EBCDIC, 0); + } + else /* translate EBCDIC to ASCII */ convert_to_ascii = 1; } + else{ + if (r->method_number == M_PUT) + ap_bsetflag(r->connection->client, B_ASCII2EBCDIC, 0); + /* don't translate non-text files to EBCDIC */ + } /* Enable conversion if it's a text document */ ap_bsetflag(r->connection->client, B_EBCDIC2ASCII, convert_to_ascii); @@ -103,51 +116,58 @@ int tpf_select(int maxfds, fd_set *reads, fd_set *writes, fd_set *excepts, struct timeval *tv) { - int sockets[24]; +/* 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; int no_writes = 0; int no_excepts = 0; int timeout = 0; - int counter = 0; - int i; - fd_set *temp; + int rv; if(maxfds) { - if(reads) - temp = reads; - else if(writes) - temp = writes; - else if(excepts) - temp = excepts; + if(tv) + timeout = tv->tv_sec * 1000 + tv->tv_usec; + sockets[0] = maxfds-1; + no_reads++; + } else - temp = NULL; + sockets[0] = 0; - for(i=0; i<maxfds; i++) { - if(FD_ISSET(i,temp)) { - sockets[counter] = i; - counter++; - } - } + ap_check_signals(); + rv = select(sockets, no_reads, no_writes, no_excepts, timeout); + ap_check_signals(); - if(tv) - timeout = tv->tv_sec * 1000 + tv->tv_usec; + return rv; - if(reads) - no_reads = counter; - else if(writes) - no_writes = counter; - else if(excepts) - no_excepts = counter; +} + +int tpf_accept(int sockfd, struct sockaddr *peer, int *paddrlen) +{ + int socks[1]; + int rv; + + ap_check_signals(); + socks[0] = sockfd; + rv = select(socks, 1, 0, 0, 1000); + errno = sock_errno(); + if(rv>0) { + ap_check_signals(); + rv = accept(sockfd, peer, paddrlen); + errno = sock_errno(); } - return select(sockets, no_reads, no_writes, no_excepts, timeout); + return rv; } -/* pipe is not yet available on TPF */ +#ifndef __PIPE_ int pipe(int fildes[2]) { errno = ENOSYS; return(-1); } +#endif /* fork and exec functions are not defined on TPF due to the implementation of tpf_fork() */ @@ -175,3 +195,213 @@ errno = ENOSYS; return(-1); } + +int execvp(const char *file, char *const argv[]) +{ + errno = ENOSYS; + return(-1); +} + + + +int ap_tpf_spawn_child(pool *p, int (*func) (void *, child_info *), + void *data, enum kill_conditions kill_how, + int *pipe_in, int *pipe_out, int *pipe_err, + int out_fds[], int in_fds[], int err_fds[]) + +{ + + int i, temp_out, temp_in, temp_err, save_errno, pid, result=0; + int fd_flags_out, fd_flags_in, fd_flags_err; + struct tpf_fork_input fork_input; + TPF_FORK_CHILD *cld = (TPF_FORK_CHILD *) data; + array_header *env_arr = ap_table_elts ((array_header *) cld->subprocess_env); + table_entry *elts = (table_entry *) env_arr->elts; + + + + if (func) { + if (result=func(data, NULL)) { + return 0; /* error from child function */ + } + } + + if (pipe_out) { + fd_flags_out = fcntl(out_fds[0], F_GETFD); + fcntl(out_fds[0], F_SETFD, FD_CLOEXEC); + temp_out = dup(STDOUT_FILENO); + fcntl(temp_out, F_SETFD, FD_CLOEXEC); + dup2(out_fds[1], STDOUT_FILENO); + } + + + if (pipe_in) { + fd_flags_in = fcntl(in_fds[1], F_GETFD); + fcntl(in_fds[1], F_SETFD, FD_CLOEXEC); + temp_in = dup(STDIN_FILENO); + fcntl(temp_in, F_SETFD, FD_CLOEXEC); + dup2(in_fds[0], STDIN_FILENO); + } + + if (pipe_err) { + fd_flags_err = fcntl(err_fds[0], F_GETFD); + fcntl(err_fds[0], F_SETFD, FD_CLOEXEC); + temp_err = dup(STDERR_FILENO); + fcntl(temp_err, F_SETFD, FD_CLOEXEC); + dup2(err_fds[1], STDERR_FILENO); + } + + if (cld->subprocess_env) { + for (i = 0; i < env_arr->nelts; ++i) { + if (!elts[i].key) + continue; + setenv (elts[i].key, elts[i].val, 1); + } + } + + fork_input.program = (const char*) cld->filename; + fork_input.prog_type = cld->prog_type; + fork_input.istream = TPF_FORK_IS_BALANCE; + fork_input.ebw_data_length = 0; + fork_input.ebw_data = NULL; + fork_input.parm_data = NULL; + + + if ((pid = tpf_fork(&fork_input)) < 0) { + save_errno = errno; + if (pipe_out) { + close(out_fds[0]); + } + if (pipe_in) { + close(in_fds[1]); + } + if (pipe_err) { + close(err_fds[0]); + } + errno = save_errno; + pid = 0; + } + + if (cld->subprocess_env) { + for (i = 0; i < env_arr->nelts; ++i) { + if (!elts[i].key) + continue; + unsetenv (elts[i].key); + } + } + + if (pipe_out) { + close(out_fds[1]); + dup2(temp_out, STDOUT_FILENO); + close(temp_out); + fcntl(out_fds[0], F_SETFD, fd_flags_out); + } + + if (pipe_in) { + close(in_fds[0]); + dup2(temp_in, STDIN_FILENO); + close(temp_in); + fcntl(in_fds[1], F_SETFD, fd_flags_in); + } + + + if (pipe_err) { + close(err_fds[1]); + dup2(temp_err, STDERR_FILENO); + close(temp_err); + fcntl(err_fds[0], F_SETFD, fd_flags_err); + } + + + if (pid) { + + ap_note_subprocess(p, pid, kill_how); + + if (pipe_out) { + *pipe_out = out_fds[0]; + } + if (pipe_in) { + *pipe_in = in_fds[1]; + } + if (pipe_err) { + *pipe_err = err_fds[0]; + } + } + + return pid; + +} + +pid_t os_fork(server_rec *s, int slot) +{ + struct tpf_fork_input fork_input; + APACHE_TPF_INPUT input_parms; + int count; + listen_rec *lr; + + fflush(stdin); + if (dup2(fileno(sock_fp), STDIN_FILENO) == -1) + ap_log_error(APLOG_MARK, APLOG_CRIT, s, + "unable to replace stdin with sock device driver"); + fflush(stdout); + if (dup2(fileno(sock_fp), STDOUT_FILENO) == -1) + 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 */ + input_parms.scoreboard_heap = ap_scoreboard_image; +#endif + + lr = ap_listeners; + count = 0; + do { + input_parms.listeners[count] = lr->fd; + lr = lr->next; + count++; + } while(lr != ap_listeners); + + input_parms.slot = slot; + input_parms.restart_time = ap_restart_time; + fork_input.ebw_data = &input_parms; + fork_input.program = ap_server_argv0; + fork_input.prog_type = TPF_FORK_NAME; + fork_input.istream = TPF_FORK_IS_BALANCE; + fork_input.ebw_data_length = sizeof(input_parms); + fork_input.parm_data = "-x"; + return tpf_fork(&fork_input); +} + +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 { + current_acn = (int *)cinfc_fast(CINFC_CMMACNUM); + if(ecbp2()->ce2acn != *current_acn) + return 1; + } + #endif + return 0; +} + +void os_note_additional_cleanups(pool *p, int sd) { + char sockfilename[50]; + /* write the socket to file so that TPF socket device driver will close socket in case + we happen to abend. */ + sprintf(sockfilename, "/dev/tpf.socket.file/%.8X", sd); + sock_fp = fopen(sockfilename, "r+"); + ap_note_cleanups_for_file(p, sock_fp); /* arrange to close on exec or restart */ + fcntl(sd,F_SETFD,FD_CLOEXEC); +} + +void os_tpf_child(APACHE_TPF_INPUT *input_parms) { + tpf_child = 1; + ap_my_generation = input_parms->generation; + ap_restart_time = input_parms->restart_time; +} + + 1.6 +50 -55 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.5 retrieving revision 1.6 diff -u -u -r1.5 -r1.6 --- os.h 1999/01/08 23:46:45 1.5 +++ os.h 1999/04/27 20:36:38 1.6 @@ -20,9 +20,6 @@ * part of the header */ #define INLINE extern ap_inline - -INLINE int ap_os_is_path_absolute(const char *file); - #include "os-inline.c" #endif @@ -30,7 +27,7 @@ /* Compiler does not support inline, so prototype the inlineable functions * as normal */ -extern int ap_os_is_path_absolute(const char *file); +extern int ap_os_is_path_absolute(const char *f); #endif /* Other ap_os_ routines not used by this platform */ @@ -42,70 +39,68 @@ struct request_rec; extern int ap_checkconv(struct request_rec *r); -#ifdef FD_SETSIZE -#undef FD_SETSIZE -#endif +#include <strings.h> +#ifndef __strings_h #define FD_SETSIZE 2048 -#ifdef __FD_MASK -#undef __FD_MASK -#endif - -typedef long __FD_MASK; - -#ifdef __NBBY -#undef __NBBY -#endif - -#define __NBBY 8 /* number of bits in a byte */ - -#ifdef __NFDBITS -#undef __NFDBITS -#endif +typedef long fd_mask; -#define __NFDBITS (sizeof(__FD_MASK) * __NBBY) +#define NBBY 8 /* number of bits in a byte */ +#define NFDBITS (sizeof(fd_mask) * NBBY) +#define howmany(x, y) (((x)+((y)-1))/(y)) -#ifndef __howmany -#define __howmany(x, y) (((x)+((y)-1))/(y)) -#endif - typedef struct fd_set { - __FD_MASK fds_bits [__howmany(FD_SETSIZE, __NFDBITS)]; + fd_mask fds_bits [howmany(FD_SETSIZE, NFDBITS)]; } fd_set; - -#define FD_SET(n, p)((p)->fds_bits[(n)/__NFDBITS] |= (1 <<((n) % __NFDBITS))) -#define FD_CLR(n, p)((p)->fds_bits[(n)/__NFDBITS] &= ~(1 << ((n) % __NFDBITS))) - -#define FD_ISSET(n, p)((p)->fds_bits[(n)/__NFDBITS] & (1 <<((n) % __NFDBITS))) - +#define FD_CLR(n, p)((p)->fds_bits[(n)/NFDBITS] &= ~(1 << ((n) % NFDBITS))) +#define FD_ISSET(n, p)((p)->fds_bits[(n)/NFDBITS] & (1 <<((n) % NFDBITS))) #define FD_ZERO(p) memset((char *)(p), 0, sizeof(*(p))) +#endif +#ifdef FD_SET +#undef FD_SET +#define FD_SET(n, p) (0) +#endif -#define SIGPIPE 13 -#define SIGQUIT 24 -#define SO_KEEPALIVE 0x0008 +#define RESOURCE_KEY ((void*) 0xC1C2C1C3) /* TPF doesn't have, or need, tzset (it is used in mod_expires.c) */ #define tzset() - -#include <stdarg.h> -#undef va_list -#undef va_start -#undef va_arg -#undef va_end - -typedef char *va_list; -#define __va_promote(type) (((sizeof(type) + sizeof(int) - 1) \ - / sizeof(int)) * sizeof(int)) - -#define va_start(ap, last) (ap = ((char *)&(last) + __va_promote(last))) - -#define va_arg(ap, type) ((type *)(ap += sizeof(type) < sizeof(int) ? \ - (abort(), 0) : sizeof(type)))[-1] - -#define va_end(ap) - +#include <i$netd.h> +struct apache_input { + INETD_SERVER_INPUT inetd_server; + 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]; + time_t restart_time; +}; + +typedef struct apache_input APACHE_TPF_INPUT; + +typedef struct tpf_fork_child { + char *filename; + enum { FORK_NAME = 1, FORK_FILE = 2 } prog_type; + void *subprocess_env; +}TPF_FORK_CHILD; + +int tpf_accept(int sockfd, struct sockaddr *peer, int *paddrlen); +extern int tpf_child; + +struct server_rec; +pid_t os_fork(struct server_rec *s, int slot); +int os_check_server(char *server); +extern char *ap_server_argv0; +extern int scoreboard_fd; +#include <signal.h> +#ifndef SIGPIPE +#define SIGPIPE 14 +#endif +#ifdef NSIG +#undef NSIG +#endif #endif /*! APACHE_OS_H*/ 1.1 apache-1.3/src/os/tpf/cgetop.c Index: cgetop.c =================================================================== /**********************************************************************/ /* */ /* Copyright (c) 1987, 1993, 1994 */ /* The Regents of the University of California. All rights reserved. */ /* */ /* Redistribution and use in source and binary forms, with or without */ /* modification, are permitted provided that the following conditions */ /* are met: */ /* */ /* 1. Redistributions of source code must retain the above copyright */ /* notice, this list of conditions and the following disclaimer. */ /* 2. Redistributions in binary form must reproduce the above */ /* copyright notice, this list of conditions and the following */ /* disclaimer in the documentation and/or other materials provided */ /* with the distribution. */ /* 3. All advertising materials mentioning features or use of this */ /* software must display the following acknowledgement: */ /* This product includes software developed by the University of */ /* California, Berkeley and its contributors. */ /* 4. Neither the name of the University nor the names of its */ /* contributors may be used to endorse or promote products derived */ /* from this software without specific prior written permission. */ /* */ /* THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS''*/ /* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED */ /* TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A */ /* PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS */ /* OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, */ /* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT */ /* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF */ /* USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND*/ /* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, */ /* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT */ /* OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF */ /* SUCH DAMAGE. */ /* */ /**********************************************************************/ #if defined(LIBC_SCCS) && !defined(lint) static char sccsid[] = "@(#)getopt.c 8.2 (Berkeley) 4/2/94"; #endif /* LIBC_SCCS and not lint */ #include <stdio.h> #include <stdlib.h> #include <string.h> #ifndef __CGETOP_ extern char *optarg; extern int opterr, optind, optopt; int getopt (int, char * const *, const char *); char *group_from_gid (unsigned long, int); char *user_from_uid (unsigned long, int); extern int optreset; #endif int opterr = 1, /* if error message should be */ /* printed */ optind = 1, /* index into parent argv vector */ optopt, /* character checked for validity */ optreset; /* reset getopt */ char *optarg; /* argument associated with */ /* option */ #define BADCH (int)'?' #define BADARG (int)':' #define EMSG "" /**********************************************************************/ /* */ /* getopt -- */ /* Parse argc/argv argument vector. */ /* */ /**********************************************************************/ int getopt(nargc, nargv, ostr) int nargc; char * const *nargv; const char *ostr; { /* removed -- BSD2TPF -- crt0 does not create __progname on TPF */ /* extern char *__progname; */ /* end of removed -- BSD2TPF */ static char *place = EMSG; /* option letter processing */ char *oli; /* option letter list index */ /* added -- BSD2TPF -- emulate BSD crt0 function to set __progname */ char empty = '\0'; char *__progname = ∅ if (nargv[0]) { if ((__progname = strrchr(nargv[0], '/')) == NULL) { __progname = nargv[0]; } else { ++__progname; } } /* end of added -- BSD2TPF */ if (optreset || !*place) { /* update scanning pointer */ optreset = 0; if (optind >= nargc || *(place = nargv[optind]) != '-') { place = EMSG; return (EOF); } if (place[1] && *++place == '-') { /* found "--" */ ++optind; place = EMSG; return (EOF); } } /* option letter okay? */ if ((optopt = (int)*place++) == (int)':' || !(oli = strchr(ostr, optopt))) { /* if the user didn't */ /* specify '-' as an option, */ /* assume it means EOF. */ if (optopt == (int)'-') return (EOF); if (!*place) ++optind; if (opterr && *ostr != ':') (void)fprintf(stderr, "%s: illegal option -- %c\n", __progname, optopt); return (BADCH); } if (*++oli != ':') { /* don't need argument */ optarg = NULL; if (!*place) ++optind; } else { /* need an argument */ if (*place) /* no white space */ optarg = place; else if (nargc <= ++optind) { /* no arg */ place = EMSG; if (*ostr == ':') return (BADARG); if (opterr) (void)fprintf(stderr, "%s: option requires an argument -- %c\n", __progname, optopt); return (BADCH); } else /* white space */ optarg = nargv[optind]; place = EMSG; ++optind; } return (optopt); /* dump back option letter */ }