本文整理汇总了C++中DurableMappedFile::length方法的典型用法代码示例。如果您正苦于以下问题:C++ DurableMappedFile::length方法的具体用法?C++ DurableMappedFile::length怎么用?C++ DurableMappedFile::length使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类DurableMappedFile
的用法示例。
在下文中一共展示了DurableMappedFile::length方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: debugCheckLastDeclaredWrite
void DurableImpl::debugCheckLastDeclaredWrite() {
static int n;
++n;
verify(debug && storageGlobalParams.dur);
if (commitJob.writes().empty())
return;
const WriteIntent &i = commitJob.lastWrite();
size_t ofs;
DurableMappedFile *mmf = privateViews.find(i.start(), ofs);
if( mmf == 0 )
return;
size_t past = ofs + i.length();
if( mmf->length() < past + 8 )
return; // too close to end of view
char *priv = (char *) mmf->getView();
char *writ = (char *) mmf->view_write();
unsigned long long *a = (unsigned long long *) (priv+past);
unsigned long long *b = (unsigned long long *) (writ+past);
if( *a != *b ) {
for( set<WriteIntent>::iterator it(commitJob.writes().begin()), end((commitJob.writes().begin())); it != end; ++it ) {
const WriteIntent& wi = *it;
char *r1 = (char*) wi.start();
char *r2 = (char*) wi.end();
if( r1 <= (((char*)a)+8) && r2 > (char*)a ) {
//log() << "it's ok " << wi.p << ' ' << wi.len << endl;
return;
}
}
log() << "journal data after write area " << i.start() << " does not agree" << endl;
log() << " was: " << ((void*)b) << " " << hexdump((char*)b, 8) << endl;
log() << " now: " << ((void*)a) << " " << hexdump((char*)a, 8) << endl;
log() << " n: " << n << endl;
log() << endl;
}
}
示例2: lkPrivateViews
__declspec(noinline) void PointerToDurableMappedFile::makeChunkWritable(size_t chunkno) {
mutex::scoped_lock lkPrivateViews(_m);
if (writable.get(chunkno)) // double check lock
return;
// remap all maps in this chunk.
// common case is a single map, but could have more than one with smallfiles or .ns files
size_t chunkStart = chunkno * MemoryMappedCOWBitset::ChunkSize;
size_t chunkNext = chunkStart + MemoryMappedCOWBitset::ChunkSize;
scoped_lock lkMapView(mapViewMutex);
map<void*, DurableMappedFile*>::iterator i = _views.upper_bound((void*)(chunkNext - 1));
while (1) {
const pair<void*, DurableMappedFile*> x = *(--i);
DurableMappedFile *mmf = x.second;
if (mmf == 0)
break;
size_t viewStart = reinterpret_cast<size_t>(x.first);
size_t viewEnd = viewStart + mmf->length();
if (viewEnd <= chunkStart)
break;
size_t protectStart = std::max(viewStart, chunkStart);
dassert(protectStart < chunkNext);
size_t protectEnd = std::min(viewEnd, chunkNext);
size_t protectSize = protectEnd - protectStart;
dassert(protectSize > 0 && protectSize <= MemoryMappedCOWBitset::ChunkSize);
DWORD oldProtection;
bool ok = VirtualProtect(reinterpret_cast<void*>(protectStart),
protectSize,
PAGE_WRITECOPY,
&oldProtection);
if (!ok) {
DWORD dosError = GetLastError();
if (dosError == ERROR_COMMITMENT_LIMIT) {
// System has run out of memory between physical RAM & page file, tell the user
BSONObjBuilder bb;
ProcessInfo p;
p.getExtraInfo(bb);
severe() << "MongoDB has exhausted the system memory capacity.";
severe() << "Current Memory Status: " << bb.obj().toString();
}
severe() << "VirtualProtect for " << mmf->filename()
<< " chunk " << chunkno
<< " failed with " << errnoWithDescription(dosError)
<< " (chunk size is " << protectSize
<< ", address is " << hex << protectStart << dec << ")"
<< " in mongo::makeChunkWritable, terminating"
<< endl;
fassertFailed(16362);
}
}
writable.set(chunkno);
}