mirror of
https://github.com/mongodb/mongo.git
synced 2024-12-01 09:32:32 +01:00
by ref is used everywhere else in errmsg
This commit is contained in:
parent
c01bef0ef1
commit
9086cd331d
@ -639,7 +639,7 @@ namespace mongo {
|
||||
maxSize = cmdObj[ ShardFields::maxSize.name() ].numberLong();
|
||||
}
|
||||
|
||||
if ( ! grid.addShard( &name , shardAddr.toString() , maxSize , &errmsg ) ){
|
||||
if ( ! grid.addShard( &name , shardAddr.toString() , maxSize , errmsg ) ){
|
||||
log() << "addshard request " << cmdObj << " failed: " << errmsg << endl;
|
||||
return false;
|
||||
}
|
||||
|
23
s/grid.cpp
23
s/grid.cpp
@ -115,9 +115,8 @@ namespace mongo {
|
||||
_allowLocalShard = allow;
|
||||
}
|
||||
|
||||
bool Grid::addShard( string* name , const string& host , long long maxSize , string* errMsg ){
|
||||
// errMsg is required but name is optional
|
||||
DEV assert( errMsg );
|
||||
bool Grid::addShard( string* name , const string& host , long long maxSize , string& errMsg ){
|
||||
// name is optional
|
||||
string nameInternal;
|
||||
if ( ! name ) {
|
||||
name = &nameInternal;
|
||||
@ -135,7 +134,7 @@ namespace mongo {
|
||||
|
||||
if ( newShardConn->type() == ConnectionString::SYNC ){
|
||||
newShardConn.done();
|
||||
*errMsg = "can't use sync cluster as a shard. for replica set, have to use <name>/<server1>,<server2>,...";
|
||||
errMsg = "can't use sync cluster as a shard. for replica set, have to use <name>/<server1>,<server2>,...";
|
||||
return false;
|
||||
}
|
||||
|
||||
@ -145,7 +144,7 @@ namespace mongo {
|
||||
if ( !ok ){
|
||||
ostringstream ss;
|
||||
ss << "failed listing " << host << " databases:" << res;
|
||||
*errMsg = ss.str();
|
||||
errMsg = ss.str();
|
||||
newShardConn.done();
|
||||
return false;
|
||||
}
|
||||
@ -168,7 +167,7 @@ namespace mongo {
|
||||
ostringstream ss;
|
||||
ss << "couldn't connect to new shard ";
|
||||
ss << e.what();
|
||||
*errMsg = ss.str();
|
||||
errMsg = ss.str();
|
||||
return false;
|
||||
}
|
||||
|
||||
@ -179,14 +178,14 @@ namespace mongo {
|
||||
ostringstream ss;
|
||||
ss << "trying to add shard " << host << " because local database " << *it;
|
||||
ss << " exists in another " << config->getPrimary().toString();
|
||||
*errMsg = ss.str();
|
||||
errMsg = ss.str();
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
// if a name for a shard wasn't provided, pick one.
|
||||
if ( name->empty() && ! _getNewShardName( name ) ){
|
||||
*errMsg = "error generating new shard name";
|
||||
errMsg = "error generating new shard name";
|
||||
return false;
|
||||
}
|
||||
|
||||
@ -205,7 +204,7 @@ namespace mongo {
|
||||
// check whether this host:port is not an already a known shard
|
||||
BSONObj old = conn->findOne( ShardNS::shard , BSON( "host" << host ) );
|
||||
if ( ! old.isEmpty() ){
|
||||
*errMsg = "host already used";
|
||||
errMsg = "host already used";
|
||||
conn.done();
|
||||
return false;
|
||||
}
|
||||
@ -213,9 +212,9 @@ namespace mongo {
|
||||
log() << "going to add shard: " << shardDoc << endl;
|
||||
|
||||
conn->insert( ShardNS::shard , shardDoc );
|
||||
*errMsg = conn->getLastError();
|
||||
if ( ! errMsg->empty() ){
|
||||
log() << "error adding shard: " << shardDoc << " err: " << *errMsg << endl;
|
||||
errMsg = conn->getLastError();
|
||||
if ( ! errMsg.empty() ){
|
||||
log() << "error adding shard: " << shardDoc << " err: " << errMsg << endl;
|
||||
conn.done();
|
||||
return false;
|
||||
}
|
||||
|
2
s/grid.h
2
s/grid.h
@ -68,7 +68,7 @@ namespace mongo {
|
||||
* @param errMsg is the error description in case the operation failed.
|
||||
* @return true if shard was successfully added.
|
||||
*/
|
||||
bool addShard( string* name , const string& host , long long maxSize , string* errMsg );
|
||||
bool addShard( string* name , const string& host , long long maxSize , string& errMsg );
|
||||
|
||||
/**
|
||||
* @return true if the config database knows about a host 'name'
|
||||
|
Loading…
Reference in New Issue
Block a user