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

fix bug with auto reconnect in the client

This commit is contained in:
Dwight 2009-02-24 13:14:08 -05:00
parent c5fc4e2919
commit d654aa6788

View File

@ -384,7 +384,6 @@ namespace mongo {
int port;
size_t idx = serverAddress.find( ":" );
if ( idx != string::npos ) {
//out() << "port string:" << ip.substr( idx ) << endl;
port = strtol( serverAddress.substr( idx + 1 ).c_str(), 0, 10 );
ip = serverAddress.substr( 0 , idx );
ip = hostbyname(ip.c_str());
@ -590,11 +589,21 @@ namespace mongo {
}
bool DBClientConnection::call( Message &toSend, Message &response, bool assertOk ) {
if ( !port().call(toSend, response) ) {
/* todo: this is very ugly messagingport::call returns an error code AND can throw
an exception. we should make it return void and just throw an exception anytime
it fails
*/
try {
if ( !port().call(toSend, response) ) {
failed = true;
if ( assertOk )
massert("dbclient error communicating with server", false);
return false;
}
}
catch( SocketException & ) {
failed = true;
if ( assertOk )
massert("dbclient error communicating with server", false);
return false;
throw;
}
return true;
}