1
0
Fork 0
mirror of https://github.com/ruby/ruby.git synced 2022-11-09 12:17:21 -05:00

* thread_pthread.c (USE_MONOTONIC_COND): check the availability

more strictly.
* thread_pthread.h (rb_thread_cond_t): ditto.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@31462 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
nobu 2011-05-07 09:28:43 +00:00
parent 562a1a7929
commit 1bd2c78b05
3 changed files with 15 additions and 3 deletions

View file

@ -1,3 +1,10 @@
Sat May 7 18:28:37 2011 Nobuyoshi Nakada <nobu@ruby-lang.org>
* thread_pthread.c (USE_MONOTONIC_COND): check the availability
more strictly.
* thread_pthread.h (rb_thread_cond_t): ditto.
Sat May 7 15:18:06 2011 KOSAKI Motohiro <kosaki.motohiro@gmail.com> Sat May 7 15:18:06 2011 KOSAKI Motohiro <kosaki.motohiro@gmail.com>
fix incorrect native_cond_signal call when deadlock was detected. fix incorrect native_cond_signal call when deadlock was detected.

View file

@ -30,8 +30,11 @@ static void native_cond_destroy(rb_thread_cond_t *cond);
#define RB_CONDATTR_CLOCK_MONOTONIC 1 #define RB_CONDATTR_CLOCK_MONOTONIC 1
#if defined(HAVE_PTHREAD_CONDATTR_SETCLOCK) && defined(CLOCK_MONOTONIC) && defined(HAVE_CLOCK_GETTIME) #if defined(HAVE_PTHREAD_CONDATTR_SETCLOCK) && defined(HAVE_CLOCKID_T) && \
defined(CLOCK_REALTIME) && defined(CLOCK_MONOTONIC) && defined(HAVE_CLOCK_GETTIME)
#define USE_MONOTONIC_COND 1 #define USE_MONOTONIC_COND 1
#else
#define USE_MONOTONIC_COND 0
#endif #endif
#define GVL_SIMPLE_LOCK 0 #define GVL_SIMPLE_LOCK 0
@ -230,10 +233,10 @@ native_cond_initialize(rb_thread_cond_t *cond, int flags)
int r; int r;
pthread_condattr_t attr; pthread_condattr_t attr;
cond->clockid = CLOCK_REALTIME;
pthread_condattr_init(&attr); pthread_condattr_init(&attr);
#if USE_MONOTONIC_COND #if USE_MONOTONIC_COND
cond->clockid = CLOCK_REALTIME;
if (flags & RB_CONDATTR_CLOCK_MONOTONIC) { if (flags & RB_CONDATTR_CLOCK_MONOTONIC) {
r = pthread_condattr_setclock(&attr, CLOCK_MONOTONIC); r = pthread_condattr_setclock(&attr, CLOCK_MONOTONIC);
if (r == 0) { if (r == 0) {
@ -323,10 +326,10 @@ native_cond_timeout(rb_thread_cond_t *cond, struct timespec timeout_rel)
rb_sys_fail("clock_gettime()"); rb_sys_fail("clock_gettime()");
goto out; goto out;
} }
#endif
if (cond->clockid != CLOCK_REALTIME) if (cond->clockid != CLOCK_REALTIME)
rb_bug("unsupported clockid %d", cond->clockid); rb_bug("unsupported clockid %d", cond->clockid);
#endif
ret = gettimeofday(&tv, 0); ret = gettimeofday(&tv, 0);
if (ret != 0) if (ret != 0)

View file

@ -20,7 +20,9 @@ typedef pthread_mutex_t rb_thread_lock_t;
typedef struct rb_thread_cond_struct { typedef struct rb_thread_cond_struct {
pthread_cond_t cond; pthread_cond_t cond;
#ifdef HAVE_CLOCKID_T
clockid_t clockid; clockid_t clockid;
#endif
} rb_thread_cond_t; } rb_thread_cond_t;
typedef struct native_thread_data_struct { typedef struct native_thread_data_struct {