$OpenBSD: patch-base_gp_psync_c,v 1.1 2012/09/09 08:57:36 kili Exp $

Use PTHREAD_MUTEX_RECURSIVE, which works fine even with the (broken)
wrappers still around which try to simulate PTHREAD_MUTEX_RECURSIVE
for mutexes created with default attributes.

--- base/gp_psync.c.orig	Wed Aug  8 10:01:36 2012
+++ base/gp_psync.c	Sun Sep  9 09:03:31 2012
@@ -147,13 +147,21 @@ int
 gp_monitor_open(gp_monitor * mona)
 {
     pthread_mutex_t *mon;
+    pthread_mutexattr_t mattr;
     int scode;
 
     if (!mona)
         return -1;		/* monitors are not movable */
     mon = &((gp_pthread_recursive_t *)mona)->mutex;
     ((gp_pthread_recursive_t *)mona)->self_id = 0;	/* Not valid unless mutex is locked */
-    scode = pthread_mutex_init(mon, NULL);
+    scode = pthread_mutexattr_init(&mattr);
+    if (scode != 0)
+	return SEM_ERROR_CODE(scode);
+    scode = pthread_mutexattr_settype(&mattr, PTHREAD_MUTEX_RECURSIVE);
+    if (scode != 0)
+	return SEM_ERROR_CODE(scode);
+    scode = pthread_mutex_init(mon, &mattr);
+    pthread_mutexattr_destroy(&mattr);
     return SEM_ERROR_CODE(scode);
 }
 
