pcs         98/02/24 02:30:57

  Modified:    src      ApacheCore.dsp ApacheCore.mak
               src/modules/standard mod_so.c
               src/os/unix os.h
               src/os/win32 modules.c os.h
  Log:
  Replace os/win32/mod_dll.c and modules/standard/mod_so.c with a single
  unified mod_so. The required dynamic loading functions are abstracted
  in os/{win32,unix}/os.h to these manifest constants:
  
    os_dl_module_handle_type    type of handle returned by os_dl_load
    os_dl_load(l)               load a file
    os_dl_unload(l)             unload a file
    os_dl_sym(h,s)              find address of a symbol
    os_dl_error()               get last os_dl_*() call error as a string
  
  Reviewed by:  Randy Terbush and Martin Kraemer (untested)
  
  Revision  Changes    Path
  1.20      +4 -4      apache-1.3/src/ApacheCore.dsp
  
  Index: ApacheCore.dsp
  ===================================================================
  RCS file: /export/home/cvs/apache-1.3/src/ApacheCore.dsp,v
  retrieving revision 1.19
  retrieving revision 1.20
  diff -u -r1.19 -r1.20
  --- ApacheCore.dsp    1998/02/24 09:23:46     1.19
  +++ ApacheCore.dsp    1998/02/24 10:30:52     1.20
  @@ -185,10 +185,6 @@
   # End Source File
   # Begin Source File
   
  -SOURCE=.\os\win32\mod_dll.c
  -# End Source File
  -# Begin Source File
  -
   SOURCE=.\modules\standard\mod_env.c
   # End Source File
   # Begin Source File
  @@ -218,6 +214,10 @@
   # Begin Source File
   
   SOURCE=.\modules\standard\mod_setenvif.c
  +# End Source File
  +# Begin Source File
  +
  +SOURCE=.\modules\standard\mod_so.c
   # End Source File
   # Begin Source File
   
  
  
  
  1.30      +58 -50    apache-1.3/src/ApacheCore.mak
  
  Index: ApacheCore.mak
  ===================================================================
  RCS file: /export/home/cvs/apache-1.3/src/ApacheCore.mak,v
  retrieving revision 1.29
  retrieving revision 1.30
  diff -u -r1.29 -r1.30
  --- ApacheCore.mak    1998/02/24 09:23:47     1.29
  +++ ApacheCore.mak    1998/02/24 10:30:52     1.30
  @@ -73,7 +73,6 @@
        [EMAIL PROTECTED] "$(INTDIR)\mod_autoindex.obj"
        [EMAIL PROTECTED] "$(INTDIR)\mod_cgi.obj"
        [EMAIL PROTECTED] "$(INTDIR)\mod_dir.obj"
  -     [EMAIL PROTECTED] "$(INTDIR)\mod_dll.obj"
        [EMAIL PROTECTED] "$(INTDIR)\mod_env.obj"
        [EMAIL PROTECTED] "$(INTDIR)\mod_imap.obj"
        [EMAIL PROTECTED] "$(INTDIR)\mod_include.obj"
  @@ -82,6 +81,7 @@
        [EMAIL PROTECTED] "$(INTDIR)\mod_mime.obj"
        [EMAIL PROTECTED] "$(INTDIR)\mod_negotiation.obj"
        [EMAIL PROTECTED] "$(INTDIR)\mod_setenvif.obj"
  +     [EMAIL PROTECTED] "$(INTDIR)\mod_so.obj"
        [EMAIL PROTECTED] "$(INTDIR)\mod_userdir.obj"
        [EMAIL PROTECTED] "$(INTDIR)\modules.obj"
        [EMAIL PROTECTED] "$(INTDIR)\multithread.obj"
  @@ -143,7 +143,6 @@
        "$(INTDIR)\mod_autoindex.obj" \
        "$(INTDIR)\mod_cgi.obj" \
        "$(INTDIR)\mod_dir.obj" \
  -     "$(INTDIR)\mod_dll.obj" \
        "$(INTDIR)\mod_env.obj" \
        "$(INTDIR)\mod_imap.obj" \
        "$(INTDIR)\mod_include.obj" \
  @@ -152,6 +151,7 @@
        "$(INTDIR)\mod_mime.obj" \
        "$(INTDIR)\mod_negotiation.obj" \
        "$(INTDIR)\mod_setenvif.obj" \
  +     "$(INTDIR)\mod_so.obj" \
        "$(INTDIR)\mod_userdir.obj" \
        "$(INTDIR)\modules.obj" \
        "$(INTDIR)\multithread.obj" \
  @@ -232,8 +232,6 @@
        [EMAIL PROTECTED] "$(INTDIR)\mod_cgi.sbr"
        [EMAIL PROTECTED] "$(INTDIR)\mod_dir.obj"
        [EMAIL PROTECTED] "$(INTDIR)\mod_dir.sbr"
  -     [EMAIL PROTECTED] "$(INTDIR)\mod_dll.obj"
  -     [EMAIL PROTECTED] "$(INTDIR)\mod_dll.sbr"
        [EMAIL PROTECTED] "$(INTDIR)\mod_env.obj"
        [EMAIL PROTECTED] "$(INTDIR)\mod_env.sbr"
        [EMAIL PROTECTED] "$(INTDIR)\mod_imap.obj"
  @@ -250,6 +248,8 @@
        [EMAIL PROTECTED] "$(INTDIR)\mod_negotiation.sbr"
        [EMAIL PROTECTED] "$(INTDIR)\mod_setenvif.obj"
        [EMAIL PROTECTED] "$(INTDIR)\mod_setenvif.sbr"
  +     [EMAIL PROTECTED] "$(INTDIR)\mod_so.obj"
  +     [EMAIL PROTECTED] "$(INTDIR)\mod_so.sbr"
        [EMAIL PROTECTED] "$(INTDIR)\mod_userdir.obj"
        [EMAIL PROTECTED] "$(INTDIR)\mod_userdir.sbr"
        [EMAIL PROTECTED] "$(INTDIR)\modules.obj"
  @@ -315,7 +315,6 @@
        "$(INTDIR)\mod_autoindex.sbr" \
        "$(INTDIR)\mod_cgi.sbr" \
        "$(INTDIR)\mod_dir.sbr" \
  -     "$(INTDIR)\mod_dll.sbr" \
        "$(INTDIR)\mod_env.sbr" \
        "$(INTDIR)\mod_imap.sbr" \
        "$(INTDIR)\mod_include.sbr" \
  @@ -324,6 +323,7 @@
        "$(INTDIR)\mod_mime.sbr" \
        "$(INTDIR)\mod_negotiation.sbr" \
        "$(INTDIR)\mod_setenvif.sbr" \
  +     "$(INTDIR)\mod_so.sbr" \
        "$(INTDIR)\mod_userdir.sbr" \
        "$(INTDIR)\modules.sbr" \
        "$(INTDIR)\multithread.sbr" \
  @@ -373,7 +373,6 @@
        "$(INTDIR)\mod_autoindex.obj" \
        "$(INTDIR)\mod_cgi.obj" \
        "$(INTDIR)\mod_dir.obj" \
  -     "$(INTDIR)\mod_dll.obj" \
        "$(INTDIR)\mod_env.obj" \
        "$(INTDIR)\mod_imap.obj" \
        "$(INTDIR)\mod_include.obj" \
  @@ -382,6 +381,7 @@
        "$(INTDIR)\mod_mime.obj" \
        "$(INTDIR)\mod_negotiation.obj" \
        "$(INTDIR)\mod_setenvif.obj" \
  +     "$(INTDIR)\mod_so.obj" \
        "$(INTDIR)\mod_userdir.obj" \
        "$(INTDIR)\modules.obj" \
        "$(INTDIR)\multithread.obj" \
  @@ -1439,47 +1439,6 @@
   
   !ENDIF 
   
  -SOURCE=.\os\win32\mod_dll.c
  -
  -!IF  "$(CFG)" == "ApacheCore - Win32 Release"
  -
  -DEP_CPP_MOD_DL=\
  -     ".\include\alloc.h"\
  -     ".\include\ap.h"\
  -     ".\include\buff.h"\
  -     ".\include\conf.h"\
  -     ".\include\hsregex.h"\
  -     ".\include\http_config.h"\
  -     ".\include\httpd.h"\
  -     ".\os\win32\os.h"\
  -     ".\os\win32\readdir.h"\
  -     
  -
  -"$(INTDIR)\mod_dll.obj" : $(SOURCE) $(DEP_CPP_MOD_DL) "$(INTDIR)"
  -     $(CPP) $(CPP_PROJ) $(SOURCE)
  -
  -
  -!ELSEIF  "$(CFG)" == "ApacheCore - Win32 Debug"
  -
  -DEP_CPP_MOD_DL=\
  -     ".\include\alloc.h"\
  -     ".\include\ap.h"\
  -     ".\include\buff.h"\
  -     ".\include\conf.h"\
  -     ".\include\hsregex.h"\
  -     ".\include\http_config.h"\
  -     ".\include\httpd.h"\
  -     ".\os\win32\os.h"\
  -     ".\os\win32\readdir.h"\
  -     
  -
  -"$(INTDIR)\mod_dll.obj"      "$(INTDIR)\mod_dll.sbr" : $(SOURCE) 
