Skip to content

Commit 8e17144

Browse files
author
gotoyuzo
committed
* 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. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@5098 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
1 parent dc9603b commit 8e17144

File tree

3 files changed

+23
-6
lines changed

3 files changed

+23
-6
lines changed

ChangeLog

+11
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,14 @@
1+
Thu Dec 4 08:29:43 2003 GOTOU Yuuzou <gotoyuzo@notwork.org>
2+
3+
* lib/webrick/server.rb (GenericServer#start): should rescue
4+
Exception to avoid unexpected aborting. [ruby-core:01853]
5+
6+
* lib/webrick/server.rb (GenericServer#start_thread): should check
7+
that peeraddr isn't nil before printing.
8+
9+
* lib/webrick/httpresponse.rb (HTTPResponse#start_thread): should
10+
rescue Exception to avoid unexpected aborting of thread.
11+
112
Thu Dec 4 03:48:59 2003 Tanaka Akira <akr@m17n.org>
213

314
* lib/pathname.rb (Pathname#link, Pathname#symlink): obsoleted.

lib/webrick/httpresponse.rb

+3-3
Original file line numberDiff line numberDiff line change
@@ -84,10 +84,10 @@ def send_response(socket)
8484
setup_header()
8585
send_header(socket)
8686
send_body(socket)
87-
rescue Errno::EPIPE
88-
@logger.error("HTTPResponse#send_response: EPIPE occured.")
87+
rescue Errno::EPIPE, Errno::ECONNRESET, Errno::ENOTCONN => ex
88+
@logger.debug(ex)
8989
@keep_alive = false
90-
rescue => ex
90+
rescue Exception => ex
9191
@logger.error(ex)
9292
@keep_alive = false
9393
end

lib/webrick/server.rb

+9-3
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,7 @@ def start(&block)
102102
rescue Errno::EBADF, IOError => ex
103103
# if the listening socket was closed in GenericServer#shutdown,
104104
# IO::select raise it.
105-
rescue => ex
105+
rescue Exception => ex
106106
msg = "#{ex.class}: #{ex.message}\n\t#{ex.backtrace[0]}"
107107
@logger.error msg
108108
end
@@ -148,14 +148,20 @@ def start_thread(sock, &block)
148148
@logger.debug "accept: #{addr[3]}:#{addr[1]}"
149149
call_callback(:AcceptCallback, sock)
150150
block ? block.call(sock) : run(sock)
151-
rescue ServerError, Errno::ENOTCONN => ex
151+
rescue Errno::ENOTCONN
152+
@logger.debug "Errno::ENOTCONN raised"
153+
rescue ServerError => ex
152154
msg = "#{ex.class}: #{ex.message}\n\t#{ex.backtrace[0]}"
153155
@logger.error msg
154156
rescue Exception => ex
155157
@logger.error ex
156158
ensure
157159
Thread.current[:WEBrickSocket] = nil
158-
@logger.debug "close: #{addr[3]}:#{addr[1]}"
160+
if addr
161+
@logger.debug "close: #{addr[3]}:#{addr[1]}"
162+
else
163+
@logger.debug "close: <address unknown>"
164+
end
159165
sock.close
160166
end
161167
@tokens.push(nil)

0 commit comments

Comments
 (0)