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

ruby-changes:31063

From: nagachika <ko1@a...>
Date: Sat, 5 Oct 2013 01:25:53 +0900 (JST)
Subject: [ruby-changes:31063] nagachika:r43142 (ruby_2_0_0): merge revision(s) 40534, 41886, 41903, 41910: [Backport #8616]

nagachika	2013-10-05 01:25:39 +0900 (Sat, 05 Oct 2013)

  New Revision: 43142

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

  Log:
    merge revision(s) 40534,41886,41903,41910: [Backport #8616]
    
    process.c: rb_daemon should not raise
    
    * process.c (rb_daemon): should not raise exceptions, since
      proc_daemon() will deal with errors.
    * process.c (fork_daemon): kill the other threads all and abandon the
      kept mutexes.
    
    * process.c (fork_daemon): kill the other threads all and abandon the
      kept mutexes.
    
    * process.c (rb_daemon): daemon(3) is implemented with fork(2).
      Therefore it needs rb_thread_atfork(). (and revert r41903)

  Modified directories:
    branches/ruby_2_0_0/
  Modified files:
    branches/ruby_2_0_0/ChangeLog
    branches/ruby_2_0_0/process.c
    branches/ruby_2_0_0/test/ruby/test_process.rb
    branches/ruby_2_0_0/version.h
Index: ruby_2_0_0/ChangeLog
===================================================================
--- ruby_2_0_0/ChangeLog	(revision 43141)
+++ ruby_2_0_0/ChangeLog	(revision 43142)
@@ -1,3 +1,18 @@ https://github.com/ruby/ruby/blob/trunk/ruby_2_0_0/ChangeLog#L1
+Sat Oct  5 00:16:33 2013  NARUSE, Yui  <naruse@r...>
+
+	* process.c (rb_daemon): daemon(3) is implemented with fork(2).
+	  Therefore it needs rb_thread_atfork(). (and revert r41903)
+
+Sat Oct  5 00:16:33 2013  Nobuyoshi Nakada  <nobu@r...>
+
+	* process.c (fork_daemon): kill the other threads all and abandon the
+	  kept mutexes.
+
+Sat Oct  5 00:16:33 2013  Nobuyoshi Nakada  <nobu@r...>
+
+	* process.c (fork_daemon): kill the other threads all and abandon the
+	  kept mutexes.
+
 Tue Oct  1 00:28:40 2013  SHIBATA Hiroshi  <shibata.hiroshi@g...>
 
 	* tool/make-snapshot: Fix order of priority for option parameter.
Index: ruby_2_0_0/process.c
===================================================================
--- ruby_2_0_0/process.c	(revision 43141)
+++ ruby_2_0_0/process.c	(revision 43142)
@@ -5667,29 +5667,23 @@ rb_daemon(int nochdir, int noclose) https://github.com/ruby/ruby/blob/trunk/ruby_2_0_0/process.c#L5667
     before_fork();
     err = daemon(nochdir, noclose);
     after_fork();
+    rb_thread_atfork();
 #else
     int n;
 
-    switch (rb_fork_ruby(NULL)) {
-      case -1:
-	rb_sys_fail("daemon");
-      case 0:
-	break;
-      default:
-	_exit(EXIT_SUCCESS);
+#define fork_daemon() \
+    switch (rb_fork_ruby(NULL)) { \
+      case -1: return -1; \
+      case 0:  rb_thread_atfork(); break; \
+      default: _exit(EXIT_SUCCESS); \
     }
 
-    proc_setsid();
+    fork_daemon();
+
+    if (setsid() < 0) return -1;
 
     /* must not be process-leader */
-    switch (rb_fork_ruby(NULL)) {
-      case -1:
-	return -1;
-      case 0:
-	break;
-      default:
-	_exit(EXIT_SUCCESS);
-    }
+    fork_daemon();
 
     if (!nochdir)
 	err = chdir("/");
Index: ruby_2_0_0/version.h
===================================================================
--- ruby_2_0_0/version.h	(revision 43141)
+++ ruby_2_0_0/version.h	(revision 43142)
@@ -1,10 +1,10 @@ https://github.com/ruby/ruby/blob/trunk/ruby_2_0_0/version.h#L1
 #define RUBY_VERSION "2.0.0"
-#define RUBY_RELEASE_DATE "2013-10-01"
-#define RUBY_PATCHLEVEL 323
+#define RUBY_RELEASE_DATE "2013-10-05"
+#define RUBY_PATCHLEVEL 324
 
 #define RUBY_RELEASE_YEAR 2013
 #define RUBY_RELEASE_MONTH 10
-#define RUBY_RELEASE_DAY 1
+#define RUBY_RELEASE_DAY 5
 
 #include "ruby/version.h"
 
Index: ruby_2_0_0/test/ruby/test_process.rb
===================================================================
--- ruby_2_0_0/test/ruby/test_process.rb	(revision 43141)
+++ ruby_2_0_0/test/ruby/test_process.rb	(revision 43142)
@@ -1471,6 +1471,15 @@ class TestProcess < Test::Unit::TestCase https://github.com/ruby/ruby/blob/trunk/ruby_2_0_0/test/ruby/test_process.rb#L1471
       assert_equal("ok?\n", data)
     end
 
+    def test_daemon_pid
+      cpid, dpid = IO.popen("-", "r+") do |f|
+        break f.pid, Integer(f.read) if f
+        Process.daemon(false, true)
+        puts $$
+      end
+      assert_not_equal(cpid, dpid)
+    end
+
     if File.directory?("/proc/self/task") && /netbsd[a-z]*[1-6]/ !~ RUBY_PLATFORM
       def test_daemon_no_threads
         pid, data = IO.popen("-", "r+") do |f|
@@ -1482,6 +1491,18 @@ class TestProcess < Test::Unit::TestCase https://github.com/ruby/ruby/blob/trunk/ruby_2_0_0/test/ruby/test_process.rb#L1491
         assert_equal(2, data.size, bug4920)
         assert_not_include(data.map(&:to_i), pid)
       end
+    else # darwin
+      def test_daemon_no_threads
+        data = Timeout.timeout(3) do
+          IO.popen("-") do |f|
+            break f.readlines.map(&:chomp) if f
+            th = Thread.start {sleep 3}
+            Process.daemon(true, true)
+            puts Thread.list.size, th.status.inspect
+          end
+        end
+        assert_equal(["1", "false"], data)
+      end
     end
   end
 

Property changes on: ruby_2_0_0
___________________________________________________________________
Modified: svn:mergeinfo
   Merged /trunk:r40534,41886,41903,41910


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

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