$(DEP_CPP_MOD_DL)\
  - "$(INTDIR)"
  -     $(CPP) $(CPP_PROJ) $(SOURCE)
  -
  -
  -!ENDIF 
  -
   SOURCE=.\modules\standard\mod_env.c
   
   !IF  "$(CFG)" == "ApacheCore - Win32 Release"
  @@ -1860,6 +1819,49 @@
   
   !ENDIF 
   
  +SOURCE=.\modules\standard\mod_so.c
  +
  +!IF  "$(CFG)" == "ApacheCore - Win32 Release"
  +
  +DEP_CPP_MOD_SO=\
  +     ".\include\alloc.h"\
  +     ".\include\ap.h"\
  +     ".\include\buff.h"\
  +     ".\include\conf.h"\
  +     ".\include\hsregex.h"\
  +     ".\include\http_config.h"\
  +     ".\include\http_log.h"\
  +     ".\include\httpd.h"\
  +     ".\os\win32\os.h"\
  +     ".\os\win32\readdir.h"\
  +     
  +
  +"$(INTDIR)\mod_so.obj" : $(SOURCE) $(DEP_CPP_MOD_SO) "$(INTDIR)"
  +     $(CPP) $(CPP_PROJ) $(SOURCE)
  +
  +
  +!ELSEIF  "$(CFG)" == "ApacheCore - Win32 Debug"
  +
  +DEP_CPP_MOD_SO=\
  +     ".\include\alloc.h"\
  +     ".\include\ap.h"\
  +     ".\include\buff.h"\
  +     ".\include\conf.h"\
  +     ".\include\hsregex.h"\
  +     ".\include\http_config.h"\
  +     ".\include\http_log.h"\
  +     ".\include\httpd.h"\
  +     ".\os\win32\os.h"\
  +     ".\os\win32\readdir.h"\
  +     
  +
  +"$(INTDIR)\mod_so.obj"       "$(INTDIR)\mod_so.sbr" : $(SOURCE) 
