Hi --

   I happened to discover that calling apr_global_mutex_trylock()
caused a core dump (I'm using Solaris 8, but that doesn't really
matter here).  It's because line 917 in the apr_proc_mutex_trylock()
function in apr/locks/unix/proc_mutex.c calls:

mutex->meth->tryacquire(mutex)

but the tryacquire function pointer is, for all cases, set to NULL.
A quick fix, without actually implementing any of the tryacquire
functions, is below; APR_ENOTIMPL is returned by stub functions instead.

   I'll follow this up with a patch that tries to implement
the proc_pthreads tryacquire case ... but since I'm only just
reading man pages now, I really can't be sure I've got it correct.

Chris.

===========================================================

--- proc_mutex.c.orig   2002-08-22 14:04:12.259144000 -0400
+++ proc_mutex.c        2002-08-22 14:57:15.826790000 -0400
@@ -138,6 +138,11 @@
     return APR_SUCCESS;
 }

+static apr_status_t proc_mutex_posix_tryacquire(apr_proc_mutex_t *mutex)
+{
+    return APR_ENOTIMPL;
+}
+
 static apr_status_t proc_mutex_posix_release(apr_proc_mutex_t *mutex)
 {
     int rc;
@@ -176,7 +181,7 @@
 #endif
     proc_mutex_posix_create,
     proc_mutex_posix_acquire,
-    NULL, /* no tryacquire */
+    proc_mutex_posix_tryacquire,
     proc_mutex_posix_release,
     proc_mutex_posix_destroy,
     proc_mutex_posix_child_init,
@@ -253,6 +258,11 @@
     return APR_SUCCESS;
 }

+static apr_status_t proc_mutex_sysv_tryacquire(apr_proc_mutex_t *mutex)
+{
+    return APR_ENOTIMPL;
+}
+
 static apr_status_t proc_mutex_sysv_release(apr_proc_mutex_t *mutex)
 {
     int rc;
@@ -292,7 +302,7 @@
 #endif
     proc_mutex_sysv_create,
     proc_mutex_sysv_acquire,
-    NULL, /* no tryacquire */
+    proc_mutex_sysv_tryacquire,
     proc_mutex_sysv_release,
     proc_mutex_sysv_destroy,
     proc_mutex_sysv_child_init,
@@ -427,7 +437,14 @@
     return APR_SUCCESS;
 }

-/* TODO: Add proc_mutex_proc_pthread_tryacquire(apr_proc_mutex_t *mutex) */
+static apr_status_t proc_mutex_proc_pthread_tryacquire(apr_proc_mutex_t *mutex)
+{
+ apr_status_t rv;
+
+ /**** DEBUG ****/
+
+ return APR_ENOTIMPL;
+}


static apr_status_t proc_mutex_proc_pthread_release(apr_proc_mutex_t *mutex)
{
@@ -467,7 +484,7 @@
APR_PROCESS_LOCK_MECH_IS_GLOBAL,
proc_mutex_proc_pthread_create,
proc_mutex_proc_pthread_acquire,
- NULL, /* no tryacquire */
+ proc_mutex_proc_pthread_tryacquire,
proc_mutex_proc_pthread_release,
proc_mutex_proc_pthread_destroy,
proc_mutex_proc_pthread_child_init,
@@ -563,6 +580,11 @@
return APR_SUCCESS;
}


+static apr_status_t proc_mutex_fcntl_tryacquire(apr_proc_mutex_t *mutex)
+{
+    return APR_ENOTIMPL;
+}
+
 static apr_status_t proc_mutex_fcntl_release(apr_proc_mutex_t *mutex)
 {
     int rc;
@@ -603,7 +625,7 @@
 #endif
     proc_mutex_fcntl_create,
     proc_mutex_fcntl_acquire,
-    NULL, /* no tryacquire */
+    proc_mutex_fcntl_tryacquire,
     proc_mutex_fcntl_release,
     proc_mutex_fcntl_destroy,
     proc_mutex_fcntl_child_init,
@@ -678,6 +700,11 @@
     return APR_SUCCESS;
 }

+static apr_status_t proc_mutex_flock_tryacquire(apr_proc_mutex_t *mutex)
+{
+    return APR_ENOTIMPL;
+}
+
 static apr_status_t proc_mutex_flock_release(apr_proc_mutex_t *mutex)
 {
     int rc;
@@ -733,7 +760,7 @@
 #endif
     proc_mutex_flock_create,
     proc_mutex_flock_acquire,
-    NULL, /* no tryacquire */
+    proc_mutex_flock_tryacquire,
     proc_mutex_flock_release,
     proc_mutex_flock_destroy,
     proc_mutex_flock_child_init,



Reply via email to