celluloid / celluloid-io

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

Monitors in Reactor seem to accumulate for IO Objects indefinitely (until actor dies or is terminated) #118

Open monolar opened 9 years ago

monolar commented 9 years ago

It seems that the reactor used in the celluloid-io mailbox only ever creates monitors (and keeps those references in @monitors).

The assignment happens here: https://github.com/celluloid/celluloid-io/blob/master/lib/celluloid/io/reactor.rb#L49

I am however unable to find that those monitors are ever cleaned up again for a given io object.

Specifically i am trying to deal with a new TCPSocket which fails on initialize. This is used for having one actor establishing a connection to some remote host and reconnecting by itself (without letting the actor die!) and reestablishing a new connection.

I tried, naively, to approach this by having some sort of 'unwait' mechanism telling the reactor to stop monitoring an io resource: https://github.com/monolar/celluloid-io/commit/ede7cda79a56af699d3710b3645c5f85ab1dce1f

The cleanup not happeing has the main problem of file-descriptors leaking and the secondary problem of socket objects remaining referenced (by the reactor) leading to them not being GC'd.

tarcieri commented 9 years ago

Looks like this was introduced in a4e953c6 (cc @halorgium)

A hash isn't really the right solution here. We should be able to track the state of all monitors via the reactor itself.

I would suggest reverting a4e953c6 for now. There will still be sporadic brokenness around simultaneous read/write interests, but at least programs won't leak file descriptors.

HoneyryderChuck commented 9 years ago

This has been solved in 0.16.1, or am I mistaken?