apr-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jor...@apache.org
Subject cvs commit: apr/test testlock.c
Date Mon, 29 Dec 2003 15:31:39 GMT
jorton      2003/12/29 07:31:39

  Modified:    include  apr_thread_cond.h
               locks/unix thread_cond.c
               test     testlock.c
  Log:
  * include/apr_thread_cond.h: Note when destroying a condvar gives
  undefined results in a POSIX implementation.
  
  * locks/unix/thread_cond.c (apr_thread_cond_create): Don't run cleanup
  if pthread_cond_init fails since that gives undefined results.
  (apr_thread_cond_destroy): Use apr_pool_cleanup_run so the cleanup is
  always unregistered.
  
  * test/testlock.c (test_cond): Test apr_thread_cond_destroy and use
  apr_assert_success() a little more.
  
  Revision  Changes    Path
  1.10      +6 -0      apr/include/apr_thread_cond.h
  
  Index: apr_thread_cond.h
  ===================================================================
  RCS file: /home/cvs/apr/include/apr_thread_cond.h,v
  retrieving revision 1.9
  retrieving revision 1.10
  diff -u -u -r1.9 -r1.10
  --- apr_thread_cond.h	29 Dec 2003 14:57:30 -0000	1.9
  +++ apr_thread_cond.h	29 Dec 2003 15:31:39 -0000	1.10
  @@ -82,6 +82,12 @@
   typedef struct apr_thread_cond_t apr_thread_cond_t;
   
   /**
  + * Note: destroying a condition variable (or likewise, destroying or
  + * clearing the pool from which a condition variable was allocated) if
  + * any threads are blocked waiting on it gives undefined results.
  + */
  +
  +/**
    * Create and initialize a condition variable that can be used to signal
    * and schedule threads in a single process.
    * @param cond the memory address where the newly created condition variable
  
  
  
  1.11      +1 -7      apr/locks/unix/thread_cond.c
  
  Index: thread_cond.c
  ===================================================================
  RCS file: /home/cvs/apr/locks/unix/thread_cond.c,v
  retrieving revision 1.10
  retrieving revision 1.11
  diff -u -u -r1.10 -r1.11
  --- thread_cond.c	29 Dec 2003 15:06:38 -0000	1.10
  +++ thread_cond.c	29 Dec 2003 15:31:39 -0000	1.11
  @@ -87,7 +87,6 @@
   #ifdef PTHREAD_SETS_ERRNO
           rv = errno;
   #endif
  -        thread_cond_cleanup(new_cond);
           return rv;
       }
   
  @@ -166,12 +165,7 @@
   
   APR_DECLARE(apr_status_t) apr_thread_cond_destroy(apr_thread_cond_t *cond)
   {
  -    apr_status_t rv;
  -    if ((rv = thread_cond_cleanup(cond)) == APR_SUCCESS) {
  -        apr_pool_cleanup_kill(cond->pool, cond, thread_cond_cleanup);
  -        return APR_SUCCESS;
  -    }
  -    return rv;
  +    return apr_pool_cleanup_run(cond->pool, cond, thread_cond_cleanup);
   }
   
   APR_POOL_IMPLEMENT_ACCESSOR(thread_cond)
  
  
  
  1.25      +12 -7     apr/test/testlock.c
  
  Index: testlock.c
  ===================================================================
  RCS file: /home/cvs/apr/test/testlock.c,v
  retrieving revision 1.24
  retrieving revision 1.25
  diff -u -u -r1.24 -r1.25
  --- testlock.c	1 Jan 2003 00:01:56 -0000	1.24
  +++ testlock.c	29 Dec 2003 15:31:39 -0000	1.25
  @@ -251,17 +251,19 @@
       apr_status_t s0, s1, s2, s3, s4;
       int count1, count2, count3, count4;
       int sum;
  -
  -    s1 = apr_thread_mutex_create(&put.mutex, APR_THREAD_MUTEX_DEFAULT, p);
  -    CuAssertIntEquals(tc, APR_SUCCESS, s1);
  +    
  +    apr_assert_success(tc, "create put mutex",
  +                       apr_thread_mutex_create(&put.mutex, 
  +                                               APR_THREAD_MUTEX_DEFAULT, p));
       CuAssertPtrNotNull(tc, put.mutex);
   
  -    s1 = apr_thread_mutex_create(&nready.mutex, APR_THREAD_MUTEX_DEFAULT, p);
  -    CuAssertIntEquals(tc, APR_SUCCESS, s1);
  +    apr_assert_success(tc, "create nready mutex",
  +                       apr_thread_mutex_create(&nready.mutex, 
  +                                               APR_THREAD_MUTEX_DEFAULT, p));
       CuAssertPtrNotNull(tc, nready.mutex);
   
  -    s1 = apr_thread_cond_create(&nready.cond, p);
  -    CuAssertIntEquals(tc, APR_SUCCESS, s1);
  +    apr_assert_success(tc, "create condvar",
  +                       apr_thread_cond_create(&nready.cond, p));
       CuAssertPtrNotNull(tc, nready.cond);
   
       count1 = count2 = count3 = count4 = 0;
  @@ -286,6 +288,9 @@
       apr_thread_join(&s2, p3);
       apr_thread_join(&s3, p4);
       apr_thread_join(&s4, c1);
  +
  +    apr_assert_success(tc, "destroy condvar", 
  +                       apr_thread_cond_destroy(nready.cond));
   
       sum = count1 + count2 + count3 + count4;
       /*
  
  
  

Mime
View raw message