summaryrefslogtreecommitdiff
path: root/mysys/my_pthread.c
diff options
context:
space:
mode:
authorunknown <monty@hundin.mysql.fi>2002-08-06 17:15:51 +0300
committerunknown <monty@hundin.mysql.fi>2002-08-06 17:15:51 +0300
commit95417c335edf9c5aec9d85e0693ee7012ae001d1 (patch)
treef9540fefe755c8821c56bca905ef1eb1b2b1f4fb /mysys/my_pthread.c
parent7917a18b50627d92cf5dec915afc5246bbb4d227 (diff)
downloadmariadb-git-95417c335edf9c5aec9d85e0693ee7012ae001d1.tar.gz
Backported pthread_mutex_trylock code from MySQL 4.0 to fix problem on HPUX.
Removed Heikki's patch for handling this.
Diffstat (limited to 'mysys/my_pthread.c')
-rw-r--r--mysys/my_pthread.c23
1 files changed, 21 insertions, 2 deletions
diff --git a/mysys/my_pthread.c b/mysys/my_pthread.c
index 696b62f8b0e..e4e0eff95e6 100644
--- a/mysys/my_pthread.c
+++ b/mysys/my_pthread.c
@@ -409,7 +409,7 @@ int my_pthread_cond_init(pthread_cond_t *mp, const pthread_condattr_t *attr)
/* Change functions on HP to work according to POSIX */
-#ifdef HAVE_BROKEN_PTHREAD_COND_TIMEDWAIT
+#if defined(HPUX) || defined(HAVE_BROKEN_PTHREAD_COND_TIMEDWAIT)
#undef pthread_cond_timedwait
int my_pthread_cond_timedwait(pthread_cond_t *cond,
@@ -426,7 +426,26 @@ int my_pthread_cond_timedwait(pthread_cond_t *cond,
error= ETIMEDOUT;
return error;
}
-#endif /* HAVE_BROKEN_PTHREAD_COND_TIMEDWAIT */
+#endif
+
+
+#ifdef HPUX
+/*
+ In HP-UX-10.20 and other old Posix 1003.4a Draft 4 implementations
+ pthread_mutex_trylock returns 1 on success, not 0 like
+ pthread_mutex_lock
+*/
+
+int my_pthread_mutex_trylock(pthread_mutex_t *mutex)
+{
+ int error=pthread_mutex_trylock(mutex);
+ if (error == 1) /* Safety if the lib is fixed */
+ return 0; /* Mutex was locked */
+ if (error == -1) /* Safety if the lib is fixed */
+ error=errno;
+ return error;
+}
+#endif
/* Some help functions */