ChicoTeam / chingu

OpenGL accelerated 2D game framework for Ruby
http://ippa.se/chingu
GNU Lesser General Public License v2.1
1 stars 0 forks source link

example28_networking uninitialized constant IO::WaitReadable + possible fix #4

Open flipcoder opened 13 years ago

flipcoder commented 13 years ago

I get an error when I try to run example28_networking (error occurs in chingu/lib/chingu/game_states/network_server.rb line 208). I'm not too familiar with ruby yet but it looks like an exception had an invalid type or something.

By changing line 208 to:

rescue Errno::EAGAIN, Errno::EINTR

It works. Should I commit this or am I missing something?

The full error is here:

$ ruby example28_networking.rb 
/home/flipcoder/Projects/School/ChicoTeam/chingu/lib/chingu/game_states/network_server.rb:208:in `handle_incoming_connections': uninitialized constant IO::WaitReadable (NameError)
    from /home/flipcoder/Projects/School/ChicoTeam/chingu/lib/chingu/game_states/network_server.rb:176:in `update'
    from example28_networking.rb:32:in `update'
    from example28_networking.rb:80
flipcoder commented 13 years ago

Decided to commit the change. We can always go back if necessary.

cqcallaw commented 13 years ago

The relevant bit from the stack trace seems to be "uninitialized constant IO::WaitReadable".

IO::WaitReadable is documented here: http://www.ruby-doc.org/core-1.9/classes/IO/WaitReadable.html. Certainly doesn't seem like an exception type.

However, searching for "rescue IO::WaitReadable" yields results such as http://stackoverflow.com/questions/7127603/why-is-iowaitreadable-being-raised-differently-for-stdout-than-stderr-ruby-1 and http://ruby-doc.org/stdlib/libdoc/socket/rdoc/classes/TCPServer.html, so it seems like a valid construct. The second hit, http://lists.macosforge.org/pipermail/macruby-devel/2010-May/005127.html, is also interesting because it seems like a very similar bug report.

I'd also hesitate to say Errno::EAGAIN is the correct fix until you've figured out what exceptions could possibly be raised by the begin block...

References for Ruby exception handling (based on a quick search, not extensive study): http://ruby-doc.org/docs/ProgrammingRuby/html/tut_exceptions.html http://www.ruby-doc.org/docs/ProgrammingRuby/html/ref_m_errno.html

flipcoder commented 13 years ago

Thanks for the info. I wasn't clear in my post about the reason I added Errno::EAGAIN. That was another unhandled exception I received after removing the IO::WaitReadable. I agree with your suggestion and am still unsure about this being the final solution, but wanted to commit these changes so we could see if it was a problem with something on my machine or not. I'll reopen the issue.