$(DEP_CPP_MOD_SO)\
  + "$(INTDIR)"
  +     $(CPP) $(CPP_PROJ) $(SOURCE)
  +
  +
  +!ENDIF 
  +
   SOURCE=.\modules\standard\mod_userdir.c
   
   !IF  "$(CFG)" == "ApacheCore - Win32 Release"
  @@ -1943,6 +1945,9 @@
   !ENDIF 
   
   SOURCE=.\os\win32\multithread.c
  +
  +!IF  "$(CFG)" == "ApacheCore - Win32 Release"
  +
   DEP_CPP_MULTI=\
        ".\include\conf.h"\
        ".\include\hsregex.h"\
  @@ -1950,15 +1955,18 @@
        ".\os\win32\os.h"\
        
   
  -!IF  "$(CFG)" == "ApacheCore - Win32 Release"
  -
  -
   "$(INTDIR)\multithread.obj" : $(SOURCE) $(DEP_CPP_MULTI) "$(INTDIR)"
        $(CPP) $(CPP_PROJ) $(SOURCE)
   
   
   !ELSEIF  "$(CFG)" == "ApacheCore - Win32 Debug"
   
  +DEP_CPP_MULTI=\
  +     ".\include\conf.h"\
  +     ".\include\hsregex.h"\
  +     ".\include\multithread.h"\
  +     ".\os\win32\os.h"\
  +     
   
   "$(INTDIR)\multithread.obj"  "$(INTDIR)\multithread.sbr" : $(SOURCE)\
    $(DEP_CPP_MULTI) "$(INTDIR)"
  
  
  
  1.5       +29 -50    apache-1.3/src/modules/standard/mod_so.c
  
  Index: mod_so.c
  ===================================================================
  RCS file: /export/home/cvs/apache-1.3/src/modules/standard/mod_so.c,v
  retrieving revision 1.4
  retrieving revision 1.5
  diff -u -r1.4 -r1.5
  --- mod_so.c  1998/02/07 01:07:11     1.4
  +++ mod_so.c  1998/02/24 10:30:54     1.5
  @@ -114,7 +114,7 @@
   */
   
   /*
  - * Module definition information
  + * Module definition information used by Configure
    *
    * MODULE-DEFINITION-START
    * Name: so_module
  @@ -139,43 +139,6 @@
   #include "http_config.h"
   #include "http_log.h"
   
  -     /* Os-specific stuff that goes in conf.h */
  -
  -#if defined(LINUX) || defined(__FreeBSD__) || defined(SOLARIS) || \
  -    defined(__bsdi__) || defined(IRIX)
  -#define HAS_DLFCN
  -#endif
  -
  -#if defined(__FreeBSD__)
  -#define NEED_UNDERSCORE_SYM
  -#endif
  -
  -     /* OSes that don't support dlopen */
  -#if defined(UW) || defined(ULTRIX)
  -#define NO_DL
  -#endif
  -
  -     /* Start of real module */
  -#ifdef HAS_DLFCN
  -#include <dlfcn.h>
  -#else
  -void * dlopen (__const char * __filename, int __flag);
  -__const char * dlerror (void);
  -void * dlsym (void *, __const char *);
  -int dlclose (void *);
  -#endif
  -
  -#ifndef RTLD_NOW
  -/* 
  - * probably on an older system that doesn't support RTLD_NOW or RTLD_LAZY.
  - * The below define is a lie since we are really doing RTLD_LAZY since the
  - * system doesn't support RTLD_NOW.
  - */
  -#define RTLD_NOW 1
  -#endif
  -
  -static int have_symbol_table = 0;
  -
   #ifndef NO_DLOPEN
   
   /* This is the cleanup for a loaded DLL. It unloads the module.
  @@ -195,7 +158,7 @@
   
       /* The Linux manpage doesn't give any way to check the success of
        * dlclose() */
  -    dlclose(modp->dynamic_load_handle);
  +    os_dl_unload((os_dl_module_handle_type)modp->dynamic_load_handle);
   
       aplog_error(APLOG_MARK, APLOG_DEBUG|APLOG_NOERRNO, NULL,
                "unloaded module %s", mod_name);
  @@ -211,8 +174,21 @@
   {
       /* The Linux manpage doesn't give any way to check the success of
        * dlclose() */
  -    dlclose(handle);
  +    os_dl_unload((os_dl_module_handle_type)handle);
  +}
  +
  +#ifdef WIN32
  +/* This is a cleanup which does nothing. On Win32 using the API-provided
  + * null_cleanup() function gives a "pointers to functions 
  + * with different attributes" error during compilation.
  + */
  +void mod_so_null_cleanup(module *modp)
  +{
  +    /* This function left intentionally blank */
   }
  +#else
  +# define mod_so_null_cleanup null_cleanup
  +#endif
   
   /* load_module is called for the directive LoadModule 
    */
  @@ -223,11 +199,12 @@
       module *modp;
       const char *szModuleFile=server_root_relative(cmd->pool, filename);
   
  -    if (!(modhandle = dlopen(szModuleFile, RTLD_NOW)))
  +    if (!(modhandle = os_dl_load(szModuleFile)))
         {
  -     const char *my_error = dlerror();
  +     const char *my_error = os_dl_error();
        return pstrcat (cmd->pool, "Cannot load ", szModuleFile,
  -                     " into server: ", my_error,
  +                     " into server: ", 
  +                     my_error ? my_error : "(reason unknown)",
                        NULL);
         }
    
  @@ -238,9 +215,9 @@
       modname = pstrcat(cmd->pool, "_", modname, NULL);
   #endif
   
  -    if (!(modp = (module *)(dlsym (modhandle, modname)))) {
  +    if (!(modp = (module *)(os_dl_sym (modhandle, modname)))) {
        return pstrcat (cmd->pool, "Can't find module ", modname,
  -                     " in file ", filename, ":", dlerror(), NULL);
  +                     " in file ", filename, ":", os_dl_error(), NULL);
       }
        
       modp->dynamic_load_handle = modhandle;
  @@ -252,7 +229,7 @@
        * DLL to be unloaded.
        */
       register_cleanup(cmd->pool, modp, 
  -                  (void (*)(void*))unload_module, null_cleanup);
  +                  (void (*)(void*))unload_module, mod_so_null_cleanup);
   
       /* Alethea Patch (rws,djw2) - need to run configuration functions
          in new modules */
  @@ -278,16 +255,18 @@
   
       file = server_root_relative(cmd->pool, filename);
       
  -    if (!(handle = dlopen(file, 1))) {
  -     const char *my_error = dlerror();
  +    if (!(handle = os_dl_load(file))) {
  +     const char *my_error = os_dl_error();
        return pstrcat (cmd->pool, "Cannot load ", filename, 
  -                     " into server:", my_error, NULL);
  +                     " into server:", 
  +                     my_error ? my_error : "(reason unknown)",
  +                     NULL);
       }
       
       aplog_error(APLOG_MARK, APLOG_DEBUG|APLOG_NOERRNO, NULL,
                "loaded file %s", filename);
   
  -    register_cleanup(cmd->pool, handle, unload_file, null_cleanup);
  +    register_cleanup(cmd->pool, handle, unload_file, mod_so_null_cleanup);
   
       return NULL;
   }
  
  
  
  1.6       +43 -0     apache-1.3/src/os/unix/os.h
  
  Index: os.h
  ===================================================================
  RCS file: /export/home/cvs/apache-1.3/src/os/unix/os.h,v
  retrieving revision 1.5
  retrieving revision 1.6
  diff -u -r1.5 -r1.6
  --- os.h      1998/02/14 03:07:58     1.5
  +++ os.h      1998/02/24 10:30:55     1.6
  @@ -18,3 +18,46 @@
    */
   extern int os_is_path_absolute(const char *f);
   #endif
  +
  +/*
  + * Abstraction layer for dynamic loading of modules (mod_so.c)
  + */
  +
  +#if defined(LINUX) || defined(__FreeBSD__) || defined(SOLARIS) || \
  +    defined(__bsdi__) || defined(IRIX)
  +# define HAS_DLFCN
  +#endif
  +
  +#if defined(__FreeBSD__)
  +# define NEED_UNDERSCORE_SYM
  +#endif
  +
  +     /* OSes that don't support dlopen */
  +#if defined(UW) || defined(ULTRIX)
  +# define NO_DL
  +#endif
  +
  +     /* Start of real module */
  +#ifdef HAS_DLFCN
  +# include <dlfcn.h>
  +#else
  +void * dlopen (__const char * __filename, int __flag);
  +__const char * dlerror (void);
  +void * dlsym (void *, __const char *);
  +int dlclose (void *);
  +#endif
  +
  +#ifndef RTLD_NOW
  +/* 
  + * probably on an older system that doesn't support RTLD_NOW or RTLD_LAZY.
  + * The below define is a lie since we are really doing RTLD_LAZY since the
  + * system doesn't support RTLD_NOW.
  + */
  +# define RTLD_NOW 1
  +#endif
  +
  +#define os_dl_module_handle_type void *
  +#define os_dl_load(l)   dlopen(l, RTLD_NOW)
  +#define os_dl_unload(l) dlclose(l)
  +#define os_dl_sym(h,s)  dlsym(h,s)
  +#define os_dl_error()   dlerror()
  
  
  
  1.7       +3 -3      apache-1.3/src/os/win32/modules.c
  
  Index: modules.c
  ===================================================================
  RCS file: /export/home/cvs/apache-1.3/src/os/win32/modules.c,v
  retrieving revision 1.6
  retrieving revision 1.7
  diff -u -r1.6 -r1.7
  --- modules.c 1997/08/13 08:37:34     1.6
  +++ modules.c 1998/02/24 10:30:56     1.7
  @@ -6,7 +6,7 @@
   #include "http_config.h"
   
   extern module core_module;
  -extern module dll_module;
  +extern module so_module;
   extern module mime_module;
   extern module access_module;
   extern module auth_module;
  @@ -27,7 +27,7 @@
   
   module *prelinked_modules[] = {
     &core_module,
  -  &dll_module,
  +  &so_module,
     &mime_module,
     &access_module,
     &auth_module,
  @@ -49,7 +49,7 @@
   };
   module *preloaded_modules[] = {
     &core_module,
  -  &dll_module,
  +  &so_module,
     &mime_module,
     &access_module,
     &auth_module,
  
  
  
  1.13      +9 -0      apache-1.3/src/os/win32/os.h
  
  Index: os.h
  ===================================================================
  RCS file: /export/home/cvs/apache-1.3/src/os/win32/os.h,v
  retrieving revision 1.12
  retrieving revision 1.13
  diff -u -r1.12 -r1.13
  --- os.h      1998/02/14 03:08:00     1.12
  +++ os.h      1998/02/24 10:30:56     1.13
  @@ -95,3 +95,12 @@
   #define _spawnle                         os_spawnle
   #define spawnle                                  os_spawnle
   API_EXPORT(int) os_spawnle(int mode,const char *cmdname,...);
  +
  +/* Abstractions for dealing with shared object files (DLLs on Win32).
  + * These are used by mod_so.c
  + */
  +#define os_dl_module_handle_type HINSTANCE
  +#define os_dl_load(l)   LoadLibraryEx(l, NULL, LOAD_WITH_ALTERED_SEARCH_PATH)
  +#define os_dl_unload(l) FreeLibrary(l)
  +#define os_dl_sym(h,s)  GetProcAddress(h,s)
  +#define os_dl_error()   ""   /* for now */
  
  
  

Reply via email to