Hi,

Am Montag, 27. November 2006 18:24 schrieb Bogdan-Andrei Iancu:
> I think we should go for the "best, but more difficult" option - how a
> module is to be load must be 100% transparent for the user, so this
> information should not reside in script, but in the module interface.

ACK.

> let's have a new field in the interface saying how the module should be
> load - if set to RTLD_GLOBAL, the module will be accordingly reloaded.

I'm attaching a patch. It creates a new struct "mod_info" in the modules. 
Uppon loading a module, the symbol is looked up. If it does not exist, 
everything remains as it was; if it _does_ exist, it's currently single 
element dlopenflags is used for a second dlopen call.

Please tell me if this is approximately what you'd like.

Thx,
   Bastian

-- 
Collax GmbH . Burkheimer Straße 3 . 79111 Freiburg . Germany
p: +49 (0) 761-45684-24
f: +49 (0) 761-45684-10        www.collax.com

\ God I want patience, and I WANT IT NOW!
Index: sr_module.h
===================================================================
RCS file: /cvsroot/openser/sip-server/sr_module.h,v
retrieving revision 1.8
diff -u -r1.8 sr_module.h
--- sr_module.h	23 Nov 2006 21:57:14 -0000	1.8
+++ sr_module.h	28 Nov 2006 08:49:33 -0000
@@ -159,5 +159,10 @@
  *  - returns >0 if ok, 0 to drop message
  */
 
+struct mod_info_ {
+	int dlopenflags;
+};
+
+typedef struct mod_info_ mod_info_t;
 
 #endif
Index: sr_module.c
===================================================================
RCS file: /cvsroot/openser/sip-server/sr_module.c,v
retrieving revision 1.7
diff -u -r1.7 sr_module.c
--- sr_module.c	23 Nov 2006 21:57:13 -0000	1.7
+++ sr_module.c	28 Nov 2006 08:49:33 -0000
@@ -199,6 +199,8 @@
 	char* error;
 	struct module_exports* exp;
 	struct sr_module* t;
+	mod_info_t *info;
+	int flags;
 	
 #ifndef RTLD_NOW
 /* for openbsd */
@@ -210,6 +212,22 @@
 					path, dlerror() );
 		goto error;
 	}
+
+	dlerror();
+	if ((info = dlsym(handle, "mod_info"))) {	/* mod_info found */
+		if (!dlerror()) {			/* ... and no error occured */
+			flags = info->dlopenflags;
+			dlclose(handle);
+			DBG("DEBUG:load_module:Reloading module %s with flags %d\n", path, flags);
+			handle = dlopen(path, flags);
+			if (handle==0){
+				LOG(L_ERR, "ERROR: load_module: could not open module <%s>: %s\n",
+							path, dlerror() );
+				goto error;
+			}
+
+		}
+	}
 	
 	for(t=modules;t; t=t->next){
 		if (t->handle==handle){
_______________________________________________
Devel mailing list
[email protected]
http://openser.org/cgi-bin/mailman/listinfo/devel

Reply via email to