summaryrefslogtreecommitdiff
path: root/mysys
diff options
context:
space:
mode:
authormonty@hundin.mysql.fi <>2002-08-16 14:41:22 +0300
committermonty@hundin.mysql.fi <>2002-08-16 14:41:22 +0300
commit5ff30464a68f70e01664a0af8dd9406e839c99ab (patch)
tree8877ea5d5b884ec2013f7d882aa020d79917ef74 /mysys
parent9e90a915ce21a073f6b0fd6b5006555e43d6e13a (diff)
parentb8e611b46471326ca29fa01a0a7d4f30e5b033fa (diff)
downloadmariadb-git-5ff30464a68f70e01664a0af8dd9406e839c99ab.tar.gz
merge with 3.23.53
New fix for pthread_mutex_trylock for HPUX 10.20
Diffstat (limited to 'mysys')
-rw-r--r--mysys/my_port.c2
-rw-r--r--mysys/my_pthread.c36
2 files changed, 30 insertions, 8 deletions
diff --git a/mysys/my_port.c b/mysys/my_port.c
index a9778875850..bf5dbcbace1 100644
--- a/mysys/my_port.c
+++ b/mysys/my_port.c
@@ -33,7 +33,7 @@
-double my_longlong2double(unsigned long long nr)
+double my_ulonglong2double(unsigned long long nr)
{
return (double) nr;
}
diff --git a/mysys/my_pthread.c b/mysys/my_pthread.c
index e10a8dec480..d9487de638e 100644
--- a/mysys/my_pthread.c
+++ b/mysys/my_pthread.c
@@ -437,25 +437,47 @@ int my_pthread_cond_timedwait(pthread_cond_t *cond, pthread_mutex_t *mutex,
#endif
-#ifdef HPUX
+#ifdef HAVE_POSIX1003_4a_MUTEX
/*
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
+
+ From the HP-UX-10.20 man page:
+ RETURN VALUES
+ If the function fails, errno may be set to one of the following
+ values:
+ Return | Error | Description
+ _______|__________|_________________________________________
+ 1 | | Successful completion.
+ 0 | | The mutex is locked; therefore, it was
+ | | not acquired.
+ -1 | [EINVAL] | The value specified by mutex is invalid.
+
*/
-#undef pthread_mutex_trylock
+/*
+ Convert pthread_mutex_trylock to return values according to latest POSIX
+
+ RETURN VALUES
+ 0 If we are able successfully lock the mutex.
+ EBUSY Mutex was locked by another thread
+ != errno set by pthread_mutex_trylock()
+*/
+
+#undef pthread_mutex_trylock
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)
+ return 0; /* Got lock on mutex */
+ if (error == 0) /* Someon else is locking mutex */
+ return EBUSY;
if (error == -1) /* Safety if the lib is fixed */
- error=errno;
+ error= errno; /* Probably invalid parameter */
return error;
}
-#endif
-
+#endif /* HAVE_POSIX1003_4a_MUTEX */
/* Some help functions */