apr-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From s.@apache.org
Subject svn commit: r1460183 - in /apr/apr/trunk/util-misc: apr_reslist.c apr_thread_pool.c
Date Sat, 23 Mar 2013 16:12:52 GMT
Author: sf
Date: Sat Mar 23 16:12:52 2013
New Revision: 1460183

URL: http://svn.apache.org/r1460183
Log:
thread_pool/reslist: take ownership of the pool when we lock the mutex

(except in cases where there is no chance that the pool is used)


Modified:
    apr/apr/trunk/util-misc/apr_reslist.c
    apr/apr/trunk/util-misc/apr_thread_pool.c

Modified: apr/apr/trunk/util-misc/apr_reslist.c
URL: http://svn.apache.org/viewvc/apr/apr/trunk/util-misc/apr_reslist.c?rev=1460183&r1=1460182&r2=1460183&view=diff
==============================================================================
--- apr/apr/trunk/util-misc/apr_reslist.c (original)
+++ apr/apr/trunk/util-misc/apr_reslist.c Sat Mar 23 16:12:52 2013
@@ -143,6 +143,7 @@ static apr_status_t reslist_cleanup(void
 
 #if APR_HAS_THREADS
     apr_thread_mutex_lock(rl->listlock);
+    apr_pool_owner_set(rl->pool, 0);
 #endif
 
     while (rl->nidle > 0) {
@@ -182,6 +183,7 @@ APR_DECLARE(apr_status_t) apr_reslist_ma
 
 #if APR_HAS_THREADS
     apr_thread_mutex_lock(reslist->listlock);
+    apr_pool_owner_set(reslist->pool, 0);
 #endif
 
     /* Check if we need to create more resources, and if we are allowed to. */
@@ -332,6 +334,7 @@ APR_DECLARE(apr_status_t) apr_reslist_ac
 
 #if APR_HAS_THREADS
     apr_thread_mutex_lock(reslist->listlock);
+    apr_pool_owner_set(reslist->pool, 0);
 #endif
     /* If there are idle resources on the available list, use
      * them right away. */
@@ -412,6 +415,7 @@ APR_DECLARE(apr_status_t) apr_reslist_re
 
 #if APR_HAS_THREADS
     apr_thread_mutex_lock(reslist->listlock);
+    apr_pool_owner_set(reslist->pool, 0);
 #endif
     res = get_container(reslist);
     res->opaque = resource;
@@ -436,6 +440,7 @@ APR_DECLARE(apr_uint32_t) apr_reslist_ac
 
 #if APR_HAS_THREADS
     apr_thread_mutex_lock(reslist->listlock);
+    apr_pool_owner_set(reslist->pool, 0);
 #endif
     count = reslist->ntotal - reslist->nidle;
 #if APR_HAS_THREADS
@@ -451,6 +456,7 @@ APR_DECLARE(apr_status_t) apr_reslist_in
     apr_status_t ret;
 #if APR_HAS_THREADS
     apr_thread_mutex_lock(reslist->listlock);
+    apr_pool_owner_set(reslist->pool, 0);
 #endif
     ret = reslist->destructor(resource, reslist->params, reslist->pool);
     reslist->ntotal--;

Modified: apr/apr/trunk/util-misc/apr_thread_pool.c
URL: http://svn.apache.org/viewvc/apr/apr/trunk/util-misc/apr_thread_pool.c?rev=1460183&r1=1460182&r2=1460183&view=diff
==============================================================================
--- apr/apr/trunk/util-misc/apr_thread_pool.c (original)
+++ apr/apr/trunk/util-misc/apr_thread_pool.c Sat Mar 23 16:12:52 2013
@@ -243,6 +243,7 @@ static void *APR_THREAD_FUNC thread_pool
     struct apr_thread_list_elt *elt;
 
     apr_thread_mutex_lock(me->lock);
+    apr_pool_owner_set(me->pool, 0);
     elt = elt_new(me, t);
     if (!elt) {
         apr_thread_mutex_unlock(me->lock);
@@ -265,6 +266,7 @@ static void *APR_THREAD_FUNC thread_pool
             apr_thread_data_set(task, "apr_thread_pool_task", NULL, t);
             task->func(t, task->param);
             apr_thread_mutex_lock(me->lock);
+            apr_pool_owner_set(me->pool, 0);
             APR_RING_INSERT_TAIL(me->recycled_tasks, task,
                                  apr_thread_pool_task, link);
             elt->current_owner = NULL;
@@ -335,6 +337,7 @@ static apr_status_t thread_pool_cleanup(
     while (_myself->thd_cnt) {
         apr_sleep(20 * 1000);   /* spin lock with 20 ms */
     }
+    apr_pool_owner_set(_myself->pool, 0);
     apr_thread_mutex_destroy(_myself->lock);
     apr_thread_cond_destroy(_myself->cond);
     return APR_SUCCESS;
@@ -372,6 +375,7 @@ APR_DECLARE(apr_status_t) apr_thread_poo
          * initial threads to create.
          */
         apr_thread_mutex_lock(tp->lock);
+        apr_pool_owner_set(tp->pool, 0);
         rv = apr_thread_create(&t, NULL, thread_pool_func, tp, tp->pool);
         apr_thread_mutex_unlock(tp->lock);
         if (APR_SUCCESS != rv) {
@@ -485,6 +489,7 @@ static apr_status_t schedule_task(apr_th
     apr_thread_t *thd;
     apr_status_t rv = APR_SUCCESS;
     apr_thread_mutex_lock(me->lock);
+    apr_pool_owner_set(me->pool, 0);
 
     t = task_new(me, func, param, 0, owner, time);
     if (NULL == t) {
@@ -535,6 +540,7 @@ static apr_status_t add_task(apr_thread_
     apr_status_t rv = APR_SUCCESS;
 
     apr_thread_mutex_lock(me->lock);
+    apr_pool_owner_set(me->pool, 0);
 
     t = task_new(me, func, param, priority, owner, 0);
     if (NULL == t) {
@@ -696,6 +702,7 @@ APR_DECLARE(apr_status_t) apr_thread_poo
     apr_status_t rv = APR_SUCCESS;
 
     apr_thread_mutex_lock(me->lock);
+    apr_pool_owner_set(me->pool, 0);
     if (me->task_cnt > 0) {
         rv = remove_tasks(me, owner);
     }
@@ -783,6 +790,7 @@ static struct apr_thread_list_elt *trim_
     struct apr_thread_list_elt *head, *tail, *elt;
 
     apr_thread_mutex_lock(me->lock);
+    apr_pool_owner_set(me->pool, 0);
     if (idle) {
         thds = me->idle_thds;
         n = me->idle_cnt;



Mime
View raw message