httpd-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Garey Smiley" <ga...@main.slink.com>
Subject OS/2 code reduction.
Date Wed, 07 Aug 1996 21:38:33 GMT
I had thought the following changes would work after Apache went to
buff.c, but I didn't have time to test it until now. The following
changes should reduce the amount of OS/2 specific code.

*** alloc.c.orig	Sat Aug 03 21:02:06 1996
--- alloc.c	Mon Aug 05 15:04:18 1996
***************
*** 973,1072 ****
    }
  }
  
- #ifdef __EMX__
- int spawn_child_os2 (pool *p, void (*func)(void *), void *data,
-          enum kill_conditions kill_how,
-          FILE **pipe_in, FILE **pipe_out, char *buffer, int lenp)
- {
-   int pid;
-   int in_fds[2];
-   int out_fds[2];
- 
-   block_alarms();
- 
-   if (pipe_in && pipe (in_fds) < 0)
-   {
-       unblock_alarms();
-       return 0;
-   }
- 
-   if (pipe_out && pipe (out_fds) < 0) {
-     if (pipe_in) {
-       close (in_fds[0]); close (in_fds[1]);
-     }
-     unblock_alarms();
-     return 0;
-   }
- 
-   if ((pid = fork()) < 0) {
-     if (pipe_in) {
-       close (in_fds[0]); close (in_fds[1]);
-     }
-     if (pipe_out) {
-       close (out_fds[0]); close (out_fds[1]);
-     }
-     unblock_alarms();
-     return 0;
-   }
- 
-   if (!pid) {
-     int stdinpipe[2];
- 
-     /* Due to a limitation of EMX, inheriting socket handles is not
-     allowed so we need to read the input and place it in a pipe and
-     then pass that handle instead of the socket. */
- 
-     if (lenp > 0) {
-         pipe(stdinpipe);
-         write(stdinpipe[1], buffer, lenp);
-         close(stdinpipe[1]);
-         in_fds[0] = dup(stdinpipe[0]);
-         close(stdinpipe[0]);
-     }
- 
-     /* Child process */
- 
-     if (pipe_out) {
-       close (out_fds[0]);
-       dup2 (out_fds[1], STDOUT_FILENO);
-       close (out_fds[1]);
-     }
- 
-     if (pipe_in) {
-       close (in_fds[1]);
-       dup2 (in_fds[0], STDIN_FILENO);
-       close (in_fds[0]);
-     }
- 
-     /* HP-UX SIGCHLD fix goes here, if someone will remind me what it
is... */
-     signal (SIGCHLD, SIG_DFL);    /* Was that it? */
- 
-     func (data);
-     exit (0);            /* Should never get here... */
-   }
- 
-   /* Parent process */
- 
-   note_subprocess (p, pid, kill_how);
- 
-   if (pipe_out) {
-     close (out_fds[1]);
-     /* Need binary mode set for OS/2. */
-     *pipe_out = fdopen (out_fds[0], "rb");
- 
-     if (*pipe_out) note_cleanups_for_file (p, *pipe_out);
-   }
- 
-   if (pipe_in) {
-     close (in_fds[0]);
-     /* Need binary mode set for OS/2. */
-     *pipe_in = fdopen (in_fds[1], "wb");
- 
-     if (*pipe_in) note_cleanups_for_file (p, *pipe_in);
-   }
- 
-   unblock_alarms();
-   return pid;
- }
- #endif
- 
--- 973,975 ----

*** alloc.h.orig	Sat Jun 08 18:14:34 1996
--- alloc.h	Mon Aug 05 15:15:02 1996
***************
*** 227,236 ****
  
  int spawn_child (pool *, void (*)(void *), void *,
  		 enum kill_conditions, FILE **pipe_in, FILE **pipe_out);
- #ifdef __EMX__
- int spawn_child_os2 (pool *, void (*)(void *), void *,
-          enum kill_conditions, FILE **pipe_in, FILE **pipe_out, char
*buffer, int lenp);
- #endif
  
  /* magic numbers --- only one so far, min free bytes in a new pool
block */
  
--- 227,232 ----

*** mod_cgi.c.orig	Mon Jun 17 13:43:46 1996
--- mod_cgi.c	Wed Aug 07 17:34:36 1996
***************
*** 251,286 ****
      add_common_vars (r);
      cld.argv0 = argv0; cld.r = r; cld.nph = nph;
      
- #ifdef __EMX__
-     if (r->method_number == M_POST || r->method_number == M_PUT) {
-         int len_to_read = atoi (lenp);
-     
-         if (len_to_read > HUGE_STRING_LEN) len_to_read =
HUGE_STRING_LEN;
-         read_client_block (r, argsbuffer, len_to_read);
- 
-         if (!spawn_child_os2 (r->connection->pool, cgi_child, (void
*)&cld,
-                   nph ? just_wait : kill_after_timeout, 
-                   &script_out, &script_in, argsbuffer, atoi(lenp))) {

-             log_reason ("couldn't spawn child process", r->filename,
r);
-             return SERVER_ERROR;
-         }
-     } else {
          if (!spawn_child (r->connection->pool, cgi_child, (void
*)&cld,
                    nph ? just_wait : kill_after_timeout,
                    &script_out, &script_in)) {
-             log_reason ("couldn't spawn child process", r->filename,
r);
-             return SERVER_ERROR;
-         }
-     }
-     
  #else
-      if (!spawn_child (r->connection->pool, cgi_child, (void *)&cld,
- 		       nph ? just_wait : kill_after_timeout, 
  		       &script_out, nph ? NULL : &script_in)) {
          log_reason ("couldn't spawn child process", r->filename, r);
          return SERVER_ERROR;
      }
- #endif
  
      /* Transfer any put/post args, CERN style...
       * Note that if a buggy script fails to read everything we throw
--- 251,266 ----
      add_common_vars (r);
      cld.argv0 = argv0; cld.r = r; cld.nph = nph;
  
       if (!spawn_child (r->connection->pool, cgi_child, (void *)&cld,
                 nph ? just_wait : kill_after_timeout,
+ #ifdef __EMX__
                 &script_out, &script_in)) {
  #else
                 &script_out, nph ? NULL : &script_in)) {
+ #endif
          log_reason ("couldn't spawn child process", r->filename, r);
          return SERVER_ERROR;
      }
  
      /* Transfer any put/post args, CERN style...
       * Note that if a buggy script fails to read everything we throw
***************
*** 291,297 ****
       * spurious newline).
       */
      
- #ifndef __EMX__
      if (r->method_number == M_POST || r->method_number == M_PUT) {
          void (*handler)();
  	int remaining = atoi (lenp);
--- 271,276 ----
***************
*** 330,336 ****
  	
  	kill_timeout (r);
      }
- #endif    
      
      pfclose (r->connection->pool, script_out);
      
--- 309,314 ----




Garey Smiley
SoftLink Services
garey@slink.com
http://www.slink.com/
(330)848-1312 FAX/Data(330)699-4474

Mime
View raw message