diff options
author | Kentoku <kentokushiba@gmail.com> | 2019-08-02 21:48:56 +0900 |
---|---|---|
committer | Kentoku <kentokushiba@gmail.com> | 2019-08-02 21:48:56 +0900 |
commit | 7fbb0c85980507772d624b680d866aaac1aea1ba (patch) | |
tree | 6ae3004f663e5f084ad1a81e704f05424861f5c2 | |
parent | 36b785df6f95b53b4f54bd0ca3efa9a96cc5720e (diff) | |
download | mariadb-git-7fbb0c85980507772d624b680d866aaac1aea1ba.tar.gz |
revert MDEV-6268 221e6b48a233de44e6a6e900ff487af2c9b1b1fb
-rw-r--r-- | include/my_pthread.h | 3 | ||||
-rw-r--r-- | include/mysql/psi/mysql_thread.h | 59 | ||||
-rw-r--r-- | mysys/my_winthread.c | 34 | ||||
-rw-r--r-- | storage/spider/mysql-test/spider/bugfix/include/self_reference_deinit.inc | 1 | ||||
-rw-r--r-- | storage/spider/mysql-test/spider/bugfix/include/self_reference_init.inc | 2 | ||||
-rw-r--r-- | storage/spider/mysql-test/spider/bugfix/r/self_reference.result | 3 |
6 files changed, 29 insertions, 73 deletions
diff --git a/include/my_pthread.h b/include/my_pthread.h index 74d28eee004..d02fd25730c 100644 --- a/include/my_pthread.h +++ b/include/my_pthread.h @@ -71,8 +71,6 @@ struct timespec { #endif int win_pthread_mutex_trylock(pthread_mutex_t *mutex); -int win_pthread_mutex_timedlock(pthread_mutex_t *mutex, - const struct timespec *abstime); int pthread_create(pthread_t *, const 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); @@ -125,7 +123,6 @@ int pthread_cancel(pthread_t thread); #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_timedlock(A,B) win_pthread_mutex_timedlock((A),(B)) #define pthread_mutex_unlock(A) (LeaveCriticalSection(A), 0) #define pthread_mutex_destroy(A) (DeleteCriticalSection(A), 0) #define pthread_kill(A,B) pthread_dummy((A) ? 0 : ESRCH) diff --git a/include/mysql/psi/mysql_thread.h b/include/mysql/psi/mysql_thread.h index 3e5cdd77a5a..28d8899e1d2 100644 --- a/include/mysql/psi/mysql_thread.h +++ b/include/mysql/psi/mysql_thread.h @@ -118,7 +118,6 @@ struct st_mysql_mutex @sa mysql_mutex_assert_not_owner @sa mysql_mutex_init @sa mysql_mutex_lock - @sa mysql_mutex_trylock @sa mysql_mutex_timedlock @sa mysql_mutex_unlock @sa mysql_mutex_destroy @@ -323,33 +322,33 @@ typedef struct st_mysql_cond mysql_cond_t; #endif /** - @def mysql_mutex_trylock(M) + @def mysql_mutex_timedlock(M) Instrumented mutex_lock. - @c mysql_mutex_trylock is a drop-in replacement - for @c pthread_mutex_trylock. + @c mysql_mutex_timedlock is a drop-in replacement + for @c pthread_mutex_timedlock. */ #if defined(SAFE_MUTEX) || defined (HAVE_PSI_MUTEX_INTERFACE) - #define mysql_mutex_trylock(M) \ - inline_mysql_mutex_trylock(M, __FILE__, __LINE__) + #define mysql_mutex_timedlock(M, W) \ + inline_mysql_mutex_timedlock(M, W, __FILE__, __LINE__) #else - #define mysql_mutex_trylock(M) \ - inline_mysql_mutex_trylock(M) + #define mysql_mutex_timedlock(M, W) \ + inline_mysql_mutex_timedlock(M, W) #endif /** - @def mysql_mutex_timedlock(M) + @def mysql_mutex_trylock(M) Instrumented mutex_lock. - @c mysql_mutex_timedlock is a drop-in replacement - for @c pthread_mutex_timedlock. + @c mysql_mutex_trylock is a drop-in replacement + for @c pthread_mutex_trylock. */ #if defined(SAFE_MUTEX) || defined (HAVE_PSI_MUTEX_INTERFACE) - #define mysql_mutex_timedlock(M, W) \ - inline_mysql_mutex_timedlock(M, W, __FILE__, __LINE__) + #define mysql_mutex_trylock(M) \ + inline_mysql_mutex_trylock(M, __FILE__, __LINE__) #else - #define mysql_mutex_timedlock(M, W) \ - inline_mysql_mutex_timedlock(M, W) + #define mysql_mutex_trylock(M) \ + inline_mysql_mutex_trylock(M) #endif /** @@ -732,8 +731,9 @@ static inline int inline_mysql_mutex_lock( return result; } -static inline int inline_mysql_mutex_trylock( - mysql_mutex_t *that +static inline int inline_mysql_mutex_timedlock( + mysql_mutex_t *that, + const struct timespec *abstime #if defined(SAFE_MUTEX) || defined (HAVE_PSI_MUTEX_INTERFACE) , const char *src_file, uint src_line #endif @@ -748,13 +748,13 @@ static inline int inline_mysql_mutex_trylock( PSI_mutex_locker *locker; PSI_mutex_locker_state state; locker= PSI_MUTEX_CALL(start_mutex_wait)(&state, that->m_psi, - PSI_MUTEX_TRYLOCK, src_file, src_line); + PSI_MUTEX_LOCK, src_file, src_line); /* Instrumented code */ #ifdef SAFE_MUTEX - result= safe_mutex_lock(&that->m_mutex, TRUE, src_file, src_line); + result= safe_mutex_timedlock(&that->m_mutex, abstime, FALSE, src_file, src_line); #else - result= pthread_mutex_trylock(&that->m_mutex); + result= pthread_mutex_timedlock(&that->m_mutex, abstime); #endif /* Instrumentation end */ @@ -767,17 +767,16 @@ static inline int inline_mysql_mutex_trylock( /* Non instrumented code */ #ifdef SAFE_MUTEX - result= safe_mutex_lock(&that->m_mutex, TRUE, src_file, src_line); + result= safe_mutex_timedlock(&that->m_mutex, abstime, FALSE, src_file, src_line); #else - result= pthread_mutex_trylock(&that->m_mutex); + result= pthread_mutex_timedlock(&that->m_mutex, abstime); #endif return result; } -static inline int inline_mysql_mutex_timedlock( - mysql_mutex_t *that, - const struct timespec *abstime +static inline int inline_mysql_mutex_trylock( + mysql_mutex_t *that #if defined(SAFE_MUTEX) || defined (HAVE_PSI_MUTEX_INTERFACE) , const char *src_file, uint src_line #endif @@ -792,13 +791,13 @@ static inline int inline_mysql_mutex_timedlock( PSI_mutex_locker *locker; PSI_mutex_locker_state state; locker= PSI_MUTEX_CALL(start_mutex_wait)(&state, that->m_psi, - PSI_MUTEX_LOCK, src_file, src_line); + PSI_MUTEX_TRYLOCK, src_file, src_line); /* Instrumented code */ #ifdef SAFE_MUTEX - result= safe_mutex_timedlock(&that->m_mutex, abstime, FALSE, src_file, src_line); + result= safe_mutex_lock(&that->m_mutex, TRUE, src_file, src_line); #else - result= pthread_mutex_timedlock(&that->m_mutex, abstime); + result= pthread_mutex_trylock(&that->m_mutex); #endif /* Instrumentation end */ @@ -811,9 +810,9 @@ static inline int inline_mysql_mutex_timedlock( /* Non instrumented code */ #ifdef SAFE_MUTEX - result= safe_mutex_timedlock(&that->m_mutex, abstime, FALSE, src_file, src_line); + result= safe_mutex_lock(&that->m_mutex, TRUE, src_file, src_line); #else - result= pthread_mutex_timedlock(&that->m_mutex, abstime); + result= pthread_mutex_trylock(&that->m_mutex); #endif return result; diff --git a/mysys/my_winthread.c b/mysys/my_winthread.c index 4383c12354e..080eeb49f63 100644 --- a/mysys/my_winthread.c +++ b/mysys/my_winthread.c @@ -31,28 +31,6 @@ struct thread_start_parameter }; /** - Convert abstime to milliseconds -*/ - -static DWORD get_milliseconds(const struct timespec *abstime) -{ - struct timespec current_time; - long long ms; - - if (abstime == NULL) - return INFINITE; - - set_timespec_nsec(current_time, 0); - ms= (abstime->tv_sec - current_time.tv_sec)*1000LL + - (abstime->tv_nsec - current_time.tv_nsec)/1000000LL; - if(ms < 0 ) - ms= 0; - if(ms > UINT_MAX) - ms= INFINITE; - return (DWORD)ms; -} - -/** Adapter to @c pthread_mutex_trylock() @retval 0 Mutex was acquired @@ -73,18 +51,6 @@ win_pthread_mutex_trylock(pthread_mutex_t *mutex) return EBUSY; } -int win_pthread_mutex_timedlock(pthread_mutex_t *mutex, - const struct timespec *abstime) -{ - while (win_pthread_mutex_trylock(mutex)) - { - if (!get_milliseconds(abstime)) - return ETIMEDOUT; - Sleep(1); - } - return 0; -} - static unsigned int __stdcall pthread_start(void *p) { struct thread_start_parameter *par= (struct thread_start_parameter *)p; diff --git a/storage/spider/mysql-test/spider/bugfix/include/self_reference_deinit.inc b/storage/spider/mysql-test/spider/bugfix/include/self_reference_deinit.inc index bc97cbf2267..c8ac13bbcea 100644 --- a/storage/spider/mysql-test/spider/bugfix/include/self_reference_deinit.inc +++ b/storage/spider/mysql-test/spider/bugfix/include/self_reference_deinit.inc @@ -1,6 +1,5 @@ --connection master_1 set global spider_internal_lock_wait_timeout= @old_spider_internal_lock_wait_timeout; -set spider_same_server_link= @old_spider_same_server_link; --let $MASTER_1_COMMENT_2_1= $MASTER_1_COMMENT_2_1_BACKUP --disable_warnings --disable_query_log diff --git a/storage/spider/mysql-test/spider/bugfix/include/self_reference_init.inc b/storage/spider/mysql-test/spider/bugfix/include/self_reference_init.inc index aa647836122..1c79946a96d 100644 --- a/storage/spider/mysql-test/spider/bugfix/include/self_reference_init.inc +++ b/storage/spider/mysql-test/spider/bugfix/include/self_reference_init.inc @@ -10,6 +10,4 @@ let $MASTER_1_COMMENT_2_1= COMMENT='table "tbl_a", host "127.0.0.1", port "$MASTER_1_MYPORT", user "root"'; --connection master_1 set @old_spider_internal_lock_wait_timeout= @@spider_internal_lock_wait_timeout; -set @old_spider_same_server_link= @@spider_same_server_link; set global spider_internal_lock_wait_timeout= 0; -set spider_same_server_link= ON; diff --git a/storage/spider/mysql-test/spider/bugfix/r/self_reference.result b/storage/spider/mysql-test/spider/bugfix/r/self_reference.result index 3bce19b0749..7017ca39e06 100644 --- a/storage/spider/mysql-test/spider/bugfix/r/self_reference.result +++ b/storage/spider/mysql-test/spider/bugfix/r/self_reference.result @@ -3,9 +3,7 @@ for child2 for child3 connection master_1; set @old_spider_internal_lock_wait_timeout= @@spider_internal_lock_wait_timeout; -set @old_spider_same_server_link= @@spider_same_server_link; set global spider_internal_lock_wait_timeout= 0; -set spider_same_server_link= ON; this test is for MDEV-6268 @@ -31,7 +29,6 @@ connection master_1; DROP DATABASE IF EXISTS auto_test_local; connection master_1; set global spider_internal_lock_wait_timeout= @old_spider_internal_lock_wait_timeout; -set spider_same_server_link= @old_spider_same_server_link; for master_1 for child2 for child3 |