httpd-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Allan Edwards" <...@raleigh.ibm.com>
Subject hook registration & DSO reloads
Date Wed, 22 Mar 2000 15:20:54 GMT
This will fix the problem reported recently in 2.0 whereby hook
registrations are not cleared out when DSO's are unloaded, causing segfaults
if the DSO gets reloaded to a different address (tested on Win32). Comments
welcomed...

Allan
----------------------------------------------------------------------------
----------------------------------------------------------
Index: ap/ap_hooks.c
===================================================================
RCS file: /home/cvs/apache-2.0/src/ap/ap_hooks.c,v
retrieving revision 1.10
diff -u -r1.10 ap_hooks.c
--- ap/ap_hooks.c	2000/01/28 18:00:33	1.10
+++ ap/ap_hooks.c	2000/03/22 14:51:12
@@ -42,7 +42,7 @@
     qsort(pItems,nItems,sizeof *pItems,crude_order);
     for(n=0 ; n < nItems ; ++n) {
 	pData[n].nPredecessors=0;
-	pData[n].ppPredecessors=ap_palloc(p,nItems*sizeof
*pData[n].ppPredecessors);
+	pData[n].ppPredecessors=ap_pcalloc(p,nItems*sizeof
*pData[n].ppPredecessors);
 	pData[n].pNext=NULL;
 	pData[n].pData=&pItems[n];
     }
@@ -165,6 +165,17 @@
 	HookSortEntry *pEntry=&((HookSortEntry *)s_aHooksToSort->elts)[n];
 	*pEntry->paHooks=sort_hook(*pEntry->paHooks,pEntry->szHookName);
     }
+}
+
+void ap_hook_deregister_all(void)
+{
+    int n;
+
+    for(n=0 ; n < s_aHooksToSort->nelts ; ++n) {
+        HookSortEntry *pEntry=&((HookSortEntry *)s_aHooksToSort->elts)[n];
+        *pEntry->paHooks=NULL;
+    }
+    s_aHooksToSort=NULL;
 }

 void ap_show_hook(const char *szName,const char * const *aszPre,
Index: include/http_config.h
===================================================================
RCS file: /home/cvs/apache-2.0/src/include/http_config.h,v
retrieving revision 1.7
diff -u -r1.7 http_config.h
--- include/http_config.h	2000/03/10 00:05:50	1.7
+++ include/http_config.h	2000/03/22 14:51:13
@@ -329,6 +329,8 @@
 server_rec *ap_read_config(process_rec *process, ap_context_t *temp_pool,
const char *config_name);
 void ap_post_config_hook(ap_context_t *pconf, ap_context_t *plog,
ap_context_t *ptemp, server_rec *s);
 void ap_child_init_hook(ap_context_t *pchild, server_rec *s);
+void ap_register_hooks(module *m);
+void ap_hook_deregister_all(void);

 /* For http_request.c... */

Index: main/http_config.c
===================================================================
RCS file: /home/cvs/apache-2.0/src/main/http_config.c,v
retrieving revision 1.28
diff -u -r1.28 http_config.c
--- main/http_config.c	2000/03/15 23:18:31	1.28
+++ main/http_config.c	2000/03/22 14:51:17
@@ -360,7 +360,7 @@
 int g_bDebugHooks;
 const char *g_szCurrentHookName;

-static void register_hooks(module *m)
+void ap_register_hooks(module *m)
     {
     if(m->register_hooks)
 	{
@@ -430,7 +430,7 @@
 #endif /*_OSD_POSIX*/

     /* FIXME: is this the right place to call this? */
-    register_hooks(m);
+    ap_register_hooks(m);
 }

 /*
Index: main/http_main.c
===================================================================
RCS file: /home/cvs/apache-2.0/src/main/http_main.c,v
retrieving revision 1.34
diff -u -r1.34 http_main.c
--- main/http_main.c	2000/03/15 23:18:31	1.34
+++ main/http_main.c	2000/03/22 14:51:18
@@ -291,6 +291,7 @@
     ap_context_t *plog; /* Pool of log streams, reset _after_ each read of
conf */
     ap_context_t *ptemp; /* Pool for temporary config stuff, reset often */
     ap_context_t *pcommands; /* Pool for -C and -c switches */
+    module **mod;

     ap_initialize();
     process = create_process(argc, (const char **)argv);
@@ -300,7 +301,7 @@

     ap_util_uri_init();

-    g_pHookPool=pglobal;
+    g_pHookPool=pconf;

     ap_setup_prelinked_modules(process);

@@ -370,7 +371,11 @@
     ap_destroy_pool(ptemp);

     for (;;) {
+	ap_hook_deregister_all();
 	ap_clear_pool(pconf);
+	for (mod = ap_prelinked_modules; *mod != NULL; mod++) {
+		ap_register_hooks(*mod);
+	}
 	ap_create_context(&ptemp, pconf);
 	ap_server_root = def_server_root;
 	ap_run_pre_config(pconf, plog, ptemp);


Mime
View raw message