Example #1
0
void FreeConnection(Connection** connection) {
    Connection* pConnection = NULL;

    if (connection != NULL && (pConnection = *connection) != NULL) {
        if (pConnection->socket != -1) {
#ifndef AIO4C_WIN32
            close(pConnection->socket);
#else /* AIO4C_WIN32 */
            closesocket(pConnection->socket);
#endif /* AIO4C_WIN32 */
        }

        if (!pConnection->isFactory) {
            _ConnectionEventHandle(pConnection, AIO4C_FREE_EVENT);
        }

        if (pConnection->readBuffer != NULL) {
            ReleaseBuffer(&pConnection->readBuffer);
        }

        if (pConnection->writeBuffer != NULL) {
            ReleaseBuffer(&pConnection->writeBuffer);
        }

        if (pConnection->freeAddress && pConnection->address != NULL) {
            FreeAddress(&pConnection->address);
        }

        if (pConnection->userHandlers != NULL) {
            FreeEventQueue(&pConnection->userHandlers);
        }

        if (pConnection->systemHandlers != NULL) {
            FreeEventQueue(&pConnection->systemHandlers);
        }

        if (pConnection->managedByLock != NULL) {
            FreeLock(&pConnection->managedByLock);
        }

        if (pConnection->stateLock != NULL) {
            FreeLock(&pConnection->stateLock);
        }

        if (pConnection->closedByLock != NULL) {
            FreeLock(&pConnection->closedByLock);
        }

        if (pConnection->stringAllocated) {
            aio4c_free(pConnection->string);
            pConnection->stringAllocated = false;
        }

        aio4c_free(pConnection);
        *connection = NULL;
    }
}
Example #2
0
afs_int32
SBUDB_FreeLock(struct rx_call *call, afs_uint32 lockHandle)
{
    afs_int32 code;

    code = FreeLock(call, lockHandle);
    osi_auditU(call, BUDB_FreLckEvent, code, AUD_END);
    return code;
}
Example #3
0
nsresult
XRemoteClient::SendCommandLine (const char *aProgram, const char *aUsername,
                                const char *aProfile,
                                int32_t argc, char **argv,
                                const char* aDesktopStartupID,
                                char **aResponse, bool *aWindowFound)
{
  PR_LOG(sRemoteLm, PR_LOG_DEBUG, ("XRemoteClient::SendCommandLine"));

  *aWindowFound = false;

  // FindBestWindow() iterates down the window hierarchy, so catch X errors
  // when windows get destroyed before being accessed.
  sOldHandler = XSetErrorHandler(HandleBadWindow);

  Window w = FindBestWindow(aProgram, aUsername, aProfile);

  nsresult rv = NS_OK;

  if (w) {
    // ok, let the caller know that we at least found a window.
    *aWindowFound = true;

    // Ignore BadWindow errors up to this point.  The last request from
    // FindBestWindow() was a synchronous XGetWindowProperty(), so no need to
    // Sync.  Leave the error handler installed to detect if w gets destroyed.
    sGotBadWindow = false;

    // make sure we get the right events on that window
    XSelectInput(mDisplay, w,
                 (PropertyChangeMask|StructureNotifyMask));

    bool destroyed = false;

    // get the lock on the window
    rv = GetLock(w, &destroyed);

    if (NS_SUCCEEDED(rv)) {
      // send our command
      rv = DoSendCommandLine(w, argc, argv, aDesktopStartupID, aResponse,
                             &destroyed);

      // if the window was destroyed, don't bother trying to free the
      // lock.
      if (!destroyed)
          FreeLock(w); // doesn't really matter what this returns

    }
  }

  XSetErrorHandler(sOldHandler);

  PR_LOG(sRemoteLm, PR_LOG_DEBUG, ("SendCommandInternal returning 0x%x\n", rv));

  return rv;
}
BOOLEAN
	CDirControlList::Unload()
{
	BOOLEAN				bRet				= FALSE;

	LPDIR_CONTROL_LIST	lpDirProtectInfo	= NULL;
	PLIST_ENTRY			pNode				= NULL;


	KdPrintKrnl(LOG_PRINTF_LEVEL_INFO, LOG_RECORED_LEVEL_NEED, L"begin");

	__try
	{
		GetLock();

		while (!IsListEmpty(&ms_ListHead))
		{
			lpDirProtectInfo = CONTAINING_RECORD(ms_ListHead.Flink, DIR_CONTROL_LIST, List);
			if (!lpDirProtectInfo)
			{
				KdPrintKrnl(LOG_PRINTF_LEVEL_ERROR, LOG_RECORED_LEVEL_NEED, L"CONTAINING_RECORD failed");
				__leave;
			}

			KdPrintKrnl(LOG_PRINTF_LEVEL_INFO, LOG_RECORED_LEVEL_NEED, L"Rule(%wZ) Type(0x%08x)",
				lpDirProtectInfo->RuleEx.Get(), lpDirProtectInfo->Type);

			RemoveEntryList(&lpDirProtectInfo->List);
			delete lpDirProtectInfo;
			lpDirProtectInfo = NULL;

			ms_ulCount--;
		}

		bRet = TRUE;
	}
	__finally
	{
		FreeLock();

		ExDeleteResourceLite(&ms_Lock);
		RtlZeroMemory(&ms_Lock, sizeof(ms_Lock));
	}

	KdPrintKrnl(LOG_PRINTF_LEVEL_INFO, LOG_RECORED_LEVEL_NEED, L"end");

	return bRet;
}
Example #5
0
/*
* 函数说明:
*		卸载模块,清理卷实例时,会调用该模块,释放卷信息链表
*
* 参数:
*		无			
*
* 返回值:
*		无
*
* 备注:
*		加锁
*/
BOOLEAN 
	CFileName::Unload()
{
	BOOLEAN				bRet			= FALSE;

	LPVOLUME_NAME_INFO	lpVolNameInfo	= NULL;


	KdPrintKrnl(LOG_PRINTF_LEVEL_INFO, LOG_RECORED_LEVEL_NEED, L"begin");

	__try
	{
		GetLock();

		while (!IsListEmpty(&ms_ListHead))
		{
			lpVolNameInfo = CONTAINING_RECORD(ms_ListHead.Flink, VOLUME_NAME_INFO, List);
			if (!lpVolNameInfo)
			{
				KdPrintKrnl(LOG_PRINTF_LEVEL_ERROR, LOG_RECORED_LEVEL_NEED, L"CONTAINING_RECORD failed");
				__leave;
			}

			RemoveEntryList(&lpVolNameInfo->List);
			delete lpVolNameInfo;
			lpVolNameInfo = NULL;
		}

		bRet = TRUE;
	}
	__finally
	{
		FreeLock();

		ExDeleteResourceLite(&ms_Lock);
		RtlZeroMemory(&ms_Lock, sizeof(ms_Lock));
	}

	KdPrintKrnl(LOG_PRINTF_LEVEL_INFO, LOG_RECORED_LEVEL_NEED, L"end");

	return bRet;
}
Example #6
0
BOOLEAN
	CLog::Unload()
{
	BOOLEAN			bRet		= FALSE;

	NTSTATUS		ntStatus	= STATUS_UNSUCCESSFUL;
	KPRIORITY		kPriority	= 0;
	PLIST_ENTRY		pNode		= NULL;
	LPLOG_INFO		lpLogInfo	= NULL;

	CKrnlStr		LogInfo;


	KdPrintKrnl(LOG_PRINTF_LEVEL_INFO, LOG_RECORED_LEVEL_NEEDNOT, L"begin");

	__try
	{
		GetLock();

		ms_bCanInsertLog = FALSE;

		FreeLock();
		if (KeSetEvent(&ms_UnloadEvent, kPriority, FALSE))
		{
			GetLock();
			KdPrintKrnl(LOG_PRINTF_LEVEL_ERROR, LOG_RECORED_LEVEL_NEEDNOT, L"already signaled");
			__leave;
		}

		ntStatus = KeWaitForSingleObject(
			ms_pEThread,
			Executive,
			KernelMode,
			FALSE,
			NULL
			);
		GetLock();
		if (!NT_SUCCESS(ntStatus))
		{
			KdPrintKrnl(LOG_PRINTF_LEVEL_ERROR, LOG_RECORED_LEVEL_NEEDNOT, L"KeWaitForSingleObject failed. (%x)",
				ntStatus);

			__leave;
		}

		while (!IsListEmpty(&ms_ListHead))
		{
			pNode = RemoveHeadList(&ms_ListHead);

			lpLogInfo = CONTAINING_RECORD(pNode, LOG_INFO, List);
			if (!lpLogInfo)
			{
				KdPrintKrnl(LOG_PRINTF_LEVEL_ERROR, LOG_RECORED_LEVEL_NEEDNOT, L"CONTAINING_RECORD failed");
				__leave;
			}

			delete lpLogInfo;
			lpLogInfo = NULL;
		}

		bRet = TRUE;
	}
	__finally
	{
		delete ms_pLogFile;
		ms_pLogFile = NULL;

		delete ms_pLogDir;
		ms_pLogDir = NULL;

		FreeLock();

		ExDeleteResourceLite(&ms_Lock);
		RtlZeroMemory(&ms_Lock, sizeof(ms_Lock));
	}

	KdPrintKrnl(LOG_PRINTF_LEVEL_INFO, LOG_RECORED_LEVEL_NEEDNOT, L"end");

	return bRet;
}
Example #7
0
// Destructor
CondorLockFile::~CondorLockFile( void )
{
	(void) FreeLock( );
}