gabipetrovay/node-orientdb — pull request #14 by ryanfields (2012-03-30 04:02:59+00:00)
Title: Refactored error handling / Prevent hang/crash on protocol mismatch

As per the "To be implemented", I moved all of the ERROR status handling up into manager.js and set all of the commands to assume a status of 0 by the time their read() method is called. All tests passed.

I also added a couple of clean-up steps to the protocol mismatch code. The socketPool entry gets deleted and the command sitting in the command queue is used to send an err to command.callback. This fixes both a hang and a crash scenario. The hang was caused by the driver not sending anything back to the calling program on protocol mismatch during the connection handshake. The crash was caused by not invalidating the socket before another connection attempt was made, causing an unhandled "socket is closed" condition. The change makes sure that the calling program gets to see a "Protocol not supported message" and more importantly prevents the caller from being crashed by an exception if it tries to connect again.

The protocol mismatch brought to my attention a separate issue, which I'll open in the main repository (and then see about resolving myself.)