You are viewing a plain text version of this content. The canonical link for it is here.
Posted to cvs@httpd.apache.org by wr...@locus.apache.org on 2000/10/08 06:14:50 UTC

cvs commit: apache-1.3/src/os/win32 util_win32.c os.h mod_isapi.c

wrowe       00/10/07 21:14:49

  Modified:    src      ApacheCore.def
               src/os/win32 util_win32.c os.h mod_isapi.c
  Log:
    Move some critical OS code from mod_isapi into the Win32 platform dso
    support.  1) made isapi simpler, 2) made dso more robust, and...
  
    I have observed odd GP faults when using LoadLibrary[Ex] with forward
    slashes, and MS warns in several places that it must use backslashes
    in this context.  Well... we are seeing some odd gp faults at shutdown
    with mod_perl.  So perhaps, maybe, this makes them go away.
  
  Revision  Changes    Path
  1.26      +1 -0      apache-1.3/src/ApacheCore.def
  
  Index: ApacheCore.def
  ===================================================================
  RCS file: /home/cvs/apache-1.3/src/ApacheCore.def,v
  retrieving revision 1.25
  retrieving revision 1.26
  diff -u -r1.25 -r1.26
  --- ApacheCore.def	2000/10/08 00:27:19	1.25
  +++ ApacheCore.def	2000/10/08 04:14:48	1.26
  @@ -387,3 +387,4 @@
           ap_start_shutdown @378
   	ap_start_restart @379
   	ap_stripprefix @380
  +        ap_os_dso_load @381
  
  
  
  1.39      +29 -0     apache-1.3/src/os/win32/util_win32.c
  
  Index: util_win32.c
  ===================================================================
  RCS file: /home/cvs/apache-1.3/src/os/win32/util_win32.c,v
  retrieving revision 1.38
  retrieving revision 1.39
  diff -u -r1.38 -r1.39
  --- util_win32.c	2000/09/26 02:30:39	1.38
  +++ util_win32.c	2000/10/08 04:14:49	1.39
  @@ -700,3 +700,32 @@
   
       return 1;
   }
  +
  +
  +API_EXPORT(ap_os_dso_handle_t) ap_os_dso_load(const char *module_name)
  +{
  +    ap_os_dso_handle_t dsoh;
  +    char path[MAX_PATH], *p;
  +    /* Load the module...
  +     * per PR2555, the LoadLibraryEx function is very picky about slashes.
  +     * Debugging on NT 4 SP 6a reveals First Chance Exception within NTDLL.
  +     * LoadLibrary in the MS PSDK also reveals that it -explicitly- states
  +     * that backslashes must be used.
  +     *
  +     * Transpose '\' for '/' in the filename.
  +     */
  +    ap_cpystrn(path, module_name, MAX_PATH);
  +    p = path;
  +    while (p = strchr(p, '/'))
  +        *p = '\\';
  +    
  +    /* First assume the dso/dll's required by -this- dso are sitting in the 
  +     * same path or can be found in the usual places.  Failing that, let's
  +     * let that dso look in the apache root.
  +     */
  +    dsoh = LoadLibraryEx(path, NULL, LOAD_WITH_ALTERED_SEARCH_PATH);
  +    if (!dsoh) {
  +        dsoh = LoadLibraryEx(path, NULL, 0);
  +    }
  +    return dsoh;
  +}
  \ No newline at end of file
  
  
  
  1.34      +2 -1      apache-1.3/src/os/win32/os.h
  
  Index: os.h
  ===================================================================
  RCS file: /home/cvs/apache-1.3/src/os/win32/os.h,v
  retrieving revision 1.33
  retrieving revision 1.34
  diff -u -r1.33 -r1.34
  --- os.h	2000/09/22 18:20:49	1.33
  +++ os.h	2000/10/08 04:14:49	1.34
  @@ -195,10 +195,11 @@
    */
   #define ap_os_dso_handle_t  HINSTANCE
   #define ap_os_dso_init()
  -#define ap_os_dso_load(l)   LoadLibraryEx(l, NULL, LOAD_WITH_ALTERED_SEARCH_PATH)
   #define ap_os_dso_unload(l) FreeLibrary(l)
   #define ap_os_dso_sym(h,s)  GetProcAddress(h,s)
   #define ap_os_dso_error()   ""	/* for now */
  +
  +API_EXPORT(ap_os_dso_handle_t) ap_os_dso_load(const char *);
   
   /* Other ap_os_ routines not used by this platform */
   #define ap_os_kill(pid, sig)                kill(pid, sig)
  
  
  
  1.23      +13 -33    apache-1.3/src/os/win32/mod_isapi.c
  
  Index: mod_isapi.c
  ===================================================================
  RCS file: /home/cvs/apache-1.3/src/os/win32/mod_isapi.c,v
  retrieving revision 1.22
  retrieving revision 1.23
  diff -u -r1.22 -r1.23
  --- mod_isapi.c	2000/10/05 18:36:19	1.22
  +++ mod_isapi.c	2000/10/08 04:14:49	1.23
  @@ -85,7 +85,6 @@
   #include "http_log.h"
   #include "util_script.h"
   #include <stdlib.h>
  -
   /* We use the exact same header file as the original */
   #include <HttpExt.h>
   
  @@ -140,7 +139,6 @@
       isapi_cid *cid = ap_pcalloc(r->pool, sizeof(isapi_cid));
       table *e = r->subprocess_env;
       DWORD read;
  -    char *fspec;
       char *p;
       int retval;
       int res;
  @@ -155,57 +153,39 @@
   
       if (S_ISDIR(r->finfo.st_mode))
           return FORBIDDEN;
  -
  -    /* Load the module...
  -     * per PR2555, the LoadLibraryEx function is very picky about slashes.
  -     * Debugging on NT 4 SP 6a reveals First Chance Exception within NTDLL.
  -     * LoadLibrary in the MS PSDK also reveals that it -explicitly- states
  -     * that backslashes must be used.
  -     *
  -     * Transpose '\' for '/' in the filename.
  -     */
  -    p = fspec = ap_pstrdup(r->pool, r->filename);
  -    while (*p) {
  -        if (*p == '/')
  -            *p = '\\';
  -        ++p;
  -    }
   
  -    if (!(isapi_handle = LoadLibraryEx(fspec, NULL,
  -                                       LOAD_WITH_ALTERED_SEARCH_PATH))) {
  -        if (!(isapi_handle = LoadLibraryEx(fspec, NULL, 0))) {
  -            ap_log_rerror(APLOG_MARK, APLOG_ALERT, r,
  -                          "Could not load DLL: %s", r->filename);
  -            return SERVER_ERROR;
  -        }
  +    if (!(isapi_handle = ap_os_dso_load(r->filename))) {
  +        ap_log_rerror(APLOG_MARK, APLOG_ALERT, r,
  +                      "ISAPI Could not load DLL: %s", r->filename);
  +        return SERVER_ERROR;
       }
   
       if (!(isapi_version =
  -          (void *)(GetProcAddress(isapi_handle, "GetExtensionVersion")))) {
  +          (void *)(ap_os_dso_sym(isapi_handle, "GetExtensionVersion")))) {
           ap_log_rerror(APLOG_MARK, APLOG_ALERT, r,
                         "DLL could not load GetExtensionVersion(): %s", 
                         r->filename);
  -        FreeLibrary(isapi_handle);
  +        ap_os_dso_unload(isapi_handle);
           return SERVER_ERROR;
       }
   
       if (!(isapi_entry =
  -          (void *)(GetProcAddress(isapi_handle, "HttpExtensionProc")))) {
  +          (void *)(ap_os_dso_sym(isapi_handle, "HttpExtensionProc")))) {
           ap_log_rerror(APLOG_MARK, APLOG_ALERT, r,
                         "DLL could not load HttpExtensionProc(): %s", 
                         r->filename);
  -        FreeLibrary(isapi_handle);
  +        ap_os_dso_unload(isapi_handle);
           return SERVER_ERROR;
       }
   
  -    isapi_term = (void *)(GetProcAddress(isapi_handle, "TerminateExtension"));
  +    isapi_term = (void *)(ap_os_dso_sym(isapi_handle, "TerminateExtension"));
   
       /* Run GetExtensionVersion() */
   
       if (!(*isapi_version)(pVer)) {
           ap_log_rerror(APLOG_MARK, APLOG_ALERT, r,
                         "ISAPI GetExtensionVersion() failed: %s", r->filename);
  -        FreeLibrary(isapi_handle);
  +        ap_os_dso_unload(isapi_handle);
           return SERVER_ERROR;
       }
   
  @@ -238,7 +218,7 @@
       /* Set up client input */
       if ((retval = ap_setup_client_block(r, REQUEST_CHUNKED_ERROR))) {
           if (isapi_term) (*isapi_term)( 2 /* HSE_TERM_MUST_UNLOAD */);
  -        FreeLibrary(isapi_handle);
  +        ap_os_dso_unload(isapi_handle);
           return retval;
       }
   
  @@ -272,7 +252,7 @@
   
           if (res < 0) {
               if (isapi_term) (*isapi_term)(HSE_TERM_MUST_UNLOAD);
  -            FreeLibrary(isapi_handle);
  +            ap_os_dso_unload(isapi_handle);
               return SERVER_ERROR;
           }
   
  @@ -321,7 +301,7 @@
   
       /* All done with the DLL... get rid of it */
       if (isapi_term) (*isapi_term)(HSE_TERM_MUST_UNLOAD);
  -    FreeLibrary(isapi_handle);
  +    ap_os_dso_unload(isapi_handle);
   
       switch(retval) {
       case HSE_STATUS_SUCCESS: