joyent/node — pull request #4262 by fat-crocodile (2012-11-09 20:57:14+00:00)
Title: fix bug in node_crypto.cc

Fixed problem:

1) OpenSSL contains errors in thread-specific errors stacks. Becouse of asynchronous nature of nodejs, all nodejs connections share the same errors stack. So, if you didn't process error (and clean stack) in one connection, you will surprisingly get it in another one.

2) Function SSL_get_error can not work correctly if before apropriate SSL/TLS call errors stack was not empty (see http://openssl.org/docs/ssl/SSL_get_error.html )

3) Your version of HandleSSLError always interpret zero as a non-error code. For SSL_accept, SSL_connect and SS_write it is not true (see http://openssl.org/docs/ssl/SSL_connect.html ). Apropriate errors were never processed and another connection got them.

4) And see comment about SSL_shutdown in my code.