Below is the list of changes that have just been committed into a local
5.0 repository of msvensson. When msvensson does a push these changes will
be propagated to the main repository and, within 24 hours after the
push, to the public repository.
For information on how to access the public repository
see http://dev.mysql.com/doc/mysql/en/installing-source-tree.html
ChangeSet@stripped, 2007-10-02 19:59:32+02:00, msvensson@stripped +3 -0
Bug#30992 Wrong implementation of pthread_mutex_trylock()
It's not possible to use WaitForSingleObject to wait
on a CRITICAL_SECTION, instead use the TryEnterCriticalSection function.
- it returns 0 if "mutex" was already taken => return EBUSY
- it returns > 0 if "mutex" was aquired => return 0
include/config-win.h@stripped, 2007-10-02 19:59:30+02:00, msvensson@stripped +3 -0
Make windows.h define TryEnterCriticalSection
include/my_pthread.h@stripped, 2007-10-02 19:59:30+02:00, msvensson@stripped +1 -2
It's not possible to use WaitForSingleObject to wait
on a CRITICAL_SECTION, instead use the TryEnterCriticalSection function.
- it returns 0 if "mutex" was already taken => return EBUSY
- it returns > 0 if "mutex" was aquired => return 0
mysys/my_winthread.c@stripped, 2007-10-02 19:59:30+02:00, msvensson@stripped +0 -24
Remove 'win_pthread_mutext_trylock'
diff -Nrup a/include/config-win.h b/include/config-win.h
--- a/include/config-win.h 2007-03-28 23:00:25 +02:00
+++ b/include/config-win.h 2007-10-02 19:59:30 +02:00
@@ -19,6 +19,9 @@
/* We have to do this define before including windows.h to get the AWE API
functions */
#define _WIN32_WINNT 0x0500
+#else
+/* Get NT 4.0 functions */
+#define _WIN32_WINNT 0x0400
#endif
#if defined(_MSC_VER) && _MSC_VER >= 1400
diff -Nrup a/include/my_pthread.h b/include/my_pthread.h
--- a/include/my_pthread.h 2007-10-01 15:14:53 +02:00
+++ b/include/my_pthread.h 2007-10-02 19:59:30 +02:00
@@ -116,7 +116,6 @@ struct timespec {
void win_pthread_init(void);
int win_pthread_setspecific(void *A,void *B,uint length);
-int win_pthread_mutex_trylock(pthread_mutex_t *mutex);
int pthread_create(pthread_t *,pthread_attr_t *,pthread_handler,void *);
int pthread_cond_init(pthread_cond_t *cond, const pthread_condattr_t *attr);
int pthread_cond_wait(pthread_cond_t *cond, pthread_mutex_t *mutex);
@@ -177,7 +176,7 @@ extern int pthread_mutex_destroy (pthrea
#else
#define pthread_mutex_init(A,B) (InitializeCriticalSection(A),0)
#define pthread_mutex_lock(A) (EnterCriticalSection(A),0)
-#define pthread_mutex_trylock(A) win_pthread_mutex_trylock((A))
+#define pthread_mutex_trylock(A) (TryEnterCriticalSection(A) ? 0 : EBUSY)
#define pthread_mutex_unlock(A) LeaveCriticalSection(A)
#define pthread_mutex_destroy(A) DeleteCriticalSection(A)
#define my_pthread_setprio(A,B) SetThreadPriority(GetCurrentThread(), (B))
diff -Nrup a/mysys/my_winthread.c b/mysys/my_winthread.c
--- a/mysys/my_winthread.c 2007-10-01 15:11:12 +02:00
+++ b/mysys/my_winthread.c 2007-10-02 19:59:30 +02:00
@@ -40,30 +40,6 @@ void win_pthread_init(void)
pthread_mutex_init(&THR_LOCK_thread,MY_MUTEX_INIT_FAST);
}
-/**
- Adapter to @c pthread_mutex_trylock()
-
- @retval 0 Mutex was acquired
- @retval EBUSY Mutex was already locked by a thread
- @retval EINVAL Mutex could not be acquired due to other error
- */
-int
-win_pthread_mutex_trylock(pthread_mutex_t *mutex)
-{
- switch (WaitForSingleObject(mutex, 0)) {
- case WAIT_TIMEOUT:
- return EBUSY;
-
- default:
- case WAIT_FAILURE:
- return EINVAL;
-
- case WAIT_OBJECT_0:
- case WAIT_ABANDONED: /* The mutex was acquired because it was
- * abandoned */
- return 0;
- }
-}
/*
** We have tried to use '_beginthreadex' instead of '_beginthread' here