You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@httpd.apache.org by Paul Sutton <pa...@awe.com> on 1998/02/09 13:05:49 UTC

[PATCH] merge mod_so and mod_dll (fwd)

> So this patch updates mod_so.c to support building on NT. It provides a

Um, the past message contained a virtual patch. Here is the real patch.

//pcs

Index: mod_so.c
===================================================================
RCS file: /export/home/cvs/apache-1.3/src/modules/standard/mod_so.c,v
retrieving revision 1.4
diff -u -r1.4 mod_so.c
--- mod_so.c	1998/02/07 01:07:11	1.4
+++ mod_so.c	1998/02/09 11:53:13
@@ -114,7 +114,7 @@
 */
 
 /*
- * Module definition information
+ * Module definition information used by Configure
  *
  * MODULE-DEFINITION-START
  * Name: so_module
@@ -139,39 +139,57 @@
 #include "http_config.h"
 #include "http_log.h"
 
-     /* Os-specific stuff that goes in conf.h */
+/* Os-specific stuff that goes in conf.h */
 
-#if defined(LINUX) || defined(__FreeBSD__) || defined(SOLARIS) || \
+#ifdef WIN32
+
+# 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 */
+
+#else
+
+# if defined(LINUX) || defined(__FreeBSD__) || defined(SOLARIS) || \
     defined(__bsdi__) || defined(IRIX)
-#define HAS_DLFCN
-#endif
+#  define HAS_DLFCN
+# endif
 
-#if defined(__FreeBSD__)
-#define NEED_UNDERSCORE_SYM
-#endif
+# if defined(__FreeBSD__)
+#  define NEED_UNDERSCORE_SYM
+# endif
 
      /* OSes that don't support dlopen */
-#if defined(UW) || defined(ULTRIX)
-#define NO_DL
-#endif
+# if defined(UW) || defined(ULTRIX)
+#  define NO_DL
+# endif
 
      /* Start of real module */
-#ifdef HAS_DLFCN
-#include <dlfcn.h>
-#else
+# 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
+# endif
 
-#ifndef RTLD_NOW
+# 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
+#  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()
+
 #endif
 
 static int have_symbol_table = 0;
@@ -195,7 +213,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,7 +229,16 @@
 {
     /* 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);
+}
+
+/* This is a cleanup which does nothing. It would be nicer to use
+ * the API-provided null_cleanup() gives a "pointers to functions 
+ * with different attributes" error when compiling on Win32.
+ */
+void mod_so_null_cleanup(module *modp)
+{
+    /* This function left intentionally blank */
 }
 
 /* load_module is called for the directive LoadModule 
@@ -223,11 +250,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 +266,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 +280,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 +306,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;
 }



Re: [PATCH] merge mod_so and mod_dll (fwd)

Posted by Martin Kraemer <Ma...@mch.sni.de>.
On Mon, Feb 09, 1998 at 12:05:49PM +0000, Paul Sutton wrote:
> > So this patch updates mod_so.c to support building on NT. It provides a

(Untested) +1. Good idea to merge the two! I would have thought the
differences were bigger.

    Martin
-- 
| S I E M E N S |  <Ma...@mch.sni.de>  |      Siemens Nixdorf
| ------------- |   Voice: +49-89-636-46021     |  Informationssysteme AG
| N I X D O R F |   FAX:   +49-89-636-44994     |   81730 Munich, Germany
~~~~~~~~~~~~~~~~My opinions only, of course; pgp key available on request

Re: [PATCH] merge mod_so and mod_dll (fwd)

Posted by Randy Terbush <ra...@covalent.net>.
+1 untested

Paul Sutton <pa...@awe.com> wrote:
> > So this patch updates mod_so.c to support building on NT. It provides a
> 
> Um, the past message contained a virtual patch. Here is the real patch.
> 
> //pcs
> 
> Index: mod_so.c
> ===================================================================
> RCS file: /export/home/cvs/apache-1.3/src/modules/standard/mod_so.c,v
> retrieving revision 1.4
> diff -u -r1.4 mod_so.c
> --- mod_so.c	1998/02/07 01:07:11	1.4
> +++ mod_so.c	1998/02/09 11:53:13
> @@ -114,7 +114,7 @@
>  */
>  
>  /*
> - * Module definition information
> + * Module definition information used by Configure
>   *
>   * MODULE-DEFINITION-START
>   * Name: so_module
> @@ -139,39 +139,57 @@
>  #include "http_config.h"
>  #include "http_log.h"
>  
> -     /* Os-specific stuff that goes in conf.h */
> +/* Os-specific stuff that goes in conf.h */
>  
> -#if defined(LINUX) || defined(__FreeBSD__) || defined(SOLARIS) || \
> +#ifdef WIN32
> +
> +# 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 */
> +
> +#else
> +
> +# if defined(LINUX) || defined(__FreeBSD__) || defined(SOLARIS) || \
>      defined(__bsdi__) || defined(IRIX)
> -#define HAS_DLFCN
> -#endif
> +#  define HAS_DLFCN
> +# endif
>  
> -#if defined(__FreeBSD__)
> -#define NEED_UNDERSCORE_SYM
> -#endif
> +# if defined(__FreeBSD__)
> +#  define NEED_UNDERSCORE_SYM
> +# endif
>  
>       /* OSes that don't support dlopen */
> -#if defined(UW) || defined(ULTRIX)
> -#define NO_DL
> -#endif
> +# if defined(UW) || defined(ULTRIX)
> +#  define NO_DL
> +# endif
>  
>       /* Start of real module */
> -#ifdef HAS_DLFCN
> -#include <dlfcn.h>
> -#else
> +# 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
> +# endif
>  
> -#ifndef RTLD_NOW
> +# 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
> +#  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()
> +
>  #endif
>  
>  static int have_symbol_table = 0;
> @@ -195,7 +213,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,7 +229,16 @@
>  {
>      /* 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);
> +}
> +
> +/* This is a cleanup which does nothing. It would be nicer to use
> + * the API-provided null_cleanup() gives a "pointers to functions 
> + * with different attributes" error when compiling on Win32.
> + */
> +void mod_so_null_cleanup(module *modp)
> +{
> +    /* This function left intentionally blank */
>  }
>  
>  /* load_module is called for the directive LoadModule 
> @@ -223,11 +250,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 +266,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 +280,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 +306,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;
>  }
>