Skip to content

Commit

Permalink
* lib/webrick/server.rb (GenericServer#start): should rescue
Browse files Browse the repository at this point in the history
  Exception to avoid unexpected aborting. [ruby-core:01853]

* lib/webrick/server.rb (GenericServer#start_thread): should check
  that peeraddr isn't nil before printing.

* lib/webrick/httpresponse.rb (HTTPResponse#start_thread): should
  rescue Exception to avoid unexpected aborting of thread.


git-svn-id: http://svn.ruby-lang.org/repos/ruby/trunk@5098 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
  • Loading branch information
gotoyuzo committed Dec 4, 2003
1 parent 6facf92 commit c6ab282
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 6 deletions.
11 changes: 11 additions & 0 deletions ChangeLog
@@ -1,3 +1,14 @@
Thu Dec 4 08:29:43 2003 GOTOU Yuuzou <gotoyuzo@notwork.org>

* lib/webrick/server.rb (GenericServer#start): should rescue
Exception to avoid unexpected aborting. [ruby-core:01853]

* lib/webrick/server.rb (GenericServer#start_thread): should check
that peeraddr isn't nil before printing.

* lib/webrick/httpresponse.rb (HTTPResponse#start_thread): should
rescue Exception to avoid unexpected aborting of thread.

Thu Dec 4 03:48:59 2003 Tanaka Akira <akr@m17n.org>

* lib/pathname.rb (Pathname#link, Pathname#symlink): obsoleted.
Expand Down
6 changes: 3 additions & 3 deletions lib/webrick/httpresponse.rb
Expand Up @@ -84,10 +84,10 @@ def send_response(socket)
setup_header()
send_header(socket)
send_body(socket)
rescue Errno::EPIPE
@logger.error("HTTPResponse#send_response: EPIPE occured.")
rescue Errno::EPIPE, Errno::ECONNRESET, Errno::ENOTCONN => ex
@logger.debug(ex)
@keep_alive = false
rescue => ex
rescue Exception => ex
@logger.error(ex)
@keep_alive = false
end
Expand Down
12 changes: 9 additions & 3 deletions lib/webrick/server.rb
Expand Up @@ -102,7 +102,7 @@ def start(&block)
rescue Errno::EBADF, IOError => ex
# if the listening socket was closed in GenericServer#shutdown,
# IO::select raise it.
rescue => ex
rescue Exception => ex
msg = "#{ex.class}: #{ex.message}\n\t#{ex.backtrace[0]}"
@logger.error msg
end
Expand Down Expand Up @@ -148,14 +148,20 @@ def start_thread(sock, &block)
@logger.debug "accept: #{addr[3]}:#{addr[1]}"
call_callback(:AcceptCallback, sock)
block ? block.call(sock) : run(sock)
rescue ServerError, Errno::ENOTCONN => ex
rescue Errno::ENOTCONN
@logger.debug "Errno::ENOTCONN raised"
rescue ServerError => ex
msg = "#{ex.class}: #{ex.message}\n\t#{ex.backtrace[0]}"
@logger.error msg
rescue Exception => ex
@logger.error ex
ensure
Thread.current[:WEBrickSocket] = nil
@logger.debug "close: #{addr[3]}:#{addr[1]}"
if addr
@logger.debug "close: #{addr[3]}:#{addr[1]}"
else
@logger.debug "close: <address unknown>"
end
sock.close
end
@tokens.push(nil)
Expand Down

0 comments on commit c6ab282

Please sign in to comment.