rse         98/04/13 03:32:28

  Modified:    src/os/win32 os.h
               src/os/unix os.h os.c
               src/os/bs2000 os.h os.c
               src/modules/standard mod_so.c mod_cgi.c
               src/main http_core.c
               src/include compat.h
  Log:
  Manual DSO cleanup after renaming:
  - renamed remaining os_ stuff in os/unix/ and os/bs2000/ to ap_ variants
  - merged the ap_dso_xxxx non-HPUX-specific #defines
    and the HPUX-specific functions
  - moved the FreeBSD-underscore hack from mod_so (where it was badly placed
    because it is a low-level stuff) to the dlsym() call in os/unix/os.c
    (where is is placed better because _there_ is the os-specific stuff)
  - some minor cleanups to os.h
  - additions to compat.h
  
  Revision  Changes    Path
  1.16      +5 -5      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.15
  retrieving revision 1.16
  diff -u -r1.15 -r1.16
  --- os.h      1998/04/11 12:01:06     1.15
  +++ os.h      1998/04/13 10:32:23     1.16
  @@ -101,8 +101,8 @@
   /* 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 */
  +#define ap_dso_handle_t  HINSTANCE
  +#define ap_dso_load(l)   LoadLibraryEx(l, NULL, 
LOAD_WITH_ALTERED_SEARCH_PATH)
  +#define ap_dso_unload(l) FreeLibrary(l)
  +#define ap_dso_sym(h,s)  GetProcAddress(h,s)
  +#define ap_dso_error()   ""  /* for now */
  
  
  
  1.20      +26 -32    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.19
  retrieving revision 1.20
  diff -u -r1.19 -r1.20
  --- os.h      1998/04/12 15:49:28     1.19
  +++ os.h      1998/04/13 10:32:23     1.20
  @@ -80,55 +80,49 @@
   #endif
   
   /*
  - * Abstraction layer for dynamic loading of modules (mod_so.c)
  + *  Abstraction layer for loading
  + *  Apache modules under run-time via 
  + *  dynamic shared object (DSO) mechanism
    */
   
  -#if defined(LINUX) || defined(__FreeBSD__) || defined(SOLARIS2) || \
  -    defined(__bsdi__) || defined(IRIX) || defined(SVR4) || defined(OSF1)
  -# define HAVE_DLFCN_H 1
  +#if defined(HPUX) || defined(HPUX10)
  +#define HAVE_DL_H 1
   #endif
   
  -#if defined(__FreeBSD__)
  -# define NEED_UNDERSCORE_SYM
  +#if defined(LINUX) || defined(__FreeBSD__) || defined(SOLARIS2) || \
  +    defined(__bsdi__) || defined(IRIX) || defined(SVR4) || defined(OSF1)
  +#define HAVE_DLFCN_H 1
   #endif
   
  -     /* OSes that don't support dlopen */
  -#if defined(UW) || defined(ULTRIX) || defined(HPUX) || defined(HPUX10)
  -# define NO_DL
  +#ifdef HAVE_DL_H
  +#include <dl.h>
   #endif
   
  -     /* Start of real module */
   #ifdef HAVE_DLFCN_H
  -# include <dlfcn.h>
  +#include <dlfcn.h>
   #else
  -void * dlopen (const char * __filename, int __flag);
  -const char * dlerror (void);
  -void * dlsym (void *, const char *);
  -int dlclose (void *);
  +void *dlopen(const char *, int);
  +int dlclose(void *);
  +void *dlsym(void *, const char *);
  +const char *dlerror(void);
   #endif
   
  -#ifndef RTLD_NOW
  -/* 
  - * probably on an older system that doesn't support RTLD_NOW or RTLD_LAZY.
  +/* 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
  +#ifndef RTLD_NOW
  +#define RTLD_NOW 1
   #endif
   
  -#if defined(HPUX) || defined(HPUX10)
  -#include <dl.h>
  -#define os_dl_module_handle_type void *
  -void *os_dl_load(char *path);
  -void os_dl_unload(void *handle);
  -void *os_dl_sym(void *handle, char *symname);
  -char *os_dl_error(void);
  -#else
  -#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()
  +#if defined(__FreeBSD__)
  +#define DLSYM_NEEDS_UNDERSCORE
   #endif
  +
  +#define     ap_dso_handle_t  void *
  +void *      ap_dso_load(const char *);
  +void        ap_dso_unload(void *);
  +void *      ap_dso_sym(void *, const char *);
  +const char *ap_dso_error(void);
   
   #endif       /* !APACHE_OS_H */
  
  
  
  1.8       +31 -15    apache-1.3/src/os/unix/os.c
  
  Index: os.c
  ===================================================================
  RCS file: /export/home/cvs/apache-1.3/src/os/unix/os.c,v
  retrieving revision 1.7
  retrieving revision 1.8
  diff -u -r1.7 -r1.8
  --- os.c      1998/04/12 15:49:28     1.7
  +++ os.c      1998/04/13 10:32:24     1.8
  @@ -10,34 +10,39 @@
   /* some linkers complain unless there's at least one function in each
    * .o file... and extra prototype is for gcc -Wmissing-prototypes
    */
  -extern void os_is_not_here(void);
  -void os_is_not_here(void) {}
  +extern void ap_is_not_here(void);
  +void ap_is_not_here(void) {}
   
  -
  -#if defined(HPUX) || defined(HPUX10)
  -
   /*
  - * HPUX dlopen interface-emulation
  + *  Abstraction layer for loading
  + *  Apache modules under run-time via 
  + *  dynamic shared object (DSO) mechanism
    */
   
  -#include <dl.h>
  -#include <errno.h>
  -
  -void *os_dl_load(char *path)
  +void *ap_dso_load(const char *path)
   {
  +#if defined(HPUX) || defined(HPUX10)
       shl_t handle;
       handle = shl_load(path, BIND_IMMEDIATE|BIND_VERBOSE|BIND_NOSTART, 0L);
       return (void *)handle;
  +#else
  +    return dlopen(path, RTLD_NOW);
  +#endif
   }
   
  -void os_dl_unload(void *handle) 
  +void ap_dso_unload(void *handle) 
   {
  +#if defined(HPUX) || defined(HPUX10)
       shl_unload((shl_t)handle);
  +#else
  +    dlclose(handle);
  +#endif
       return;
   }
   
  -void *os_dl_sym(void *handle, char *symname)
  +void *ap_dso_sym(void *handle, const char *symname)
   {
  +#if defined(HPUX) || defined(HPUX10)
       void *symaddr = NULL;
       int status;
   
  @@ -46,12 +51,23 @@
       if (status == -1 && errno == 0) /* try TYPE_DATA instead */
           status = shl_findsym((shl_t *)&handle, symname, TYPE_DATA, &symaddr);
       return (status == -1 ? NULL : symaddr);
  +#else /* ndef HPUX */
  +#ifdef DLSYM_NEEDS_UNDERSCORE
  +    char symbol[256];
  +    sprintf(symbol, "_%s", symname);
  +    return dlsym(handle, symbol);
  +#else
  +    return dlsym(handle, symname);
  +#endif
  +#endif /* ndef HPUX */
   }
   
  -char *os_dl_error(void)
  +const char *ap_dso_error(void)
   {
  +#if defined(HPUX) || defined(HPUX10)
       return strerror(errno);
  +#else
  +    return dlerror();
  +#endif
   }
  -
  -#endif /* HPUX dlopen interface-emulation */
   
  
  
  
  1.6       +1 -1      apache-1.3/src/os/bs2000/os.h
  
  Index: os.h
  ===================================================================
  RCS file: /export/home/cvs/apache-1.3/src/os/bs2000/os.h,v
  retrieving revision 1.5
  retrieving revision 1.6
  diff -u -r1.5 -r1.6
  --- os.h      1998/04/11 12:01:03     1.5
  +++ os.h      1998/04/13 10:32:24     1.6
  @@ -26,5 +26,5 @@
   /* Sorry if this is ugly, but the include order doesn't allow me
    * to use request_rec here... */
   struct request_rec;
  -extern int os_checkconv(struct request_rec *r);
  +extern int ap_checkconv(struct request_rec *r);
   #endif /*AP_OS_BS2000_OS_H*/
  
  
  
  1.7       +1 -1      apache-1.3/src/os/bs2000/os.c
  
  Index: os.c
  ===================================================================
  RCS file: /export/home/cvs/apache-1.3/src/os/bs2000/os.c,v
  retrieving revision 1.6
  retrieving revision 1.7
  diff -u -r1.6 -r1.7
  --- os.c      1998/04/11 12:01:02     1.6
  +++ os.c      1998/04/13 10:32:25     1.7
  @@ -64,7 +64,7 @@
   #include "os.h"
   
   /* Check the Content-Type to decide if conversion is needed */
  -int os_checkconv(struct request_rec *r)
  +int ap_checkconv(struct request_rec *r)
   {
       int convert_to_ascii;
   
  
  
  
  1.20      +9 -19     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.19
  retrieving revision 1.20
  diff -u -r1.19 -r1.20
  --- mod_so.c  1998/04/11 12:00:51     1.19
  +++ mod_so.c  1998/04/13 10:32:25     1.20
  @@ -195,7 +195,7 @@
       ap_remove_module(modi->modp);
   
       /* unload the module space itself */
  -    os_dl_unload((os_dl_module_handle_type)modi->modp->dynamic_load_handle);
  +    ap_dso_unload((ap_dso_handle_t)modi->modp->dynamic_load_handle);
   
       /* destroy the module information */
       modi->modp = NULL;
  @@ -211,9 +211,7 @@
   
   static void unload_file(void *handle)
   {
  -    /* The Linux manpage doesn't give any way to check the success of
  -     * dlclose() */
  -    os_dl_unload((os_dl_module_handle_type)handle);
  +    ap_dso_unload((ap_dso_handle_t)handle);
   }
   
   /* 
  @@ -224,7 +222,7 @@
   static const char *load_module(cmd_parms *cmd, void *dummy, 
                                  char *modname, char *filename)
   {
  -    void *modhandle;
  +    ap_dso_handle_t modhandle;
       module *modp;
       const char *szModuleFile=ap_server_root_relative(cmd->pool, filename);
       so_server_conf *sconf;
  @@ -250,8 +248,8 @@
       /*
        * Load the file into the Apache address space
        */
  -    if (!(modhandle = os_dl_load(szModuleFile))) {
  -     const char *my_error = os_dl_error();
  +    if (!(modhandle = ap_dso_load(szModuleFile))) {
  +     const char *my_error = ap_dso_error();
        return ap_pstrcat (cmd->pool, "Cannot load ", szModuleFile,
                        " into server: ", 
                        my_error ? my_error : "(reason unknown)",
  @@ -261,21 +259,13 @@
                "loaded module %s", modname);
   
       /*
  -     * Optionally prefix the symbol with an underscore
  -     * for some platforms.
  -     */
  -#ifdef NEED_UNDERSCORE_SYM
  -    modname = ap_pstrcat(cmd->pool, "_", modname, NULL);
  -#endif
  -
  -    /*
        * Retrieve the pointer to the module structure through the module name:
        * First with the hidden variant (prefix `AP_') and then with the plain
        * symbol name.
        */
  -    if (!(modp = (module *)(os_dl_sym (modhandle, modname)))) {
  +    if (!(modp = (module *)(ap_dso_sym(modhandle, modname)))) {
        return ap_pstrcat(cmd->pool, "Can't find module ", modname,
  -                    " in file ", filename, ":", os_dl_error(), NULL);
  +                    " in file ", filename, ":", ap_dso_error(), NULL);
       }
       modi->modp = modp;
       modp->dynamic_load_handle = modhandle;
  @@ -319,8 +309,8 @@
   
       file = ap_server_root_relative(cmd->pool, filename);
       
  -    if (!(handle = os_dl_load(file))) {
  -     const char *my_error = os_dl_error();
  +    if (!(handle = ap_dso_load(file))) {
  +     const char *my_error = ap_dso_error();
        return ap_pstrcat (cmd->pool, "Cannot load ", filename, 
                        " into server:", 
                        my_error ? my_error : "(reason unknown)",
  
  
  
  1.75      +1 -1      apache-1.3/src/modules/standard/mod_cgi.c
  
  Index: mod_cgi.c
  ===================================================================
  RCS file: /export/home/cvs/apache-1.3/src/modules/standard/mod_cgi.c,v
  retrieving revision 1.74
  retrieving revision 1.75
  diff -u -r1.74 -r1.75
  --- mod_cgi.c 1998/04/11 12:00:45     1.74
  +++ mod_cgi.c 1998/04/13 10:32:26     1.75
  @@ -499,7 +499,7 @@
   
   #ifdef CHARSET_EBCDIC
           /* Now check the Content-Type to decide if conversion is needed */
  -        os_checkconv(r);
  +        ap_checkconv(r);
   #endif /*CHARSET_EBCDIC*/
   
        location = ap_table_get(r->headers_out, "Location");
  
  
  
  1.182     +1 -1      apache-1.3/src/main/http_core.c
  
  Index: http_core.c
  ===================================================================
  RCS file: /export/home/cvs/apache-1.3/src/main/http_core.c,v
  retrieving revision 1.181
  retrieving revision 1.182
  diff -u -r1.181 -r1.182
  --- http_core.c       1998/04/11 12:00:29     1.181
  +++ http_core.c       1998/04/13 10:32:26     1.182
  @@ -2127,7 +2127,7 @@
         * the type to the real text/{plain,html,...} type. Otherwise, we
         * set a flag that translation is required later on.
         */
  -        os_checkconv(r);
  +        ap_checkconv(r);
   #endif /*CHARSET_EBCDIC*/
   
        ap_send_http_header (r);
  
  
  
  1.2       +4 -0      apache-1.3/src/include/compat.h
  
  Index: compat.h
  ===================================================================
  RCS file: /export/home/cvs/apache-1.3/src/include/compat.h,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- compat.h  1998/04/11 12:02:36     1.1
  +++ compat.h  1998/04/13 10:32:27     1.2
  @@ -389,5 +389,9 @@
   #define util_uri_init                  ap_util_uri_init
   #define uudecode                       ap_uudecode
   #define vbprintf                       ap_vbprintf
  +#define os_dl_load                     ap_dso_load
  +#define os_dl_unload                   ap_dso_unload
  +#define os_dl_sym                      ap_dso_sym
  +#define os_dl_error                    ap_dso_error
   
   #endif /* APACHE_COMPAT_H */
  
  
  

Reply via email to