1
0
Fork 0

explicitly set closed flag

This commit is contained in:
Jan Steemann 2015-12-15 11:58:32 +01:00
parent 053db592d1
commit 2b83e134f9
4 changed files with 15 additions and 7 deletions

View File

@ -135,15 +135,20 @@ bool ClientConnection::connectSocket () {
if (_endpoint->isConnected()) {
_endpoint->disconnect();
_isConnected = false;
}
_socket = _endpoint->connect(_connectTimeout, _requestTimeout);
if (! TRI_isvalidsocket(_socket)) {
_errorDetails = _endpoint->_errorMessage;
_isConnected = false;
return false;
}
_isConnected = true;
// note: checkSocket will disconnect the socket if the check fails
if (checkSocket()) {
return _endpoint->isConnected();
}

View File

@ -297,10 +297,6 @@ ConnectionManager::SingleServerConnection* ConnectionManager::leaseConnection (s
// finally create the SingleServerConnection
std::unique_ptr<SingleServerConnection> c(new SingleServerConnection(s, cn.get(), ep.get(), endpoint));
if (c == nullptr) {
return nullptr;
}
// Now put it into our administration:
s->addConnection(c.get());

View File

@ -103,7 +103,7 @@ bool GeneralClientConnection::connect () {
return false;
}
_isConnected = connectSocket();
connectSocket();
if (! _isConnected) {
return false;

View File

@ -163,31 +163,37 @@ bool SslClientConnection::connectSocket () {
if (_endpoint->isConnected()) {
disconnectSocket();
_isConnected = false;
}
_socket = _endpoint->connect(_connectTimeout, _requestTimeout);
if (! TRI_isvalidsocket(_socket) || _ctx == nullptr) {
_errorDetails = _endpoint->_errorMessage;
_isConnected = false;
return false;
}
_isConnected = true;
_ssl = SSL_new(_ctx);
if (_ssl == nullptr) {
_errorDetails = std::string("failed to create ssl context");
disconnectSocket();
_isConnected = false;
return false;
}
if (SSL_set_fd(_ssl, (int) TRI_get_fd_or_handle_of_socket(_socket)) != 1) {
_errorDetails = std::string("SSL: failed to create context ") +
ERR_error_string(ERR_get_error(), NULL);
ERR_error_string(ERR_get_error(), nullptr);
disconnectSocket();
_isConnected = false;
return false;
}
SSL_set_verify(_ssl, SSL_VERIFY_NONE, NULL);
SSL_set_verify(_ssl, SSL_VERIFY_NONE, nullptr);
ERR_clear_error();
@ -242,6 +248,7 @@ bool SslClientConnection::connectSocket () {
}
}
disconnectSocket();
_isConnected = false;
return false;
}