From 96296b63bd2f5e471b05736910f7bb13984ea77e Mon Sep 17 00:00:00 2001 From: Adam Dickmeiss Date: Tue, 10 Aug 2010 12:29:21 +0200 Subject: [PATCH] Revert recursive mutex patch We don't need recursive mutexes. Interestingly, PTHREAD_MUTEX_NORMAL and PTHREAD_MUTEX_RECURSIVE from man page pthread_mutexattr_settype are not defined in header pthread.h by default on my Ubuntu Linux (possibly others). Some defines may do trigger a definition of it, but what impact do they have then on other pthread-implementations? It crashed on FreeBSD - it could be fixed by using PTHREAD_MUTEX_NORMAL (rather than 0) for pthread_settype (normal mutex). --- include/yaz/mutex.h | 11 ----------- src/mutex-p.h | 1 - src/mutex.c | 14 +++----------- 3 files changed, 3 insertions(+), 23 deletions(-) diff --git a/include/yaz/mutex.h b/include/yaz/mutex.h index ff8babb..414e09f 100644 --- a/include/yaz/mutex.h +++ b/include/yaz/mutex.h @@ -52,17 +52,6 @@ typedef struct yaz_cond *YAZ_COND; */ YAZ_EXPORT void yaz_mutex_create(YAZ_MUTEX *mutexp); -/** \brief create MUTEX with custom MUTEX flags - \param mutexp is pointer to MUTEX handle (*mutexp must be NULL) - \param attr is flags defined by PTHREAD_MUTEX_xxx - - It is important that *mutexp is NULL. If not, yaz_mutex_create will - not modify the handle (assumes it is already created!) - - This calls yax_mutex_create_attr(mutexp, PTHREAD_MUTEX_NORMAL) - */ -YAZ_EXPORT void yaz_mutex_create_attr(YAZ_MUTEX *mutexp, int flags); - /** \brief enter critical section / AKA lock \param mutex MUTEX handle */ diff --git a/src/mutex-p.h b/src/mutex-p.h index fedc459..783f119 100644 --- a/src/mutex-p.h +++ b/src/mutex-p.h @@ -8,7 +8,6 @@ struct yaz_mutex { CRITICAL_SECTION handle; #elif YAZ_POSIX_THREADS pthread_mutex_t handle; - pthread_mutexattr_t *attr; #endif char *name; int log_level; diff --git a/src/mutex.c b/src/mutex.c index 85b0c7b..c4f6d5b 100644 --- a/src/mutex.c +++ b/src/mutex.c @@ -38,27 +38,21 @@ #include "mutex-p.h" -void yaz_mutex_create_attr(YAZ_MUTEX *p, int flags) { +void yaz_mutex_create(YAZ_MUTEX *p) +{ if (!*p) { *p = (YAZ_MUTEX) malloc(sizeof(**p)); #ifdef WIN32 InitializeCriticalSection(&(*p)->handle); #elif YAZ_POSIX_THREADS - (*p)->attr = malloc(sizeof( (*p)->attr)); - pthread_mutexattr_init((*p)->attr); - pthread_mutexattr_settype((*p)->attr, flags); - pthread_mutex_init(&(*p)->handle, (*p)->attr); + pthread_mutex_init(&(*p)->handle, 0); #endif (*p)->name = 0; (*p)->log_level = 0; } } -void yaz_mutex_create(YAZ_MUTEX *p) { - yaz_mutex_create_attr(p, 0); -} - void yaz_mutex_set_name(YAZ_MUTEX p, int log_level, const char *name) { if (p->name) @@ -148,8 +142,6 @@ void yaz_mutex_destroy(YAZ_MUTEX *p) #ifdef WIN32 DeleteCriticalSection(&(*p)->handle); #elif YAZ_POSIX_THREADS - pthread_mutexattr_destroy((*p)->attr); - free((*p)->attr); pthread_mutex_destroy(&(*p)->handle); #endif if ((*p)->name) -- 1.7.10.4