celluloid / celluloid-io

UNMAINTAINED: See celluloid/celluloid#779 - Evented sockets for Celluloid actors
https://celluloid.io
MIT License
879 stars 93 forks source link

IOError: closed stream #44

Closed romansergey closed 11 years ago

romansergey commented 11 years ago

Coming from here: https://github.com/tarcieri/nio4r/issues/18 Reproduction: https://gist.github.com/romansergey/5103388

I've tried with the git versions of celluloid-io, celluloid and reel and it also crashes:

E, [2013-03-07T08:40:10.454000 #20567] ERROR -- : MyServer crashed!
IOError: closed stream
    org/nio4r/Nio4r.java:143:in `register'
    /home/rs/.rvm/gems/jruby-1.7.2/bundler/gems/celluloid-io-ebc8464622e6/lib/celluloid/io/reactor.rb:42:in `wait'
    /home/rs/.rvm/gems/jruby-1.7.2/bundler/gems/celluloid-io-ebc8464622e6/lib/celluloid/io/reactor.rb:21:in `wait_readable'
    org/jruby/RubyBasicObject.java:1665:in `__send__'
    org/jruby/RubyKernel.java:1809:in `public_send'
    /home/rs/.rvm/gems/jruby-1.7.2/bundler/gems/celluloid-adbbbd850998/lib/celluloid/calls.rb:11:in `dispatch'
    /home/rs/.rvm/gems/jruby-1.7.2/bundler/gems/celluloid-adbbbd850998/lib/celluloid/calls.rb:53:in `dispatch'
    /home/rs/.rvm/gems/jruby-1.7.2/bundler/gems/celluloid-adbbbd850998/lib/celluloid/actor.rb:328:in `handle_message'
    /home/rs/.rvm/gems/jruby-1.7.2/bundler/gems/celluloid-adbbbd850998/lib/celluloid/tasks/task_fiber.rb:28:in `initialize'
D, [2013-03-07T08:40:10.504000 #20567] DEBUG -- : Terminating 19 actors...
D, [2013-03-07T08:40:10.577000 #20567] DEBUG -- : Shutdown completed cleanly
tarcieri commented 11 years ago

Okay... let me take a look

romansergey commented 11 years ago

With the latest checkout I get: RuntimeError: Cannot use blocks with async yet

I guess this issue now turns into a feature request?

tarcieri commented 11 years ago

Well, that probably explains part of the source of your problems. We just changed the block semantics so that blocks are called on senders instead of receivers. This probably isn't what you want exactly (there's an option to override it, but it'd be pretty self-defeating in this case)

My suggestion would be to make "fire" actually do what you want, instead of just a placeholder that takes a block.

That said the CancelledKeyException is probably still an issue.

halorgium commented 11 years ago

@romansergey the change in block behaviour was designed to stop developers leaking state via blocks. You can remove the async call and allow Celluloid to proxy the block execution. If you think about it, you do not want the TestActor actor to call methods on the request, but instead want it to call the block and have the MyServer actor execute the block.

My updated gist is https://gist.github.com/halorgium/5404407