@@ -113,9 +113,15 @@ namespace mongo {
113113 return true ;
114114 }
115115
116- ConfigVersion& ShardingState::getVersion ( const string& ns ){
116+ const ConfigVersion ShardingState::getVersion ( const string& ns ) const {
117117 scoped_lock lk (_mutex);
118- return _versions[ns];
118+
119+ NSVersionMap::const_iterator it = _versions.find ( ns );
120+ if ( it != _versions.end () ) {
121+ return it->second ;
122+ } else {
123+ return 0 ;
124+ }
119125 }
120126
121127 void ShardingState::setVersion ( const string& ns , const ConfigVersion& version ){
@@ -273,8 +279,13 @@ namespace mongo {
273279 _tl.reset ();
274280 }
275281
276- ConfigVersion& ShardedConnectionInfo::getVersion ( const string& ns ){
277- return _versions[ns];
282+ const ConfigVersion ShardedConnectionInfo::getVersion ( const string& ns ) const {
283+ NSVersionMap::const_iterator it = _versions.find ( ns );
284+ if ( it != _versions.end () ) {
285+ return it->second ;
286+ } else {
287+ return 0 ;
288+ }
278289 }
279290
280291 void ShardedConnectionInfo::setVersion ( const string& ns , const ConfigVersion& version ){
@@ -421,18 +432,18 @@ namespace mongo {
421432 return false ;
422433 }
423434
424- ConfigVersion& oldVersion = info->getVersion (ns);
425- ConfigVersion& globalVersion = shardingState.getVersion (ns);
435+ const ConfigVersion oldVersion = info->getVersion (ns);
436+ const ConfigVersion globalVersion = shardingState.getVersion (ns);
426437
427438 if ( oldVersion > 0 && globalVersion == 0 ){
428439 // this had been reset
429- oldVersion = 0 ;
440+ info-> setVersion ( ns , 0 ) ;
430441 }
431442
432443 if ( version == 0 && globalVersion == 0 ){
433444 // this connection is cleaning itself
434- oldVersion = 0 ;
435- return 1 ;
445+ info-> setVersion ( ns , 0 ) ;
446+ return true ;
436447 }
437448
438449 if ( version == 0 && globalVersion > 0 ){
@@ -441,15 +452,15 @@ namespace mongo {
441452 result.appendTimestamp ( " globalVersion" , globalVersion );
442453 result.appendTimestamp ( " oldVersion" , oldVersion );
443454 errmsg = " dropping needs to be authoritative" ;
444- return 0 ;
455+ return false ;
445456 }
446457 log () << " wiping data for: " << ns << endl;
447458 result.appendTimestamp ( " beforeDrop" , globalVersion );
448459 // only setting global version on purpose
449460 // need clients to re-find meta-data
450- globalVersion = 0 ;
451- oldVersion = 0 ;
452- return 1 ;
461+ shardingState. setVersion ( ns , 0 ) ;
462+ info-> setVersion ( ns , 0 ) ;
463+ return true ;
453464 }
454465
455466 if ( version < oldVersion ){
@@ -480,17 +491,18 @@ namespace mongo {
480491 return false ;
481492 }
482493
494+ result.appendTimestamp ( " oldVersion" , oldVersion );
495+ result.append ( " ok" , 1 );
496+
497+ info->setVersion ( ns , version );
498+ shardingState.setVersion ( ns , version );
499+
483500 {
484501 dbtemprelease unlock;
485502 shardingState.getChunkMatcher ( ns );
486503 }
487504
488- result.appendTimestamp ( " oldVersion" , oldVersion );
489- oldVersion = version;
490- globalVersion = version;
491-
492- result.append ( " ok" , 1 );
493- return 1 ;
505+ return true ;
494506 }
495507
496508 } setShardVersionCmd;
0 commit comments