apr-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From traw...@apache.org
Subject svn commit: r1001679 - in /apr/apr-util/branches/1.3.x: CHANGES misc/apr_thread_pool.c
Date Mon, 27 Sep 2010 11:46:23 GMT
Author: trawick
Date: Mon Sep 27 11:46:22 2010
New Revision: 1001679

URL: http://svn.apache.org/viewvc?rev=1001679&view=rev
Log:
merge from old apr-util trunk r709135:

misc/apr_thread_pool.c
  (apr_thread_pool_create): Only set the output variable if we were successful.

Submitted by: Paul Querna

Modified:
    apr/apr-util/branches/1.3.x/CHANGES
    apr/apr-util/branches/1.3.x/misc/apr_thread_pool.c

Modified: apr/apr-util/branches/1.3.x/CHANGES
URL: http://svn.apache.org/viewvc/apr/apr-util/branches/1.3.x/CHANGES?rev=1001679&r1=1001678&r2=1001679&view=diff
==============================================================================
--- apr/apr-util/branches/1.3.x/CHANGES [utf-8] (original)
+++ apr/apr-util/branches/1.3.x/CHANGES [utf-8] Mon Sep 27 11:46:22 2010
@@ -1,6 +1,9 @@
                                                      -*- coding: utf-8 -*-
 Changes with APR-util 1.3.10
 
+  *) apr_thread_pool_create(): Only set the output thread pool handle on
+     success.  [Paul Querna]
+
   *) DBD ODBC support: Fix memory corruption using apr_dbd_datum_get() with
      several different data types, including APR_DBD_TYPE_TIME.  PR 49645.
      [<kappa psilambda.com>]

Modified: apr/apr-util/branches/1.3.x/misc/apr_thread_pool.c
URL: http://svn.apache.org/viewvc/apr/apr-util/branches/1.3.x/misc/apr_thread_pool.c?rev=1001679&r1=1001678&r2=1001679&view=diff
==============================================================================
--- apr/apr-util/branches/1.3.x/misc/apr_thread_pool.c (original)
+++ apr/apr-util/branches/1.3.x/misc/apr_thread_pool.c Mon Sep 27 11:46:22 2010
@@ -362,33 +362,36 @@ APU_DECLARE(apr_status_t) apr_thread_poo
 {
     apr_thread_t *t;
     apr_status_t rv = APR_SUCCESS;
+    apr_thread_pool_t *tp;
 
-    *me = apr_pcalloc(pool, sizeof(**me));
-    if (!*me) {
-        return APR_ENOMEM;
-    }
+    *me = NULL;
+    tp = apr_pcalloc(pool, sizeof(apr_thread_pool_t));
 
-    (*me)->pool = pool;
+    tp->pool = pool;
 
-    rv = thread_pool_construct(*me, init_threads, max_threads);
+    rv = thread_pool_construct(tp, init_threads, max_threads);
     if (APR_SUCCESS != rv) {
-        *me = NULL;
         return rv;
     }
-    apr_pool_cleanup_register(pool, *me, thread_pool_cleanup,
+    apr_pool_cleanup_register(pool, tp, thread_pool_cleanup,
                               apr_pool_cleanup_null);
 
     while (init_threads) {
-        rv = apr_thread_create(&t, NULL, thread_pool_func, *me, (*me)->pool);
+        rv = apr_thread_create(&t, NULL, thread_pool_func, tp, tp->pool);
         if (APR_SUCCESS != rv) {
             break;
         }
-        ++(*me)->thd_cnt;
-        if ((*me)->thd_cnt > (*me)->thd_high)
-            (*me)->thd_high = (*me)->thd_cnt;
+        tp->thd_cnt++;
+        if (tp->thd_cnt > tp->thd_high) {
+            tp->thd_high = tp->thd_cnt;
+        }
         --init_threads;
     }
 
+    if (rv == APR_SUCCESS) {
+        *me = tp;
+    }
+
     return rv;
 }
 



Mime
View raw message