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

SERVER-4552 avoid divide by zero error, just in case

This commit is contained in:
Eric Milkie 2011-12-27 11:38:46 -05:00
parent 01ab069471
commit 5ea3bf83f9

View File

@ -228,7 +228,9 @@ namespace mongo {
b.appendNumber( i->first , i->second );
b.appendNumber( "millisShardTotal" , millis );
b.append( "millisShardAvg" , (int)((double)millis / numExplains ) );
b.append( "millisShardAvg" ,
numExplains ? static_cast<int>( static_cast<double>(millis) / numExplains )
: 0 );
b.append( "numQueries" , (int)numExplains );
b.append( "numShards" , (int)out.size() );
}