You are viewing a plain text version of this content. The canonical link for it is here.
Posted to cvs@httpd.apache.org by wr...@apache.org on 2001/12/03 20:46:33 UTC
cvs commit: httpd-2.0/modules/arch/win32 mod_isapi.c
wrowe 01/12/03 11:46:32
Modified: . CHANGES
modules/arch/win32 mod_isapi.c
Log:
Resolved segfault in mod_isapi when configuring with ISAPICacheFile.
PR: 8563, 8919
Revision Changes Path
1.466 +3 -0 httpd-2.0/CHANGES
Index: CHANGES
===================================================================
RCS file: /home/cvs/httpd-2.0/CHANGES,v
retrieving revision 1.465
retrieving revision 1.466
diff -u -r1.465 -r1.466
--- CHANGES 2001/12/03 18:00:03 1.465
+++ CHANGES 2001/12/03 19:46:32 1.466
@@ -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]
1.54 +22 -36 httpd-2.0/modules/arch/win32/mod_isapi.c
Index: mod_isapi.c
===================================================================
RCS file: /home/cvs/httpd-2.0/modules/arch/win32/mod_isapi.c,v
retrieving revision 1.53
retrieving revision 1.54
diff -u -r1.53 -r1.54
--- mod_isapi.c 2001/11/26 16:27:01 1.53
+++ mod_isapi.c 2001/12/03 19:46:32 1.54
@@ -114,7 +114,7 @@
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 @@
/* Our isapi server config structure */
typedef struct {
- HANDLE lock;
apr_array_header_t *loaded;
DWORD ReadAheadBuffer;
int LogNotSupported;
@@ -169,39 +168,16 @@
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 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 @@
/* 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 @@
++(*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 @@
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 @@
; /* 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_appendlogtoquery(cmd_parms *cmd, void *config,
- char *arg)
+ char *arg)
{
isapi_server_conf *sconf = ap_get_module_config(cmd->server->module_config,
&isapi_module);