Fix OpenSSL error message

Reviewers: teon.banek

Reviewed By: teon.banek

Subscribers: pullbot

Differential Revision: https://phabricator.memgraph.io/D1684
This commit is contained in:
Matej Ferencevic 2018-10-19 14:38:45 +02:00
parent 7f2ad99ce7
commit c0879530cd

View File

@ -173,6 +173,20 @@ class Session final {
// again. // again.
socket_.WaitForReadyWrite(); socket_.WaitForReadyWrite();
return false; return false;
} else if (err == SSL_ERROR_SYSCALL) {
// OpenSSL returns this error when you open a connection to the server
// but you don't send any data. We do this often when we check whether
// the server is alive by trying to open a connection to it using
// `nc -z -w 1 127.0.0.1 7687`.
// When this error occurs we need to check the `errno` to find out
// what really happened.
// See: https://www.openssl.org/docs/man1.1.0/ssl/SSL_get_error.html
if (errno == 0) {
// The client closed the connection.
throw SessionClosedException("Session was closed by the client.");
}
// If `errno` isn't 0 then something bad happened.
throw utils::BasicException(SslGetLastError());
} else { } else {
// This is a fatal error. // This is a fatal error.
throw utils::BasicException(SslGetLastError()); throw utils::BasicException(SslGetLastError());