mirror of
https://github.com/mongodb/mongo.git
synced 2024-12-01 09:32:32 +01:00
rs cant use localhost
This commit is contained in:
parent
00d085ca50
commit
ffe66e6486
@ -156,7 +156,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), BSON( "_id" << i << "host" << seeds[i].toString()));
|
||||
b.appendArray("members", members.obj());
|
||||
|
@ -46,6 +46,9 @@ namespace mongo {
|
||||
return HostAndPort("localhost", cmdLine.port);
|
||||
}
|
||||
|
||||
/* uses real hostname instead of localhost */
|
||||
static HostAndPort Me();
|
||||
|
||||
bool operator<(const HostAndPort& r) const { return _host < r._host || (_host==r._host&&_port<r._port); }
|
||||
|
||||
/* returns true if the host/port combo identifies this process instance. */
|
||||
@ -77,6 +80,13 @@ namespace mongo {
|
||||
return str::before(a, '.') == str::before(b, '.');
|
||||
}
|
||||
|
||||
inline HostAndPort HostAndPort::Me() {
|
||||
string h = getHostName();
|
||||
assert( !h.empty() );
|
||||
assert( h != "localhost" );
|
||||
return HostAndPort(h, cmdLine.port);
|
||||
}
|
||||
|
||||
inline bool HostAndPort::isSelf() const {
|
||||
int p = _port == -1 ? CmdLine::DefaultDBPort : _port;
|
||||
if( p != cmdLine.port )
|
||||
|
Loading…
Reference in New Issue
Block a user