Пример #1
0
	void CacheFile::unmapAll()
	{
		QMap<void*,Entry>::iterator i = mappings.begin();
		while (i != mappings.end())
		{
			int ret = 0;
			CacheFile::Entry & e = i.value();
#ifdef Q_OS_WIN
			fptr->unmap((uchar*)e.ptr);
#else
#ifdef HAVE_MUNMAP64
			ret = munmap64(e.ptr,e.size);
#else
			ret = munmap(e.ptr,e.size);
#endif // HAVE_MUNMAP64
#endif // Q_OS_WIN
			e.thing->unmapped();
			// if it will be reopenend, we will not remove all mappings
			// so that they will be redone on reopening
			i++;
			mappings.remove(e.ptr);
			if (ret < 0)
			{
				Out(SYS_DIO|LOG_IMPORTANT) << QString("Munmap failed with error %1 : %2").arg(errno).arg(strerror(errno)) << endl;
			}
		}	
	}
Пример #2
0
void CacheFile::unmap(void* ptr,Uint32 size)
{
    int ret = 0;
    QMutexLocker lock(&mutex);
    // see if it wasn't an offsetted mapping
    if (mappings.contains(ptr))
    {
        CacheFile::Entry & e = mappings[ptr];
#if HAVE_MUNMAP64
        if (e.diff > 0)
            ret = munmap64((char*)ptr - e.diff,e.size);
        else
            ret = munmap64(ptr,e.size);
#else
        if (e.diff > 0)
            ret = munmap((char*)ptr - e.diff,e.size);
        else
            ret = munmap(ptr,e.size);
#endif
        mappings.erase(ptr);
        // no mappings, close temporary
        if (mappings.count() == 0)
            closeTemporary();
    }
    else
    {
#if HAVE_MUNMAP64
        ret = munmap64(ptr,size);
#else
        ret = munmap(ptr,size);
#endif
    }

    if (ret < 0)
    {
        Out(SYS_DIO|LOG_IMPORTANT) << QString("Munmap failed with error %1 : %2").arg(errno).arg(strerror(errno)) << endl;
    }
}
Пример #3
0
void CacheFile::close()
{
    QMutexLocker lock(&mutex);

    if (fd == -1)
        return;

    QMap<void*,Entry>::iterator i = mappings.begin();
    while (i != mappings.end())
    {
        int ret = 0;
        CacheFile::Entry & e = i.data();
#if HAVE_MUNMAP64
        if (e.diff > 0)
            ret = munmap64((char*)e.ptr - e.diff,e.size);
        else
            ret = munmap64(e.ptr,e.size);
#else
        if (e.diff > 0)
            ret = munmap((char*)e.ptr - e.diff,e.size);
        else
            ret = munmap(e.ptr,e.size);
#endif
        e.thing->unmapped();

        i++;
        mappings.erase(e.ptr);

        if (ret < 0)
        {
            Out(SYS_DIO|LOG_IMPORTANT) << QString("Munmap failed with error %1 : %2").arg(errno).arg(strerror(errno)) << endl;
        }
    }
    ::close(fd);
    fd = -1;
}
Пример #4
0
    void MMapFile::close()
    {
        if (fptr)
        {
#ifndef Q_WS_WIN
#ifdef HAVE_MUNMAP64
            munmap64(data, size);
#else
            munmap(data, size);
#endif
#else
            fptr->unmap(data);
#endif
            fptr->close();
            delete fptr;
            fptr = 0;
            ptr = size = 0;
            data = 0;
            filename = QString::null;
        }
    }
Пример #5
0
	void CacheFile::unmap(void* ptr,Uint32 size)
	{
		int ret = 0;
		QMutexLocker lock(&mutex);
#ifdef Q_OS_WIN
		if (!fptr)
			return;
			
		if (mappings.contains(ptr))
		{
			CacheFile::Entry & e = mappings[ptr];
			if (!fptr->unmap((uchar*)e.ptr))
				Out(SYS_DIO|LOG_IMPORTANT) << QString("Unmap failed : %1").arg(fptr->errorString()) << endl;
			
			mappings.remove(ptr);
			// no mappings, close temporary
			if (mappings.count() == 0)
				closeTemporary();
		}
#else
		// see if it wasn't an offsetted mapping
		if (mappings.contains(ptr))
		{
			CacheFile::Entry & e = mappings[ptr];
#ifdef HAVE_MUNMAP64
			ret = munmap64(e.ptr,e.size);
#else
			ret = munmap(e.ptr,e.size);
#endif
			if (ret < 0)
				Out(SYS_DIO|LOG_IMPORTANT) << QString("Munmap failed with error %1 : %2").arg(errno).arg(strerror(errno)) << endl;
			
			mappings.remove(ptr);
			// no mappings, close temporary
			if (mappings.count() == 0)
				closeTemporary();
		}
#endif
	}