summaryrefslogtreecommitdiff
path: root/src/mongo/db/commands/isself.cpp
diff options
context:
space:
mode:
authorRajat Chopra <rchopra@redhat.com>2013-11-13 14:55:48 -0800
committerBenety Goh <benety@mongodb.com>2014-05-29 08:44:09 -0400
commit4bb1a6155bc7bfb7cb69ff6844d427f0159a888c (patch)
tree21d7e37612bb77a39cc1c1cd9fcc297e67402d93 /src/mongo/db/commands/isself.cpp
parent8bc2783d2e6e39c0910455b4eac9e0f93a482cfc (diff)
downloadmongo-4bb1a6155bc7bfb7cb69ff6844d427f0159a888c.tar.gz
SERVER-11776 Replication 'isself' check should allow mapped ports
'isself' should match the ports only if the hosts are being string matched. In cases where an instance is being addressed through a proxy port, port matching is an incorrect check - it invalidates a genuine match. Signed-off-by: Benety Goh <benety@mongodb.com>
Diffstat (limited to 'src/mongo/db/commands/isself.cpp')
-rw-r--r--src/mongo/db/commands/isself.cpp11
1 files changed, 4 insertions, 7 deletions
diff --git a/src/mongo/db/commands/isself.cpp b/src/mongo/db/commands/isself.cpp
index df6a9dbb26b..543d512af37 100644
--- a/src/mongo/db/commands/isself.cpp
+++ b/src/mongo/db/commands/isself.cpp
@@ -207,11 +207,6 @@ namespace mongo {
int _p = port();
int p = _p == -1 ? ServerGlobalParams::DefaultDBPort : _p;
- if (p != serverGlobalParams.port) {
- // shortcut - ports have to match at the very least
- return false;
- }
-
string host = str::stream() << this->host() << ":" << p;
{
@@ -234,8 +229,10 @@ namespace mongo {
string a = *i;
string b = *j;
- if ( a == b ||
- ( str::startsWith( a , "127." ) && str::startsWith( b , "127." ) ) // 127. is all loopback
+ // check if the ports match as well
+ if ( (p == serverGlobalParams.port) &&
+ (a == b || ( str::startsWith( a , "127." ) &&
+ str::startsWith( b , "127." ) )) // 127. is all loopback
) {
// add to cache