[前][次][番号順一覧][スレッド一覧]

ruby-changes:56786

From: nagachika <ko1@a...>
Date: Sat, 3 Aug 2019 21:27:20 +0900 (JST)
Subject: [ruby-changes:56786] nagachika: 194a55259b (ruby_2_6): merge revision(s) 1ef39d8d099f145222b9352423af16a2bab6e05b: [Backport #15798]

https://git.ruby-lang.org/ruby.git/commit/?id=194a55259b

From 194a55259bc5d58b48c00f01030b460072aa7fd3 Mon Sep 17 00:00:00 2001
From: nagachika <nagachika@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>
Date: Sat, 3 Aug 2019 12:27:02 +0000
Subject: merge revision(s) 1ef39d8d099f145222b9352423af16a2bab6e05b: [Backport
 #15798]

	Fix process not waking up on signals on OpenBSD

	When using UBF_TIMER_PTHREAD (the UBF handler on OpenBSD), the
	timer_pthread_fn function will not signal the main thread with
	SIGVTALRM in cases where timer_pthread is armed before
	consume_communication_pipe is called.  This is because
	consume_communication_pipe will unarm the timer.

	Fix this by checking the return value of consume_communication_pipe.
	If it returns TRUE and the timer_pthread is disarmed, then signal
	the main thread with SIGVTALRM.

	On OpenBSD, this fixes TestThread#test_thread_timer_and_interrupt, and
	fixes hangs in TestProcess#test_execopts_redirect_open_fifo_interrupt_raise
	and TestProcess#test_execopts_redirect_open_fifo_interrupt_print.
	It also fixes the use of Ctrl+C/SIGINT in irb on OpenBSD. It does not
	cause any test failures on Linux when UBF_TIMER_PTHREAD is forced as
	the UBF handler.

	Fixes [Bug #15798]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_2_6@67725 b2dd03c8-39d4-4d8f-98ff-823fe69b080e

diff --git a/thread_pthread.c b/thread_pthread.c
index d8d3184..96d2ca9 100644
--- a/thread_pthread.c
+++ b/thread_pthread.c
@@ -2182,25 +2182,33 @@ timer_pthread_fn(void *p) https://github.com/ruby/ruby/blob/trunk/thread_pthread.c#L2182
     pthread_t main_thread_id = vm->main_thread->thread_id;
     struct pollfd pfd;
     int timeout = -1;
+    int ccp;
 
     pfd.fd = timer_pthread.low[0];
     pfd.events = POLLIN;
 
     while (system_working > 0) {
         (void)poll(&pfd, 1, timeout);
-        (void)consume_communication_pipe(pfd.fd);
+        ccp = consume_communication_pipe(pfd.fd);
 
-        if (system_working > 0 && ATOMIC_CAS(timer_pthread.armed, 1, 1)) {
-            pthread_kill(main_thread_id, SIGVTALRM);
-
-            if (rb_signal_buff_size() || !ubf_threads_empty()) {
-                timeout = TIME_QUANTUM_MSEC;
-            }
-            else {
-                ATOMIC_SET(timer_pthread.armed, 0);
-                timeout = -1;
-            }
-        }
+        if (system_working > 0) {
+	    if (ATOMIC_CAS(timer_pthread.armed, 1, 1)) {
+		pthread_kill(main_thread_id, SIGVTALRM);
+
+		if (rb_signal_buff_size() || !ubf_threads_empty()) {
+		    timeout = TIME_QUANTUM_MSEC;
+		}
+		else {
+		    ATOMIC_SET(timer_pthread.armed, 0);
+		    timeout = -1;
+		}
+	    }
+	    else if (ccp) {
+		pthread_kill(main_thread_id, SIGVTALRM);
+		ATOMIC_SET(timer_pthread.armed, 0);
+		timeout = -1;
+	    }
+	}
     }
 
     return 0;
diff --git a/version.h b/version.h
index e31a283..b81f9d7 100644
--- a/version.h
+++ b/version.h
@@ -1,10 +1,10 @@ https://github.com/ruby/ruby/blob/trunk/version.h#L1
 #define RUBY_VERSION "2.6.3"
 #define RUBY_RELEASE_DATE RUBY_RELEASE_YEAR_STR"-"RUBY_RELEASE_MONTH_STR"-"RUBY_RELEASE_DAY_STR
-#define RUBY_PATCHLEVEL 75
+#define RUBY_PATCHLEVEL 76
 
 #define RUBY_RELEASE_YEAR 2019
 #define RUBY_RELEASE_MONTH 8
-#define RUBY_RELEASE_DAY 1
+#define RUBY_RELEASE_DAY 3
 
 #include "ruby/version.h"
 
-- 
cgit v0.10.2


--
ML: ruby-changes@q...
Info: http://www.atdot.net/~ko1/quickml/

[前][次][番号順一覧][スレッド一覧]