igrigorik/em-synchrony — pull request #115 by jkchow (2012-03-11 23:23:46+00:00)
Title: EM::Synchrony::TCPSocket#closed? doesn't properly return false if connection is closed

I'm trying to debug a Dalli issue where the library doesn't properly reconnect to the memcached server if the connection is closed remotely. Since Dalli's socket class (Dalli::Server::AsyncSocket) inherits from EM::Synchrony::TCPSocket, I figured I could do a Dalli pull request call the #closed? method to properly detect whether the connection is closed or not. However, this doesn't work because on the #unbind hook, it doesn't unset the instance variables @in_req and @out_req, which is checked in #closed?.

While I'm not sure how you guys would do this exactly, I've gone ahead and changed the method to call the #closed method, since it'll unset the proper instance variables. I think it's OK to do this, since calling #close_connection after the fact shouldn't do anything.