apr-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From aa...@apache.org
Subject cvs commit: apr/test testatomic.c testglobalmutex.c testlock.c testlockperf.c testprocmutex.c testthread.c
Date Tue, 09 Apr 2002 06:45:06 GMT
aaron       02/04/08 23:45:06

  Modified:    test     testatomic.c testglobalmutex.c testlock.c
                        testlockperf.c testprocmutex.c testthread.c
  Log:
  Remove all uses of the apr_lock.h API from the tests.
  
  Revision  Changes    Path
  1.13      +5 -6      apr/test/testatomic.c
  
  Index: testatomic.c
  ===================================================================
  RCS file: /home/cvs/apr/test/testatomic.c,v
  retrieving revision 1.12
  retrieving revision 1.13
  diff -u -r1.12 -r1.13
  --- testatomic.c	22 Mar 2002 17:05:27 -0000	1.12
  +++ testatomic.c	9 Apr 2002 06:45:06 -0000	1.13
  @@ -53,7 +53,6 @@
    */
   
   #include "apr_thread_proc.h"
  -#include "apr_lock.h"
   #include "apr_errno.h"
   #include "apr_general.h"
   #include "apr_atomic.h"
  @@ -177,7 +176,7 @@
   void * APR_THREAD_FUNC thread_func_atomic(apr_thread_t *thd, void *data);
   void * APR_THREAD_FUNC thread_func_none(apr_thread_t *thd, void *data);
   
  -apr_lock_t *thread_lock;
  +apr_thread_mutex_t *thread_lock;
   apr_thread_once_t *control = NULL;
   volatile long x = 0; /* mutex locks */
   volatile long z = 0; /* no locks */
  @@ -198,9 +197,9 @@
       apr_thread_once(control, init_func);
   
       for (i = 0; i < NUM_ITERATIONS; i++) {
  -        apr_lock_acquire(thread_lock);
  +        apr_thread_mutex_lock(thread_lock);
           x++;
  -        apr_lock_release(thread_lock);
  +        apr_thread_mutex_unlock(thread_lock);
       }
       apr_thread_exit(thd, exit_ret_val);
       return NULL;
  @@ -265,8 +264,8 @@
   
       if (mutex==1) {
           printf("%-60s", "Initializing the lock"); 
  -        rv = apr_lock_create(&thread_lock, APR_MUTEX, APR_INTRAPROCESS, 
  -                             APR_LOCK_DEFAULT, "lock.file", context); 
  +        rv = apr_thread_mutex_create(&thread_lock, APR_THREAD_MUTEX_DEFAULT,
  +                                     context);
           if (rv != APR_SUCCESS) {
               fflush(stdout);
               fprintf(stderr, "Failed\nCould not create lock\n");
  
  
  
  1.3       +0 -1      apr/test/testglobalmutex.c
  
  Index: testglobalmutex.c
  ===================================================================
  RCS file: /home/cvs/apr/test/testglobalmutex.c,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- testglobalmutex.c	13 Mar 2002 20:39:27 -0000	1.2
  +++ testglobalmutex.c	9 Apr 2002 06:45:06 -0000	1.3
  @@ -55,7 +55,6 @@
   #include "apr_shm.h"
   #include "apr_thread_proc.h"
   #include "apr_file_io.h"
  -#include "apr_lock.h"
   #include "apr_global_mutex.h"
   #include "apr_errno.h"
   #include "apr_general.h"
  
  
  
  1.18      +0 -216    apr/test/testlock.c
  
  Index: testlock.c
  ===================================================================
  RCS file: /home/cvs/apr/test/testlock.c,v
  retrieving revision 1.17
  retrieving revision 1.18
  diff -u -r1.17 -r1.18
  --- testlock.c	13 Mar 2002 20:39:27 -0000	1.17
  +++ testlock.c	9 Apr 2002 06:45:06 -0000	1.18
  @@ -54,7 +54,6 @@
   
   #include "apr_thread_proc.h"
   #include "apr_file_io.h"
  -#include "apr_lock.h"
   #include "apr_thread_mutex.h"
   #include "apr_thread_rwlock.h"
   #include "apr_thread_cond.h"
  @@ -79,22 +78,16 @@
   #define MAX_COUNTER 100000
   #define MAX_RETRY 5
   
  -void * APR_THREAD_FUNC thread_rw_func(apr_thread_t *thd, void *data);
   void * APR_THREAD_FUNC thread_rwlock_func(apr_thread_t *thd, void *data);
  -void * APR_THREAD_FUNC thread_function(apr_thread_t *thd, void *data);
   void * APR_THREAD_FUNC thread_mutex_function(apr_thread_t *thd, void *data);
   void * APR_THREAD_FUNC thread_cond_producer(apr_thread_t *thd, void *data);
   void * APR_THREAD_FUNC thread_cond_consumer(apr_thread_t *thd, void *data);
  -apr_status_t test_rw(void);
  -apr_status_t test_exclusive(void);
  -apr_status_t test_multiple_locking(const char *lockfile);
   apr_status_t test_thread_mutex(void);
   apr_status_t test_thread_rwlock(void);
   apr_status_t test_cond(void);
   apr_status_t test_timeoutcond(void);
   
   apr_file_t *in, *out, *err;
  -apr_lock_t *thread_rw_lock, *thread_lock;
   apr_thread_mutex_t *thread_mutex;
   apr_thread_rwlock_t *rwlock;
   apr_pool_t *pool;
  @@ -116,31 +109,6 @@
   apr_thread_mutex_t *timeout_mutex;
   apr_thread_cond_t *timeout_cond;
   
  -void * APR_THREAD_FUNC thread_rw_func(apr_thread_t *thd, void *data)
  -{
  -    int exitLoop = 1;
  -
  -    while (1)
  -    {
  -        apr_lock_acquire_rw(thread_rw_lock, APR_READER);
  -        if (i == MAX_ITER)
  -            exitLoop = 0;
  -        apr_lock_release(thread_rw_lock);
  -
  -        if (!exitLoop)
  -            break;
  -
  -        apr_lock_acquire_rw(thread_rw_lock, APR_WRITER);
  -        if (i != MAX_ITER)
  -        {
  -            i++;
  -            x++;
  -        }
  -        apr_lock_release(thread_rw_lock);
  -    }
  -    return NULL;
  -} 
  -
   void * APR_THREAD_FUNC thread_rwlock_func(apr_thread_t *thd, void *data)
   {
       int exitLoop = 1;
  @@ -166,31 +134,6 @@
       return NULL;
   } 
   
  -void * APR_THREAD_FUNC thread_function(apr_thread_t *thd, void *data)
  -{
  -    int exitLoop = 1;
  -
  -    /* slight delay to allow things to settle */
  -    apr_sleep (1);
  -    
  -    while (1)
  -    {
  -        apr_lock_acquire(thread_lock);
  -        if (i == MAX_ITER)
  -            exitLoop = 0;
  -        else 
  -        {
  -            i++;
  -            x++;
  -        }
  -        apr_lock_release(thread_lock);
  -
  -        if (!exitLoop)
  -            break;
  -    }
  -    return NULL;
  -} 
  -
   void * APR_THREAD_FUNC thread_mutex_function(apr_thread_t *thd, void *data)
   {
       int exitLoop = 1;
  @@ -259,148 +202,6 @@
       return NULL;
   }
   
  -apr_status_t test_rw(void)
  -{
  -    apr_thread_t *t1, *t2, *t3, *t4;
  -    apr_status_t s1, s2, s3, s4;
  -
  -    printf("RW Lock Tests\n");
  -    printf("%-60s", "    Initializing the RW lock");
  -    s1 = apr_lock_create(&thread_rw_lock, APR_READWRITE, APR_INTRAPROCESS,
  -                         APR_LOCK_DEFAULT, "lock.file", pool);
  -    if (s1 != APR_SUCCESS) {
  -        printf("Failed!\n");
  -        return s1;
  -    }
  -    printf("OK\n");
  -
  -    i = 0;
  -    x = 0;
  -
  -    printf("%-60s","    Starting all the threads"); 
  -    s1 = apr_thread_create(&t1, NULL, thread_rw_func, NULL, pool);
  -    s2 = apr_thread_create(&t2, NULL, thread_rw_func, NULL, pool);
  -    s3 = apr_thread_create(&t3, NULL, thread_rw_func, NULL, pool);
  -    s4 = apr_thread_create(&t4, NULL, thread_rw_func, NULL, pool);
  -    if (s1 != APR_SUCCESS || s2 != APR_SUCCESS || 
  -        s3 != APR_SUCCESS || s4 != APR_SUCCESS) {
  -        printf("Failed!\n");
  -        return s1;
  -    }
  -    printf("OK\n");
  -
  -    printf("%-60s", "    Waiting for threads to exit");
  -    apr_thread_join(&s1, t1);
  -    apr_thread_join(&s2, t2);
  -    apr_thread_join(&s3, t3);
  -    apr_thread_join(&s4, t4);
  -    printf("OK\n");
  -
  -    if (x != MAX_ITER) {
  -        fprintf(stderr, "RW locks didn't work as expected. x = %d instead of %d\n",
  -                x, MAX_ITER);
  -    }
  -    else {
  -        printf("Test passed\n");
  -    }
  -    
  -    return APR_SUCCESS;
  -}
  -
  -apr_status_t test_exclusive(void)
  -{
  -    apr_thread_t *t1, *t2, *t3, *t4;
  -    apr_status_t s1, s2, s3, s4;
  -
  -    printf("Exclusive lock test\n");
  -    printf("%-60s", "    Initializing the lock");
  -    s1 = apr_lock_create(&thread_lock, APR_MUTEX, APR_INTRAPROCESS, 
  -                         APR_LOCK_DEFAULT, "lock.file", pool); 
  -
  -    if (s1 != APR_SUCCESS) {
  -        printf("Failed!\n");
  -        return s1;
  -    }
  -    printf("OK\n");
  -
  -    i = 0;
  -    x = 0;
  -
  -    printf("%-60s", "    Starting all the threads"); 
  -    s1 = apr_thread_create(&t1, NULL, thread_function, NULL, pool);
  -    s2 = apr_thread_create(&t2, NULL, thread_function, NULL, pool);
  -    s3 = apr_thread_create(&t3, NULL, thread_function, NULL, pool);
  -    s4 = apr_thread_create(&t4, NULL, thread_function, NULL, pool);
  -    if (s1 != APR_SUCCESS || s2 != APR_SUCCESS || 
  -        s3 != APR_SUCCESS || s4 != APR_SUCCESS) {
  -        printf("Failed!\n");
  -        return s1;
  -    }
  -    printf("OK\n");
  -
  -    printf("%-60s", "    Waiting for threads to exit");
  -    apr_thread_join(&s1, t1);
  -    apr_thread_join(&s2, t2);
  -    apr_thread_join(&s3, t3);
  -    apr_thread_join(&s4, t4);
  -    printf("OK\n");
  -
  -    if (x != MAX_ITER) {
  -        fprintf(stderr, "Locks don't appear to work!  x = %d instead of %d\n",
  -                x, MAX_ITER);
  -    }
  -    else {
  -        printf("Test passed\n");
  -    }
  -    return APR_SUCCESS;
  -}
  -
  -apr_status_t test_multiple_locking(const char *lockfile)
  -{
  -    apr_lock_t *multi;
  -    int try = 0;
  -    apr_status_t rv;
  - 
  -    printf("Testing multiple locking\n");
  -    printf("%-60s","    Creating the lock we'll use");
  -    if ((rv = apr_lock_create(&multi, APR_MUTEX, APR_LOCKALL, APR_LOCK_DEFAULT,
  -                              lockfile, pool)) != APR_SUCCESS) {
  -        printf("Failed!\n");
  -        return rv;
  -    }
  -    printf("OK\n");
  -
  -    printf("%-60s", "    Trying to lock 10 times");
  -    for (try = 0; try < 10; try++) {
  -        if ((rv = apr_lock_acquire(multi)) != APR_SUCCESS) {
  -            printf("Failed!\n");
  -            printf("Error at try %d\n", try);
  -            return rv;
  -        }
  -    }
  -    printf("OK\n");
  -
  -    printf("%-60s", "    Trying to unlock 10 times");
  -    for (try = 0; try < 10; try++) {
  -        if ((rv = apr_lock_release(multi)) != APR_SUCCESS) {
  -            printf("Failed!\n");
  -            printf("Error at try %d\n", try);
  -            return rv;
  -        }
  -    }
  -    printf("OK\n");
  -
  -    printf("%-60s", "    Destroying the lock we've been using");
  -    if ((rv = apr_lock_destroy(multi)) != APR_SUCCESS) {
  -        printf("Failed!\n");
  -        return rv;
  -    }
  -    printf("OK\n");
  -
  -    printf("Test passed\n");
  -    return APR_SUCCESS;
  -}
  -
   apr_status_t test_thread_mutex(void)
   {
       apr_thread_t *t1, *t2, *t3, *t4;
  @@ -672,23 +473,6 @@
           fprintf(stderr, "Could not parse options: [%d] %s\n",
                   rv, apr_strerror(rv, errmsg, sizeof errmsg));
           exit(-1);
  -    }
  -
  -    if ((rv = test_exclusive()) != APR_SUCCESS) {
  -        fprintf(stderr,"Exclusive Lock test failed : [%d] %s\n",
  -                rv, apr_strerror(rv, (char*)errmsg, 200));
  -        exit(-2);
  -    }
  -    
  -    if ((rv = test_multiple_locking(lockname)) != APR_SUCCESS) {
  -        fprintf(stderr,"Multiple Locking test failed : [%d] %s\n",
  -                rv, apr_strerror(rv, (char*)errmsg, 200));
  -        exit(-3);
  -    }
  -    
  -    if ((rv = test_rw()) != APR_SUCCESS) {
  -        fprintf(stderr,"RW Lock test failed : [%d] %s\n",
  -                rv, apr_strerror(rv, (char*)errmsg, 200));
       }
   
       if ((rv = test_thread_mutex()) != APR_SUCCESS) {
  
  
  
  1.8       +2 -142    apr/test/testlockperf.c
  
  Index: testlockperf.c
  ===================================================================
  RCS file: /home/cvs/apr/test/testlockperf.c,v
  retrieving revision 1.7
  retrieving revision 1.8
  diff -u -r1.7 -r1.8
  --- testlockperf.c	13 Mar 2002 20:39:27 -0000	1.7
  +++ testlockperf.c	9 Apr 2002 06:45:06 -0000	1.8
  @@ -56,7 +56,6 @@
   #include "apr_thread_mutex.h"
   #include "apr_thread_rwlock.h"
   #include "apr_file_io.h"
  -#include "apr_lock.h"
   #include "apr_errno.h"
   #include "apr_general.h"
   #include "apr_getopt.h"
  @@ -79,35 +78,19 @@
   
   static long mutex_counter;
   
  -static apr_lock_t *inter_lock;
   static apr_thread_mutex_t *thread_lock;
  -void * APR_THREAD_FUNC inter_mutex_func(apr_thread_t *thd, void *data);
   void * APR_THREAD_FUNC thread_mutex_func(apr_thread_t *thd, void *data);
  -apr_status_t test_inter_mutex(void);  /* apr_lock_t -- INTRAPROCESS */
   apr_status_t test_thread_mutex(void); /* apr_thread_mutex_t */
   
  -static apr_lock_t *inter_rwlock;
   static apr_thread_rwlock_t *thread_rwlock;
  -void * APR_THREAD_FUNC inter_rwlock_func(apr_thread_t *thd, void *data);
   void * APR_THREAD_FUNC thread_rwlock_func(apr_thread_t *thd, void *data);
  -apr_status_t test_inter_rwlock(void);  /* apr_lock_t -- READWRITE */
   apr_status_t test_thread_rwlock(void); /* apr_thread_rwlock_t */
   
  +int test_thread_mutex_nested(void);
  +
   apr_pool_t *pool;
   int i = 0, x = 0;
   
  -void * APR_THREAD_FUNC inter_mutex_func(apr_thread_t *thd, void *data)
  -{
  -    int i;
  -
  -    for (i = 0; i < MAX_COUNTER; i++) {
  -        apr_lock_acquire(inter_lock);
  -        mutex_counter++;
  -        apr_lock_release(inter_lock);
  -    }
  -    return NULL;
  -}
  -
   void * APR_THREAD_FUNC thread_mutex_func(apr_thread_t *thd, void *data)
   {
       int i;
  @@ -120,18 +103,6 @@
       return NULL;
   }
   
  -void * APR_THREAD_FUNC inter_rwlock_func(apr_thread_t *thd, void *data)
  -{
  -    int i;
  -
  -    for (i = 0; i < MAX_COUNTER; i++) {
  -        apr_lock_acquire_rw(inter_rwlock, APR_WRITER);
  -        mutex_counter++;
  -        apr_lock_release(inter_rwlock);
  -    }
  -    return NULL;
  -}
  -
   void * APR_THREAD_FUNC thread_rwlock_func(apr_thread_t *thd, void *data)
   {
       int i;
  @@ -144,57 +115,6 @@
       return NULL;
   }
   
  -int test_inter_mutex(void)
  -{
  -    apr_thread_t *t1, *t2, *t3, *t4;
  -    apr_status_t s1, s2, s3, s4;
  -    apr_time_t time_start, time_stop;
  -
  -    mutex_counter = 0;
  -
  -    printf("apr_lock(INTRAPROCESS, MUTEX) Lock Tests\n");
  -    printf("%-60s", "    Initializing the apr_lock_t");
  -    s1 = apr_lock_create(&inter_lock, APR_MUTEX, APR_INTRAPROCESS, 
  -                         APR_LOCK_DEFAULT, "lock.file", pool);
  -    if (s1 != APR_SUCCESS) {
  -        printf("Failed!\n");
  -        return s1;
  -    }
  -    printf("OK\n");
  -
  -    apr_lock_acquire(inter_lock);
  -    /* set_concurrency(4)? -aaron */
  -    printf("%-60s","    Starting all the threads"); 
  -    s1 = apr_thread_create(&t1, NULL, inter_mutex_func, NULL, pool);
  -    s2 = apr_thread_create(&t2, NULL, inter_mutex_func, NULL, pool);
  -    s3 = apr_thread_create(&t3, NULL, inter_mutex_func, NULL, pool);
  -    s4 = apr_thread_create(&t4, NULL, inter_mutex_func, NULL, pool);
  -    if (s1 != APR_SUCCESS || s2 != APR_SUCCESS || 
  -        s3 != APR_SUCCESS || s4 != APR_SUCCESS) {
  -        printf("Failed!\n");
  -        return s1;
  -    }
  -    printf("OK\n");
  -
  -    time_start = apr_time_now();
  -    apr_lock_release(inter_lock);
  -
  -    /* printf("%-60s", "    Waiting for threads to exit"); */
  -    apr_thread_join(&s1, t1);
  -    apr_thread_join(&s2, t2);
  -    apr_thread_join(&s3, t3);
  -    apr_thread_join(&s4, t4);
  -    /* printf("OK\n"); */
  -
  -    time_stop = apr_time_now();
  -    printf("microseconds: %" APR_INT64_T_FMT " usec\n",
  -           (time_stop - time_start));
  -    if (mutex_counter != MAX_COUNTER * 4)
  -        printf("error: counter = %ld\n", mutex_counter);
  -
  -    return APR_SUCCESS;
  -}
  -
   int test_thread_mutex(void)
   {
       apr_thread_t *t1, *t2, *t3, *t4;
  @@ -294,54 +214,6 @@
   
       return APR_SUCCESS;
   }
  -int test_inter_rwlock(void)
  -{
  -    apr_thread_t *t1, *t2, *t3, *t4;
  -    apr_status_t s1, s2, s3, s4;
  -    apr_time_t time_start, time_stop;
  -
  -    mutex_counter = 0;
  -
  -    printf("apr_lock(INTRAPROCESS, READWRITE) Lock Tests\n");
  -    printf("%-60s", "    Initializing the apr_lock_t");
  -    s1 = apr_lock_create(&inter_rwlock, APR_READWRITE, APR_INTRAPROCESS,
  -                         APR_LOCK_DEFAULT, "lock.file", pool);
  -    if (s1 != APR_SUCCESS) {
  -        printf("Failed!\n");
  -        return s1;
  -    }
  -    printf("OK\n");
  -
  -    apr_lock_acquire_rw(inter_rwlock, APR_WRITER);
  -    /* set_concurrency(4)? -aaron */
  -    s1 = apr_thread_create(&t1, NULL, inter_rwlock_func, NULL, pool);
  -    s2 = apr_thread_create(&t2, NULL, inter_rwlock_func, NULL, pool);
  -    s3 = apr_thread_create(&t3, NULL, inter_rwlock_func, NULL, pool);
  -    s4 = apr_thread_create(&t4, NULL, inter_rwlock_func, NULL, pool);
  -    if (s1 != APR_SUCCESS || s2 != APR_SUCCESS || 
  -        s3 != APR_SUCCESS || s4 != APR_SUCCESS) {
  -        printf("Failed!\n");
  -        return s1;
  -    }
  -
  -    time_start = apr_time_now();
  -    apr_lock_release(inter_rwlock);
  -
  -    /* printf("%-60s", "    Waiting for threads to exit"); */
  -    apr_thread_join(&s1, t1);
  -    apr_thread_join(&s2, t2);
  -    apr_thread_join(&s3, t3);
  -    apr_thread_join(&s4, t4);
  -    /* printf("OK\n"); */
  -
  -    time_stop = apr_time_now();
  -    printf("microseconds: %" APR_INT64_T_FMT " usec\n",
  -           (time_stop - time_start));
  -    if (mutex_counter != MAX_COUNTER * 4)
  -        printf("error: counter = %ld\n", mutex_counter);
  -
  -    return APR_SUCCESS;
  -}
   
   int test_thread_rwlock(void)
   {
  @@ -426,12 +298,6 @@
           exit(-1);
       }
   
  -    if ((rv = test_inter_mutex()) != APR_SUCCESS) {
  -        fprintf(stderr,"apr_lock(INTRAPROCESS, MUTEX) test failed : [%d] %s\n",
  -                rv, apr_strerror(rv, (char*)errmsg, 200));
  -        exit(-2);
  -    }
  -
       if ((rv = test_thread_mutex()) != APR_SUCCESS) {
           fprintf(stderr,"thread_mutex test failed : [%d] %s\n",
                   rv, apr_strerror(rv, (char*)errmsg, 200));
  @@ -442,12 +308,6 @@
           fprintf(stderr,"thread_mutex (NESTED) test failed : [%d] %s\n",
                   rv, apr_strerror(rv, (char*)errmsg, 200));
           exit(-4);
  -    }
  -
  -    if ((rv = test_inter_rwlock()) != APR_SUCCESS) {
  -        fprintf(stderr,"apr_lock(INTRAPROCESS, READWRITE) test failed : [%d] %s\n",
  -                rv, apr_strerror(rv, (char*)errmsg, 200));
  -        exit(-5);
       }
   
       if ((rv = test_thread_rwlock()) != APR_SUCCESS) {
  
  
  
  1.10      +0 -1      apr/test/testprocmutex.c
  
  Index: testprocmutex.c
  ===================================================================
  RCS file: /home/cvs/apr/test/testprocmutex.c,v
  retrieving revision 1.9
  retrieving revision 1.10
  diff -u -r1.9 -r1.10
  --- testprocmutex.c	13 Mar 2002 20:39:27 -0000	1.9
  +++ testprocmutex.c	9 Apr 2002 06:45:06 -0000	1.10
  @@ -55,7 +55,6 @@
   #include "apr_shm.h"
   #include "apr_thread_proc.h"
   #include "apr_file_io.h"
  -#include "apr_lock.h"
   #include "apr_proc_mutex.h"
   #include "apr_errno.h"
   #include "apr_general.h"
  
  
  
  1.29      +5 -6      apr/test/testthread.c
  
  Index: testthread.c
  ===================================================================
  RCS file: /home/cvs/apr/test/testthread.c,v
  retrieving revision 1.28
  retrieving revision 1.29
  diff -u -r1.28 -r1.29
  --- testthread.c	13 Mar 2002 20:39:28 -0000	1.28
  +++ testthread.c	9 Apr 2002 06:45:06 -0000	1.29
  @@ -53,7 +53,6 @@
    */
   
   #include "apr_thread_proc.h"
  -#include "apr_lock.h"
   #include "apr_errno.h"
   #include "apr_general.h"
   #include "errno.h"
  @@ -79,7 +78,7 @@
   void * APR_THREAD_FUNC thread_func3(apr_thread_t *thd, void *data);
   void * APR_THREAD_FUNC thread_func4(apr_thread_t *thd, void *data);
   
  -apr_lock_t *thread_lock;
  +apr_thread_mutex_t *thread_lock;
   apr_pool_t *context;
   apr_thread_once_t *control = NULL;
   int x = 0;
  @@ -98,9 +97,9 @@
       apr_thread_once(control, init_func);
   
       for (i = 0; i < 10000; i++) {
  -        apr_lock_acquire(thread_lock);
  +        apr_thread_mutex_lock(thread_lock);
           x++;
  -        apr_lock_release(thread_lock);
  +        apr_thread_mutex_unlock(thread_lock);
       }
       apr_thread_exit(thd, exit_ret_val);
       return NULL;
  @@ -129,8 +128,8 @@
       apr_thread_once_init(&control, context);
   
       printf("%-60s", "Initializing the lock"); 
  -    r1 = apr_lock_create(&thread_lock, APR_MUTEX, APR_INTRAPROCESS, 
  -                         APR_LOCK_DEFAULT, "lock.file", context); 
  +    r1 = apr_thread_mutex_create(&thread_lock, APR_THREAD_MUTEX_DEFAULT,
  +                                 context); 
       if (r1 != APR_SUCCESS) {
           fflush(stdout);
           fprintf(stderr, "Failed\nCould not create lock\n");
  
  
  

Mime
View raw message