summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--ChangeLog15
-rw-r--r--test/ruby/test_thread.rb15
-rw-r--r--thread_pthread.c24
-rw-r--r--version.h6
4 files changed, 49 insertions, 11 deletions
diff --git a/ChangeLog b/ChangeLog
index 352ce0a9be..395cf11280 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -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
diff --git a/test/ruby/test_thread.rb b/test/ruby/test_thread.rb
index 57e02849b9..209d4b006f 100644
--- a/test/ruby/test_thread.rb
+++ b/test/ruby/test_thread.rb
@@ -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
diff --git a/thread_pthread.c b/thread_pthread.c
index 255dbf02d2..c6c98f0f2c 100644
--- a/thread_pthread.c
+++ b/thread_pthread.c
@@ -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;
}
});
- return 1;
}
- else {
+}
+
+static int
+check_signal_thread_list(void)
+{
+ if (signal_thread_list_anchor.next)
+ return 1;
+ 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");
diff --git a/version.h b/version.h
index f360c37085..ae945241e4 100644
--- a/version.h
+++ b/version.h
@@ -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"