]> granicus.if.org Git - apache/commitdiff
Resolved segfault in mod_isapi when configuring with ISAPICacheFile.
authorWilliam A. Rowe Jr <wrowe@apache.org>
Mon, 3 Dec 2001 19:46:32 +0000 (19:46 +0000)
committerWilliam A. Rowe Jr <wrowe@apache.org>
Mon, 3 Dec 2001 19:46:32 +0000 (19:46 +0000)
PR: 8563, 8919

git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@92301 13f79535-47bb-0310-9956-ffa450edef68

CHANGES
modules/arch/win32/mod_isapi.c

diff --git a/CHANGES b/CHANGES
index eebf7feec654ea5ea4eaeb66f7def724573edfbd..99ab70d76f5eb2cd147c457be903a98402140540 100644 (file)
--- a/CHANGES
+++ b/CHANGES
@@ -1,4 +1,7 @@
 Changes with Apache 2.0.30-dev
+
+  *) Resolved segfault in mod_isapi when configuring with ISAPICacheFile.
+     PR 8563, 8919  [William Rowe]
   
   *) Get binary builds working when libapr and libaprutil are built
      shared [Greg Ames]
index 133baecc029d1aa291b21b4085ef026b8d4d0817..d45502ad1d805a19ea8ffc0468f9ba8541c364e3 100644 (file)
@@ -114,7 +114,7 @@ module isapi_module;
 
 BOOL WINAPI GetServerVariable (HCONN hConn, LPSTR lpszVariableName,
                                LPVOID lpvBuffer, LPDWORD lpdwSizeofBuffer);
