static void lock_destroy(test_mode_e test_mode) { if (test_mode == TEST_PROC) { assert(apr_proc_mutex_destroy(proc_mutex) == APR_SUCCESS); } else { assert(apr_global_mutex_destroy(global_mutex) == APR_SUCCESS); } }
static apr_status_t cleanup_mutex(void *not_used) { ap_log_error(APLOG_MARK, APLOG_NOTICE, 0, ap_server_conf, "cleaning up global mutex"); if (lock) { apr_global_mutex_destroy(lock); lock = NULL; } return APR_SUCCESS; }
static apr_status_t cleanup_shm_resources(void *dummy) { if (api_cache_shm) { apr_shm_destroy(api_cache_shm); api_cache_shm = NULL; } if (global_lock) { apr_global_mutex_destroy(global_lock); global_lock = NULL; } return APR_SUCCESS; }
static apr_status_t cleanup_shm(void *not_used) { ap_log_error(APLOG_MARK, APLOG_STARTUP, 0, NULL, "Notice: cleaning up shared memory"); fflush(stderr); if (shm) { apr_shm_destroy(shm); shm = NULL; } if (lock) { apr_global_mutex_destroy(lock); lock = NULL; } return APR_SUCCESS; }
void DestroyAPRGlobalStorage (APRGlobalStorage *storage_p) { if (storage_p) { if (storage_p -> ags_entries_p) { unsigned char *key_s = NULL; apr_ssize_t keylen = 0; void *value_p = NULL; apr_hash_index_t *index_p = apr_hash_first (storage_p -> ags_pool_p, storage_p -> ags_entries_p); while (index_p) { apr_hash_this (index_p, (const void **) &key_s, &keylen, (void **) &value_p); storage_p -> ags_free_key_and_value_fn (key_s, value_p); index_p = apr_hash_next (index_p); } apr_hash_clear (storage_p -> ags_entries_p); } storage_p -> ags_pool_p = NULL; if (storage_p -> ags_mutex_p) { apr_global_mutex_destroy (storage_p -> ags_mutex_p); storage_p -> ags_mutex_p = NULL; } if (storage_p -> ags_socache_instance_p) { storage_p -> ags_socache_provider_p -> destroy (storage_p -> ags_socache_instance_p, storage_p -> ags_server_p); } if (storage_p -> ags_largest_entry_memory_id) { FreeSharedMemory (storage_p -> ags_largest_entry_memory_id); } } }
void server_master_stat_fini(dav_rawx_server_conf *conf, apr_pool_t *plog) { DAV_XDEBUG_POOL(plog, 0, "%s()", __FUNCTION__); if (conf->lock.handle) { DAV_DEBUG_POOL(plog, 0, "%s: Destroying the globalmutex at [%s]", __FUNCTION__, conf->shm.path); if (APR_SUCCESS != apr_global_mutex_destroy(conf->lock.handle)) { DAV_ERROR_POOL(plog, 0, "Failed to destroy the global_mutex"); } conf->lock.handle = NULL; } if (conf->shm.handle) { DAV_DEBUG_POOL(plog, 0, "%s: Detaching the SHM segment at [%s]", __FUNCTION__, conf->shm.path); if (APR_SUCCESS != apr_shm_detach(conf->shm.handle)) { DAV_ERROR_POOL(plog, 0, "Failed to detach the SHM segment"); } conf->shm.handle = NULL; } }
static int oidc_cache_shm_destroy(server_rec *s) { oidc_cfg *cfg = (oidc_cfg *) ap_get_module_config( s->module_config, &auth_openidc_module); oidc_cache_cfg_shm_t *context = (oidc_cache_cfg_shm_t *)cfg->cache_cfg; apr_status_t rv = APR_SUCCESS; if (context->shm) { rv = apr_shm_destroy(context->shm); ap_log_error(APLOG_MARK, OIDC_DEBUG, rv, s, "oidc_cache_shm_destroy: apr_shm_destroy returned: %d", rv); context->shm = NULL; } if (context->mutex) { rv = apr_global_mutex_destroy(context->mutex); ap_log_error(APLOG_MARK, OIDC_DEBUG, rv, s, "oidc_cache_shm_destroy: apr_global_mutex_destroy returned: %d", rv); context->mutex = NULL; } return rv; }
bool InitAPRGlobalStorage (APRGlobalStorage *storage_p, apr_pool_t *pool_p, apr_hashfunc_t hash_fn, unsigned char *(*make_key_fn) (const void *data_p, uint32 raw_key_length, uint32 *key_len_p), void (*free_key_and_value_fn) (unsigned char *key_p, void *value_p), server_rec *server_p, const char *mutex_filename_s, const char *cache_id_s, const char *provider_name_s) { ap_socache_provider_t *provider_p = ap_lookup_provider (AP_SOCACHE_PROVIDER_GROUP, provider_name_s, AP_SOCACHE_PROVIDER_VERSION); if (provider_p) { apr_status_t status = apr_global_mutex_create (& (storage_p -> ags_mutex_p), mutex_filename_s, APR_THREAD_MUTEX_UNNESTED, pool_p); if (status == APR_SUCCESS) { char *current_dir_s = GetCurrentWorkingDirectory (); if (current_dir_s) { storage_p -> ags_largest_entry_memory_id = AllocateSharedMemory (current_dir_s, sizeof (unsigned int), 0644); FreeCopiedString (current_dir_s); if (storage_p -> ags_largest_entry_memory_id != -1) { storage_p -> ags_entries_p = apr_hash_make_custom (pool_p, hash_fn); if (storage_p -> ags_entries_p) { storage_p -> ags_pool_p = pool_p; storage_p -> ags_server_p = server_p; storage_p -> ags_make_key_fn = make_key_fn; storage_p -> ags_free_key_and_value_fn = free_key_and_value_fn; storage_p -> ags_cache_id_s = cache_id_s; storage_p -> ags_mutex_lock_filename_s = mutex_filename_s; storage_p -> ags_socache_instance_p = NULL; storage_p -> ags_socache_provider_p = provider_p; apr_pool_cleanup_register (pool_p, storage_p, (const void *) FreeAPRGlobalStorage, apr_pool_cleanup_null); return true; } /* if (storage_p -> ags_entries_p) */ else { PrintErrors (STM_LEVEL_SEVERE, __FILE__, __LINE__, "Failed to allocate shared memory hash table"); } FreeSharedMemory (storage_p -> ags_largest_entry_memory_id); } /* if (storage_p -> ags_largest_entry_memory_id != -1) */ else { PrintErrors (STM_LEVEL_SEVERE, __FILE__, __LINE__, "Failed to allocate shared memory for largest chunk size"); } } /* if (mem_key_s) */ else { PrintErrors (STM_LEVEL_SEVERE, __FILE__, __LINE__, "Failed to create memory key from \"%s\" and \".memory\"", cache_id_s); } apr_global_mutex_destroy (storage_p -> ags_mutex_p); storage_p -> ags_mutex_p = NULL; } /* if (status == APR_SUCCESS) */ else { PrintErrors (STM_LEVEL_SEVERE, __FILE__, __LINE__, "Failed to create global mutex for shared memory at %s", mutex_filename_s); } } /* if (provider_p) */ else { PrintErrors (STM_LEVEL_SEVERE, __FILE__, __LINE__, "Failed to find provider \"%s\"", provider_name_s ? provider_name_s : "NULL"); } return false; }