From c595bf62aab72db689edc8e70e1ebaef71b09bd2 Mon Sep 17 00:00:00 2001 From: Dwight Date: Tue, 28 Sep 2010 17:49:40 -0400 Subject: [PATCH] more intent to write declarations --- db/namespace.cpp | 8 ++++++-- db/namespace.h | 8 ++++++-- db/pdfile.cpp | 6 +++--- util/mmap_win.cpp | 6 ++---- 4 files changed, 17 insertions(+), 11 deletions(-) diff --git a/db/namespace.cpp b/db/namespace.cpp index c6130f5ca99..e7cff360425 100644 --- a/db/namespace.cpp +++ b/db/namespace.cpp @@ -183,8 +183,12 @@ namespace mongo { void NamespaceDetails::addDeletedRec(DeletedRecord *d, DiskLoc dloc) { dur::assertReading(this); BOOST_STATIC_ASSERT( sizeof(NamespaceDetails::Extra) <= sizeof(NamespaceDetails) ); - dassert( dloc.drec() == d ); - //DeletedRecord *dold = d; + +#if defined(_DEBUG) && !defined(_DURABLE) + if( dloc.drec() != d ) { + assert(false); + } +#endif d = dur::writing(d); { // defensive code: try to make us notice if we reference a deleted record diff --git a/db/namespace.h b/db/namespace.h index 7479a21da24..ee15eea9887 100644 --- a/db/namespace.h +++ b/db/namespace.h @@ -260,11 +260,15 @@ namespace mongo { bool isMultikey(int i) { return (multiKeyIndexBits & (((unsigned long long) 1) << i)) != 0; } void setIndexIsMultikey(int i) { dassert( i < NIndexesMax ); - multiKeyIndexBits |= (((unsigned long long) 1) << i); + unsigned long long x = ((unsigned long long) 1) << i; + if( multiKeyIndexBits & x ) return; + *dur::writing(&multiKeyIndexBits) |= x; } void clearIndexIsMultikey(int i) { dassert( i < NIndexesMax ); - multiKeyIndexBits &= ~(((unsigned long long) 1) << i); + unsigned long long x = ((unsigned long long) 1) << i; + if( (multiKeyIndexBits & x) == 0 ) return; + *dur::writing(&multiKeyIndexBits) &= ~x; } /* add a new index. does not add to system.indexes etc. - just to NamespaceDetails. diff --git a/db/pdfile.cpp b/db/pdfile.cpp index 848ae4e38d4..77486fa16f7 100644 --- a/db/pdfile.cpp +++ b/db/pdfile.cpp @@ -261,7 +261,7 @@ namespace mongo { } if ( mx > 0 ) - d->max = mx; + dur::writingInt( d->max ) = mx; return true; } @@ -1108,9 +1108,9 @@ namespace mongo { idx.getKeysFromObject(o, keys); int k = 0; for ( BSONObjSetDefaultOrder::iterator i=keys.begin(); i != keys.end(); i++ ) { - if( ++k == 2 ) + if( ++k == 2 ) { d->setIndexIsMultikey(idxNo); - //cout<<"SORTER ADD " << i->toString() << ' ' << loc.toString() << endl; + } sorter.add(*i, loc); nkeys++; } diff --git a/util/mmap_win.cpp b/util/mmap_win.cpp index 5901804da67..8a4368a8f4b 100644 --- a/util/mmap_win.cpp +++ b/util/mmap_win.cpp @@ -173,17 +173,15 @@ namespace mongo { size_t ofs = ((char *)p) - ((char*)mmf->view); if( ofs >= mmf->len ) { - log() << "getWriteViewFor error? " << p << endl; for( std::map::iterator i = viewToWriteable.begin(); i != viewToWriteable.end(); i++ ) { char *wl = (char *) i->second->writeView; char *wh = wl + i->second->length(); if( p >= wl && p < wh ) { - log() << "dur ERROR p " << p << " is already in the writable view of " << i->second->filename() << endl; - //wassert(false); - // could do this: + log() << "dur: perf warning p=" << p << " is already in the writable view of " << i->second->filename() << endl; return p; } } + log() << "getWriteViewFor error? " << p << endl; assert( ofs < mmf->len ); // did you call writing() with a pointer that isn't into a datafile? } return ((char *)mmf->writeView) + ofs;