diff options
Diffstat (limited to 'thread_pthread.c')
-rw-r--r-- | thread_pthread.c | 14 |
1 files changed, 12 insertions, 2 deletions
diff --git a/thread_pthread.c b/thread_pthread.c index b087d461c7..e074a854f5 100644 --- a/thread_pthread.c +++ b/thread_pthread.c @@ -1769,8 +1769,18 @@ ubf_timer_disarm(void) case RTIMER_DISARM: return; /* likely */ case RTIMER_ARMING: return; /* ubf_timer_arm will disarm itself */ case RTIMER_ARMED: - if (timer_settime(timer_posix.timerid, 0, &zero, 0)) - rb_bug_errno("timer_settime (disarm)", errno); + if (timer_settime(timer_posix.timerid, 0, &zero, 0)) { + int err = errno; + + if (err == EINVAL) { + prev = ATOMIC_CAS(timer_posix.state, RTIMER_DISARM, RTIMER_DISARM); + + /* main thread may have killed the timer */ + if (prev == RTIMER_DEAD) return; + + rb_bug_errno("timer_settime (disarm)", err); + } + } return; case RTIMER_DEAD: return; /* stay dead */ default: |