wearefractal/protosock — pull request #4 by bitmage (2013-02-22 21:33:03+00:00)
Title: Fixed Issues with Disconnect

The disconnect code in protosock was immediately calling reconnect, which caused some strange bugs in the pulsar tests. It would leave the socket in a weird state, then 4 or 5 tests later I'd get a 'socket error' with no explanation. I narrowed down the source of the problem by commenting out code until I found the offending line.

Based on the context of the other places disconnect is being called, within protosock and pulsar, it looks like the intent is to disconnect permanently most of the time. There was just one test in protosock that expected a reconnect to happen.

I modified the disconnect() code to check to see if the connection is open first (otherwise an error will occur) and I refactored the other places where the code calls disconnect to call this common method. I also provided an argument for a temporary disconnect, so in the case of that protosock test that expects a reconnect to happen, you can still attain that functionality.