Skip to content

Commit

Permalink
SERVER-17330 moved ScopedConn::keepOpen to ReplicationExecutor::Netwo…
Browse files Browse the repository at this point in the history
…rkInterface
  • Loading branch information
benety committed Feb 27, 2015
1 parent a9f2400 commit 6efb8f8
Show file tree
Hide file tree
Showing 7 changed files with 19 additions and 12 deletions.
4 changes: 2 additions & 2 deletions src/mongo/db/repl/network_interface_impl.cpp
Expand Up @@ -38,11 +38,11 @@
#include <sstream>

#include "mongo/client/connpool.h"
#include "mongo/db/auth/authorization_manager_global.h"
#include "mongo/db/auth/internal_user_auth.h"
#include "mongo/db/client.h"
#include "mongo/db/concurrency/d_concurrency.h"
#include "mongo/db/operation_context_impl.h"
#include "mongo/db/repl/scoped_conn.h"
#include "mongo/platform/unordered_map.h"
#include "mongo/stdx/functional.h"
#include "mongo/stdx/list.h"
Expand Down Expand Up @@ -319,7 +319,7 @@ namespace {
str::stream() << "Failed attempt to connect to " << target.toString() << "; " <<
errmsg,
conn->connect(target, errmsg));
conn->port().tag |= ScopedConn::keepOpen;
conn->port().tag |= ReplicationExecutor::NetworkInterface::kMessagingPortKeepOpen;
if (getGlobalAuthorizationManager()->isAuthEnabled()) {
uassert(ErrorCodes::AuthenticationFailed,
"Missing credentials for authenticating as internal user",
Expand Down
Expand Up @@ -49,8 +49,8 @@
#include "mongo/db/repl/isself.h"
#include "mongo/db/repl/master_slave.h"
#include "mongo/db/repl/oplog.h"
#include "mongo/db/repl/replication_executor.h"
#include "mongo/db/repl/rs_sync.h"
#include "mongo/db/repl/scoped_conn.h"
#include "mongo/db/storage/storage_engine.h"
#include "mongo/s/d_state.h"
#include "mongo/stdx/functional.h"
Expand Down Expand Up @@ -224,7 +224,8 @@ namespace {
}

void ReplicationCoordinatorExternalStateImpl::closeConnections() {
MessagingPort::closeAllSockets(ScopedConn::keepOpen);
MessagingPort::closeAllSockets(
ReplicationExecutor::NetworkInterface::kMessagingPortKeepOpen);
}

void ReplicationCoordinatorExternalStateImpl::killAllUserOperations(OperationContext* txn) {
Expand Down
6 changes: 6 additions & 0 deletions src/mongo/db/repl/replication_executor.cpp
Expand Up @@ -535,6 +535,12 @@ namespace {
isSignaledCondition(new boost::condition_variable) {
}

// This is a bitmask with the first bit set. It's used to mark connections that should be kept
// open during stepdowns.
#ifndef _MSC_EXTENSIONS
const unsigned int ReplicationExecutor::NetworkInterface::kMessagingPortKeepOpen;
#endif // _MSC_EXTENSIONS

ReplicationExecutor::NetworkInterface::NetworkInterface() {}
ReplicationExecutor::NetworkInterface::~NetworkInterface() {}

Expand Down
4 changes: 4 additions & 0 deletions src/mongo/db/repl/replication_executor.h
Expand Up @@ -494,6 +494,10 @@ namespace repl {
class ReplicationExecutor::NetworkInterface {
MONGO_DISALLOW_COPYING(NetworkInterface);
public:

// A flag to keep replication MessagingPorts open when all other sockets are disconnected.
static const unsigned int kMessagingPortKeepOpen = 1;

typedef RemoteCommandResponse Response;
typedef stdx::function<void (const ResponseStatus&)> RemoteCommandCompletionFn;

Expand Down
4 changes: 2 additions & 2 deletions src/mongo/db/repl/replset_commands.cpp
Expand Up @@ -47,7 +47,7 @@
#include "mongo/db/repl/repl_set_seed_list.h"
#include "mongo/db/repl/replication_coordinator_global.h"
#include "mongo/db/repl/replication_coordinator_external_state_impl.h"
#include "mongo/db/repl/scoped_conn.h"
#include "mongo/db/repl/replication_executor.h"
#include "mongo/db/repl/update_position_args.h"
#include "mongo/db/storage/storage_engine.h"
#include "mongo/util/fail_point_service.h"
Expand Down Expand Up @@ -600,7 +600,7 @@ namespace {
{
AbstractMessagingPort *mp = txn->getClient()->port();
if( mp )
mp->tag |= ScopedConn::keepOpen;
mp->tag |= ReplicationExecutor::NetworkInterface::kMessagingPortKeepOpen;
}

ReplSetHeartbeatArgs args;
Expand Down
3 changes: 0 additions & 3 deletions src/mongo/db/repl/scoped_conn.cpp
Expand Up @@ -41,9 +41,6 @@ namespace repl {

static const int DEFAULT_HEARTBEAT_TIMEOUT_SECS = 10;

// This is a bitmask with the first bit set. It's used to mark connections that should be kept
// open during stepdowns
const unsigned ScopedConn::keepOpen = 1;
ScopedConn::M& ScopedConn::_map = *(new ScopedConn::M());
mutex ScopedConn::mapMutex("ScopedConn::mapMutex");

Expand Down
5 changes: 2 additions & 3 deletions src/mongo/db/repl/scoped_conn.h
Expand Up @@ -37,6 +37,7 @@
#include "mongo/db/auth/authorization_manager_global.h"
#include "mongo/db/auth/internal_user_auth.h"
#include "mongo/db/auth/security_key.h"
#include "mongo/db/repl/replication_executor.h"

namespace mongo {
namespace repl {
Expand All @@ -59,8 +60,6 @@ namespace repl {
*/
class ScopedConn {
public:
// A flag to keep ScopedConns open when all other sockets are disconnected
static const unsigned keepOpen;

/** throws assertions if connect failure etc. */
ScopedConn(const std::string& hostport);
Expand Down Expand Up @@ -99,7 +98,7 @@ namespace repl {

void tagPort() {
MessagingPort& mp = cc->port();
mp.tag |= ScopedConn::keepOpen;
mp.tag |= ReplicationExecutor::NetworkInterface::kMessagingPortKeepOpen;
}
} *connInfo;
typedef std::map<std::string,ScopedConn::ConnectionInfo*> M;
Expand Down

0 comments on commit 6efb8f8

Please sign in to comment.