diff options
author | Spencer T Brody <spencer@10gen.com> | 2013-02-28 17:57:51 -0500 |
---|---|---|
committer | Spencer T Brody <spencer@10gen.com> | 2013-03-01 14:06:30 -0500 |
commit | b19a031dd8558d96307d021cab84a2fe4bd7ee3a (patch) | |
tree | 69d9426651c97f034268a15a929333a8700320f6 /src | |
parent | e528ff70fcc75984331612d20b0496dbb4fcf365 (diff) | |
download | mongo-b19a031dd8558d96307d021cab84a2fe4bd7ee3a.tar.gz |
SERVER-8786 Fix race condition when adding ShardingConnectionHook to connection pools
Diffstat (limited to 'src')
-rw-r--r-- | src/mongo/s/d_state.cpp | 7 |
1 files changed, 6 insertions, 1 deletions
diff --git a/src/mongo/s/d_state.cpp b/src/mongo/s/d_state.cpp index 6ea6ef58b7b..95ba21ab8f9 100644 --- a/src/mongo/s/d_state.cpp +++ b/src/mongo/s/d_state.cpp @@ -40,6 +40,7 @@ #include "mongo/s/d_logic.h" #include "mongo/s/shard.h" #include "mongo/util/queue.h" +#include "mongo/util/concurrency/mutex.h" #include "mongo/util/concurrency/ticketholder.h" using namespace std; @@ -376,9 +377,13 @@ namespace mongo { } void ShardedConnectionInfo::addHook() { + static mongo::mutex lock("ShardedConnectionInfo::addHook mutex"); static bool done = false; + + scoped_lock lk(lock); if (!done) { - LOG(1) << "adding sharding hook" << endl; + log() << "first cluster operation detected, adding sharding hook to enable versioning " + "and authentication to remote servers" << endl; pool.addHook(new ShardingConnectionHook(false)); shardConnectionPool.addHook(new ShardingConnectionHook(true)); done = true; |