Skip to content

Instantly share code, notes, and snippets.

@scotthernandez
Last active February 29, 2016 22:37
Show Gist options
  • Save scotthernandez/fe0c0f37ff4a65ab9604 to your computer and use it in GitHub Desktop.
Save scotthernandez/fe0c0f37ff4a65ab9604 to your computer and use it in GitHub Desktop.
diff --git a/src/mongo/client/dbclientinterface.h b/src/mongo/client/dbclientinterface.h
index a4e23c3..3e97358 100644
--- a/src/mongo/client/dbclientinterface.h
+++ b/src/mongo/client/dbclientinterface.h
@@ -1249,8 +1249,14 @@ protected:
// throws SocketException if in failed state and not reconnecting or if waiting to reconnect
void checkConnection() {
- if (_failed)
+ if (_failed) {
_checkConnection();
+ }
+
+ if (autoReconnect && !isStillConnected()) {
+ _failed = true;
+ _checkConnection();
+ }
}
std::map<std::string, BSONObj> authCache;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment