Skip to content

Commit

Permalink
Give every thread in the parallel recursive mkdir test its own pool
Browse files Browse the repository at this point in the history
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.


git-svn-id: https://svn.apache.org/repos/asf/apr/apr/trunk@1559975 13f79535-47bb-0310-9956-ffa450edef68
  • Loading branch information
brainy committed Jan 21, 2014
1 parent 1d7f658 commit edea0d1
Showing 1 changed file with 28 additions and 15 deletions.
43 changes: 28 additions & 15 deletions test/testdir.c
Original file line number Diff line number Diff line change
Expand Up @@ -63,47 +63,60 @@ static void test_mkdir_recurs(abts_case *tc, void *data)
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);
Expand Down

0 comments on commit edea0d1

Please sign in to comment.