예제 #1
0
void MI_CALL Perf_Indication_DisableIndications(
    _In_opt_ Perf_Indication_Self* self,
    _In_ MI_Context* indicationsContext,
    _In_opt_z_ const MI_Char* nameSpace,
    _In_opt_z_ const MI_Char* className)
{
    MI_UNREFERENCED_PARAMETER(nameSpace);
    MI_UNREFERENCED_PARAMETER(className);

#ifdef _MSC_VER
    if (self)
    {
        self->indicationContext = 0;

        self->shutdownCalled = MI_TRUE;

        SetThreadpoolTimer(self->indicationTimer, NULL, 0, 0);
        WaitForThreadpoolTimerCallbacks(self->indicationTimer, TRUE);
        CloseThreadpoolTimer(self->indicationTimer);

        self->shutdownCalled = MI_FALSE;
    }

#endif

    MI_PostResult(indicationsContext, MI_RESULT_OK);
}
void phOsalNfc_Timer_Delete(uint32_t TimerId)
{
    uint32_t uIndex;

    //
    // In various places in the code, timers are initialized only
    // after they are first needed.  Despite this fact, they are
    // deleted unconditionally when their context is being deleted
    // Intead of adding an if statement in all places where
    // timers are being deleted, this check is added to prevent 
    // a NULL deref.
    //
    if (NULL == gpphOsalNfc_Context ||
        PH_OSALNFC_TIMER_ID_INVALID == TimerId)
    {
        return;
    }

    uIndex = TimerId - PH_OSAL_TIMER_BASE_ADDRESS;

    EnterCriticalSection(&gpphOsalNfc_Context->TimerLock);

    if(gpphOsalNfc_Context->TimerList[uIndex].pTimer != NULL) 
    {
        SetThreadpoolTimer(gpphOsalNfc_Context->TimerList[uIndex].pTimer, NULL, 0, 0);
        LeaveCriticalSection(&gpphOsalNfc_Context->TimerLock);
        
        WaitForThreadpoolTimerCallbacks(gpphOsalNfc_Context->TimerList[uIndex].pTimer, TRUE);

        EnterCriticalSection(&gpphOsalNfc_Context->TimerLock);

        CloseThreadpoolTimer(gpphOsalNfc_Context->TimerList[uIndex].pTimer);
        gpphOsalNfc_Context->TimerList[uIndex].pTimer    = NULL;
        gpphOsalNfc_Context->TimerList[uIndex].pCallback = NULL;
        gpphOsalNfc_Context->TimerList[uIndex].pContext  = NULL;
        gpphOsalNfc_Context->TimerList[uIndex].bFired    = FALSE;

        uIndex = 0;
        while (uIndex < PH_MAX_OSAL_NUM_TIMERS) 
        {
            if (gpphOsalNfc_Context->TimerList[uIndex].pTimer != NULL)
            {
                break;
            }
            uIndex++;
        }
    }

    LeaveCriticalSection(&gpphOsalNfc_Context->TimerLock);
}
HRESULT CDriverSimBroadcast::Uninitialize()
{
    MethodEntry("...");

    HRESULT hr = S_OK;

    if (_TpBroadcast != nullptr) {
        SetThreadpoolTimer(_TpBroadcast, nullptr, 0, 0);
        WaitForThreadpoolTimerCallbacks(_TpBroadcast, TRUE);
        CloseThreadpoolTimer(_TpBroadcast);
        _TpBroadcast = nullptr;
    }

    _pSocketListener = nullptr;

    MethodReturnHR(hr);
}
NFCSTATUS phOsalNfc_Timer_Stop(uint32_t TimerId)
{
    uint32_t  uIndex;

    if (NULL == gpphOsalNfc_Context ||
        PH_OSALNFC_TIMER_ID_INVALID == TimerId)
    {
        return PHNFCSTVAL(CID_NFC_OSAL, NFCSTATUS_INVALID_PARAMETER);
    }

    uIndex = TimerId - PH_OSAL_TIMER_BASE_ADDRESS;
    
    SetThreadpoolTimer(gpphOsalNfc_Context->TimerList[uIndex].pTimer, NULL, 0, 0);
    WaitForThreadpoolTimerCallbacks(gpphOsalNfc_Context->TimerList[uIndex].pTimer, TRUE);

    EnterCriticalSection(&gpphOsalNfc_Context->TimerLock);

    gpphOsalNfc_Context->TimerList[uIndex].bFired    = FALSE;
    gpphOsalNfc_Context->TimerList[uIndex].pCallback = NULL;
    gpphOsalNfc_Context->TimerList[uIndex].pContext  = NULL;

    LeaveCriticalSection(&gpphOsalNfc_Context->TimerLock);
    return NFCSTATUS_SUCCESS;
}