int oss_fmedia_detach (oss_device_t * osdev) { fm801_devc *devc = (fm801_devc *) osdev->devc; if (oss_disable_device (osdev) < 0) return 0; if (devc->audio_initialized) { uninit_audio (devc); } devc->audio_initialized = 0; #ifdef OBSOLETED_STUFF if (devc->mpu_attached) { unload_mpu (devc); devc->mpu_attached = 0; } #endif oss_unregister_interrupts (devc->osdev); MUTEX_CLEANUP (devc->mutex); MUTEX_CLEANUP (devc->low_mutex); UNMAP_PCI_IOADDR (devc->osdev, 0); oss_unregister_device (devc->osdev); return 1; }
int oss_als3xx_detach (oss_device_t * osdev) { als300_devc *devc = (als300_devc *) osdev->devc; unsigned int dwTemp; if (oss_disable_device (osdev) < 0) return 0; if (devc->model == MDL_ALS300PLUS) { dwTemp = gcr_readl (devc, 0x8c); gcr_writel (devc, 0x8c, dwTemp &= ~0x8000); } #ifdef OBSOLETED_STUFF if (devc->mpu_attached) unload_mpu (devc); #endif oss_unregister_interrupts (devc->osdev); MUTEX_CLEANUP (devc->mutex); MUTEX_CLEANUP (devc->low_mutex); UNMAP_PCI_IOADDR (devc->osdev, 0); oss_unregister_device (devc->osdev); return 1; }
void cleanupMutex(void) { #ifdef _WINDOWS if (MUTEX_CLEANUP(*mutex_buf) == 0) // ReleaseMutex returns 0 if failed #else if (MUTEX_CLEANUP(mutex_buf) != 0) // pthread_mutex_destroy returns 0 if successful #endif throw SecurityException(MUTEX_RELEASE_FAILED, NULL); free(mutex_buf); mutex_buf = NULL; }
int Thread_cleanup(void) { #ifdef _USE_OPENSSL int i; if (!mutex_buf) return 0; CRYPTO_set_id_callback(NULL); CRYPTO_set_locking_callback(NULL); #ifdef _DYNAMIC_LOCKING_MECHANISM_ CRYPTO_set_dynlock_create_callback(NULL); CRYPTO_set_dynlock_lock_callback(NULL); CRYPTO_set_dynlock_destroy_callback(NULL); #endif for (i=0 ; i < CRYPTO_num_locks(); i++) MUTEX_CLEANUP(mutex_buf[i]); mutex_buf = NULL ; return 1; #else return -1; #endif }
static void ymhusb_unload (void *d) { ymhusb_devc *devc = (ymhusb_devc *) d; int i; for (i = 0; i < devc->n_inputs; i++) { MUTEX_CLEANUP (devc->indevs[i].mutex); } for (i = 0; i < devc->n_outputs; i++) { MUTEX_CLEANUP (devc->outdevs[i].mutex); } MUTEX_CLEANUP (devc->mutex); }
/* * This routine destroys the EST context and frees * up other resources to prevent a memory leak. */ void cleanup (void) { int i; est_server_stop(ectx); est_destroy(ectx); if (srp_db) { SRP_VBASE_free(srp_db); } /* * Tear down the mutexes used by OpenSSL */ if (!mutex_buf) return; CRYPTO_set_id_callback(NULL); CRYPTO_set_locking_callback(NULL); for (i = 0; i < CRYPTO_num_locks(); i++) MUTEX_CLEANUP(mutex_buf[i]); free(mutex_buf); mutex_buf = NULL; BIO_free(bio_err); free(cacerts_raw); free(trustcerts); est_apps_shutdown(); #ifndef WIN32 pthread_mutex_destroy(&m); #else DeleteCriticalSection(&enrollment_critical_section); #endif }
static void dyn_destroy_function(struct CRYPTO_dynlock_value *l, const char *file, int line) { if (!file || !line) pmesg_safe(&global_flag, LOG_ERROR, __FILE__, __LINE__, ""); MUTEX_CLEANUP(l->mutex); free(l); }
EHSConnection::~EHSConnection ( ) { #ifdef EHS_MEMORY fprintf ( stderr, "[EHS_MEMORY] Deallocated: EHSConnection\n" ); #endif MUTEX_CLEANUP ( m_oConnectionMutex ); if ( m_poCurrentHttpRequest ) delete m_poCurrentHttpRequest; delete m_poNetworkAbstraction; }
int thread_cleanup(void) { int i; if (!mutex_buf) return 0; CRYPTO_set_id_callback(NULL); CRYPTO_set_locking_callback(NULL); for (i = 0; i < CRYPTO_num_locks(); i++) MUTEX_CLEANUP(mutex_buf[i]); pfree(mutex_buf); mutex_buf = NULL; return 1; }
void thread_cleanup () { #ifndef HAVE_CLIENT if (!mutex_buf) return; CRYPTO_set_id_callback (NULL); CRYPTO_set_locking_callback (NULL); int i; for (i = 0; i < CRYPTO_num_locks (); i++) MUTEX_CLEANUP (mutex_buf[i]); free (mutex_buf); mutex_buf = NULL; #endif }
static void _destroy (list_t **list) { if(list && *list) { if(I (List)->count(*list) > 0) { list_item_t *i; while((i = I (List)->pop(*list))!=NULL) I (ListItem)->destroy(&i); } MUTEX_CLEANUP((*list)->lock); free(*list); *list = NULL; } }
void CRYPTO_thread_cleanup() { int i; if (!mutex_buf) return; CRYPTO_set_id_callback(NULL); CRYPTO_set_locking_callback(NULL); CRYPTO_set_dynlock_create_callback(NULL); CRYPTO_set_dynlock_lock_callback(NULL); CRYPTO_set_dynlock_destroy_callback(NULL); for (i = 0; i < CRYPTO_num_locks(); i++) MUTEX_CLEANUP(mutex_buf[i]); free(mutex_buf); mutex_buf = NULL; }
EHSServer::~EHSServer ( ) { if ( m_poNetworkAbstraction ) { m_poNetworkAbstraction->Close (); delete m_poNetworkAbstraction; m_poNetworkAbstraction = NULL; } MUTEX_CLEANUP ( m_oMutex ); #ifdef EHS_MEMORY fprintf ( stderr, "[EHS_MEMORY] Deallocated: EHSServer\n" ); #endif }
int thread_openssl_cleanup(void) { int i; if (! mutex_arr) return -1; CRYPTO_set_id_callback(NULL); CRYPTO_set_locking_callback(NULL); for (i = 0; i < CRYPTO_num_locks( ); i++) MUTEX_CLEANUP(mutex_arr[i]); free(mutex_arr); mutex_arr = NULL; return 0; }
int THREAD_cleanup(void) { int i; if(!mutex_buf) { return 0; } CRYPTO_set_id_callback(NULL); CRYPTO_set_locking_callback(NULL); for(i = 0; i < CRYPTO_num_locks( ); i++) { MUTEX_CLEANUP(mutex_buf[i]); } free(mutex_buf); mutex_buf = NULL; return 1; }
static void dyn_destroy_function(struct CRYPTO_dynlock_value *l, const char *file, int line) { MUTEX_CLEANUP(l->mutex); free(l); }
/* The main() function for setting up and running the tests. * Returns a CUE_SUCCESS on successful running, another * CUnit error code on failure. */ int main(int argc, char *argv[]) { int xml = 0; int con = 0; CU_pFailureRecord fr; int i; if (argc >= 2 && !strcmp(argv[1], "-xml")) { xml = 1; } else if (argc >= 2 && !strcmp(argv[1], "-con")) { con = 1; } #ifdef HAVE_CUNIT int rv; #ifndef WIN32 struct sigaction sig_act; /* * Indicate that the broken pipe signal during writes should be * ignored */ memset(&sig_act, 0, sizeof(struct sigaction)); sig_act.sa_handler = SIG_IGN; sigemptyset(&sig_act.sa_mask); if (sigaction(SIGPIPE, &sig_act, NULL) == -1) { printf("\nCannot set ignore action for SIGPIPE\n"); } #endif est_apps_startup(); /* * Install thread locking mechanism for OpenSSL */ mutex_buf = malloc(CRYPTO_num_locks() * sizeof(MUTEX_TYPE)); if (!mutex_buf) { printf("Cannot allocate mutexes"); exit(1); } for (i = 0; i < CRYPTO_num_locks(); i++) MUTEX_SETUP(mutex_buf[i]); CRYPTO_set_id_callback(id_function); CRYPTO_set_locking_callback(locking_function); /* initialize the CUnit test registry */ if (CUE_SUCCESS != CU_initialize_registry()) { return CU_get_error(); } #ifdef ENABLE_ALL_SUITES rv = us748_add_suite(); if (rv != CUE_SUCCESS) { printf("\nFailed to add test suite for US748 (%d)", rv); exit(1); } #endif #ifdef ENABLE_ALL_SUITES rv = us893_add_suite(); if (rv != CUE_SUCCESS) { printf("\nFailed to add test suite for US893 (%d)", rv); exit(1); } #endif #ifdef ENABLE_ALL_SUITES rv = us894_add_suite(); if (rv != CUE_SUCCESS) { printf("\nFailed to add test suite for US894 (%d)", rv); exit(1); } #endif #ifdef ENABLE_ALL_SUITES rv = us895_add_suite(); if (rv != CUE_SUCCESS) { printf("\nFailed to add test suite for US895 (%d)", rv); exit(1); } #endif #ifdef ENABLE_ALL_SUITES rv = us896_add_suite(); if (rv != CUE_SUCCESS) { printf("\nFailed to add test suite for US896 (%d)", rv); exit(1); } #endif #ifdef ENABLE_ALL_SUITES rv = us897_add_suite(); if (rv != CUE_SUCCESS) { printf("\nFailed to add test suite for US897 (%d)", rv); exit(1); } #endif #ifdef ENABLE_ALL_SUITES rv = us898_add_suite(); if (rv != CUE_SUCCESS) { printf("\nFailed to add test suite for US898 (%d)", rv); exit(1); } #endif #ifdef ENABLE_ALL_SUITES rv = us899_add_suite(); if (rv != CUE_SUCCESS) { printf("\nFailed to add test suite for US899 (%d)", rv); exit(1); } #endif #ifdef ENABLE_ALL_SUITES rv = us900_add_suite(); if (rv != CUE_SUCCESS) { printf("\nFailed to add test suite for US900 (%d)", rv); exit(1); } #endif #ifdef ENABLE_ALL_SUITES rv = us901_add_suite(); if (rv != CUE_SUCCESS) { printf("\nFailed to add test suite for US901 (%d)", rv); exit(1); } #endif #ifdef ENABLE_ALL_SUITES rv = us902_add_suite(); if (rv != CUE_SUCCESS) { printf("\nFailed to add test suite for US902 (%d)", rv); exit(1); } #endif #ifdef ENABLE_ALL_SUITES rv = us903_add_suite(); if (rv != CUE_SUCCESS) { printf("\nFailed to add test suite for US903 (%d)", rv); exit(1); } #endif #ifdef ENABLE_ALL_SUITES rv = us1005_add_suite(); if (rv != CUE_SUCCESS) { printf("\nFailed to add test suite for US1005 (%d)", rv); exit(1); } #endif #if (DISABLE_SUITE != 0) rv = us1060_add_suite(); if (rv != CUE_SUCCESS) { printf("\nFailed to add test suite for US1060 (%d)", rv); exit(1); } #endif #ifdef ENABLE_ALL_SUITES rv = us1060c_add_suite(); if (rv != CUE_SUCCESS) { printf("\nFailed to add test suite for US1060c (%d)", rv); exit(1); } #endif #ifdef ENABLE_ALL_SUITES rv = us1159_add_suite(); if (rv != CUE_SUCCESS) { printf("\nFailed to add test suite for US1159 (%d)", rv); exit(1); } #endif #ifdef ENABLE_ALL_SUITES rv = us1190_add_suite(); if (rv != CUE_SUCCESS) { printf("\nFailed to add test suite for US1190 (%d)", rv); exit(1); } #endif #ifdef ENABLE_ALL_SUITES rv = us1864_add_suite(); if (rv != CUE_SUCCESS) { printf("\nFailed to add test suite for US1864 (%d)", rv); exit(1); } #endif #ifdef ENABLE_ALL_SUITES rv = us1883_add_suite(); if (rv != CUE_SUCCESS) { printf("\nFailed to add test suite for US1883 (%d)", rv); exit(1); } #endif #ifdef ENABLE_ALL_SUITES rv = us1884_add_suite(); if (rv != CUE_SUCCESS) { printf("\nFailed to add test suite for US1884 (%d)", rv); exit(1); } #endif #ifdef ENABLE_ALL_SUITES rv = us2174_add_suite(); if (rv != CUE_SUCCESS) { printf("\nFailed to add test suite for US2174 (%d)", rv); exit(1); } #endif #ifdef ENABLE_ALL_SUITES rv = us3496_add_suite(); if (rv != CUE_SUCCESS) { printf("\nFailed to add test suite for US3496 (%d)", rv); exit(1); } #endif #ifdef ENABLE_ALL_SUITES rv = us3512_add_suite(); if (rv != CUE_SUCCESS) { printf("\nFailed to add test suite for US3512 (%d)", rv); exit(1); } #endif #ifdef ENABLE_ALL_SUITES rv = us3612_add_suite(); if (rv != CUE_SUCCESS) { printf("\nFailed to add test suite for US3612 (%d)", rv); exit(1); } #endif #ifdef ENABLE_ALL_SUITES rv = us4020_add_suite(); if (rv != CUE_SUCCESS) { printf("\nFailed to add test suite for US4020 (%d)", rv); exit(1); } #endif if (xml) { /* Run all test using automated interface, which * generates XML output */ CU_list_tests_to_file(); CU_automated_run_tests(); } else if (con) { CU_console_run_tests(); } else { /* Run all tests using the CUnit Basic interface, * which generates text output */ CU_basic_set_mode(CU_BRM_VERBOSE); CU_basic_run_tests(); fr = CU_get_failure_list(); if (fr) { printf("\n\nHere is a summary of the failed test cases:\n"); CU_basic_show_failures(fr); } } /* * Tear down the mutexes used by OpenSSL */ if (!mutex_buf) return 0; CRYPTO_set_id_callback(NULL); CRYPTO_set_locking_callback(NULL); for (i = 0; i < CRYPTO_num_locks(); i++) MUTEX_CLEANUP(mutex_buf[i]); free(mutex_buf); mutex_buf = NULL; CU_cleanup_registry(); est_apps_shutdown(); return CU_get_error(); #else printf("\nlibcunit not installed, unit test are not enabled\n"); #endif }
void dyn_destroy_function( struct CRYPTO_dynlock_value *val,\ const char *file , int line ) { MUTEX_CLEANUP(val -> mutex); }