TVeosErr ShMem_Close() { TVeosErr iErr; boolean bLast = FALSE; THSharedRec hFinger; TPSharedRec pSaveLink; TPSemaphor pSaveSem; iErr = VEOS_SUCCESS; #ifdef _SG_ /** stop others from looking at the channel chain **/ uspsema(SHMEM_DOMAIN->pChainSem); /** this channel is about to vanish ** wait for others to finish looking at this channel **/ pSaveSem = SHMEM_CHANNEL->pSem; uspsema(pSaveSem); /** find our channel in the domain channel chain, ** remove it, recoupling the links, and free the memory **/ hFinger = &SHMEM_DOMAIN->pChannelChain; while (*hFinger) { if (*hFinger == SHMEM_CHANNEL) { pSaveLink = (*hFinger)->pNext; usfree(*hFinger, SHMEM_ARENA); *hFinger = pSaveLink; break; } hFinger = &(*hFinger)->pNext; } /** release and remove the channel semaphore **/ usvsema(pSaveSem); usfreesema(pSaveSem, SHMEM_ARENA); if (SHMEM_DOMAIN->pChannelChain == nil) bLast = TRUE; /** allow others to cleanly find no channel **/ usvsema(SHMEM_DOMAIN->pChainSem); if (bLast) { usfreesema(SHMEM_DOMAIN->pChainSem, SHMEM_ARENA); usfree(SHMEM_DOMAIN, SHMEM_ARENA); unlink(SHMEM_ARENA_FILE); } #endif return(iErr); } /* ShMem_Close */
void XMLPlatformUtils::closeMutex(void* const mtxHandle) { if ((mtxHandle != NULL) && (arena != NULL)) { usfreesema ((usema_t *)mtxHandle, arena); // never returns anything testable for failure, so nothing // to throw an exception about. } }
bool vrpn_Semaphore::destroy() { if (fUsingLock) { usfreelock(l, vrpn_Semaphore::ppaArena); } else { usfreesema(ps, vrpn_Semaphore::ppaArena); } return true; }
void thread_cleanup(void) { int i; CRYPTO_set_locking_callback(NULL); for (i = 0; i < CRYPTO_num_locks(); i++) { char buf[10]; sprintf(buf, "%2d:", i); usdumpsema(lock_cs[i], stdout, buf); usfreesema(lock_cs[i], arena); } OPENSSL_free(lock_cs); }
void CRYPTO_thread_cleanup(void) { int i; CRYPTO_set_locking_callback(NULL); for (i=0; i<CRYPTO_num_locks(); i++) { char buf[10]; TINYCLR_SSL_SPRINTF(buf,"%2d:",i); usdumpsema(lock_cs[i],OPENSSL_TYPE__FILE_STDOUT,buf); usfreesema(lock_cs[i],arena); } OPENSSL_free(lock_cs); }
void qsem_free( qsemh_t qsemh ) { #ifdef HIDDEN usema_t *usemap = ( usema_t * )qsemh; /* sanity checks */ ASSERT( qlock_inited ); ASSERT( qlock_usp ); /* free the us semaphore */ usfreesema( usemap, qlock_usp ); #endif /* HIDDEN */ }
bool vrpn_Semaphore::destroy() { #ifdef sgi if (fUsingLock) { usfreelock( l, vrpn_Semaphore::ppaArena ); } else { usfreesema( ps, vrpn_Semaphore::ppaArena ); } #elif defined(_WIN32) if (!CloseHandle(hSemaphore)) { // get error info from windows (from FormatMessage help page) LPVOID lpMsgBuf; FormatMessage( FORMAT_MESSAGE_ALLOCATE_BUFFER | FORMAT_MESSAGE_FROM_SYSTEM, NULL, GetLastError(), MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT), // Default language (LPTSTR) &lpMsgBuf, 0, NULL ); fprintf(stderr, "vrpn_Semaphore::destroy: error destroying semaphore, " "WIN32 CloseHandle call caused the following error: %s\n", (LPTSTR) lpMsgBuf); // Free the buffer. LocalFree( lpMsgBuf ); return false; } #else // Posix threads are the default. #ifdef __APPLE__ if (sem_close(semaphore) != 0) { perror("vrpn_Semaphore::destroy: error destroying semaphore."); return false; } #else if (sem_destroy(semaphore) != 0) { fprintf(stderr, "vrpn_Semaphore::destroy: error destroying semaphore.\n"); return false; } #endif semaphore = NULL; #endif return true; }