0
0
mirror of https://github.com/mongodb/mongo.git synced 2024-12-01 09:32:32 +01:00

special case localhost = 127.0.0.1 (for now)

This commit is contained in:
Mathias Stearn 2010-04-08 01:44:33 -04:00
parent 60d44a675a
commit 5cad0d6a80
2 changed files with 4 additions and 1 deletions

View File

@ -27,7 +27,7 @@ namespace SockTests {
class HostByName { class HostByName {
public: public:
void run() { void run() {
ASSERT( hostbyname( "localhost" ) == "127.0.0.1" || hostbyname( "localhost" ) == "::1" ); ASSERT_EQUALS( "127.0.0.1", hostbyname( "localhost" ) );
ASSERT_EQUALS( "127.0.0.1", hostbyname( "127.0.0.1" ) ); ASSERT_EQUALS( "127.0.0.1", hostbyname( "127.0.0.1" ) );
ASSERT_EQUALS( "::1", hostbyname( "::1" ) ); ASSERT_EQUALS( "::1", hostbyname( "::1" ) );
} }

View File

@ -31,6 +31,9 @@ namespace mongo {
} }
SockAddr::SockAddr(const char * iporhost , int port) { SockAddr::SockAddr(const char * iporhost , int port) {
if (!strcmp(iporhost, "localhost"))
iporhost = "127.0.0.1";
if (strchr(iporhost, '/')){ if (strchr(iporhost, '/')){
#ifdef _WIN32 #ifdef _WIN32
uassert(13080, "no unix socket support on windows", false); uassert(13080, "no unix socket support on windows", false);