apr-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "William A. Rowe, Jr." <wr...@apache.org>
Subject Re: [PATCH] Global apr_thread_rwlock
Date Thu, 23 Oct 2003 22:14:59 GMT
I don't believe we need an _ex flavor if you are proposing this for APR 1.0.
Just change the args, the 1.0 version may break (expand) our api.

Bill

At 04:24 PM 10/23/2003, MATHIHALLI,MADHUSUDAN (HP-Cupertino,ex1) wrote:
>Hi,
>        I was wondering if there's any interest in having a option to make
>the apr_thread_rwlock to support GLOBAL rwlocks. Currently,
>apr_thread_rwlock exhibits the default pthread behaviour - to be process
>specific. Since the pthread library gives an option to make it global, can
>we add it to APR too ?
>
>-Madhu
>
>--- thread_rwlock.c     Thu Oct 23 14:17:44 2003
>+++ thread_rwlock.c.g   Thu Oct 23 14:21:12 2003
>@@ -99,6 +99,53 @@
>     return APR_SUCCESS;
> }
>
>+APR_DECLARE(apr_status_t) apr_thread_rwlock_create_ex(apr_thread_rwlock_t
>**rwl
>ock,
>+                                                      unsigned int flags,


where is flags evaluated below?


>+                                                      apr_pool_t *pool)
>+{
>+    apr_thread_rwlock_t *new_rwlock;
>+    pthread_rwlockattr_t rwattr;
>+    apr_status_t stat;
>+
>+    new_rwlock = apr_palloc(pool, sizeof(apr_thread_rwlock_t));
>+    new_rwlock->pool = pool;
>+
>+    if ((rv = pthread_rwlockattr_init(&rwattr))) {
>+#ifdef PTHREAD_SETS_ERRNO
>+        stat = errno;
>+#endif
>+        return stat;
>+    }
>+
>+    if ((rv = pthread_rwlockattr_setpshared(&rwattr,
>PTHREAD_PROCESS_SHARED)))
>{
>+#ifdef PTHREAD_SETS_ERRNO
>+        stat = errno;
>+#endif
>+        return stat;
>+    }
>+
>+    if ((stat = pthread_rwlock_init(&new_rwlock->rwlock, &rwattr))) {
>+#ifdef PTHREAD_SETS_ERRNO
>+        stat = errno;
>+#endif
>+        return stat;
>+    }
>+
>+    if ((rv = pthread_rwlockattr_destroy(&rwattr))) {
>+#ifdef PTHREAD_SETS_ERRNO
>+        stat = errno;
>+#endif
>+        return stat;
>+    }
>+
>+    apr_pool_cleanup_register(new_rwlock->pool,
>+                              (void *)new_rwlock, thread_rwlock_cleanup,
>+                              apr_pool_cleanup_null);
>+
>+    *rwlock = new_rwlock;
>+    return APR_SUCCESS;
>+}
>+
> APR_DECLARE(apr_status_t) apr_thread_rwlock_rdlock(apr_thread_rwlock_t
>*rwlock)
> {
>     apr_status_t stat;


Mime
View raw message