diff options
author | Mathias Stearn <redbeard0531@gmail.com> | 2010-09-27 18:21:36 -0400 |
---|---|---|
committer | Mathias Stearn <redbeard0531@gmail.com> | 2010-09-27 18:23:33 -0400 |
commit | 8f6b5ab3d2fade6a6f6b37af48f55b5a204a6401 (patch) | |
tree | b202a698907db1c1aca21da57cbc6942cc39e99a | |
parent | aab1fcff76c2374692f8c56bfefea3e6203a6eb4 (diff) | |
download | mongo-8f6b5ab3d2fade6a6f6b37af48f55b5a204a6401.tar.gz |
Move bind_ip handling from me() to Me(). SERVER-1813
-rw-r--r-- | db/repl/rs_initiate.cpp | 2 | ||||
-rw-r--r-- | util/hostandport.h | 33 |
2 files changed, 18 insertions, 17 deletions
diff --git a/db/repl/rs_initiate.cpp b/db/repl/rs_initiate.cpp index 41bf8d87fd8..9c74be08df6 100644 --- a/db/repl/rs_initiate.cpp +++ b/db/repl/rs_initiate.cpp @@ -187,7 +187,7 @@ namespace mongo { bob b; b.append("_id", name); bob members; - members.append("0", BSON( "_id" << 0 << "host" << HostAndPort::me().toString() )); + members.append("0", BSON( "_id" << 0 << "host" << HostAndPort::Me().toString() )); for( unsigned i = 0; i < seeds.size(); i++ ) members.append(bob::numStr(i+1), BSON( "_id" << i+1 << "host" << seeds[i].toString())); b.appendArray("members", members.obj()); diff --git a/util/hostandport.h b/util/hostandport.h index dbae86aa53d..55a87d0cb50 100644 --- a/util/hostandport.h +++ b/util/hostandport.h @@ -43,22 +43,6 @@ namespace mongo { } static HostAndPort me() { - const char* ips = cmdLine.bind_ip.c_str(); - while(*ips){ - string ip; - const char * comma = strchr(ips, ','); - if (comma){ - ip = string(ips, comma - ips); - ips = comma + 1; - }else{ - ip = string(ips); - ips = ""; - } - HostAndPort h = HostAndPort(ip, cmdLine.port); - if (!h.isLocalHost()) { - return h; - } - } return HostAndPort("localhost", cmdLine.port); } @@ -109,6 +93,23 @@ namespace mongo { } inline HostAndPort HostAndPort::Me() { + const char* ips = cmdLine.bind_ip.c_str(); + while(*ips){ + string ip; + const char * comma = strchr(ips, ','); + if (comma){ + ip = string(ips, comma - ips); + ips = comma + 1; + }else{ + ip = string(ips); + ips = ""; + } + HostAndPort h = HostAndPort(ip, cmdLine.port); + if (!h.isLocalHost()) { + return h; + } + } + string h = getHostName(); assert( !h.empty() ); assert( h != "localhost" ); |