summaryrefslogtreecommitdiff
path: root/include
diff options
context:
space:
mode:
Diffstat (limited to 'include')
-rw-r--r--include/my_pthread.h6
-rw-r--r--include/mysql/psi/mysql_thread.h17
2 files changed, 16 insertions, 7 deletions
diff --git a/include/my_pthread.h b/include/my_pthread.h
index 404d5fb5258..5a921fe0f26 100644
--- a/include/my_pthread.h
+++ b/include/my_pthread.h
@@ -350,9 +350,9 @@ int my_pthread_mutex_trylock(pthread_mutex_t *mutex);
#ifndef set_timespec_time_nsec
#define set_timespec_time_nsec(ABSTIME,NSEC) do { \
- ulonglong now= (NSEC); \
- (ABSTIME).MY_tv_sec= (now / 1000000000ULL); \
- (ABSTIME).MY_tv_nsec= (now % 1000000000ULL); \
+ ulonglong _now_= (NSEC); \
+ (ABSTIME).MY_tv_sec= (_now_ / 1000000000ULL); \
+ (ABSTIME).MY_tv_nsec= (_now_ % 1000000000ULL); \
} while(0)
#endif /* !set_timespec_time_nsec */
diff --git a/include/mysql/psi/mysql_thread.h b/include/mysql/psi/mysql_thread.h
index 18b4fde8c5c..7615985ec24 100644
--- a/include/mysql/psi/mysql_thread.h
+++ b/include/mysql/psi/mysql_thread.h
@@ -477,7 +477,7 @@ typedef struct st_mysql_cond mysql_cond_t;
Instrumented cond_wait.
@c mysql_cond_wait is a drop-in replacement for @c pthread_cond_wait.
*/
-#ifdef HAVE_PSI_INTERFACE
+#if defined(HAVE_PSI_INTERFACE) || defined(SAFE_MUTEX)
#define mysql_cond_wait(C, M) \
inline_mysql_cond_wait(C, M, __FILE__, __LINE__)
#else
@@ -491,7 +491,7 @@ typedef struct st_mysql_cond mysql_cond_t;
@c mysql_cond_timedwait is a drop-in replacement
for @c pthread_cond_timedwait.
*/
-#ifdef HAVE_PSI_INTERFACE
+#if defined(HAVE_PSI_INTERFACE) || defined(SAFE_MUTEX)
#define mysql_cond_timedwait(C, M, W) \
inline_mysql_cond_timedwait(C, M, W, __FILE__, __LINE__)
#else
@@ -963,7 +963,7 @@ static inline int inline_mysql_cond_destroy(
static inline int inline_mysql_cond_wait(
mysql_cond_t *that,
mysql_mutex_t *mutex
-#ifdef HAVE_PSI_INTERFACE
+#if defined(HAVE_PSI_INTERFACE) || defined(SAFE_MUTEX)
, const char *src_file, uint src_line
#endif
)
@@ -980,7 +980,11 @@ static inline int inline_mysql_cond_wait(
PSI_server->start_cond_wait(locker, src_file, src_line);
}
#endif
+#ifdef SAFE_MUTEX
+ result= safe_cond_wait(&that->m_cond, &mutex->m_mutex, src_file, src_line);
+#else
result= pthread_cond_wait(&that->m_cond, &mutex->m_mutex);
+#endif
#ifdef HAVE_PSI_INTERFACE
if (likely(locker != NULL))
PSI_server->end_cond_wait(locker, result);
@@ -992,7 +996,7 @@ static inline int inline_mysql_cond_timedwait(
mysql_cond_t *that,
mysql_mutex_t *mutex,
struct timespec *abstime
-#ifdef HAVE_PSI_INTERFACE
+#if defined(HAVE_PSI_INTERFACE) || defined(SAFE_MUTEX)
, const char *src_file, uint src_line
#endif
)
@@ -1009,7 +1013,12 @@ static inline int inline_mysql_cond_timedwait(
PSI_server->start_cond_wait(locker, src_file, src_line);
}
#endif
+#ifdef SAFE_MUTEX
+ result= safe_cond_timedwait(&that->m_cond, &mutex->m_mutex, abstime,
+ src_file, src_line);
+#else
result= pthread_cond_timedwait(&that->m_cond, &mutex->m_mutex, abstime);
+#endif
#ifdef HAVE_PSI_INTERFACE
if (likely(locker != NULL))
PSI_server->end_cond_wait(locker, result);