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

merge revision(s) r34038,34099:

* 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.

	* thread_pthread.c (ping_signal_thread_list): remove return value.

	* thread_pthread.c (check_signal_thread_list): add a new function to
	  check if signal thread list is empty.

	* thread_pthread.c (thread_timer): check signal thread list after
	  timer_thread_function(). main thread might be added into signal thread
	  list during timer_thread_function().


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_1_9_3@34425 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
naruse 2012-02-03 01:11:37 +00:00
parent aea7069f79
commit 5dc6d20cc3
4 changed files with 49 additions and 11 deletions

View file

@ -1,3 +1,18 @@
Fri Feb 3 10:10:02 2012 CHIKANAGA Tomoyuki <nagachika00@gmail.com>
* thread_pthread.c (ping_signal_thread_list): remove return value.
* thread_pthread.c (check_signal_thread_list): add a new function to
check if signal thread list is empty.
* thread_pthread.c (thread_timer): check signal thread list after
timer_thread_function(). main thread might be added into signal thread
list during timer_thread_function().
Fri Feb 3 10:10:02 2012 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 Feb 1 09:50:10 2012 Nobuyoshi Nakada <nobu@ruby-lang.org>
* doc/re.rdoc (Repetition): fix typo. reported by Ori Avtalion

View file

@ -685,4 +685,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

@ -35,6 +35,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
@ -1009,11 +1010,12 @@ 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);
}
static int
static void
ping_signal_thread_list(void) {
if (signal_thread_list_anchor.next) {
FGLOCK(&signal_thread_list_lock, {
@ -1025,20 +1027,25 @@ ping_signal_thread_list(void) {
list = list->next;
}
});
}
}
static int
check_signal_thread_list(void)
{
if (signal_thread_list_anchor.next)
return 1;
}
else {
else
return 0;
}
}
#else /* USE_SIGNAL_THREAD_LIST */
static void add_signal_thread_list(rb_thread_t *th) { }
static void remove_signal_thread_list(rb_thread_t *th) { }
#define ubf_select 0
static int ping_signal_thread_list(void) { return 0; }
static void ping_signal_thread_list(void) { return; }
static int check_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;
@ -1126,8 +1133,9 @@ thread_timer(void *p)
int need_polling;
/* timer function */
need_polling = ping_signal_thread_list();
ping_signal_thread_list();
timer_thread_function(0);
need_polling = check_signal_thread_list();
if (TT_DEBUG) WRITE_CONST(2, "tick\n");

View file

@ -1,10 +1,10 @@
#define RUBY_VERSION "1.9.3"
#define RUBY_PATCHLEVEL 29
#define RUBY_PATCHLEVEL 30
#define RUBY_RELEASE_DATE "2012-02-01"
#define RUBY_RELEASE_DATE "2012-02-03"
#define RUBY_RELEASE_YEAR 2012
#define RUBY_RELEASE_MONTH 2
#define RUBY_RELEASE_DAY 1
#define RUBY_RELEASE_DAY 3
#include "ruby/version.h"