Return-Path: Delivered-To: apmail-apr-cvs-archive@apr.apache.org Received: (qmail 3903 invoked by uid 500); 23 Jul 2001 20:49:59 -0000 Mailing-List: contact cvs-help@apr.apache.org; run by ezmlm Precedence: bulk List-Post: List-Help: List-Unsubscribe: List-Subscribe: Reply-To: dev@apr.apache.org Delivered-To: mailing list cvs@apr.apache.org Received: (qmail 3872 invoked from network); 23 Jul 2001 20:49:58 -0000 Date: 23 Jul 2001 20:47:31 -0000 Message-ID: <20010723204731.4266.qmail@icarus.apache.org> From: jerenkrantz@apache.org To: apr-cvs@apache.org Subject: cvs commit: apr/memory/unix apr_sms.c X-Spam-Rating: h31.sny.collab.net 1.6.2 0/1000/N jerenkrantz 01/07/23 13:47:31 Modified: memory/unix apr_sms.c Log: Ensure that our parent knows to be thread-safe before we continue Switch to INTRAPROCESS lock - when we fork(), our shared memory doesn't matter anymore Create the lock from our parent's memory space - not our own as it may disappear while we still need the lock Revision Changes Path 1.49 +33 -24 apr/memory/unix/apr_sms.c Index: apr_sms.c =================================================================== RCS file: /home/cvs/apr/memory/unix/apr_sms.c,v retrieving revision 1.48 retrieving revision 1.49 diff -u -r1.48 -r1.49 --- apr_sms.c 2001/07/11 14:20:02 1.48 +++ apr_sms.c 2001/07/23 20:47:31 1.49 @@ -319,8 +319,7 @@ rv = APR_SUCCESS; #if APR_HAS_THREADS - if (sms->thread_register_fn) - rv = sms->thread_register_fn(sms, apr_os_thread_current()); + apr_sms_thread_register(sms, apr_os_thread_current()); #endif /* APR_HAS_THREADS */ #if APR_DEBUG_SHOW_FUNCTIONS @@ -612,7 +611,11 @@ sms->pre_destroy_fn(sms); if (sms->sms_lock) + { apr_lock_destroy(sms->sms_lock); + if (pms->free_fn) + return apr_sms_free(sms->parent, sms->sms_lock); + } #ifndef APR_POOLS_ARE_SMS /* XXX - This should eventually be removed */ @@ -856,38 +859,44 @@ apr_os_thread_t thread) { apr_status_t rv; - - do { + + /* Before attempting to acquire a lock for us, we must ensure that our + * parent is lock-safe. + */ + if (sms->parent) + { + apr_sms_thread_register(sms->parent, thread); + if (!sms->sms_lock) { /* Create the sms framework lock we'll use. */ - apr_lock_create(&sms->sms_lock, APR_MUTEX, APR_LOCKALL, - NULL, sms->pool); + apr_lock_create(&sms->sms_lock, APR_MUTEX, APR_INTRAPROCESS, + NULL, sms->parent->pool); } + } + if (sms->sms_lock) apr_lock_acquire(sms->sms_lock); - sms->threads++; + sms->threads++; - /* let the sms know about the thread if it is - * interested (so it can protect its private - * data with its own lock) - * - * if the sms is doesn't have a thread register - * function, or it wasn't able to register the - * thread, we should bomb out! - * XXX - not sure how to implement the bombing out - */ - rv = APR_ENOTIMPL; - if (sms->thread_register_fn) - rv = sms->thread_register_fn(sms, thread); + /* let the sms know about the thread if it is + * interested (so it can protect its private + * data with its own lock) + * + * if the sms is doesn't have a thread register + * function, or it wasn't able to register the + * thread, we should bomb out! + * XXX - not sure how to implement the bombing out + */ + rv = APR_ENOTIMPL; + if (sms->thread_register_fn) + rv = sms->thread_register_fn(sms, thread); + if (sms->sms_lock) apr_lock_release(sms->sms_lock); - if (rv != APR_SUCCESS) - return rv; - - sms = sms->parent; - } while (sms); + if (rv != APR_SUCCESS) + return rv; return APR_SUCCESS; }