You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@httpd.apache.org by Joe Moenich <mo...@us.ibm.com> on 1998/10/12 18:30:41 UTC

[PATCH] TPF http_main.c

TPF implementation of select, ignore alarms, provide an out if user attempts to
run standalone with this implementation.  Include TPF in inetd path of REALMAIN.

Index: http_main.c
===================================================================
RCS file: /apache/apache/src/main/http_main.c,v
retrieving revision 1.1.1.1
diff -a -b -C3 -r1.1.1.1 http_main.c
*** http_main.c 1998/10/12 09:15:41     1.1.1.1
--- http_main.c 1998/10/12 09:18:10
***************
*** 116,122 ****
  #endif
  #ifdef WIN32
  #include "../os/win32/getopt.h"
! #elif !defined(BEOS)
  #include <netinet/tcp.h>
  #endif

--- 116,122 ----
  #endif
  #ifdef WIN32
  #include "../os/win32/getopt.h"
! #elif !defined(BEOS) && !defined(TPF)
  #include <netinet/tcp.h>
  #endif

***************
*** 1102,1107 ****
--- 1102,1108 ----
   * which is itself being cleared); we have to support that here.
   */

+ #ifndef TPF
  API_EXPORT(void) ap_block_alarms(void)
  {
      ++alarms_blocked;
***************
*** 1129,1134 ****
--- 1130,1136 ----
      }
      }
  }
+ #endif /* TPF */


  static APACHE_TLS void (*volatile alarm_fn) (int) = NULL;
***************
*** 2174,2180 ****
--- 2176,2186 ----
      tv.tv_sec = waittime / 1000000;
      tv.tv_usec = waittime % 1000000;
      waittime = waittime * 4;
+ #ifdef TPF
+     ap_select(NULL, 0, 0, 0, tv.tv_sec*1000000);
+ #else
      ap_select(0, NULL, NULL, NULL, &tv);
+ #endif /* TPF */

      /* now see who is done */
      not_dead_yet = 0;
***************
*** 2354,2360 ****
--- 2360,2370 ----
  #endif
      tv.tv_sec = SCOREBOARD_MAINTENANCE_INTERVAL / 1000000;
      tv.tv_usec = SCOREBOARD_MAINTENANCE_INTERVAL % 1000000;
+ #ifdef TPF
+     ap_select(NULL, 0, 0, 0, tv.tv_sec * 1000000);
+ #else
      ap_select(0, NULL, NULL, NULL, &tv);
+ #endif /* TPF */
      return -1;
  #endif /* WIN32 */
  }
***************
*** 2781,2787 ****
      int x;

      chdir("/");
! #if !defined(MPE) && !defined(OS2)
  /* Don't detach for MPE because child processes can't survive the death of
     the parent. */
      if ((x = fork()) > 0)
--- 2791,2797 ----
      int x;

      chdir("/");
! #if !defined(MPE) && !defined(OS2) && !defined(TPF)
  /* Don't detach for MPE because child processes can't survive the death of
     the parent. */
      if ((x = fork()) > 0)
***************
*** 2805,2812 ****
        fprintf(stderr, "httpd: setpgrp or getpgrp failed\n");
        exit(1);
      }
! #elif defined(OS2)
!     /* OS/2 don't support process group IDs */
      pgrp = getpid();
  #elif defined(MPE)
      /* MPE uses negative pid for process group */
--- 2815,2822 ----
      fprintf(stderr, "httpd: setpgrp or getpgrp failed\n");
      exit(1);
      }
! #elif defined(OS2) || defined(TPF)
!     /* OS/2 and TPF don't support process group IDs */
      pgrp = getpid();
  #elif defined(MPE)
      /* MPE uses negative pid for process group */
