summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authordwight <dwight@Dwights-MacBook.local>2008-08-04 09:43:02 -0400
committerdwight <dwight@Dwights-MacBook.local>2008-08-04 09:43:02 -0400
commit50d596bcfdcd4617e20174bbbfe76892e4367898 (patch)
treeec9e7a8187c38f0462cca2eb52213974e7e015c7
parent187156c2801da232aa01464a61e6926b44fa208b (diff)
parent278e8ad04a642077ecb642a57bd590c85074890e (diff)
downloadmongo-50d596bcfdcd4617e20174bbbfe76892e4367898.tar.gz
Merge branch 'master' of ssh://git.10gen.com/data/gitroot/pr0.1.0_rc2
-rw-r--r--db/dbclient.cpp20
1 files changed, 18 insertions, 2 deletions
diff --git a/db/dbclient.cpp b/db/dbclient.cpp
index 55da39a98a5..91afe876927 100644
--- a/db/dbclient.cpp
+++ b/db/dbclient.cpp
@@ -34,13 +34,29 @@ JSObj DBClientConnection::findOne(const char *ns, JSObj query, JSObj *fieldsToRe
bool DBClientConnection::connect(const char *serverAddress, string& errmsg) {
/* not reentrant!
ok as used right now (we are in a big lock), but won't be later, so fix. */
+
+ int port = DBPort;
+
+
string ip = hostbyname_nonreentrant(serverAddress);
if( ip.empty() )
ip = serverAddress;
- server = auto_ptr<SockAddr>(new SockAddr(ip.c_str(), DBPort));
+ int idx = ip.find( ":" );
+ if ( idx != string::npos ){
+ cout << "port string:" << ip.substr( idx ) << endl;
+ port = atoi( ip.substr( idx + 1 ).c_str() );
+ ip = ip.substr( 0 , idx );
+ ip = hostbyname_nonreentrant(ip.c_str());
+
+ }
+ if( ip.empty() )
+ ip = serverAddress;
+
+ cout << "port:" << port << endl;
+ server = auto_ptr<SockAddr>(new SockAddr(ip.c_str(), port));
if( !p.connect(*server) ) {
- errmsg = string("couldn't connect to server ") + serverAddress + ' ' + ip;
+ errmsg = string("couldn't connect to server ") + serverAddress + ' ' + ip;
return false;
}
return true;