summaryrefslogtreecommitdiff
path: root/mysys/my_pthread.c
diff options
context:
space:
mode:
authormonty@hundin.mysql.fi <>2002-08-06 17:15:51 +0300
committermonty@hundin.mysql.fi <>2002-08-06 17:15:51 +0300
commit842e8fca83d85e5a5cc6a1f75b3c61ecca9e3130 (patch)
treef9540fefe755c8821c56bca905ef1eb1b2b1f4fb /mysys/my_pthread.c
parenta500c7de66c822bdbe333891b58a0e9762632002 (diff)
downloadmariadb-git-842e8fca83d85e5a5cc6a1f75b3c61ecca9e3130.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 */