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

ruby-changes:35275

From: akr <ko1@a...>
Date: Tue, 2 Sep 2014 23:47:53 +0900 (JST)
Subject: [ruby-changes:35275] akr:r47357 (trunk): * process.c (retry_fork_async_signal_safe): Specialized version of

akr	2014-09-02 23:47:46 +0900 (Tue, 02 Sep 2014)

  New Revision: 47357

  http://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=revision&revision=47357

  Log:
    * process.c (retry_fork_async_signal_safe): Specialized version of
      retry_fork respect to rb_fork_async_signal_safe.
      (retry_fork_ruby): Specialized version of retry_fork respect to
      rb_fork_ruby.
      (rb_fork_ruby): Removed.

  Modified files:
    trunk/ChangeLog
    trunk/process.c
Index: ChangeLog
===================================================================
--- ChangeLog	(revision 47356)
+++ ChangeLog	(revision 47357)
@@ -1,3 +1,11 @@ https://github.com/ruby/ruby/blob/trunk/ChangeLog#L1
+Tue Sep  2 23:47:35 2014  Tanaka Akira  <akr@f...>
+
+	* process.c (retry_fork_async_signal_safe): Specialized version of
+	  retry_fork respect to rb_fork_async_signal_safe.
+	  (retry_fork_ruby): Specialized version of retry_fork respect to
+	  rb_fork_ruby.
+	  (rb_fork_ruby): Removed.
+
 Tue Sep  2 23:26:26 2014  Tanaka Akira  <akr@f...>
 
 	* process.c (send_child_error): Simplified.
Index: process.c
===================================================================
--- process.c	(revision 47356)
+++ process.c	(revision 47357)
@@ -3221,30 +3221,6 @@ handle_fork_error(int *status, int *ep, https://github.com/ruby/ruby/blob/trunk/process.c#L3221
  * +chfunc+ must not raise any exceptions.
  */
 
-static rb_pid_t
-retry_fork(int *status, int *ep, int chfunc_is_async_signal_safe)
-{
-    rb_pid_t pid;
-    int state = 0;
-    int try_gc = 1;
-
-    while (1) {
-        prefork();
-        if (!chfunc_is_async_signal_safe)
-            before_fork();
-        pid = fork();
-        if (pid == 0) /* fork succeed, child process */
-            return pid;
-        if (!chfunc_is_async_signal_safe)
-            preserving_errno(after_fork());
-        if (0 < pid) /* fork succeed, parent process */
-            return pid;
-        /* fork failed */
-        if (handle_fork_error(status, ep, &state, &try_gc))
-            return -1;
-    }
-}
-
 static ssize_t
 write_retry(int fd, const void *buf, size_t len)
 {
@@ -3304,6 +3280,26 @@ recv_child_error(int fd, int *errp, char https://github.com/ruby/ruby/blob/trunk/process.c#L3280
     return size != 0;
 }
 
+static rb_pid_t
+retry_fork_async_signal_safe(int *status, int *ep)
+{
+    rb_pid_t pid;
+    int state = 0;
+    int try_gc = 1;
+
+    while (1) {
+        prefork();
+        pid = fork();
+        if (pid == 0) /* fork succeed, child process */
+            return pid;
+        if (0 < pid) /* fork succeed, parent process */
+            return pid;
+        /* fork failed */
+        if (handle_fork_error(status, ep, &state, &try_gc))
+            return -1;
+    }
+}
+
 rb_pid_t
 rb_fork_async_signal_safe(int *status, int (*chfunc)(void*, char *, size_t), void *charg, VALUE fds,
         char *errmsg, size_t errmsg_buflen)
@@ -3313,12 +3309,11 @@ rb_fork_async_signal_safe(int *status, i https://github.com/ruby/ruby/blob/trunk/process.c#L3309
     int ep[2];
     VALUE exc = Qnil;
     int error_occurred;
-    int chfunc_is_async_signal_safe = TRUE;
 
     if (status) *status = 0;
 
     if (pipe_nocrash(ep, fds)) return -1;
-    pid = retry_fork(status, ep, chfunc_is_async_signal_safe);
+    pid = retry_fork_async_signal_safe(status, ep);
     if (pid < 0)
         return pid;
     if (!pid) {
@@ -3351,6 +3346,28 @@ rb_fork_async_signal_safe(int *status, i https://github.com/ruby/ruby/blob/trunk/process.c#L3346
     return pid;
 }
 
+static rb_pid_t
+retry_fork_ruby(int *status)
+{
+    rb_pid_t pid;
+    int state = 0;
+    int try_gc = 1;
+
+    while (1) {
+        prefork();
+        before_fork();
+        pid = fork();
+        if (pid == 0) /* fork succeed, child process */
+            return pid;
+        preserving_errno(after_fork());
+        if (0 < pid) /* fork succeed, parent process */
+            return pid;
+        /* fork failed */
+        if (handle_fork_error(status, NULL, &state, &try_gc))
+            return -1;
+    }
+}
+
 rb_pid_t
 rb_fork_ruby(int *status)
 {
@@ -3358,7 +3375,7 @@ rb_fork_ruby(int *status) https://github.com/ruby/ruby/blob/trunk/process.c#L3375
 
     if (status) *status = 0;
 
-    pid = retry_fork(status, NULL, FALSE);
+    pid = retry_fork_ruby(status);
     if (pid < 0)
         return pid;
     if (!pid) {

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

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