/** * Destroys an module after the reference count has reached zero. * * @param pDbgMod The module instance. */ static void rtDbgModDestroy(PRTDBGMODINT pDbgMod) { /* * Close the debug info interpreter first, then the image interpret. */ RTCritSectEnter(&pDbgMod->CritSect); /* paranoia */ if (pDbgMod->pDbgVt) { pDbgMod->pDbgVt->pfnClose(pDbgMod); pDbgMod->pDbgVt = NULL; pDbgMod->pvDbgPriv = NULL; } if (pDbgMod->pImgVt) { pDbgMod->pImgVt->pfnClose(pDbgMod); pDbgMod->pImgVt = NULL; pDbgMod->pvImgPriv = NULL; } /* * Free the resources. */ ASMAtomicWriteU32(&pDbgMod->u32Magic, ~RTDBGMOD_MAGIC); RTStrCacheRelease(g_hDbgModStrCache, pDbgMod->pszName); RTStrCacheRelease(g_hDbgModStrCache, pDbgMod->pszImgFile); RTStrCacheRelease(g_hDbgModStrCache, pDbgMod->pszDbgFile); RTCritSectLeave(&pDbgMod->CritSect); /* paranoia */ RTCritSectDelete(&pDbgMod->CritSect); RTMemFree(pDbgMod); }
RTDECL(int) RTPipeClose(RTPIPE hPipe) { RTPIPEINTERNAL *pThis = hPipe; if (pThis == NIL_RTPIPE) return VINF_SUCCESS; AssertPtrReturn(pThis, VERR_INVALID_PARAMETER); AssertReturn(pThis->u32Magic == RTPIPE_MAGIC, VERR_INVALID_HANDLE); /* * Do the cleanup. */ AssertReturn(ASMAtomicCmpXchgU32(&pThis->u32Magic, ~RTPIPE_MAGIC, RTPIPE_MAGIC), VERR_INVALID_HANDLE); RTCritSectEnter(&pThis->CritSect); Assert(pThis->cUsers == 0); if (!pThis->fRead && pThis->fIOPending) rtPipeWriteCheckCompletion(pThis); CloseHandle(pThis->hPipe); pThis->hPipe = INVALID_HANDLE_VALUE; CloseHandle(pThis->Overlapped.hEvent); pThis->Overlapped.hEvent = NULL; RTMemFree(pThis->pbBounceBuf); pThis->pbBounceBuf = NULL; RTCritSectLeave(&pThis->CritSect); RTCritSectDelete(&pThis->CritSect); RTMemFree(pThis); return VINF_SUCCESS; }
/** * Closes the specified stream. * * @returns iprt status code. * @param pStream The stream to close. */ RTR3DECL(int) RTStrmClose(PRTSTREAM pStream) { if (!pStream) return VINF_SUCCESS; AssertReturn(RT_VALID_PTR(pStream) && pStream->u32Magic == RTSTREAM_MAGIC, VERR_INVALID_PARAMETER); if (!fclose(pStream->pFile)) { pStream->u32Magic = 0xdeaddead; pStream->pFile = NULL; #ifndef HAVE_FWRITE_UNLOCKED if (pStream->pCritSect) { RTCritSectEnter(pStream->pCritSect); RTCritSectLeave(pStream->pCritSect); RTCritSectDelete(pStream->pCritSect); RTMemFree(pStream->pCritSect); pStream->pCritSect = NULL; } #endif RTMemFree(pStream); return VINF_SUCCESS; } return RTErrConvertFromErrno(errno); }
/** * Destroys a async I/O manager. * * @returns nothing. * @param pAioMgr The async I/O manager to destroy. */ static void pdmacFileAioMgrDestroy(PPDMASYNCCOMPLETIONEPCLASSFILE pEpClassFile, PPDMACEPFILEMGR pAioMgr) { int rc = pdmacFileAioMgrShutdown(pAioMgr); AssertRC(rc); /* Unlink from the list. */ rc = RTCritSectEnter(&pEpClassFile->CritSect); AssertRC(rc); PPDMACEPFILEMGR pPrev = pAioMgr->pPrev; PPDMACEPFILEMGR pNext = pAioMgr->pNext; if (pPrev) pPrev->pNext = pNext; else pEpClassFile->pAioMgrHead = pNext; if (pNext) pNext->pPrev = pPrev; pEpClassFile->cAioMgrs--; rc = RTCritSectLeave(&pEpClassFile->CritSect); AssertRC(rc); /* Free the resources. */ RTCritSectDelete(&pAioMgr->CritSectBlockingEvent); RTSemEventDestroy(pAioMgr->EventSem); if (pAioMgr->enmMgrType != PDMACEPFILEMGRTYPE_SIMPLE) pdmacFileAioMgrNormalDestroy(pAioMgr); MMR3HeapFree(pAioMgr); }
/** * @interface_method_impl{TXSTRANSPORT,pfnInit} */ static DECLCALLBACK(int) txsTcpInit(void) { int rc = RTCritSectInit(&g_TcpCritSect); if (RT_SUCCESS(rc) && g_enmTcpMode != TXSTCPMODE_CLIENT) { rc = RTTcpServerCreateEx(g_szTcpBindAddr[0] ? g_szTcpBindAddr : NULL, g_uTcpBindPort, &g_pTcpServer); if (RT_FAILURE(rc)) { if (rc == VERR_NET_DOWN) { RTMsgInfo("RTTcpServerCreateEx(%s, %u,) failed: %Rrc, retrying for 20 seconds...\n", g_szTcpBindAddr[0] ? g_szTcpBindAddr : NULL, g_uTcpBindPort, rc); uint64_t StartMs = RTTimeMilliTS(); do { RTThreadSleep(1000); rc = RTTcpServerCreateEx(g_szTcpBindAddr[0] ? g_szTcpBindAddr : NULL, g_uTcpBindPort, &g_pTcpServer); } while ( rc == VERR_NET_DOWN && RTTimeMilliTS() - StartMs < 20000); if (RT_SUCCESS(rc)) RTMsgInfo("RTTcpServerCreateEx succceeded.\n"); } if (RT_FAILURE(rc)) { g_pTcpServer = NULL; RTCritSectDelete(&g_TcpCritSect); RTMsgError("RTTcpServerCreateEx(%s, %u,) failed: %Rrc\n", g_szTcpBindAddr[0] ? g_szTcpBindAddr : NULL, g_uTcpBindPort, rc); } } } return rc; }
/** * Allocates and acquires the lock for the stream. * * @returns IPRT status. * @param pStream The stream (valid). */ static int rtStrmAllocLock(PRTSTREAM pStream) { Assert(pStream->pCritSect == NULL); PRTCRITSECT pCritSect = (PRTCRITSECT)RTMemAlloc(sizeof(*pCritSect)); if (!pCritSect) return VERR_NO_MEMORY; /* The native stream lock are normally not recursive. */ int rc = RTCritSectInitEx(pCritSect, RTCRITSECT_FLAGS_NO_NESTING, NIL_RTLOCKVALCLASS, RTLOCKVAL_SUB_CLASS_NONE, "RTSemSpinMutex"); if (RT_SUCCESS(rc)) { rc = RTCritSectEnter(pCritSect); if (RT_SUCCESS(rc)) { if (RT_LIKELY(ASMAtomicCmpXchgPtr(&pStream->pCritSect, pCritSect, NULL))) return VINF_SUCCESS; RTCritSectLeave(pCritSect); } RTCritSectDelete(pCritSect); } RTMemFree(pCritSect); /* Handle the lost race case... */ pCritSect = ASMAtomicReadPtrT(&pStream->pCritSect, PRTCRITSECT); if (pCritSect) return RTCritSectEnter(pCritSect); return rc; }
void hgcmObjUninit (void) { if (RTCritSectIsInitialized (&g_critsect)) { RTCritSectDelete (&g_critsect); } }
/** * Copy the device and free resources associated with the backend. */ static DECLCALLBACK(void) usbProxyWinClose(PUSBPROXYDEV pProxyDev) { /* Here we just close the device and free up p->priv * there is no need to do anything like cancel outstanding requests * that will have been done already */ PPRIV_USBW32 pPriv = USBPROXYDEV_2_DATA(pProxyDev, PPRIV_USBW32); Assert(pPriv); if (!pPriv) return; Log(("usbProxyWinClose: %p\n", pPriv->hDev)); if (pPriv->hDev != INVALID_HANDLE_VALUE) { Assert(pPriv->fClaimed); USBSUP_RELEASEDEV in; DWORD cbReturned = 0; in.bInterfaceNumber = pPriv->bInterfaceNumber; if (!DeviceIoControl(pPriv->hDev, SUPUSB_IOCTL_USB_RELEASE_DEVICE, &in, sizeof(in), NULL, 0, &cbReturned, NULL)) { Log(("usbproxy: usbProxyWinClose: DeviceIoControl %#x failed with %#x!!\n", pPriv->hDev, GetLastError())); } if (!CloseHandle(pPriv->hDev)) AssertLogRelMsgFailed(("usbproxy: usbProxyWinClose: CloseHandle %#x failed with %#x!!\n", pPriv->hDev, GetLastError())); pPriv->hDev = INVALID_HANDLE_VALUE; } CloseHandle(pPriv->hEventWakeup); RTCritSectDelete(&pPriv->CritSect); RTMemFree(pPriv->paQueuedUrbs); RTMemFree(pPriv->paHandles); }
VBoxNetBaseService::~VBoxNetBaseService() { /* * Close the interface connection. */ if (m) { shutdown(); if (m->m_hIf != INTNET_HANDLE_INVALID) { INTNETIFCLOSEREQ CloseReq; CloseReq.Hdr.u32Magic = SUPVMMR0REQHDR_MAGIC; CloseReq.Hdr.cbReq = sizeof(CloseReq); CloseReq.pSession = m->m_pSession; CloseReq.hIf = m->m_hIf; m->m_hIf = INTNET_HANDLE_INVALID; int rc = SUPR3CallVMMR0Ex(NIL_RTR0PTR, NIL_VMCPUID, VMMR0_DO_INTNET_IF_CLOSE, 0, &CloseReq.Hdr); AssertRC(rc); } if (m->m_pSession != NIL_RTR0PTR) { SUPR3Term(false /*fForced*/); m->m_pSession = NIL_RTR0PTR; } RTCritSectDelete(&m->m_csThis); delete m; m = NULL; } }
/** * @interface_method_impl{TXSTRANSPORT,pfnTerm} */ static DECLCALLBACK(void) txsTcpTerm(void) { /* Signal thread */ if (RTCritSectIsInitialized(&g_TcpCritSect)) { RTCritSectEnter(&g_TcpCritSect); g_fTcpStopConnecting = true; RTCritSectLeave(&g_TcpCritSect); } if (g_hThreadTcpConnect != NIL_RTTHREAD) { RTThreadUserSignal(g_hThreadTcpConnect); RTTcpClientCancelConnect(&g_pTcpConnectCancelCookie); } /* Shut down the server (will wake up thread). */ if (g_pTcpServer) { Log(("txsTcpTerm: Destroying server...\n")); int rc = RTTcpServerDestroy(g_pTcpServer); if (RT_FAILURE(rc)) RTMsgInfo("RTTcpServerDestroy failed in txsTcpTerm: %Rrc", rc); g_pTcpServer = NULL; } /* Shut down client */ if (g_hTcpClient != NIL_RTSOCKET) { if (g_fTcpClientFromServer) { Log(("txsTcpTerm: Disconnecting client...\n")); int rc = RTTcpServerDisconnectClient2(g_hTcpClient); if (RT_FAILURE(rc)) RTMsgInfo("RTTcpServerDisconnectClient2(%RTsock) failed in txsTcpTerm: %Rrc", g_hTcpClient, rc); } else { int rc = RTTcpClientClose(g_hTcpClient); if (RT_FAILURE(rc)) RTMsgInfo("RTTcpClientClose(%RTsock) failed in txsTcpTerm: %Rrc", g_hTcpClient, rc); } g_hTcpClient = NIL_RTSOCKET; } /* Clean up stashing. */ RTMemFree(g_pbTcpStashed); g_pbTcpStashed = NULL; g_cbTcpStashed = 0; g_cbTcpStashedAlloced = 0; /* Wait for the thread (they should've had some time to quit by now). */ txsTcpConnectWaitOnThreads(15000); /* Finally, clean up the critical section. */ if (RTCritSectIsInitialized(&g_TcpCritSect)) RTCritSectDelete(&g_TcpCritSect); Log(("txsTcpTerm: done\n")); }
/** * Destroy a heap. * * @param pHeap Heap handle. */ void mmR3HeapDestroy(PMMHEAP pHeap) { /* * Start by deleting the lock, that'll trap anyone * attempting to use the heap. */ RTCritSectDelete(&pHeap->Lock); /* * Walk the node list and free all the memory. */ PMMHEAPHDR pHdr = pHeap->pHead; while (pHdr) { void *pv = pHdr; pHdr = pHdr->pNext; RTMemFree(pv); } /* * Free the stat nodes. */ /** @todo free all nodes in a AVL tree. */ RTMemFree(pHeap); }
AutostartDb::~AutostartDb() { #ifdef RT_OS_LINUX RTCritSectDelete(&this->CritSect); if (m_pszAutostartDbPath) RTStrFree(m_pszAutostartDbPath); #endif }
/** * Terminate the info handlers. * * @returns VBox status code. * @param pVM Pointer to the VM. */ int dbgfR3InfoTerm(PVM pVM) { /* * Delete the crit sect. */ int rc = RTCritSectDelete(&pVM->dbgf.s.InfoCritSect); AssertRC(rc); return rc; }
void GuestBase::baseUninit(void) { LogFlowThisFuncEnter(); int rc = RTCritSectDelete(&mWaitEventCritSect); LogFlowFuncLeaveRC(rc); /* No return value. */ }
UIFrameBuffer::~UIFrameBuffer() { /* Deinitialize critical-section: */ RTCritSectDelete(&m_critSect); /* Disconnect handlers: */ if (m_pMachineView) cleanupConnections(); }
/** * Node destructor. * * @returns true. * @param pNode The node. * @param fLocked Whether it's locked. */ static bool vboxfuseNodeDestroy(PVBOXFUSENODE pNode, bool fLocked) { Assert(pNode->cRefs == 0); /* * Type specific cleanups. */ switch (pNode->enmType) { case VBOXFUSETYPE_DIRECTORY: { PVBOXFUSEDIR pDir = (PVBOXFUSEDIR)pNode; RTMemFree(pDir->paEntries); pDir->paEntries = NULL; pDir->cEntries = 0; break; } case VBOXFUSETYPE_FLAT_IMAGE: { PVBOXFUSEFLATIMAGE pFlatImage = (PVBOXFUSEFLATIMAGE)pNode; if (pFlatImage->pDisk) { int rc2 = VDClose(pFlatImage->pDisk, false /* fDelete */); AssertRC(rc2); pFlatImage->pDisk = NULL; } RTStrFree(pFlatImage->pszFormat); pFlatImage->pszFormat = NULL; break; } case VBOXFUSETYPE_CONTROL_PIPE: break; default: AssertMsgFailed(("%d\n", pNode->enmType)); break; } /* * Generic cleanup. */ pNode->enmType = VBOXFUSETYPE_INVALID; pNode->pszName = NULL; /* * Unlock and destroy the lock, before we finally frees the node. */ if (fLocked) RTCritSectLeave(&pNode->CritSect); RTCritSectDelete(&pNode->CritSect); RTMemFree(pNode); return true; }
RTDECL(int) RTSemSpinMutexDestroy(RTSEMSPINMUTEX hSpinMtx) { if (hSpinMtx == NIL_RTSEMSPINMUTEX) return VERR_INVALID_PARAMETER; PRTCRITSECT pCritSect = (PRTCRITSECT)hSpinMtx; int rc = RTCritSectDelete(pCritSect); if (RT_SUCCESS(rc)) RTMemFree(pCritSect); return rc; }
RTDECL(int) RTLocalIpcServerCreate(PRTLOCALIPCSERVER phServer, const char *pszName, uint32_t fFlags) { /* * Basic parameter validation. */ AssertPtrReturn(phServer, VERR_INVALID_POINTER); AssertPtrReturn(pszName, VERR_INVALID_POINTER); AssertReturn(*pszName, VERR_INVALID_PARAMETER); AssertReturn(!(fFlags & ~(RTLOCALIPC_FLAGS_VALID_MASK)), VERR_INVALID_PARAMETER); AssertReturn((fFlags & RTLOCALIPC_FLAGS_MULTI_SESSION), VERR_INVALID_PARAMETER); /** @todo Implement !RTLOCALIPC_FLAGS_MULTI_SESSION */ /* * Allocate and initialize the instance data. */ size_t cchName = strlen(pszName); size_t cch = RT_OFFSETOF(RTLOCALIPCSERVERINT, szName[cchName + sizeof(RTLOCALIPC_WIN_PREFIX)]); PRTLOCALIPCSERVERINT pThis = (PRTLOCALIPCSERVERINT)RTMemAlloc(cch); if (!pThis) return VERR_NO_MEMORY; pThis->u32Magic = RTLOCALIPCSERVER_MAGIC; pThis->cRefs = 1; /* the one we return */ pThis->fCancelled = false; memcpy(pThis->szName, RTLOCALIPC_WIN_PREFIX, sizeof(RTLOCALIPC_WIN_PREFIX) - 1); memcpy(&pThis->szName[sizeof(RTLOCALIPC_WIN_PREFIX) - 1], pszName, cchName + 1); int rc = RTCritSectInit(&pThis->CritSect); if (RT_SUCCESS(rc)) { pThis->hEvent = CreateEvent(NULL /*lpEventAttributes*/, TRUE /*bManualReset*/, FALSE /*bInitialState*/, NULL /*lpName*/); if (pThis->hEvent != NULL) { RT_ZERO(pThis->OverlappedIO); pThis->OverlappedIO.Internal = STATUS_PENDING; pThis->OverlappedIO.hEvent = pThis->hEvent; rc = rtLocalIpcServerWinCreatePipeInstance(&pThis->hNmPipe, pThis->szName, true /* fFirst */); if (RT_SUCCESS(rc)) { *phServer = pThis; return VINF_SUCCESS; } BOOL fRc = CloseHandle(pThis->hEvent); AssertMsg(fRc, ("%d\n", GetLastError())); NOREF(fRc); } else rc = RTErrConvertFromWin32(GetLastError()); int rc2 = RTCritSectDelete(&pThis->CritSect); AssertRC(rc2); } RTMemFree(pThis); return rc; }
RemoteUSBBackend::~RemoteUSBBackend() { Assert(cRefs == 0); if (RTCritSectIsInitialized(&mCritsect)) { RTCritSectDelete(&mCritsect); } RTMemFree(mpvDeviceList); mServer->usbBackendRemoveFromList(this); }
static void pdmacFileTerminate(PPDMASYNCCOMPLETIONEPCLASS pClassGlobals) { PPDMASYNCCOMPLETIONEPCLASSFILE pEpClassFile = (PPDMASYNCCOMPLETIONEPCLASSFILE)pClassGlobals; /* All endpoints should be closed at this point. */ AssertMsg(!pEpClassFile->Core.pEndpointsHead, ("There are still endpoints left\n")); /* Destroy all left async I/O managers. */ while (pEpClassFile->pAioMgrHead) pdmacFileAioMgrDestroy(pEpClassFile, pEpClassFile->pAioMgrHead); RTCritSectDelete(&pEpClassFile->CritSect); }
static int pdmNsBwGroupCreate(PPDMNETSHAPER pShaper, const char *pcszBwGroup, uint64_t cbTransferPerSecMax) { LogFlowFunc(("pShaper=%#p pcszBwGroup=%#p{%s} cbTransferPerSecMax=%u\n", pShaper, pcszBwGroup, pcszBwGroup, cbTransferPerSecMax)); AssertPtrReturn(pShaper, VERR_INVALID_POINTER); AssertPtrReturn(pcszBwGroup, VERR_INVALID_POINTER); AssertReturn(*pcszBwGroup != '\0', VERR_INVALID_PARAMETER); int rc; PPDMNSBWGROUP pBwGroup = pdmNsBwGroupFindById(pShaper, pcszBwGroup); if (!pBwGroup) { rc = MMR3HeapAllocZEx(pShaper->pVM, MM_TAG_PDM_NET_SHAPER, sizeof(PDMNSBWGROUP), (void **)&pBwGroup); if (RT_SUCCESS(rc)) { rc = RTCritSectInit(&pBwGroup->cs); if (RT_SUCCESS(rc)) { pBwGroup->pszName = RTStrDup(pcszBwGroup); if (pBwGroup->pszName) { pBwGroup->pShaper = pShaper; pBwGroup->cRefs = 0; pdmNsBwGroupSetLimit(pBwGroup, cbTransferPerSecMax); ; pBwGroup->cbTokensLast = pBwGroup->cbBucketSize; pBwGroup->tsUpdatedLast = RTTimeSystemNanoTS(); LogFlowFunc(("pcszBwGroup={%s} cbBucketSize=%u\n", pcszBwGroup, pBwGroup->cbBucketSize)); pdmNsBwGroupLink(pBwGroup); return VINF_SUCCESS; } RTCritSectDelete(&pBwGroup->cs); } MMR3HeapFree(pBwGroup); } else rc = VERR_NO_MEMORY; } else rc = VERR_ALREADY_EXISTS; LogFlowFunc(("returns rc=%Rrc\n", rc)); return rc; }
EventQueue::~EventQueue(void) { int rc = RTCritSectDelete(&mCritSect); AssertRC(rc); rc = RTSemEventDestroy(mSemEvent); AssertRC(rc); EventQueueListIterator it = mEvents.begin(); while (it != mEvents.end()) { (*it)->Release(); it = mEvents.erase(it); } }
SDLFramebuffer::~SDLFramebuffer() { LogFlow(("SDLFramebuffer::~SDLFramebuffer\n")); RTCritSectDelete(&mUpdateLock); AssertMsg(mSdlNativeThread == RTThreadNativeSelf(), ("Wrong thread! SDL is not threadsafe!\n")); SDL_QuitSubSystem(SDL_INIT_VIDEO); #ifdef VBOX_SECURELABEL if (mLabelFont) TTF_CloseFont(mLabelFont); TTF_Quit(); #endif mScreen = NULL; }
/** * Call when the reference count reaches 0. * Caller owns the critsect. * @param pThis The instance to destroy. */ static void rtLocalIpcSessionWinDestroy(PRTLOCALIPCSESSIONINT pThis) { BOOL fRc = CloseHandle(pThis->hNmPipe); AssertMsg(fRc, ("%d\n", GetLastError())); NOREF(fRc); pThis->hNmPipe = INVALID_HANDLE_VALUE; fRc = CloseHandle(pThis->hEvent); AssertMsg(fRc, ("%d\n", GetLastError())); NOREF(fRc); pThis->hEvent = NULL; RTCritSectLeave(&pThis->CritSect); RTCritSectDelete(&pThis->CritSect); RTMemFree(pThis); }
/** * Create a session instance. * * @returns IPRT status code. * * @param phClientSession Where to store the session handle on success. * @param hNmPipeSession The named pipe handle. This will be consumed by this session, meaning on failure * to create the session it will be closed. */ static int rtLocalIpcWinCreateSession(PRTLOCALIPCSESSION phClientSession, HANDLE hNmPipeSession) { AssertPtrReturn(phClientSession, VERR_INVALID_POINTER); AssertReturn(hNmPipeSession != INVALID_HANDLE_VALUE, VERR_INVALID_HANDLE); int rc; /* * Allocate and initialize the session instance data. */ PRTLOCALIPCSESSIONINT pThis = (PRTLOCALIPCSESSIONINT)RTMemAlloc(sizeof(*pThis)); if (pThis) { pThis->u32Magic = RTLOCALIPCSESSION_MAGIC; pThis->cRefs = 1; /* our ref */ pThis->fCancelled = false; pThis->fIOPending = false; pThis->fZeroByteRead = false; pThis->hNmPipe = hNmPipeSession; rc = RTCritSectInit(&pThis->CritSect); if (RT_SUCCESS(rc)) { pThis->hEvent = CreateEvent(NULL /*lpEventAttributes*/, TRUE /*bManualReset*/, FALSE /*bInitialState*/, NULL /*lpName*/); if (pThis->hEvent != NULL) { RT_ZERO(pThis->OverlappedIO); pThis->OverlappedIO.Internal = STATUS_PENDING; pThis->OverlappedIO.hEvent = pThis->hEvent; *phClientSession = pThis; return VINF_SUCCESS; } /* bail out */ rc = RTErrConvertFromWin32(GetLastError()); RTCritSectDelete(&pThis->CritSect); } RTMemFree(pThis); } else rc = VERR_NO_MEMORY; BOOL fRc = CloseHandle(hNmPipeSession); AssertMsg(fRc, ("%d\n", GetLastError())); NOREF(fRc); return rc; }
void GuestBase::unregisterEventListener(void) { if (mListener) { ComPtr<IEventSource> es; HRESULT hr = mConsole->COMGETTER(EventSource)(es.asOutParam()); if (SUCCEEDED(hr)) { Assert(!es.isNull()); es->UnregisterListener(mListener); } mListener.setNull(); } int rc2 = RTCritSectDelete(&mWaitEventCritSect); AssertRC(rc2); }
/** * Creates a module based on the default debug info container. * * This can be used to manually load a module and its symbol. The primary user * group is the debug info interpreters, which use this API to create an * efficient debug info container behind the scenes and forward all queries to * it once the info has been loaded. * * @returns IPRT status code. * * @param phDbgMod Where to return the module handle. * @param pszName The name of the module (mandatory). * @param cbSeg The size of initial segment. If zero, segments will * have to be added manually using RTDbgModSegmentAdd. * @param fFlags Flags reserved for future extensions, MBZ for now. */ RTDECL(int) RTDbgModCreate(PRTDBGMOD phDbgMod, const char *pszName, RTUINTPTR cbSeg, uint32_t fFlags) { /* * Input validation and lazy initialization. */ AssertPtrReturn(phDbgMod, VERR_INVALID_POINTER); *phDbgMod = NIL_RTDBGMOD; AssertPtrReturn(pszName, VERR_INVALID_POINTER); AssertReturn(*pszName, VERR_INVALID_PARAMETER); AssertReturn(fFlags == 0, VERR_INVALID_PARAMETER); int rc = rtDbgModLazyInit(); if (RT_FAILURE(rc)) return rc; /* * Allocate a new module instance. */ PRTDBGMODINT pDbgMod = (PRTDBGMODINT)RTMemAllocZ(sizeof(*pDbgMod)); if (!pDbgMod) return VERR_NO_MEMORY; pDbgMod->u32Magic = RTDBGMOD_MAGIC; pDbgMod->cRefs = 1; rc = RTCritSectInit(&pDbgMod->CritSect); if (RT_SUCCESS(rc)) { pDbgMod->pszName = RTStrCacheEnter(g_hDbgModStrCache, pszName); if (pDbgMod->pszName) { rc = rtDbgModContainerCreate(pDbgMod, cbSeg); if (RT_SUCCESS(rc)) { *phDbgMod = pDbgMod; return rc; } RTStrCacheRelease(g_hDbgModStrCache, pDbgMod->pszName); } RTCritSectDelete(&pDbgMod->CritSect); } RTMemFree(pDbgMod); return rc; }
void renderspuWindowTerm( WindowInfo *window ) { GET_CONTEXT(pOldCtx); /* ensure no concurrent draws can take place */ renderspuVBoxCompositorSet(window, NULL); renderspuVBoxPresentBlitterCleanup(window); renderspu_SystemDestroyWindow( window ); RTCritSectDelete(&window->CompositorLock); /* check if this window is bound to some ctx. Note: window pointer is already freed here */ crHashtableWalk(render_spu.contextTable, renderspuCheckCurrentCtxWindowCB, window); /* restore current context */ { GET_CONTEXT(pNewCtx); if (pNewCtx!=pOldCtx) { renderspuMakeCurrent(pOldCtx&&pOldCtx->currentWindow ? pOldCtx->currentWindow->BltInfo.Base.id:CR_RENDER_DEFAULT_WINDOW_ID, 0, pOldCtx ? pOldCtx->BltInfo.Base.id:CR_RENDER_DEFAULT_CONTEXT_ID); } } }
/** * Terminate the network shaper. * * @returns VBox error code. * @param pVM Pointer to VM. * * @remarks This method destroys all bandwidth group objects. */ int pdmR3NetShaperTerm(PVM pVM) { PUVM pUVM = pVM->pUVM; AssertPtrReturn(pUVM, VERR_INVALID_POINTER); PPDMNETSHAPER pShaper = pUVM->pdm.s.pNetShaper; AssertPtrReturn(pShaper, VERR_INVALID_POINTER); /* Destroy the bandwidth managers. */ PPDMNSBWGROUP pBwGroup = pShaper->pBwGroupsHead; while (pBwGroup) { PPDMNSBWGROUP pFree = pBwGroup; pBwGroup = pBwGroup->pNext; pdmNsBwGroupTerminate(pFree); MMHyperFree(pVM, pFree); } RTCritSectDelete(&pShaper->cs); return VINF_SUCCESS; }
RTDECL(int) RTMemCacheDestroy(RTMEMCACHE hMemCache) { RTMEMCACHEINT *pThis = hMemCache; if (!pThis) return VINF_SUCCESS; AssertPtrReturn(pThis, VERR_INVALID_HANDLE); AssertReturn(pThis->u32Magic == RTMEMCACHE_MAGIC, VERR_INVALID_HANDLE); #if 0 /*def RT_STRICT - don't require eveything to be freed. Caches are very convenient for lazy cleanup. */ uint32_t cFree = pThis->cFree; for (PRTMEMCACHEFREEOBJ pFree = pThis->pFreeTop; pFree && cFree < pThis->cTotal + 5; pFree = pFree->pNext) cFree++; AssertMsg(cFree == pThis->cTotal, ("cFree=%u cTotal=%u\n", cFree, pThis->cTotal)); #endif /* * Destroy it. */ AssertReturn(ASMAtomicCmpXchgU32(&pThis->u32Magic, RTMEMCACHE_MAGIC_DEAD, RTMEMCACHE_MAGIC), VERR_INVALID_HANDLE); RTCritSectDelete(&pThis->CritSect); while (pThis->pPageHead) { PRTMEMCACHEPAGE pPage = pThis->pPageHead; pThis->pPageHead = pPage->pNext; pPage->cFree = 0; if (pThis->pfnDtor) { uint32_t iObj = pPage->cObjects; while (iObj-- > 0) if (ASMBitTestAndClear(pPage->pbmCtor, iObj)) pThis->pfnDtor(hMemCache, pPage->pbObjects + iObj * pThis->cbObject, pThis->pvUser); } RTMemPageFree(pPage, PAGE_SIZE); } RTMemFree(pThis); return VINF_SUCCESS; }