You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@apr.apache.org by br...@apache.org on 2014/01/21 12:25:06 UTC

svn commit: r1559977 - in /apr/apr/branches/1.4.x: ./ test/testdir.c

Author: brane
Date: Tue Jan 21 11:25:06 2014
New Revision: 1559977

URL: http://svn.apache.org/r1559977
Log:
Merged r1559975 from trunk:

    Give every thread in the parallel recursive mkdir test its own pool
    to play with, to prevent weird data interdependencies.

    * test/testdir.c
      (struct thread_data): Encapsulates abts_case and per-thread pool.
      (thread_mkdir_func): Thread data is thread_data, not abts_case.
      (test_mkdir_recurs_parallel):
         Create a separate pool and thread data struct for each thread.

Modified:
    apr/apr/branches/1.4.x/   (props changed)
    apr/apr/branches/1.4.x/test/testdir.c

Propchange: apr/apr/branches/1.4.x/
------------------------------------------------------------------------------
  Merged /apr/apr/trunk:r1559975

Modified: apr/apr/branches/1.4.x/test/testdir.c
URL: http://svn.apache.org/viewvc/apr/apr/branches/1.4.x/test/testdir.c?rev=1559977&r1=1559976&r2=1559977&view=diff
==============================================================================
--- apr/apr/branches/1.4.x/test/testdir.c (original)
+++ apr/apr/branches/1.4.x/test/testdir.c Tue Jan 21 11:25:06 2014
@@ -60,47 +60,60 @@ static void test_mkdir_recurs(abts_case 
     ABTS_INT_EQUAL(tc, APR_DIR, finfo.filetype);
 }
 
+struct thread_data
+{
+    abts_case *tc;
+    apr_pool_t *pool;
+};
+
 static void *APR_THREAD_FUNC thread_mkdir_func(apr_thread_t *thd, void *data)
 {
-    abts_case *tc = data;
+    struct thread_data *td = data;
     apr_status_t s1, s2, s3, s4, s5;
 
     s1 = apr_dir_make_recursive("data/prll/one/thwo/three",
                                 APR_FPROT_UREAD | APR_FPROT_UWRITE | APR_FPROT_UEXECUTE,
-                                p);
+                                td->pool);
     s2 = apr_dir_make_recursive("data/prll/four/five/six/seven/eight",
                                 APR_FPROT_UREAD | APR_FPROT_UWRITE | APR_FPROT_UEXECUTE,
-                                p);
+                                td->pool);
     s3 = apr_dir_make_recursive("data/prll/nine/ten",
                                 APR_FPROT_UREAD | APR_FPROT_UWRITE | APR_FPROT_UEXECUTE,
-                                p);
+                                td->pool);
     s4 = apr_dir_make_recursive("data/prll/11/12/13/14/15/16/17/18/19/20",
                                 APR_FPROT_UREAD | APR_FPROT_UWRITE | APR_FPROT_UEXECUTE,
-                                p);
+                                td->pool);
     s5 = apr_dir_make_recursive("data/fortytwo",
                                 APR_FPROT_UREAD | APR_FPROT_UWRITE | APR_FPROT_UEXECUTE,
-                                p);
+                                td->pool);
 
-    ABTS_INT_EQUAL(tc, APR_SUCCESS, s1);
-    ABTS_INT_EQUAL(tc, APR_SUCCESS, s2);
-    ABTS_INT_EQUAL(tc, APR_SUCCESS, s3);
-    ABTS_INT_EQUAL(tc, APR_SUCCESS, s4);
-    ABTS_INT_EQUAL(tc, APR_SUCCESS, s5);
+    ABTS_INT_EQUAL(td->tc, APR_SUCCESS, s1);
+    ABTS_INT_EQUAL(td->tc, APR_SUCCESS, s2);
+    ABTS_INT_EQUAL(td->tc, APR_SUCCESS, s3);
+    ABTS_INT_EQUAL(td->tc, APR_SUCCESS, s4);
+    ABTS_INT_EQUAL(td->tc, APR_SUCCESS, s5);
     return NULL;
 }
 
 static void test_mkdir_recurs_parallel(abts_case *tc, void *data)
 {
+    struct thread_data td1, td2, td3, td4;
     apr_thread_t *t1, *t2, *t3, *t4;
     apr_status_t s1, s2, s3, s4;
 
-    s1 = apr_thread_create(&t1, NULL, thread_mkdir_func, tc, p);
+    td1.tc = td2.tc = td3.tc = td4.tc = tc;
+    apr_pool_create(&td1.pool, p);
+    apr_pool_create(&td2.pool, p);
+    apr_pool_create(&td3.pool, p);
+    apr_pool_create(&td4.pool, p);
+
+    s1 = apr_thread_create(&t1, NULL, thread_mkdir_func, &td1, td1.pool);
     ABTS_INT_EQUAL(tc, APR_SUCCESS, s1);
-    s2 = apr_thread_create(&t2, NULL, thread_mkdir_func, tc, p);
+    s2 = apr_thread_create(&t2, NULL, thread_mkdir_func, &td2, td2.pool);
     ABTS_INT_EQUAL(tc, APR_SUCCESS, s2);
-    s3 = apr_thread_create(&t3, NULL, thread_mkdir_func, tc, p);
+    s3 = apr_thread_create(&t3, NULL, thread_mkdir_func, &td3, td3.pool);
     ABTS_INT_EQUAL(tc, APR_SUCCESS, s3);
-    s4 = apr_thread_create(&t4, NULL, thread_mkdir_func, tc, p);
+    s4 = apr_thread_create(&t4, NULL, thread_mkdir_func, &td4, td4.pool);
     ABTS_INT_EQUAL(tc, APR_SUCCESS, s4);
 
     apr_thread_join(&s1, t1);