diff options
author | Spencer T Brody <spencer@mongodb.com> | 2015-08-17 16:52:01 -0400 |
---|---|---|
committer | Spencer T Brody <spencer@mongodb.com> | 2015-08-18 19:27:49 -0400 |
commit | 594d851e53c85b2711db41034f9d42e1a0a5c25d (patch) | |
tree | 0406d4c8ea17ce60dfc63a0507c04bfc379ec5f7 /src/mongo/client/dbclient.cpp | |
parent | 4c00f062fd6f29b6f5547ffbc0117c684fddafac (diff) | |
download | mongo-594d851e53c85b2711db41034f9d42e1a0a5c25d.tar.gz |
SERVER-19543 Add connection hook for checking config server mode to connections used by SyncClusterConnection
Diffstat (limited to 'src/mongo/client/dbclient.cpp')
-rw-r--r-- | src/mongo/client/dbclient.cpp | 20 |
1 files changed, 13 insertions, 7 deletions
diff --git a/src/mongo/client/dbclient.cpp b/src/mongo/client/dbclient.cpp index 53131c188a1..77c55d3cf4c 100644 --- a/src/mongo/client/dbclient.cpp +++ b/src/mongo/client/dbclient.cpp @@ -892,8 +892,7 @@ bool DBClientConnection::connect(const HostAndPort& server, std::string& errmsg) return true; } -Status DBClientConnection::connect(const HostAndPort& serverAddress, - const HandshakeValidationHook& hook) { +Status DBClientConnection::connect(const HostAndPort& serverAddress) { auto connectStatus = connectSocketOnly(serverAddress); if (!connectStatus.isOK()) { return connectStatus; @@ -912,8 +911,8 @@ Status DBClientConnection::connect(const HostAndPort& serverAddress, _setServerRPCProtocols(swProtocolSet.getValue()); - if (hook) { - auto validationStatus = hook(swIsMasterReply.getValue()); + if (_hook) { + auto validationStatus = _hook(swIsMasterReply.getValue()); if (!validationStatus.isOK()) { // Disconnect and mark failed. _failed = true; @@ -1010,7 +1009,11 @@ void DBClientConnection::_checkConnection() { if (!connectStatus.isOK()) { _failed = true; LOG(_logLevel) << "reconnect " << toString() << " failed " << errmsg << endl; - throw SocketException(SocketException::CONNECT_ERROR, connectStatus.reason()); + if (connectStatus == ErrorCodes::IncompatibleCatalogManager) { + uassertStatusOK(connectStatus); // Will always throw + } else { + throw SocketException(SocketException::CONNECT_ERROR, connectStatus.reason()); + } } LOG(_logLevel) << "reconnect " << toString() << " ok" << endl; @@ -1438,11 +1441,14 @@ void assembleQueryRequest(const string& ns, toSend.setData(dbQuery, b.buf(), b.len()); } -DBClientConnection::DBClientConnection(bool _autoReconnect, double so_timeout) +DBClientConnection::DBClientConnection(bool _autoReconnect, + double so_timeout, + const HandshakeValidationHook& hook) : _failed(false), autoReconnect(_autoReconnect), autoReconnectBackoff(1000, 2000), - _so_timeout(so_timeout) { + _so_timeout(so_timeout), + _hook(hook) { _numConnections.fetchAndAdd(1); } |