/* * Close the library */ int nvm_close_lib() { int rc = NVM_SUCCESS; // remove any simulators that were loaded // don't care about any failures here because there may // not be a simulator loaded nvm_remove_simulator(); // close the database if (close_lib_store() != COMMON_SUCCESS) { rc = NVM_ERR_UNKNOWN; } // clean up the locks if (!mutex_delete((OS_MUTEX*)&g_eventmonitor_lock, NULL)) { rc = NVM_ERR_UNKNOWN; } if (!mutex_delete((OS_MUTEX*)&g_context_lock, NULL)) { rc = NVM_ERR_UNKNOWN; } return rc; }
int fini_zlog() { gs_zlog.is_to_exit = TRUE; sema_v(gs_zlog.sema); thread_stop(gs_zlog.thread); sema_delete(gs_zlog.sema); mutex_delete(gs_zlog.mutex); if (gs_zlog.file_prefix != NULL) free(gs_zlog.file_prefix); if (gs_zlog.file != NULL) fclose(gs_zlog.file); return S_OK; }
int rw_mutex_new(rw_mutex_t *lock) { int rc; rc = mutex_new(&lock->lock); if (rc) return rc; rc = pthread_cond_init(&lock->read_sig, NULL); if (rc) { mutex_delete(&lock->lock); return rc; } rc = pthread_cond_init(&lock->write_sig, NULL); if (rc) { mutex_delete(&lock->lock); pthread_cond_destroy(&lock->read_sig); return rc; } lock->state = 0; lock->blocked_writers = 0; return 0; }