static DWORD VmDnsCacheCleanupRefreshThread( PVMDNS_CACHE_CONTEXT pContext ) { DWORD dwError = 0; if (pContext->bRunning) { dwError = ERROR_INVALID_STATE; BAIL_ON_VMDNS_ERROR(dwError); } VmDnsFreeThread(pContext->pRefreshThread); pContext->pThreadLock = NULL; VmDnsFreeCondition(pContext->pRefreshEvent); pContext->pRefreshEvent = NULL; VmDnsFreeMutex(pContext->pThreadLock); pContext->pThreadLock = NULL; cleanup: return dwError; error: goto cleanup; }
VOID VmDnsSockPosixFreeEventQueue( PVM_SOCK_EVENT_QUEUE pQueue ) { if (pQueue->pSignalReader) { VmDnsSockPosixReleaseSocket(pQueue->pSignalReader); } if (pQueue->pSignalWriter) { VmDnsSockPosixReleaseSocket(pQueue->pSignalWriter); } if (pQueue->pMutex) { VmDnsFreeMutex(pQueue->pMutex); } if (pQueue->epollFd >= 0) { close(pQueue->epollFd); } if (pQueue->pEventArray) { VmDnsFreeMemory(pQueue->pEventArray); pQueue->pEventArray = NULL; } VmDnsFreeMemory(pQueue); }
static VOID VmDnsSockPosixFreeSocket( PVM_SOCKET pSocket ) { if (pSocket->fd >= 0) { close(pSocket->fd); } if (pSocket->pMutex) { VmDnsFreeMutex(pSocket->pMutex); } VmDnsFreeMemory(pSocket); }
static DWORD VmDnsCacheInitRefreshThread( PVMDNS_CACHE_CONTEXT pContext ) { DWORD dwError = 0; PVMDNS_THREAD pRefreshThread = NULL; PVMDNS_COND pRefreshEvent = NULL; PVMDNS_MUTEX pThreadMutex = NULL; dwError = VmDnsAllocateCondition(&pRefreshEvent); BAIL_ON_VMDNS_ERROR(dwError); dwError = VmDnsAllocateMutex(&pThreadMutex); BAIL_ON_VMDNS_ERROR(dwError); dwError = VmDnsAllocateMemory(sizeof(*pRefreshThread), (PVOID *)&pRefreshThread); BAIL_ON_VMDNS_ERROR(dwError); pContext->pRefreshEvent = pRefreshEvent; pContext->pThreadLock = pThreadMutex; pContext->pRefreshThread = pRefreshThread; cleanup: return dwError; error: VmDnsFreeMutex(pThreadMutex); VmDnsFreeCondition(pRefreshEvent); VmDnsFreeMemory(pRefreshThread); goto cleanup; }