CCritSection::~CCritSection() { DeleteCriticalSection(&m_CS); }
CNdasServiceDeviceEventHandler::~CNdasServiceDeviceEventHandler() { Uninitialize(); DeleteCriticalSection(&m_DevNotifyMapSection); }
int pthread_mutex_destroy(pthread_mutex_t *mutex) { DeleteCriticalSection((_pthread_mutex_t *) mutex); return 0; }
void vlc_mutex_destroy (vlc_mutex_t *p_mutex) { assert (p_mutex->dynamic); DeleteCriticalSection (&p_mutex->mutex); }
MutexCS::~MutexCS() { DeleteCriticalSection(&m_criticalSection); }
DECLINLINE(int) RTCritSectDelete(PCRITICAL_SECTION pCritSect) { DeleteCriticalSection(pCritSect); return VINF_SUCCESS; }
/*! \brief Opens the wan (dialup, vpn...) adapter. \return If the function succeeds, the return value is the pointer to a properly initialized WAN_ADAPTER structure, otherwise the return value is NULL. */ PWAN_ADAPTER WanPacketOpenAdapter() { PWAN_ADAPTER pWanAdapter = NULL; PBLOB_TABLE pBlobTable = NULL; HBLOB hFilterBlob = NULL; HRESULT hResult; DWORD i; if ( g_hModule == NULL) { g_hModule = LoadLibrarySafe(_T("npp\\ndisnpp.dll")); } if ( g_hModule == NULL) { return NULL; } hResult = CoInitialize(NULL); // // if the calling thread has already initialized COM with a // different threading model, we have this error // however, we are able to support another threading model, // so we try to initialize COM with another threading model. // This new call should succeed with S_FALSE. // if (hResult == RPC_E_CHANGED_MODE) { hResult = CoInitializeEx(NULL, COINIT_APARTMENTTHREADED); //MULTITHREADED threading is only supported on Windows 2000 if (hResult == RPC_E_CHANGED_MODE && IsWindows2000()) { hResult = CoInitializeEx(NULL, COINIT_MULTITHREADED); } } if (hResult != S_OK && hResult != S_FALSE) return NULL; pWanAdapter = (PWAN_ADAPTER)GlobalAlloc(GPTR, sizeof (WAN_ADAPTER)); if ( pWanAdapter == NULL ) goto error; memset(pWanAdapter, 0, sizeof(WAN_ADAPTER)); if ( CreateBlob(&hFilterBlob) != NMERR_SUCCESS ) { goto error; } if ( SetBoolInBlob(hFilterBlob, OWNER_NPP, CATEGORY_CONFIG, TAG_INTERFACE_REALTIME_CAPTURE, TRUE) != NMERR_SUCCESS ) { DestroyBlob( hFilterBlob); goto error; } if ( SetBoolInBlob(hFilterBlob, OWNER_NPP, CATEGORY_LOCATION, TAG_RAS, TRUE) != NMERR_SUCCESS ) { DestroyBlob( hFilterBlob); goto error; } if ( GetNPPBlobTable(hFilterBlob, &pBlobTable) != NMERR_SUCCESS ) { DestroyBlob( hFilterBlob); goto error; } DestroyBlob (hFilterBlob); if ( pBlobTable->dwNumBlobs == 0 || pBlobTable->dwNumBlobs > 1) { ///fixme..... for ( i = 0 ; i < pBlobTable->dwNumBlobs ; i++ ) DestroyBlob(pBlobTable->hBlobs[i]); GlobalFree(pBlobTable); goto error; } pWanAdapter->hCaptureBlob = pBlobTable->hBlobs[0]; GlobalFree(pBlobTable); InitializeCriticalSection(&pWanAdapter->CriticalSection); pWanAdapter->hReadEvent = CreateEvent(NULL, TRUE, FALSE, NULL); if ( pWanAdapter->hReadEvent == NULL ) goto error; #ifdef HAVE_BUGGY_TME_SUPPORT pWanAdapter->MemEx.buffer = (PUCHAR)GlobalAlloc(GPTR, DEFAULT_MEM_EX_SIZE); if (pWanAdapter->MemEx.buffer == NULL) goto error; pWanAdapter->MemEx.size = DEFAULT_MEM_EX_SIZE; pWanAdapter->Tme.active = TME_NONE_ACTIVE; #endif //HAVE_BUGGY_TME_SUPPORT if (CreateNPPInterface(pWanAdapter->hCaptureBlob, IID_IRTC, (void**) &pWanAdapter->pIRTC) == NMERR_SUCCESS && pWanAdapter->pIRTC != NULL) { //create OK if (pWanAdapter->pIRTC->Connect(pWanAdapter->hCaptureBlob, NULL, WanPacketReceiverCallback, (LPVOID)pWanAdapter , NULL) == NMERR_SUCCESS) { //connect OK if (pWanAdapter->pIRTC->Start() == NMERR_SUCCESS) { return pWanAdapter; } else { pWanAdapter->pIRTC->Disconnect(); pWanAdapter->pIRTC->Release(); goto error; } } else { pWanAdapter->pIRTC->Release(); goto error; } } else { goto error; } //awfully never reached // return NULL; error: if (pWanAdapter != NULL) { if (pWanAdapter->hReadEvent != NULL) CloseHandle(pWanAdapter->hReadEvent); DeleteCriticalSection(&pWanAdapter->CriticalSection); if (pWanAdapter->hCaptureBlob) DestroyBlob(pWanAdapter->hCaptureBlob); GlobalFree(pWanAdapter); } CoUninitialize(); return NULL; }
MutexImpl::~MutexImpl() { DeleteCriticalSection(&_cs); }
CriticalSection::~CriticalSection() noexcept { DeleteCriticalSection ((CRITICAL_SECTION*) lock); }
CVideoProcessor::~CVideoProcessor() { DeleteCriticalSection(&m_csLock); }
_PPLXIMP critical_section_impl::~critical_section_impl() { DeleteCriticalSection(reinterpret_cast<LPCRITICAL_SECTION>(&_M_impl)); }
~AbortCookieManager() { Clear(); DeleteCriticalSection(&cookieAccess); }
Player::~Player() { FreeData(); DeleteCriticalSection(&cs); }
//关闭线程,释放资源 CWavePlay::~CWavePlay(void) { CloseDevice(); DeleteCriticalSection(&_waveCriticalSection); }
static void VisualCppMutexDestroy(PlatformSpecificMutex mutex) { CRITICAL_SECTION *critical_section = (CRITICAL_SECTION*)mutex; DeleteCriticalSection(critical_section); delete critical_section; }
~PageRenderer() { if (thread) WaitForSingleObject(thread, INFINITE); delete currBmp; DeleteCriticalSection(&currAccess); }
~ase_fast_mutex() { /* DCHK */ DeleteCriticalSection(&cri); }
CMsgContainerCAN::~CMsgContainerCAN(void) { DeleteCriticalSection(&m_sCritSecDataSync); DeleteCriticalSection(&m_omCritSecFilter); }
void CUdpClient::Destroy() { StopThread(); closesocket(client_socket); DeleteCriticalSection(&critical_section); }
CClientNotificationSink::~CClientNotificationSink() { DeleteCriticalSection( &m_printfCriticalSection ); }
int amp_raw_condition_variable_init(amp_condition_variable_t cond) { int retval = AMP_UNSUPPORTED; assert(NULL != cond); retval = InitializeCriticalSectionAndSpinCount(&cond->access_waiting_threads_count_critsec, AMP_RAW_MUTEX_WINTHREADS_CRITICAL_SECTION_DEFAULT_SPIN_COUNT | AMP_RAW_MUTEX_WINTHREADS_CRITICAL_SECTION_CREATE_IMMEDIATELY_ON_WIN2000); if (FALSE == retval) { DWORD const last_error = GetLastError(); /** * TODO: @todo Differentiate between no-memory and other errors. */ return AMP_ERROR; } retval = InitializeCriticalSectionAndSpinCount(&cond->wake_waiting_threads_critsec, AMP_RAW_MUTEX_WINTHREADS_CRITICAL_SECTION_DEFAULT_SPIN_COUNT | AMP_RAW_MUTEX_WINTHREADS_CRITICAL_SECTION_CREATE_IMMEDIATELY_ON_WIN2000); if (FALSE == retval) { DWORD const last_error = GetLastError(); /** * TODO: @todo Differentiate between no-memory and other errors. */ DeleteCriticalSection(&cond->access_waiting_threads_count_critsec); return AMP_ERROR; } /* Assuming that less threads exist than max possible semaphore count. */ cond->waking_waiting_threads_count_control_sem = CreateSemaphore(NULL, /* No inheritance to child processes */ 0, /* Initially no threads can pass */ LONG_MAX, /* Max semaphore count */ NULL); /* Only intra-process semaphore */ if (NULL == cond->waking_waiting_threads_count_control_sem) { DWORD const last_error = GetLastError(); assert(ERROR_ALREADY_EXISTS != last_error); DeleteCriticalSection(&cond->wake_waiting_threads_critsec); DeleteCriticalSection(&cond->access_waiting_threads_count_critsec); return AMP_ERROR; } cond->finished_waking_waiting_threads_event = CreateEvent(NULL, /* Default security and no inheritance to child processes */ FALSE, /* No manual reset */ 0, /* Initially not signaled */ NULL /* Not inter-process available */ ); if (NULL == cond->finished_waking_waiting_threads_event) { BOOL close_retval = FALSE; DWORD const create_event_error = GetLastError(); assert(ERROR_ALREADY_EXISTS != create_event_error); DeleteCriticalSection(&cond->wake_waiting_threads_critsec); DeleteCriticalSection(&cond->access_waiting_threads_count_critsec); close_retval = CloseHandle(&cond->waking_waiting_threads_count_control_sem); if (FALSE == close_retval) { DWORD const close_handle_error = GetLastError(); assert(ERROR_INVALID_HANDLE != close_handle_error); assert(0); } /* I don't know the possible return values of GetLastError if event * creation didn't work - just returning an error code. */ return AMP_ERROR; } cond->waiting_thread_count = 0l; cond->broadcast_in_progress = FALSE; /* Preliminary tests that waiting_thread_count and broadcast_in_progress * are correctly aligned to allow atomic access to them. * * TODO: @todo Re-enable alignment test assertions. * * TODO: @todo Check which alignment is needed on 32bit and 64bit systems * and on which platforms. */ /* assert(0x0 == ((uintptr_t)(&cond->waiting_thread_count) & 0x3)); */ /* assert(0x0 ==((uintptr_t)(&cond->broadcast_in_progress) & 0x3)); */ return AMP_SUCCESS; }
void TRI_DestroyCondition(TRI_condition_t* cond) { DeleteCriticalSection(&cond->_lockWaiters); }
Lock::~Lock(void) { DeleteCriticalSection(&_lock); }
void opj_mutex_destroy(opj_mutex_t* mutex) { if( !mutex ) return; DeleteCriticalSection( &(mutex->cs) ); opj_free( mutex ); }
int __cdecl main(int argc, char **argv) { DWORD dwRet; DWORD dwRet1; bTestResult = FAIL; if ((PAL_Initialize(argc,argv)) != 0) { return(bTestResult); } /* * Create Critical Section Object */ InitializeCriticalSection ( &CriticalSection ); EnterCriticalSection ( &CriticalSection ); hThread[0] = CreateThread(NULL, 0, &ThreadTest1, (LPVOID) 0, CREATE_SUSPENDED, &dwThreadId[0]); if (hThread[0] == NULL) { Trace("PALSUITE ERROR: CreateThread(%p, %d, %p, %p, %d, %p) call " "failed.\nGetLastError returned %d.\n", NULL, 0, &ThreadTest1, (LPVOID) 0, CREATE_SUSPENDED, &dwThreadId[0], GetLastError()); LeaveCriticalSection(&CriticalSection); DeleteCriticalSection ( &CriticalSection ); Fail(""); } hThread[1] = CreateThread(NULL, 0, &ThreadTest2, (LPVOID) 0, CREATE_SUSPENDED, &dwThreadId[1]); if (hThread[1] == NULL) { Trace("PALSUITE ERROR: CreateThread(%p, %d, %p, %p, %d, %p) call " "failed.\nGetLastError returned %d.\n", NULL, 0, &ThreadTest2, (LPVOID) 0, CREATE_SUSPENDED, &dwThreadId[1], GetLastError()); LeaveCriticalSection(&CriticalSection); dwRet = ResumeThread(hThread[0]); if (-1 == dwRet) { Trace("PALSUITE ERROR: ResumeThread(%p) call failed.\n" "GetLastError returned '%d'.\n", hThread[0], GetLastError()); } dwRet = WaitForSingleObject(hThread[0], 10000); if (WAIT_OBJECT_0 == dwRet) { Trace("PALSUITE ERROR: WaitForSingleObject(%p, %d) call " "failed. '%d' was returned instead of the expected '%d'.\n" "GetLastError returned '%d'.\n", hThread[0], 10000, dwRet, WAIT_OBJECT_0, GetLastError()); } if (0 == CloseHandle(hThread[0])) { Trace("PALSUITE NOTIFICATION: CloseHandle(%p) call failed.\n" "GetLastError returned %d. Not failing tests.\n", hThread[0], GetLastError()); } DeleteCriticalSection(&CriticalSection); Fail(""); } /* * Set other thread priorities to be higher than ours & Sleep to ensure * we give up the processor. */ dwRet = (DWORD) SetThreadPriority(hThread[0], THREAD_PRIORITY_ABOVE_NORMAL); if (0 == dwRet) { Trace("PALSUITE ERROR: SetThreadPriority(%p, %d) call failed.\n" "GetLastError returned %d", hThread[0], THREAD_PRIORITY_ABOVE_NORMAL, GetLastError()); } dwRet = (DWORD) SetThreadPriority(hThread[1], THREAD_PRIORITY_ABOVE_NORMAL); if (0 == dwRet) { Trace("PALSUITE ERROR: SetThreadPriority(%p, %d) call failed.\n" "GetLastError returned %d", hThread[1], THREAD_PRIORITY_ABOVE_NORMAL, GetLastError()); } dwRet = ResumeThread(hThread[0]); if (-1 == dwRet) { Trace("PALSUITE ERROR: ResumeThread(%p, %d) call failed.\n" "GetLastError returned %d", hThread[0], GetLastError() ); } dwRet = ResumeThread(hThread[1]); if (-1 == dwRet) { Trace("PALSUITE ERROR: ResumeThread(%p, %d) call failed.\n" "GetLastError returned %d", hThread[0], GetLastError()); } Sleep (0); LeaveCriticalSection (&CriticalSection); dwRet = WaitForSingleObject(hThread[0], 10000); dwRet1 = WaitForSingleObject(hThread[1], 10000); if ((WAIT_OBJECT_0 == dwRet) || (WAIT_OBJECT_0 == dwRet1)) { if ((1 == flags[0] && 0 == flags[1]) || (0 == flags[0] && 1 == flags[1])) { bTestResult = PASS; } else { bTestResult = FAIL; Trace ("PALSUITE ERROR: flags[%d] = {%d,%d}. These values are" "inconsistent.\nCriticalSection test failed.\n", NUM_BLOCKING_THREADS, flags[0], flags[1]); } /* Fail the test if both threads returned WAIT_OBJECT_0 */ if ((WAIT_OBJECT_0 == dwRet) && (WAIT_OBJECT_0 == dwRet1)) { bTestResult = FAIL; Trace ("PALSUITE ERROR: WaitForSingleObject(%p, %d) and " "WaitForSingleObject(%p, %d)\nboth returned dwRet = '%d'\n" "One should have returned WAIT_TIMEOUT ('%d').\n", hThread[0], 10000, hThread[1], 10000, dwRet, WAIT_TIMEOUT); } } else { bTestResult = FAIL; Trace ("PALSUITE ERROR: WaitForSingleObject(%p, %d) and " "WaitForSingleObject(%p, %d)\nReturned dwRet = '%d' and\n" "dwRet1 = '%d' respectively.\n", hThread[0], 10000, hThread[1], 10000, dwRet, dwRet1); } if (WAIT_OBJECT_0 == dwRet) { if (0 == CloseHandle(hThread[0])) { Trace("PALSUITE NOTIFICATION: CloseHandle(%p) call failed.\n" "GetLastError returned %d. Not failing tests.\n", hThread[0], GetLastError()); } } if (WAIT_OBJECT_0 == dwRet1) { if (0 == CloseHandle(hThread[1])) { Trace("PALSUITE NOTIFICATION: CloseHandle(%p) call failed.\n" "GetLastError returned %d. Not failing tests.\n", hThread[1], GetLastError()); } } /* Leaking the CS on purpose, since there is still a thread waiting on it */ PAL_TerminateEx(bTestResult); return (bTestResult); }
CUartCtrl::~CUartCtrl() { CloseUart(); DeleteCriticalSection(&m_csCom); }
bool CLogger::lock_deinit() { DeleteCriticalSection(&m_crit); return true; }
void ssl_lock_dyn_destroy_callback(CRYPTO_dynlock_value* l, const char *file, int line) { DeleteCriticalSection(&l->lock); free(l); }
Mutex::~Mutex() { DeleteCriticalSection(&m_mutex.m_internalMutex); }
Mutex::~Mutex() { // http://msdn.microsoft.com/en-us/library/ms686360(VS.85).aspx DeleteCriticalSection( &m_kCriticalSection ); }