celluloid / celluloid-io

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

Celluloid::IO does not respect terminate when reading from a buffer that is always full #90

Open Burgestrand opened 10 years ago

Burgestrand commented 10 years ago

/cc @jnicklas

Here’s a gist of a reproduction case: https://gist.github.com/Burgestrand/7421e529fd92a4889afd

Some caveats about the code in the gist. I tried it on:

For celluloid / celluloid io versions:

With the following results:

Version of celluloid does not change the results, except 0.15.x will whine more in the log about terminated tasks.

digitalextremist commented 9 years ago

Is this still an issue @Burgestrand?

Burgestrand commented 9 years ago

I would assume so, but I will not be at a computer for another 24 hours to test the reproduction case against the newest release of celluloid.

The origin of the bug is based on that the non-blocking read in Celluloid::IO will never yield to the event loop because there is always data to be read from the socket, and because of this it will never receive the mailbox termination message, or any other message for that part. sleep(0) is a relatively sane workaround to yield to the event loop before reading from the socket, but I'm not sure I think it should be necessary.

digitalextremist commented 9 years ago

I ran your reproduction and I see your issue. This is still affecting jruby-1.7.19

digitalextremist commented 9 years ago

@Burgestrand thank you for getting back to me on this, and for the beautiful repro... long ago.