~james-page/ubuntu/precise/mongodb/arch-enablement

« back to all changes in this revision

Viewing changes to s/d_migrate.cpp

  • Committer: Package Import Robot
  • Author(s): Antonin Kral
  • Date: 2012-06-05 19:52:28 UTC
  • mfrom: (1.2.18)
  • Revision ID: package-import@ubuntu.com-20120605195228-y35631zus0oblqd7
Tags: 1:2.0.6-1
New upstream release 2.0.6
https://jira.mongodb.org/browse/SERVER/fixforversion/11165

Show diffs side-by-side

added added

removed removed

Lines of Context:
482
482
            
483
483
            while ( 1 ) {
484
484
                bool filledBuffer = false;
485
 
                
486
 
                readlock l( _ns );
487
 
                Client::Context ctx( _ns );
488
 
                scoped_spinlock lk( _trackerLocks );
489
 
                set<DiskLoc>::iterator i = _cloneLocs.begin();
490
 
                for ( ; i!=_cloneLocs.end(); ++i ) {
491
 
                    if (tracker.ping()) // should I yield?
492
 
                        break;
493
 
 
494
 
                    DiskLoc dl = *i;
495
 
                    BSONObj o = dl.obj();
496
 
 
497
 
                    // use the builder size instead of accumulating 'o's size so that we take into consideration
498
 
                    // the overhead of BSONArray indices
499
 
                    if ( a.len() + o.objsize() + 1024 > BSONObjMaxUserSize ) {
500
 
                        filledBuffer = true; // break out of outer while loop
501
 
                        break;
 
485
 
 
486
                auto_ptr<RWLockRecursive::Shared> fileLock;
 
487
                Record* recordToTouch = NULL;
 
488
 
 
489
                {
 
490
                    readlock rlk(_ns);
 
491
                    Client::Context ctx( _ns ); // ReadContext?
 
492
                    scoped_spinlock lk( _trackerLocks );
 
493
                    set<DiskLoc>::iterator i = _cloneLocs.begin();
 
494
                    for ( ; i!=_cloneLocs.end(); ++i ) {
 
495
                        if (tracker.ping()) // should I yield?
 
496
                            break;
 
497
 
 
498
                        DiskLoc dl = *i;
 
499
                        Record* r = dl.rec();
 
500
                        if ( ! r->likelyInPhysicalMemory() ) {
 
501
                            fileLock.reset( new RWLockRecursive::Shared( MongoFile::mmmutex) );
 
502
                            recordToTouch = r;
 
503
                            break;
 
504
                        }
 
505
 
 
506
                        BSONObj o = dl.obj();
 
507
 
 
508
                        // use the builder size instead of accumulating 'o's size so that we take into consideration
 
509
                        // the overhead of BSONArray indices
 
510
                        if ( a.len() + o.objsize() + 1024 > BSONObjMaxUserSize ) {
 
511
                            filledBuffer = true; // break out of outer while loop
 
512
                            break;
 
513
                        }
 
514
 
 
515
                        a.append( o );
502
516
                    }
503
517
 
504
 
                    a.append( o );
505
 
                }
506
 
 
507
518
                _cloneLocs.erase( _cloneLocs.begin() , i );
508
519
 
509
520
                if ( _cloneLocs.empty() || filledBuffer )
510
521
                    break;
 
522
                }
 
523
                if ( recordToTouch ) {
 
524
                    // its safe to touch here because we have a LockMongoFilesShared
 
525
                    // we can't do where we get the lock because we would have to unlock the main readlock and tne _trackerLocks
 
526
                    // simpler to handle this out there
 
527
                    recordToTouch->touch();
 
528
                    recordToTouch = NULL;
 
529
                }
 
530
 
 
531
 
511
532
            }
512
533
 
513
534
            result.appendArray( "objects" , a.arr() );