httpd-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Amund Elstad <Amund.Els...@ergo.no>
Subject RE: DBM SSL Session Cache (Bug # 12705)
Date Tue, 17 Sep 2002 12:27:55 GMT
Thank you, I will experiment with mutex protection and see if it makes
things more stable. 

I am not very familiar with the sourcecode, but it does look very strange to
me. Even the (unused?) status function has mutex protection -:)

amund




-----Original Message-----
From: Jeff Trawick [mailto:trawick@attglobal.net]
Sent: 17. september 2002 13:35
To: dev@httpd.apache.org
Subject: Re: DBM SSL Session Cache (Bug # 12705)


Amund Elstad <Amund.Elstad@ergo.no> writes:

> Hi,
> 
> Can someone please explain why ssl_scache_dbm_retrieve() in
> modules/ssl/ssl_scache_dbm.c 
> is not protected by the the SSLMutex ? 
> 
> The function uses the same pool (module config) as the store/remove/expire
> operations, 
> so shouldn't it also be protected to avoid race conditions ? 
> 
> Our ssl-enabled server (httpd 2.0.40 on win32) server locks up in endless
> loops regulary, 
> and I have a trace showing that it is stuck inside pool-cleanup after
> calling dbm_close.
> (see http://nagoya.apache.org/bugzilla/show_bug.cgi?id=12705)

I can't explain why it isn't protected by the mutex.  Have you tried
protecting the code with a mutex and rebuilding?  At worse it would
slow things down a bit.

untested patch:

Index: modules/ssl/ssl_scache_dbm.c
===================================================================
RCS file: /home/cvs/httpd-2.0/modules/ssl/ssl_scache_dbm.c,v
retrieving revision 1.16
diff -u -r1.16 ssl_scache_dbm.c
--- modules/ssl/ssl_scache_dbm.c	17 May 2002 11:24:17 -0000	1.16
+++ modules/ssl/ssl_scache_dbm.c	17 Sep 2002 11:32:47 -0000
@@ -228,21 +228,25 @@
      * XXX: Should we open the dbm against r->pool so the cleanup will
      * do the apr_dbm_close? This would make the code a bit cleaner.
      */
+    ssl_mutex_on(s);
     if ((rc = apr_dbm_open(&dbm, mc->szSessionCacheDataFile,
 	    APR_DBM_RWCREATE, SSL_DBM_FILE_MODE, mc->pPool)) != APR_SUCCESS)
{
         ap_log_error(APLOG_MARK, APLOG_ERR, rc, s,
                      "Cannot open SSLSessionCache DBM file `%s' for reading
"
                      "(fetch)",
                      mc->szSessionCacheDataFile);
+        ssl_mutex_off(s);
         return NULL;
     }
     rc = apr_dbm_fetch(dbm, dbmkey, &dbmval);
     if (rc != APR_SUCCESS) {
         apr_dbm_close(dbm);
+        ssl_mutex_off(s);
         return NULL;
     }
     if (dbmval.dptr == NULL || dbmval.dsize <= sizeof(time_t)) {
         apr_dbm_close(dbm);
+        ssl_mutex_off(s);
         return NULL;
     }
 
@@ -251,12 +255,14 @@
     ucpData = (UCHAR *)malloc(nData);
     if (ucpData == NULL) {
         apr_dbm_close(dbm);
+        ssl_mutex_off(s);
         return NULL;
     }
     memcpy(ucpData, (char *)dbmval.dptr+sizeof(time_t), nData);
     memcpy(&expiry, dbmval.dptr, sizeof(time_t));
 
     apr_dbm_close(dbm);
+    ssl_mutex_off(s);
 
     /* make sure the stuff is still not expired */
     now = time(NULL);


-- 
Jeff Trawick | trawick@attglobal.net
Born in Roswell... married an alien...

Mime
View raw message