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

* thread_pthread.c (ubf_select): call rb_thread_wakeup_timer_thread()

only when it is not timer_thread. [Bug #5757] [ruby-dev:44985]
  patched by Tomoyuki Chikanaga.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@34038 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
naruse 2011-12-14 02:26:20 +00:00
parent 24c3766624
commit 23f9e74604
3 changed files with 24 additions and 2 deletions

View file

@ -1,3 +1,9 @@
Wed Dec 14 11:23:45 2011 NARUSE, Yui <naruse@ruby-lang.org>
* thread_pthread.c (ubf_select): call rb_thread_wakeup_timer_thread()
only when it is not timer_thread. [Bug #5757] [ruby-dev:44985]
patched by Tomoyuki Chikanaga.
Wed Dec 14 10:20:08 2011 Nobuyoshi Nakada <nobu@ruby-lang.org>
* load.c (load_lock): delete the loading barrier if it has been

View file

@ -686,4 +686,19 @@ class TestThreadGroup < Test::Unit::TestCase
t.join
assert_equal(nil, t.backtrace)
end
def test_thread_timer_and_interrupt
bug5757 = '[ruby-dev:44985]'
t0 = Time.now.to_f
pid = spawn(EnvUtil.rubybin, '-e', '$stdin.read')
sleep 1;
Process.kill(:SIGQUIT, pid)
Process.wait(pid)
s = $?
assert_equal([false, true, false],
[s.exited?, s.signaled?, s.stopped?],
"[s.exited?, s.signaled?, s.stopped?]")
t1 = Time.now.to_f
assert_in_delta(t1 - t0, 1, 1)
end
end

View file

@ -38,6 +38,7 @@ static void native_cond_broadcast(rb_thread_cond_t *cond);
static void native_cond_wait(rb_thread_cond_t *cond, pthread_mutex_t *mutex);
static void native_cond_initialize(rb_thread_cond_t *cond, int flags);
static void native_cond_destroy(rb_thread_cond_t *cond);
static pthread_t timer_thread_id;
#define RB_CONDATTR_CLOCK_MONOTONIC 1
@ -1018,7 +1019,8 @@ ubf_select(void *ptr)
{
rb_thread_t *th = (rb_thread_t *)ptr;
add_signal_thread_list(th);
rb_thread_wakeup_timer_thread(); /* activate timer thread */
if (pthread_self() != timer_thread_id)
rb_thread_wakeup_timer_thread(); /* activate timer thread */
ubf_select_each(th);
}
@ -1047,7 +1049,6 @@ ping_signal_thread_list(void) {
static int ping_signal_thread_list(void) { return 0; }
#endif /* USE_SIGNAL_THREAD_LIST */
static pthread_t timer_thread_id;
static int timer_thread_pipe[2] = {-1, -1};
static int timer_thread_pipe_owner_process;