diff --git a/src/mongo/db/repl/oplogreader.cpp b/src/mongo/db/repl/oplogreader.cpp index bb3e5c85fe3..950517d6192 100644 --- a/src/mongo/db/repl/oplogreader.cpp +++ b/src/mongo/db/repl/oplogreader.cpp @@ -76,6 +76,8 @@ bool replAuthenticate(DBClientBase* conn) { return authenticateInternalUser(conn); } +const Seconds OplogReader::kSocketTimeout(30); + OplogReader::OplogReader() { _tailingQueryOptions = QueryOption_SlaveOk; _tailingQueryOptions |= QueryOption_CursorTailable | QueryOption_OplogReplay; @@ -89,7 +91,8 @@ OplogReader::OplogReader() { bool OplogReader::connect(const HostAndPort& host) { if (conn() == NULL || _host != host) { resetConnection(); - _conn = shared_ptr(new DBClientConnection(false, tcp_timeout)); + _conn = + shared_ptr(new DBClientConnection(false, kSocketTimeout.count())); string errmsg; if (!_conn->connect(host, errmsg) || (getGlobalAuthorizationManager()->isAuthEnabled() && !replAuthenticate(_conn.get()))) { diff --git a/src/mongo/db/repl/oplogreader.h b/src/mongo/db/repl/oplogreader.h index 718fa162d88..65e101415a0 100644 --- a/src/mongo/db/repl/oplogreader.h +++ b/src/mongo/db/repl/oplogreader.h @@ -35,6 +35,7 @@ #include "mongo/client/constants.h" #include "mongo/client/dbclientcursor.h" #include "mongo/util/net/hostandport.h" +#include "mongo/util/time_support.h" namespace mongo { @@ -91,7 +92,7 @@ public: } /* SO_TIMEOUT (send/recv time out) for our DBClientConnections */ - static const int tcp_timeout = 30; + static const Seconds kSocketTimeout; /* ok to call if already connected */ bool connect(const HostAndPort& host); diff --git a/src/mongo/db/repl/sync_source_feedback.cpp b/src/mongo/db/repl/sync_source_feedback.cpp index c0ead3596d5..75b729c85ad 100644 --- a/src/mongo/db/repl/sync_source_feedback.cpp +++ b/src/mongo/db/repl/sync_source_feedback.cpp @@ -79,7 +79,7 @@ bool SyncSourceFeedback::_connect(OperationContext* txn, const HostAndPort& host return true; } log() << "setting syncSourceFeedback to " << host.toString(); - _connection.reset(new DBClientConnection(false, OplogReader::tcp_timeout)); + _connection.reset(new DBClientConnection(false, OplogReader::kSocketTimeout.count())); string errmsg; try { if (!_connection->connect(host, errmsg) ||