-BOOL WINAPI WriteClient (HCONN ConnID, LPVOID Buffer, LPDWORD lpwdwBytes,
+BOOL WINAPI WriteClient (HCONN ConnID, LPVOID Buffer, LPDWORD lpdwBytes,
                          DWORD dwReserved);
 BOOL WINAPI ReadClient (HCONN ConnID, LPVOID lpvBuffer, LPDWORD lpdwSize);
 BOOL WINAPI ServerSupportFunction (HCONN hConn, DWORD dwHSERequest,
@@ -134,7 +134,6 @@ BOOL WINAPI ServerSupportFunction (HCONN hConn, DWORD dwHSERequest,
 /* Our isapi server config structure */
 
 typedef struct {
-    HANDLE lock;
     apr_array_header_t *loaded;
     DWORD ReadAheadBuffer;
     int LogNotSupported;
@@ -169,39 +168,16 @@ typedef struct {
     HANDLE complete;
 } isapi_cid;
 
-static BOOL isapi_unload(isapi_loaded* isa, int force);
-
-static apr_status_t cleanup_isapi_server_config(void *sconfv)
-{
-    isapi_server_conf *sconf = sconfv;
-    size_t n;
-    isapi_loaded **isa;
-    n = sconf->loaded->nelts;
-    isa = (isapi_loaded **)sconf->loaded->elts;
-    while(n--) {
-        if ((*isa)->handle)
-            isapi_unload(*isa, TRUE); 
-        ++isa;
-    }
-    CloseHandle(sconf->lock);
-    return APR_SUCCESS;
-}
-
 static void *create_isapi_server_config(apr_pool_t *p, server_rec *s)
 {
     isapi_server_conf *sconf = apr_palloc(p, sizeof(isapi_server_conf));
     sconf->loaded = apr_array_make(p, 20, sizeof(isapi_loaded*));
-    sconf->lock = CreateMutex(NULL, FALSE, NULL);
-
+    
     sconf->ReadAheadBuffer = 49152;
     sconf->LogNotSupported    = -1;
     sconf->AppendLogToErrors   = 0;
     sconf->AppendLogToQuery    = 0;
 
-    apr_pool_cleanup_register(p, sconf, cleanup_isapi_server_config, 
-                                   apr_pool_cleanup_null);
-
     return sconf;
 }
 
@@ -214,7 +190,7 @@ static int compare_loaded(const void *av, const void *bv)
 }
 
 static int isapi_post_config(apr_pool_t *p, apr_pool_t *plog,
-                              apr_pool_t *ptemp, server_rec *s)
+                             apr_pool_t *ptemp, server_rec *s)
 {
     isapi_server_conf *sconf = ap_get_module_config(s->module_config, 
                                                     &isapi_module);
@@ -224,13 +200,20 @@ static int isapi_post_config(apr_pool_t *p, apr_pool_t *plog,
     /* sort the elements of the main_server, by filename */
     qsort(elts, nelts, sizeof(isapi_loaded*), compare_loaded);
 
-    /* and make the virtualhosts share the same thing */
+    /* and make all virtualhosts share the same */
     for (s = s->next; s; s = s->next) {
        ap_set_module_config(s->module_config, &isapi_module, sconf);
     }
     return OK;
 }
 
+static apr_status_t isapi_unload(isapi_loaded* isa, int force);
+
+static apr_status_t cleanup_isapi(void *isa)
+{
+    return isapi_unload((isapi_loaded*) isa, TRUE);
+}
+
 static apr_status_t isapi_load(apr_pool_t *p, isapi_server_conf *sconf, 
                                request_rec *r, const char *fpath, 
                                isapi_loaded** isa)
@@ -323,27 +306,30 @@ static apr_status_t isapi_load(apr_pool_t *p, isapi_server_conf *sconf,
 
     ++(*isa)->refcount;
 
+    apr_pool_cleanup_register(p, *isa, cleanup_isapi, 
+                                   apr_pool_cleanup_null);
+
     return APR_SUCCESS;
 }
 
-static int isapi_unload(isapi_loaded* isa, int force)
+static apr_status_t isapi_unload(isapi_loaded* isa, int force)
 {
     /* All done with the DLL... get rid of it...
      *
      * If optionally cached, pass HSE_TERM_ADVISORY_UNLOAD,
      * and if it returns TRUE, unload, otherwise, cache it.
      */
-    if ((--isa->refcount > 0) && !force)
-        return FALSE;
+    if (((--isa->refcount > 0) && !force) || !isa->handle)
+        return APR_SUCCESS;
     if (isa->TerminateExtension) {
         if (force)
             (*isa->TerminateExtension)(HSE_TERM_MUST_UNLOAD);
         else if (!(*isa->TerminateExtension)(HSE_TERM_ADVISORY_UNLOAD))
-            return FALSE;
+            return APR_EGENERAL;
     }
     apr_dso_unload(isa->handle);
     isa->handle = NULL;
-    return TRUE;
+    return APR_SUCCESS;
 }
 
 apr_status_t isapi_handler (request_rec *r)
@@ -653,7 +639,7 @@ BOOL WINAPI GetServerVariable (HCONN hConn, LPSTR lpszVariableName,
     return FALSE;
 }
 
-BOOL WINAPI WriteClient (HCONN ConnID, LPVOID Buffer, LPDWORD lpwdwBytes,
+BOOL WINAPI WriteClient (HCONN ConnID, LPVOID Buffer, LPDWORD lpdwBytes,
                          DWORD dwReserved)
 {
     request_rec *r = ((isapi_cid *)ConnID)->r;
@@ -664,7 +650,7 @@ BOOL WINAPI WriteClient (HCONN ConnID, LPVOID Buffer, LPDWORD lpwdwBytes,
         ; /* XXX: Fake it */
 
     bb = apr_brigade_create(r->pool);
-    b = apr_bucket_transient_create(Buffer, *lpwdwBytes);
+    b = apr_bucket_transient_create(Buffer, *lpdwBytes);
     APR_BRIGADE_INSERT_TAIL(bb, b);
     b = apr_bucket_flush_create();
     APR_BRIGADE_INSERT_TAIL(bb, b);
@@ -1214,7 +1200,7 @@ static const char *isapi_cmd_appendlogtoerrors(cmd_parms *cmd, void *config,
 }
 
 static const char *isapi_cmd_appendlogtoquery(cmd_parms *cmd, void *config, 
-                                               char *arg)
+                                              char *arg)
 {
     isapi_server_conf *sconf = ap_get_module_config(cmd->server->module_config,
                                                    &isapi_module);