virtual void
	detach(MM_HeapRegionDescriptorSegregated *cur)
	{
		lock();
		detachInternal(cur);
		unlock();
	}
Beispiel #2
0
void AbstractDb::detach(Db* otherDb)
{
    QWriteLocker locker(&dbOperLock);

    if (!isOpenInternal())
        return;

    detachInternal(otherDb);
}
Beispiel #3
0
void AbstractDb::detachAll()
{
    QWriteLocker locker(&dbOperLock);

    if (!isOpenInternal())
        return;

    foreach (Db* db, attachedDbMap.rightValues())
        detachInternal(db);
}
void
MMTT_SharedMem::resize(unsigned int s)
{

    // This can't be called by someone that didn't create it in the first place
    // Also you can't resize it if you arn't using the info feature
    // Finally, don't set the size to 0, just delete this object if you want to clean it
    if (mySize > 0 && mySharedMemInfo && myAmOwner)
    {
		mySharedMemInfo->lock();
		MMTT_SharedMemInfo *info = (MMTT_SharedMemInfo*)mySharedMemInfo->getMemory();
		if (info && info->supported)
		{
		    detachInternal();
		    mySize = s;
		    // Keep trying until we find a name that works
		    do 
		    {
				randomizePostFix();
				createName();
		    } while(!createSharedMem());
		    memcpy(info->namePostFix, myNamePostFix, MMTT_SHM_MAX_POST_FIX_SIZE);
		}
		else // Otherwise, just try and detach and resize, if it fails give up
		{
		    detachInternal();
		    mySize = s;
		    if (!createSharedMem())
		    {
				myErrorState = MMTT_SHM_ERR_ALREADY_EXIST;
		    }

		}
		mySharedMemInfo->unlock();
    }
}
bool
MMTT_SharedMem::checkInfo()
{
	if (mySupportInfo)
	{
		// If we are looking for an info and can't find it,
		// then release the segment also
		if (!createInfo())
		{
			detach();
			myErrorState = MMTT_SHM_ERR_INFO_DOESNT_EXIST;
			return false;
		}
	}

    if (mySharedMemInfo && mySharedMemInfo->getErrorState() == MMTT_SHM_ERR_NONE && !myAmOwner)
    {
		mySharedMemInfo->lock();
		MMTT_SharedMemInfo *info = (MMTT_SharedMemInfo*)mySharedMemInfo->getMemory();

		if (info->version > 1)
		{
			if (info->detach)
			{
				mySharedMemInfo->unlock();
				detach();
				myErrorState = MMTT_SHM_ERR_INFO_DOESNT_EXIST;
				return false;
			}
		}

		char pn[MMTT_SHM_MAX_POST_FIX_SIZE];
		memcpy(pn, info->namePostFix, MMTT_SHM_MAX_POST_FIX_SIZE);
		
		if (strcmp(pn, myNamePostFix) != 0)
		{
		    memcpy(myNamePostFix, pn, MMTT_SHM_MAX_POST_FIX_SIZE);
		    detachInternal();
		}
		mySharedMemInfo->unlock();

    }
	return true;
}
bool
MMTT_SharedMem::detach()
{
    if (mySharedMemInfo)
    {
		if (mySharedMemInfo->getErrorState() == MMTT_SHM_ERR_NONE)
		{
			mySharedMemInfo->lock();
			MMTT_SharedMemInfo *info = (MMTT_SharedMemInfo*)mySharedMemInfo->getMemory();
			if (info && myAmOwner)
			{
				info->detach = true;
			}
			mySharedMemInfo->unlock();
		}
		delete mySharedMemInfo;
		mySharedMemInfo = NULL;
	}
	memset(myNamePostFix, 0, sizeof(myNamePostFix));
	return detachInternal();
}