apr-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From wr...@apache.org
Subject cvs commit: apr/threadproc/win32 proc.c
Date Mon, 17 Sep 2001 20:00:08 GMT
wrowe       01/09/17 13:00:07

  Modified:    memory/unix apr_pools.c
               threadproc/win32 proc.c
  Log:
    Fix two odd bits of breakage.  Don't you just -love- casts?
  
  Revision  Changes    Path
  1.110     +6 -2      apr/memory/unix/apr_pools.c
  
  Index: apr_pools.c
  ===================================================================
  RCS file: /home/cvs/apr/memory/unix/apr_pools.c,v
  retrieving revision 1.109
  retrieving revision 1.110
  diff -u -r1.109 -r1.110
  --- apr_pools.c	2001/09/02 18:11:33	1.109
  +++ apr_pools.c	2001/09/17 20:00:07	1.110
  @@ -1466,11 +1466,15 @@
       }
   #ifdef WIN32
       /* 
  -     * Do we need an APR function to clean-up a proc_t?
  +     * XXX: Do we need an APR function to clean-up a proc_t?
  +     * Well ... yeah ... but we can't since it's scope is ill defined.
        */
       {
           for (p = procs; p; p = p->next) {
  -            CloseHandle((HANDLE)p->pid->pid);
  +            if (p->pid->hproc) {
  +                CloseHandle(p->pid->hproc);
  +                p->pid->hproc = NULL;
  +            }
           }
       }
   #endif /* WIN32 */
  
  
  
  1.53      +28 -15    apr/threadproc/win32/proc.c
  
  Index: proc.c
  ===================================================================
  RCS file: /home/cvs/apr/threadproc/win32/proc.c,v
  retrieving revision 1.52
  retrieving revision 1.53
  diff -u -r1.52 -r1.53
  --- proc.c	2001/09/11 06:00:04	1.52
  +++ proc.c	2001/09/17 20:00:07	1.53
  @@ -355,8 +355,19 @@
           else if (strchr(shellcmd, ' '))
               shellcmd = apr_pstrcat(cont, "\"", shellcmd, "\"", NULL);
           cmdline = apr_pstrcat(cont, shellcmd, " /C \"", cmdline, "\"", NULL);
  +    } 
  +    else {
  +        /* Win32 is _different_ than unix.  While unix will find the given
  +         * program since it's already chdir'ed, Win32 cannot since the parent
  +         * attempts to open the program with it's own path.
  +         * ###: This solution isn't much better - it may defeat path searching
  +         * when the path search was desired.  Open to further discussion.
  +         */
  +        apr_filepath_merge(&progname, attr->currdir, progname, 
  +                           APR_FILEPATH_NATIVE, cont);
       }
   
  +
       if (!env) 
           pEnvBlock = NULL;
       else {
  @@ -420,27 +431,29 @@
       if (os_level >= APR_WIN_NT)
       {
           STARTUPINFOW si;
  -        apr_wchar_t wprg[APR_PATH_MAX];
  +        apr_size_t nprg = strlen(progname) + 1;
  +        apr_size_t nwprg = nprg + 6;
  +        apr_wchar_t *wprg = apr_palloc(cont, nwprg * sizeof(wprg[0]));
           apr_size_t ncmd = strlen(cmdline) + 1, nwcmd = ncmd;
  +        apr_wchar_t *wcmd = apr_palloc(cont, nwcmd * sizeof(wcmd[0]));
           apr_size_t ncwd = 0, nwcwd = 0;
  -        apr_wchar_t *wcmd = apr_palloc(cont, ncmd * sizeof(wcmd[0]));
           apr_wchar_t *wcwd = NULL;
   
  +        if (((rv = utf8_to_unicode_path(wprg, nwprg, progname))
  +                 != APR_SUCCESS)
  +         || ((rv = conv_utf8_to_ucs2(cmdline, &ncmd, wcmd, &nwcmd))
  +                 != APR_SUCCESS)) {
  +            return rv;
  +        }
  +
           if (attr->currdir)
           {
               ncwd = nwcwd = strlen(attr->currdir) + 1;
               wcwd = apr_palloc(cont, ncwd * sizeof(wcwd[0]));
  -        }
  -
  -        if (((rv = utf8_to_unicode_path(wprg, sizeof(wprg)/sizeof(wprg[0]),
  -                                        progname))
  -                    != APR_SUCCESS)
  -         || ((rv = conv_utf8_to_ucs2(cmdline, &ncmd, wcmd, &nwcmd)) 
  -                    != APR_SUCCESS)
  -         || (attr->currdir &&
  -             (rv = conv_utf8_to_ucs2(attr->currdir, &ncwd, wcwd, &nwcwd)) 
  -                    != APR_SUCCESS)) {
  -            return rv;
  +            if ((rv = conv_utf8_to_ucs2(attr->currdir, &ncwd, wcwd, &nwcwd))
  +                    != APR_SUCCESS) {
  +                return rv;
  +            }
           }
   
           memset(&si, 0, sizeof(si));
  @@ -462,12 +475,12 @@
                   si.hStdError = attr->child_err->filehand;
           }
   
  -        rv = CreateProcessW(wprg, wcmd,        /* Command line */
  +        rv = CreateProcessW(wprg, wcmd,        /* Executable & Command line */
                               NULL, NULL,        /* Proc & thread security attributes
*/
                               TRUE,              /* Inherit handles */
                               dwCreationFlags,   /* Creation flags */
                               pEnvBlock,         /* Environment block */
  -                            wcwd,     /* Current directory name */
  +                            wcwd,              /* Current directory name */
                               &si, &pi);
       }
       else {
  
  
  

Mime
View raw message