Carlos Carrasco
2009-Feb-08 12:24 UTC
[Rev-talk] [PATCH] Optionally pass descriptors to Rev::IOWatcher.initialize
After experimenting a bit with ruby-pg, Rev and the world''s fastest pure Ruby 1-line web server (request_buffer =~ /\x0d\x0a\x0d\x0a/) I started to get EBADF errors under light load testing (ab -c 2 and higher, or even -c 1 for 5+ seconds). I tracked down the source of the errors to this: SQLRequester.new(IO.for_fd(pg_connection.socket), ''r'') where SQLRequester is my subclass of Rev::IOWatcher. The problem appears to be Ruby''s IO.for_fd() doing something that eventually makes the socket go bad and/or making the postgresql client library to freak out. Since PGconn.socket is already a plain Fixnum of the descriptor, and ev_io_init takes an int with the descriptor, I''ve modified Rev::IOWatcher.initialize to optionally accept a Fixnum in place of the IO object and pass it directly to ev_io_init. Doing this has stoped the EBADF errors. Thanks for Rev! -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://rubyforge.org/pipermail/rev-talk/attachments/20090208/3cc4605f/attachment.html> -------------- next part -------------- A non-text attachment was scrubbed... Name: add_initialize_desc_param.diff Type: application/octet-stream Size: 1376 bytes Desc: not available URL: <http://rubyforge.org/pipermail/rev-talk/attachments/20090208/3cc4605f/attachment.obj>