***************
*** 3616,3622 ****
--- 3626,3636 ----
          if (ap_listeners->next != ap_listeners) {
          /* more than one socket */
          memcpy(&main_fds, &listenfds, sizeof(fd_set));
+ #ifdef TPF
+         srv = ap_select(&main_fds.fds_bits[0], listenmaxfd, 0, 0, 0);
+ #else
          srv = ap_select(listenmaxfd + 1, &main_fds, NULL, NULL, NULL);
+ #endif /* TPF */

          if (srv < 0 && errno != EINTR) {
              /* Single Unix documents select as returning errnos
***************
*** 4097,4103 ****
--- 4111,4127 ----
              idle_count, total_non_dead);
          }
          for (i = 0; i < free_length; ++i) {
+ #ifdef TPF
+         if(make_child(server_conf, free_slots[i], now) == -1) {
+             if(free_length == 1) {
+                 shutdown_pending = 1;
+                 ap_log_error(APLOG_MARK, APLOG_EMERG, server_conf,
+                 "No active child processes: shutting down");
+             }
+         }
+ #else
          make_child(server_conf, free_slots[i], now);
+ #endif /* TPF */
          }
          /* 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
***************
*** 4422,4427 ****
--- 4446,4453 ----
  {
      int c;
      int configtestonly = 0;
+     int sock_in;
+     int sock_out;

  #ifdef SecureWare
      if (set_auth_parameters(argc, argv) < 0)
***************
*** 4447,4452 ****
--- 4473,4479 ----

      ap_setup_prelinked_modules();

+ #ifndef TPF
      while ((c = getopt(argc, argv,
                                    "D:C:c:Xd:f:vVhlL:St"
  #ifdef DEBUG_SIGSTOP
***************
*** 4515,4520 ****
--- 4542,4548 ----
            usage(argv[0]);
        }
      }
+ #endif /* TPF */

      ap_suexec_enabled = init_suexec();
      server_conf = ap_read_config(pconf, ptrans, ap_server_confname);
***************
*** 4570,4602 ****
            exit(0);
        }

        l = sizeof(sa_client);
!       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) {
            perror("getsockname");
            fprintf(stderr, "Error getting local address\n");
            exit(1);
        }
        server_conf->port = ntohs(((struct sockaddr_in *) &sa_server)->sin_port
        cio = ap_bcreate(ptrans, B_RDWR | B_SOCKET);
! #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
!    functionality be documented, and then to enhance the functionality to be
!    like HPUX. */
!
!       cio->fd = fileno(stdin);
! #else
!       cio->fd = fileno(stdout);
        conn = new_connection(ptrans, server_conf, cio,
                                  (struct sockaddr_in *) &sa_client,
                                  (struct sockaddr_in *) &sa_server, -1);
--- 4598,4643 ----
          exit(0);
      }

+ #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));
+ #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).
+    Go figure.  SR 5003355016 has been submitted to request that the existing
+    functionality be documented, and then to enhance the functionality to be
+    like HPUX. */
+     sock_in = fileno(stdin);
+     sock_out = fileno(stdin);
+ #else
+     sock_in = fileno(stdin);
+     sock_out = fileno(stdout);
+ #endif
+
      l = sizeof(sa_client);
!     if ((getpeername(sock_in, &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(sock_in, &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);
      cio = ap_bcreate(ptrans, B_RDWR | B_SOCKET);
!     cio->fd = sock_out;
!     cio->fd_in = sock_in;
      conn = new_connection(ptrans, server_conf, cio,
                        (struct sockaddr_in *) &sa_client,
                        (struct sockaddr_in *) &sa_server, -1);


Joe Moenich
moenich@us.ibm.com
303 773-5483
tie-line 656-7487

Re: several messages

Posted by Ben Laurie <be...@algroup.co.uk>.
Dean Gaudet wrote:
> 
> On Mon, 12 Oct 1998, Joe Moenich wrote:
> 
> > TPF implementation of select, force processing of signals and typecast
> > ebcdic2ascii for TPF.
> 
> On Mon, 12 Oct 1998, Joe Moenich wrote:
> 
> > TPF implementation of select, ignore alarms, provide an out if user attempts to
> > run standalone with this implementation.  Include TPF in inetd path of REALMAIN.
> 
> I haven't looked closely -- but instead of changing the code which calls
> ap_select(), could you instead put a special tpf_select() in your OS
> specific directory and change the #define for ap_select to use
> tpf_select() ?

It looked to me like they are too different. TPF's select looked like
the only similarity was the name :-)

Cheers,

Ben.

-- 
Ben Laurie            |Phone: +44 (181) 735 0686| Apache Group member
Freelance Consultant  |Fax:   +44 (181) 735 0689|http://www.apache.org/
and Technical Director|Email: ben@algroup.co.uk |
A.L. Digital Ltd,     |Apache-SSL author     http://www.apache-ssl.org/
London, England.      |"Apache: TDG" http://www.ora.com/catalog/apache/

WE'RE RECRUITING! http://www.aldigital.co.uk/

Re: several messages

Posted by Dean Gaudet <dg...@arctic.org>.

On Mon, 12 Oct 1998, Joe Moenich wrote:

> TPF implementation of select, force processing of signals and typecast
> ebcdic2ascii for TPF.

On Mon, 12 Oct 1998, Joe Moenich wrote:

> TPF implementation of select, ignore alarms, provide an out if user attempts to
> run standalone with this implementation.  Include TPF in inetd path of REALMAIN.

I haven't looked closely -- but instead of changing the code which calls
ap_select(), could you instead put a special tpf_select() in your OS
specific directory and change the #define for ap_select to use
tpf_select() ?

Dean