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

ruby-changes:36273

From: akr <ko1@a...>
Date: Mon, 10 Nov 2014 12:20:14 +0900 (JST)
Subject: [ruby-changes:36273] akr:r48354 (trunk): * lib/webrick/server.rb (shutdown): Use close() on @shutdown_pipe_w to

akr	2014-11-10 12:20:06 +0900 (Mon, 10 Nov 2014)

  New Revision: 48354

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

  Log:
    * lib/webrick/server.rb (shutdown): Use close() on @shutdown_pipe_w to
      notify readability on the read side of the pipe.
      write_nonblock() is not usable for pipe on Windows.
      (cleanup_shutdown_pipe): Rescue IOError for @shutdown_pipe_w.close.

  Modified files:
    trunk/ChangeLog
    trunk/lib/webrick/server.rb
Index: ChangeLog
===================================================================
--- ChangeLog	(revision 48353)
+++ ChangeLog	(revision 48354)
@@ -1,3 +1,10 @@ https://github.com/ruby/ruby/blob/trunk/ChangeLog#L1
+Mon Nov 10 12:19:43 2014  Tanaka Akira  <akr@f...>
+
+	* lib/webrick/server.rb (shutdown): Use close() on @shutdown_pipe_w to
+	  notify readability on the read side of the pipe.
+	  write_nonblock() is not usable for pipe on Windows.
+	  (cleanup_shutdown_pipe): Rescue IOError for @shutdown_pipe_w.close.
+
 Mon Nov 10 07:31:59 2014  Tanaka Akira  <akr@f...>
 
 	* lib/webrick/server.rb (initialize): Initialize shutdown pipe here
Index: lib/webrick/server.rb
===================================================================
--- lib/webrick/server.rb	(revision 48353)
+++ lib/webrick/server.rb	(revision 48354)
@@ -226,10 +226,9 @@ module WEBrick https://github.com/ruby/ruby/blob/trunk/lib/webrick/server.rb#L226
       stop
 
       shutdown_pipe_w = @shutdown_pipe_w # another thread may modify @shutdown_pipe_w.
-      if shutdown_pipe_w
+      if shutdown_pipe_w && !shutdown_pipe_w.closed?
         begin
-          shutdown_pipe_w.write_nonblock "a"
-        rescue IO::WaitWritable
+          shutdown_pipe_w.close
         rescue IOError # closed by another thread.
         end
       end
@@ -320,7 +319,10 @@ module WEBrick https://github.com/ruby/ruby/blob/trunk/lib/webrick/server.rb#L319
 
     def cleanup_shutdown_pipe
       @shutdown_pipe_r.close
-      @shutdown_pipe_w.close
+      begin
+        @shutdown_pipe_w.close
+      rescue IOError # another thread closed @shutdown_pipe_w.
+      end
       @shutdown_pipe_r = @shutdown_pipe_w = nil
     end
 

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

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