summaryrefslogtreecommitdiff
path: root/util/hostandport.h
diff options
context:
space:
mode:
Diffstat (limited to 'util/hostandport.h')
-rw-r--r--util/hostandport.h33
1 files changed, 17 insertions, 16 deletions
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" );