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

ruby-changes:23264

From: naruse <ko1@a...>
Date: Fri, 13 Apr 2012 15:21:59 +0900 (JST)
Subject: [ruby-changes:23264] naruse:r35315 (trunk): * lib/webrick/server.rb (WEBrick::GenericServer#stop): fix r35303;

naruse	2012-04-13 15:21:50 +0900 (Fri, 13 Apr 2012)

  New Revision: 35315

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

  Log:
    * lib/webrick/server.rb (WEBrick::GenericServer#stop): fix r35303;
      this method is to deny new connections, not shutdown yet.
    
    * lib/webrick/server.rb (WEBrick::GenericServer#start):
      re-raise exception only when the exception is Interrupt (^C).

  Modified files:
    trunk/ChangeLog
    trunk/lib/webrick/server.rb
    trunk/test/webrick/test_server.rb

Index: ChangeLog
===================================================================
--- ChangeLog	(revision 35314)
+++ ChangeLog	(revision 35315)
@@ -1,3 +1,11 @@
+Fri Apr 13 15:17:36 2012  NARUSE, Yui  <naruse@r...>
+
+	* lib/webrick/server.rb (WEBrick::GenericServer#stop): fix r35303;
+	  this method is to deny new connections, not shutdown yet.
+
+	* lib/webrick/server.rb (WEBrick::GenericServer#start):
+	  re-raise exception only when the exception is Interrupt (^C).
+
 Thu Apr 12 19:51:45 2012  Tadayoshi Funaba  <tadf@d...>
 
 	* ext/date/date_core.c: added some notes.
@@ -7,11 +15,11 @@
 	* compile.c (compile_array, compile_array_):
 	  Divide big array (or hash) literals into several blocks and
 	  concatetene them.  There was a problem that a big array (hash)
-          literal causes SystemStackError exception (stack overflow)
-          because VM push all contents of the literal onto VM stack to
-          make an array (or hash).  To solve this issue, we make several
-          arrays (hashes) and concatenate them to make a big array (hash)
-          object.  [ruby-dev:37701] [Bug #982]
+	  literal causes SystemStackError exception (stack overflow)
+	  because VM push all contents of the literal onto VM stack to
+	  make an array (or hash).  To solve this issue, we make several
+	  arrays (hashes) and concatenate them to make a big array (hash)
+	  object.  [ruby-dev:37701] [Bug #982]
 
 	* compile.c (iseq_compile_each, setup_args): use modified
 	  compile_array.
Index: lib/webrick/server.rb
===================================================================
--- lib/webrick/server.rb	(revision 35314)
+++ lib/webrick/server.rb	(revision 35315)
@@ -133,16 +133,17 @@
             rescue Errno::EBADF, IOError => ex
               # if the listening socket was closed in GenericServer#shutdown,
               # IO::select raise it.
-            rescue StandardError => ex
+            rescue Interrupt => ex # ^C
+              @logger.fatal ex
+              raise
+            rescue Exception => ex
               msg = "#{ex.class}: #{ex.message}\n\t#{ex.backtrace[0]}"
               @logger.error msg
-            rescue Exception => ex
-              @logger.fatal ex
-              raise
             end
           end
 
         ensure
+          @status = :Shutdown
           @logger.info "going to shutdown ..."
           thgroup.list.each{|th| th.join if th[:WEBrickThread] }
           call_callback(:StopCallback)
@@ -157,7 +158,7 @@
 
     def stop
       if @status == :Running
-        @status = :Stop
+        @status = :Shutdown
       end
     end
 
Index: test/webrick/test_server.rb
===================================================================
--- test/webrick/test_server.rb	(revision 35314)
+++ test/webrick/test_server.rb	(revision 35315)
@@ -29,23 +29,22 @@
       :StopCallback => Proc.new{ stopped += 1 },
     }
 
-    e = assert_raises(Exception) do
+    e = assert_raises(Interrupt) do
       TestWEBrick.start_server(Echo, config) { |server, addr, port, log|
         listener = server.listeners.first
 
         def listener.accept
-          raise Exception, 'fatal' # simulate ^C
+          Process.kill(:INT, $$) # simulate ^C
         end
 
-        true while server.status != :Running
+        Thread.pass while server.status != :Running
 
         TCPSocket.open(addr, port) { |sock| sock << "foo\n" }
 
-        sleep 0.1 until server.status == :Stop
+        Thread.pass until server.status == :Stop
       }
     end
 
-    assert_equal('fatal', e.message)
     assert_equal(stopped, 1)
   end
 

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

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