
SUSv3 says that default mutexes are of unspecified type. This can lead to
deadlocks turning into a return value EDEADLK, which we don't really want
since we don't check every single lock()/unlock() return value.

This patch initializes them properly by setting the mutexes to normal,
non-error-checking ones.

---

 cur-root/trans.c |   13 +++++++++++--
 1 files changed, 11 insertions(+), 2 deletions(-)

diff -puN trans.c~init_mutexes trans.c
--- cur/trans.c~init_mutexes	2004-09-18 16:33:04.160567616 -0300
+++ cur-root/trans.c	2004-09-19 01:30:06.120185952 -0300
@@ -96,13 +96,18 @@ exit:
 /* initialize a transaction structure */
 void jtrans_init(struct jfs *fs, struct jtrans *ts)
 {
+	pthread_mutexattr_t attr;
+
 	ts->fs = fs;
 	ts->name = NULL;
 	ts->id = 0;
 	ts->flags = fs->flags;
 	ts->op = NULL;
 	ts->numops = 0;
-	pthread_mutex_init( &(ts->lock), NULL);
+	pthread_mutexattr_init(&attr);
+	pthread_mutexattr_settype(&attr, PTHREAD_MUTEX_NORMAL);
+	pthread_mutex_init( &(ts->lock), &attr);
+	pthread_mutexattr_destroy(&attr);
 }
 
 
@@ -511,6 +516,7 @@ int jopen(struct jfs *fs, const char *na
 	unsigned int t;
 	char jdir[PATH_MAX], jlockfile[PATH_MAX];
 	struct stat sinfo;
+	pthread_mutexattr_t attr;
 
 	fs->fd = -1;
 	fs->jfd = -1;
@@ -540,7 +546,10 @@ int jopen(struct jfs *fs, const char *na
 	 * make it easier for them by taking care of it here. If performance
 	 * is essential, the jpread/jpwrite functions should be used, just as
 	 * real life. */
-	pthread_mutex_init( &(fs->lock), NULL);
+	pthread_mutexattr_init(&attr);
+	pthread_mutexattr_settype(&attr, PTHREAD_MUTEX_NORMAL);
+	pthread_mutex_init( &(fs->lock), &attr);
+	pthread_mutexattr_destroy(&attr);
 
 	fs->fd = open(name, flags, mode);
 	if (fs->fd < 0)
_

