Ben Armstrong created JRUBY-6274:
------------------------------------
Summary: OpenVMS: IOError when TCP client hangs up, filling
webrick log with unhandled exceptions
Key: JRUBY-6274
URL: https://jira.codehaus.org/browse/JRUBY-6274
Project: JRuby
Issue Type: Bug
Components: Standard Library
Affects Versions: JRuby 1.6.5, JRuby 1.6.3, JRuby 1.6
Environment: OpenVMS V8.3-1H1/I64, Java 1.6.0
Reporter: Ben Armstrong
Assignee: Thomas E Enebo
Priority: Minor
Wrong exceptions are thrown when TCP client hangs up, filling WEBrick's log
with spurious error messages, since these "normal" conditions that could have
been caught by WEBrick and dealt with are not being handled. This happens, for
example, if I serve up a large file from a WEBrick server and break the
connection before the file is completely delivered, a perfectly normal thing to
do.
For EPIPE and ECONNRESET errors respectively, I see messages like:
[2011-08-22 10:24:08] ERROR IOError: broken pipe (errno:32)
[2011-11-26 11:41:44] ERROR IOError: connection reset by peer (errno:54)
>From a search of the web, the errors that people more typically report look
>like:
[2011-04-02 01:04:39] ERROR Errno::EPIPE: Broken pipe
[2011-09-10 10:14:25] ERROR Errno::ECONNRESET: Connection reset by peer
In my brief survey of the WEBrick code, in some places these errors are
rescued, but since WEBrick does not (usually) handle IOError, they end up as
stack dumps in the log.
I can reproduce this in several versions of JRuby running on VMS, including the
patched for VMS 1.6.3 kit (includes FFI) from Philippe Vouters and Thierry Uso
at: http://vmsfree.ouvaton.org/freen/index.php?s=jruby and also a pristine,
unmodified 1.6.5 binary kit obtained directly from
http://www.jruby.org/download, and an unmodified 1.6.0 binary kit we have
deployed in production.
What I don't understand at this point is if these are bugs in HP Java (as we
found before with concurrent file access in webrick) or a deficiency in the
JRuby VMS port. What is responsible for mapping the error codes that appear
here as "errno:#" into proper exceptions that could then be handled by WEBrick
and other standard ruby library code?
Here is a minimal failing case, starting the server on VMS:
$ ruby -e "require
'webrick';s=WEBrick::HTTPServer.new(:DocumentRoot=>'/dsa0/bg/',:Port=>8080);['INT','TERM'].each{|_|trap(_){s.shutdown}};s.start"
and from my workstation:
$ wget http://dyma:8080/words2.txt
... ^C before the file is complete ...
where words2.txt is a 27M test file.
This is the output from webrick (on JRuby 1.6.5):
[2011-12-14 11:32:21] INFO WEBrick 1.3.1
[2011-12-14 11:32:21] INFO ruby 1.8.7 (2011-10-25) [java]
[2011-12-14 11:32:21] INFO WEBrick::HTTPServer#start: pid=564898696 port=8080
[2011-12-14 11:32:33] ERROR IOError: broken pipe (errno:32)
org/jruby/RubyIO.java:1323:in `write'
org/jruby/RubyIO.java:1469:in `<<'
/jruby_root/lib/ruby/1.8/webrick/httpresponse.rb:324:in `_write_data'
/jruby_root/lib/ruby/1.8/webrick/httpresponse.rb:317:in `_send_file'
/jruby_root/lib/ruby/1.8/webrick/httpresponse.rb:272:in `send_body_io'
/jruby_root/lib/ruby/1.8/webrick/httpresponse.rb:186:in `send_body'
/jruby_root/lib/ruby/1.8/webrick/httpresponse.rb:104:in `send_response'
/jruby_root/lib/ruby/1.8/webrick/httpserver.rb:79:in `run'
/jruby_root/lib/ruby/1.8/webrick/server.rb:173:in `start_thread'
org/jruby/RubyProc.java:270:in `call'
org/jruby/RubyProc.java:224:in `call'
24.222.19.4 - - [14/Dec/2011:11:32:32 AST] "GET /words2.txt HTTP/1.1" 200 0
- -> /words2.txt
If I keep at it long enough, re-fetching and interrupting the transfer near the
end, I can force an error that I expected to be returned as Errno::ECONNRESET
error like:
[2011-12-14 11:45:16] ERROR IOError: connection reset by peer (errno:54)
org/jruby/RubyIO.java:1851:in `eof?'
/jruby_root/lib/ruby/1.8/webrick/httpserver.rb:55:in `run'
/jruby_root/lib/ruby/1.8/webrick/httpserver.rb:48:in `run'
/jruby_root/lib/ruby/1.8/webrick/server.rb:173:in `start_thread'
/jruby_root/lib/ruby/1.8/webrick/server.rb:163:in `start_thread'
org/jruby/RubyProc.java:270:in `call'
org/jruby/RubyProc.java:224:in `call'
24.222.19.4 - - [14/Dec/2011:11:45:16 AST] "GET /words2.txt HTTP/1.1" 200
27355064
- -> /words2.txt
Having our logs filled with garbage is annoying enough, but we are on the trail
of a more serious (and apparently quite VMS-specific) issue, causing WEBrick to
crash, seen in https://gist.github.com/1416904. This issue may or may not be
contributed to by the fact that webrick is not handling these conditions
properly. That's what I would like to determine. If I can get webrick to handle
EPIPE and ECONNRESET properly and we're still seeing webrick crashes, we have
something different on our hands and I'll file a separate bug.
Once again, I understand few people are familiar with OpenVMS, so I'm reaching
out for help to debug this on my own. I require deeper knowledge of Java and
JRuby to know where to look.
Thanks,
Ben
--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators:
https://jira.codehaus.org/secure/ContactAdministrators!default.jspa
For more information on JIRA, see: http://www.atlassian.com/software/jira
---------------------------------------------------------------------
To unsubscribe from this list, please visit:
http://xircles.codehaus.org/manage_email