Loading include/my_global.h +17 −1 Original line number Diff line number Diff line Loading @@ -927,7 +927,17 @@ typedef char bool; /* Ordinary boolean values 0 1 */ #ifndef set_timespec #ifdef HAVE_TIMESPEC_TS_SEC #define set_timespec(ABSTIME,SEC) { (ABSTIME).ts_sec=time(0) + (time_t) (SEC); (ABSTIME).ts_nsec=0; } #define set_timespec(ABSTIME,SEC) \ { \ (ABSTIME).ts_sec=time(0) + (time_t) (SEC); \ (ABSTIME).ts_nsec=0; \ } #define set_timespec_nsec(ABSTIME,NSEC) \ {\ ulonglong now= my_getsystime(); \ (ABSTIME).ts_sec= (now / ULL(10000000)) + (NSEC / ULL(1000000000)); \ (ABSTIME).ts_nsec= (now % ULL(10000000)) * 100 + (NSEC % ULL(1000000000)); \ } #else #define set_timespec(ABSTIME,SEC) \ {\ Loading @@ -936,6 +946,12 @@ typedef char bool; /* Ordinary boolean values 0 1 */ (ABSTIME).tv_sec=tv.tv_sec+(time_t) (SEC);\ (ABSTIME).tv_nsec=tv.tv_usec*1000;\ } #define set_timespec_nsec(ABSTIME,NSEC) \ {\ ulonglong now= my_getsystime(); \ (ABSTIME).tv_sec= (now / ULL(10000000)) + (NSEC / ULL(1000000000)); \ (ABSTIME).tv_nsec= (now % ULL(10000000)) * 100 + (NSEC % ULL(1000000000)); \ } #endif /* HAVE_TIMESPEC_TS_SEC */ #endif /* set_timespec */ Loading sql/item_func.cc +28 −2 Original line number Diff line number Diff line Loading @@ -3266,10 +3266,36 @@ void Item_func_benchmark::print(String *str) longlong Item_func_sleep::val_int() { THD *thd= current_thd; struct timespec abstime; pthread_cond_t cond; int error= 0; DBUG_ASSERT(fixed == 1); double time= args[0]->val_real(); my_sleep((ulong)time*1000000L); return 0; set_timespec_nsec(abstime, (ulonglong)(time * ULL(1000000000))); pthread_cond_init(&cond, NULL); pthread_mutex_lock(&LOCK_user_locks); thd->mysys_var->current_mutex= &LOCK_user_locks; thd->mysys_var->current_cond= &cond; while (!thd->killed && (error= pthread_cond_timedwait(&cond, &LOCK_user_locks, &abstime) != ETIMEDOUT) && error != EINVAL) ; pthread_mutex_lock(&thd->mysys_var->mutex); thd->mysys_var->current_mutex= 0; thd->mysys_var->current_cond= 0; pthread_mutex_unlock(&thd->mysys_var->mutex); pthread_mutex_unlock(&LOCK_user_locks); pthread_cond_destroy(&cond); return (error == ETIMEDOUT) ? 0 : 1; } Loading Loading
include/my_global.h +17 −1 Original line number Diff line number Diff line Loading @@ -927,7 +927,17 @@ typedef char bool; /* Ordinary boolean values 0 1 */ #ifndef set_timespec #ifdef HAVE_TIMESPEC_TS_SEC #define set_timespec(ABSTIME,SEC) { (ABSTIME).ts_sec=time(0) + (time_t) (SEC); (ABSTIME).ts_nsec=0; } #define set_timespec(ABSTIME,SEC) \ { \ (ABSTIME).ts_sec=time(0) + (time_t) (SEC); \ (ABSTIME).ts_nsec=0; \ } #define set_timespec_nsec(ABSTIME,NSEC) \ {\ ulonglong now= my_getsystime(); \ (ABSTIME).ts_sec= (now / ULL(10000000)) + (NSEC / ULL(1000000000)); \ (ABSTIME).ts_nsec= (now % ULL(10000000)) * 100 + (NSEC % ULL(1000000000)); \ } #else #define set_timespec(ABSTIME,SEC) \ {\ Loading @@ -936,6 +946,12 @@ typedef char bool; /* Ordinary boolean values 0 1 */ (ABSTIME).tv_sec=tv.tv_sec+(time_t) (SEC);\ (ABSTIME).tv_nsec=tv.tv_usec*1000;\ } #define set_timespec_nsec(ABSTIME,NSEC) \ {\ ulonglong now= my_getsystime(); \ (ABSTIME).tv_sec= (now / ULL(10000000)) + (NSEC / ULL(1000000000)); \ (ABSTIME).tv_nsec= (now % ULL(10000000)) * 100 + (NSEC % ULL(1000000000)); \ } #endif /* HAVE_TIMESPEC_TS_SEC */ #endif /* set_timespec */ Loading
sql/item_func.cc +28 −2 Original line number Diff line number Diff line Loading @@ -3266,10 +3266,36 @@ void Item_func_benchmark::print(String *str) longlong Item_func_sleep::val_int() { THD *thd= current_thd; struct timespec abstime; pthread_cond_t cond; int error= 0; DBUG_ASSERT(fixed == 1); double time= args[0]->val_real(); my_sleep((ulong)time*1000000L); return 0; set_timespec_nsec(abstime, (ulonglong)(time * ULL(1000000000))); pthread_cond_init(&cond, NULL); pthread_mutex_lock(&LOCK_user_locks); thd->mysys_var->current_mutex= &LOCK_user_locks; thd->mysys_var->current_cond= &cond; while (!thd->killed && (error= pthread_cond_timedwait(&cond, &LOCK_user_locks, &abstime) != ETIMEDOUT) && error != EINVAL) ; pthread_mutex_lock(&thd->mysys_var->mutex); thd->mysys_var->current_mutex= 0; thd->mysys_var->current_cond= 0; pthread_mutex_unlock(&thd->mysys_var->mutex); pthread_mutex_unlock(&LOCK_user_locks); pthread_cond_destroy(&cond); return (error == ETIMEDOUT) ? 0 : 1; } Loading