当前位置: 首页>>代码示例>>C++>>正文


C++ DurableMappedFile::length方法代码示例

本文整理汇总了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;
            }
        }
开发者ID:ChrisKozak,项目名称:mongo,代码行数:36,代码来源:dur.cpp

示例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);
    }
开发者ID:rueckstiess,项目名称:mongo,代码行数:65,代码来源:durable_mapped_file.cpp


注:本文中的DurableMappedFile::length方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。