httpd-cvs mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From wr...@apache.org
Subject cvs commit: apache-1.3/src/modules/standard mod_mime_magic.c
Date Thu, 04 Oct 2001 05:48:25 GMT
wrowe       01/10/03 22:48:25

  Modified:    src/modules/standard mod_mime_magic.c
  Log:
    Should work, no change for non-win32, and use an appropriate, simple
    port of the complex code from ap_call_exec for Win32
  
  Revision  Changes    Path
  1.44      +49 -15    apache-1.3/src/modules/standard/mod_mime_magic.c
  
  Index: mod_mime_magic.c
  ===================================================================
  RCS file: /home/cvs/apache-1.3/src/modules/standard/mod_mime_magic.c,v
  retrieving revision 1.43
  retrieving revision 1.44
  diff -u -r1.43 -r1.44
  --- mod_mime_magic.c	2001/08/21 12:46:00	1.43
  +++ mod_mime_magic.c	2001/10/04 05:48:24	1.44
  @@ -131,8 +131,9 @@
   #include "http_log.h"
   #include "http_protocol.h"
   
  +#ifndef WIN32
   #include <utime.h>
  -
  +#endif
   
   /*
    * data structures and related constants
  @@ -2146,31 +2147,64 @@
   static int uncompress_child(void *data, child_info *pinfo)
   {
       struct uncompress_parms *parm = data;
  -	char *new_argv[4];
  +#ifndef WIN32
  +    char *new_argv[4];
   
  -	new_argv[0] = compr[parm->method].argv[0];
  -	new_argv[1] = compr[parm->method].argv[1];
  -	new_argv[2] = parm->r->filename;
  -	new_argv[3] = NULL;
  -
  -#if defined(WIN32)
  -    int child_pid;
  -#endif
  +    new_argv[0] = compr[parm->method].argv[0];
  +    new_argv[1] = compr[parm->method].argv[1];
  +    new_argv[2] = parm->r->filename;
  +    new_argv[3] = NULL;
   
       if (compr[parm->method].silent) {
   	close(STDERR_FILENO);
       }
   
  -#if defined(WIN32)
  -    child_pid = spawnvp(compr[parm->method].argv[0],
  -			new_argv);
  -    return (child_pid);
  -#else
       execvp(compr[parm->method].argv[0], new_argv);
       ap_log_rerror(APLOG_MARK, APLOG_ERR, parm->r,
   		MODNAME ": could not execute `%s'.",
   		compr[parm->method].argv[0]);
       return -1;
  +#else
  +    char *pCommand;
  +    STARTUPINFO si;
  +    PROCESS_INFORMATION pi;
  +    pid_t pid;
  +
  +    memset(&si, 0, sizeof(si));
  +    memset(&pi, 0, sizeof(pi));
  +
  +    pid = -1;
  +
  +    /*
  +     * Look at the arguments...
  +     */
  +    pCommand = ap_pstrcat(parm->r->pool, compr[parm->method].argv[0], " ",
  +                                         compr[parm->method].argv[1], " \"",
  +                                         parm->r->filename, "\"", NULL);
  +
  +    /*
  +     * Make child process use hPipeOutputWrite as standard out,
  +     * and make sure it does not show on screen.
  +     */
  +    si.cb = sizeof(si);
  +    si.dwFlags     = STARTF_USESTDHANDLES | STARTF_USESHOWWINDOW;
  +    si.wShowWindow = SW_HIDE;
  +    si.hStdInput   = pinfo->hPipeInputRead;
  +    si.hStdOutput  = pinfo->hPipeOutputWrite;
  +    si.hStdError   = pinfo->hPipeErrorWrite;
  +
  +    if (CreateProcess(NULL, pCommand, NULL, NULL, TRUE, 0, NULL,
  +                      ap_make_dirstr_parent(parm->r->pool, parm->r->filename),
  +                      &si, &pi)) {
  +        pid = pi.dwProcessId;
  +        /*
  +         * We must close the handles to the new process and its main thread
  +         * to prevent handle and memory leaks.
  +         */ 
  +        CloseHandle(pi.hProcess);
  +        CloseHandle(pi.hThread);
  +    }
  +    return (pid);
   #endif
   }
   
  
  
  

Mime
View raw message