/** * Callback routine that is called to destroy this * apr_queue_t when its pool is destroyed. */ static apr_status_t queue_destroy(void *data) { apr_queue_t *queue = data; /* Ignore errors here, we can't do anything about them anyway. */ apr_thread_cond_destroy(queue->not_empty); apr_thread_cond_destroy(queue->not_full); apr_thread_mutex_destroy(queue->one_big_mutex); return APR_SUCCESS; }
LLMutex::~LLMutex() { #if _DEBUG llassert(!isLocked()); // better not be locked! #endif apr_thread_mutex_destroy(mAPRMutexp); mAPRMutexp = NULL; if (mIsLocalPool) { apr_pool_destroy(mAPRPoolp); } }
/** * Callback routine that is called to destroy this * fd_queue_t when its pool is destroyed. */ static apr_status_t ap_queue_destroy(void *data) { fd_queue_t *queue = data; /* Ignore errors here, we can't do anything about them anyway. * XXX: We should at least try to signal an error here, it is * indicative of a programmer error. -aaron */ apr_thread_cond_destroy(queue->not_empty); apr_thread_mutex_destroy(queue->one_big_mutex); return APR_SUCCESS; }
static apt_bool_t mrcp_sofia_session_cleanup(mrcp_sofia_session_t *sofia_session) { if(sofia_session->mutex) { apr_thread_mutex_destroy(sofia_session->mutex); sofia_session->mutex = NULL; } if(sofia_session->home) { su_home_unref(sofia_session->home); sofia_session->home = NULL; } return TRUE; }
static apr_status_t thread_pool_cleanup(void *me) { apr_thread_pool_t *_myself = me; _myself->terminated = 1; apr_thread_pool_idle_max_set(_myself, 0); while (_myself->thd_cnt) { apr_sleep(20 * 1000); /* spin lock with 20 ms */ } apr_thread_mutex_destroy(_myself->lock); apr_thread_cond_destroy(_myself->cond); return APR_SUCCESS; }
LLMutex::~LLMutex() { #if MUTEX_DEBUG //bad assertion, the subclass LLSignal might be "locked", and that's OK //llassert_always(!isLocked()); // better not be locked! #endif apr_thread_mutex_destroy(mAPRMutexp); mAPRMutexp = NULL; if (mIsLocalPool) { apr_pool_destroy(mAPRPoolp); } }
/** Virtual destroy handler. */ static apt_bool_t mrcp_server_agent_task_on_destroy(apt_task_t *task) { mrcp_connection_agent_t *agent = apt_task_object_get(task); if(agent->guard) { apr_thread_mutex_destroy(agent->guard); agent->guard = NULL; } if(agent->msg_queue) { apt_cyclic_queue_destroy(agent->msg_queue); agent->msg_queue = NULL; } return TRUE; }
void gop_control_free(void *arg, int size, void *data) { gop_control_t *shelf = (gop_control_t *)data; int i; for (i=0; i<size; i++) { apr_thread_mutex_destroy(shelf[i].lock); apr_thread_cond_destroy(shelf[i].cond); } free(shelf); return; }
void LLPumpIO::cleanup() { LLMemType m1(LLMemType::MTYPE_IO_PUMP); #if LL_THREADS_APR if(mChainsMutex) apr_thread_mutex_destroy(mChainsMutex); if(mCallbackMutex) apr_thread_mutex_destroy(mCallbackMutex); #endif mChainsMutex = NULL; mCallbackMutex = NULL; if(mPollset) { // lldebugs << "cleaning up pollset" << llendl; apr_pollset_destroy(mPollset); mPollset = NULL; } if(mCurrentPool) { apr_pool_destroy(mCurrentPool); mCurrentPool = NULL; } mPool = NULL; }
void destroy_skiplist(skiplist_t *sl) { log_printf(15, "destroy_skiplist: sl=%p\n", sl); empty_skiplist(sl); destroy_skiplist_node(sl, sl->head); apr_thread_mutex_destroy(sl->lock); apr_pool_destroy(sl->pool); free(sl); return; }
void mq_stream_read_destroy(mq_stream_t *mqs) { log_printf(1, "START msid=%d\n", mqs->msid); if (mqs->mpool == NULL) { //** Nothing to do pack_destroy(mqs->pack); if (mqs->stream_id != NULL) free(mqs->stream_id); free(mqs); return; } //** Change the flag which signals we don't want anything else apr_thread_mutex_lock(mqs->lock); mqs->want_more = MQS_ABORT; //** Consume all the current data and request the pending while ((mqs->gop_processed != NULL) || (mqs->gop_waiting != NULL)) { log_printf(1, "Clearing pending processed=%d waiting=%p msid=%d\n", mqs->gop_processed, mqs->gop_waiting, mqs->msid); if (mqs->gop_processed != NULL) log_printf(1, "processed gid=%d\n", gop_id(mqs->gop_processed)); if (mqs->gop_waiting != NULL) log_printf(1, "waiting gid=%d\n", gop_id(mqs->gop_waiting)); mqs->want_more = MQS_ABORT; apr_thread_mutex_unlock(mqs->lock); mq_stream_read_wait(mqs); apr_thread_mutex_lock(mqs->lock); } if (log_level() >= 15) { char *rhost = mq_address_to_string(mqs->remote_host); log_printf(15, "remote_host as string = %s\n", rhost); if (rhost) free(rhost); } if (mqs->remote_host != NULL) mq_ongoing_host_dec(mqs->ongoing, mqs->remote_host, mqs->host_id, mqs->hid_len); apr_thread_mutex_unlock(mqs->lock); log_printf(2, "msid=%d transfer_packets=%d\n", mqs->msid, mqs->transfer_packets); //** Clean up if (mqs->stream_id != NULL) free(mqs->stream_id); pack_destroy(mqs->pack); apr_thread_mutex_destroy(mqs->lock); apr_thread_cond_destroy(mqs->cond); apr_pool_destroy(mqs->mpool); if (mqs->remote_host != NULL) mq_msg_destroy(mqs->remote_host); free(mqs); return; }
void free_resource_list(Resource_list_t *rl) { int i; apr_thread_mutex_destroy(rl->lock); apr_pool_destroy(rl->mpool); for (i=0; i<rl->max_res; i++) { if (rl->res[i].used == 1) free(rl->res[i].crid); } free_stack(rl->pending, 0); free(rl->res); free(rl); }
/** Cleanup poller task */ APT_DECLARE(void) apt_poller_task_cleanup(apt_poller_task_t *task) { if(task->pollset) { apt_pollset_destroy(task->pollset); task->pollset = NULL; } if(task->guard) { apr_thread_mutex_destroy(task->guard); task->guard = NULL; } if(task->msg_queue) { apt_cyclic_queue_destroy(task->msg_queue); task->msg_queue = NULL; } }
apr_status_t apr_file_socket_pipe_close(apr_file_t *file) { apr_status_t stat; if (!file->pipe) return apr_file_close(file); if ((stat = socket_pipe_cleanup(file)) == APR_SUCCESS) { apr_pool_cleanup_kill(file->pool, file, socket_pipe_cleanup); if (file->mutex) { apr_thread_mutex_destroy(file->mutex); } return APR_SUCCESS; } return stat; }
void globals_destroy(void) { /* Free existing memory in globals. */ globals_clear(); if (globals.mutex != NULL) { if (apr_thread_mutex_destroy(globals.mutex) != APR_SUCCESS) ast_log(LOG_WARNING, "Unable to destroy global mutex\n"); } if (globals.pool != NULL) apr_pool_destroy(globals.pool); /* Set values to NULL. */ globals_null(); }
static apr_status_t dbd_sqlite3_close(apr_dbd_t *handle) { apr_dbd_prepared_t *prep = handle->prep; /* finalize all prepared statements, or we'll get SQLITE_BUSY on close */ while (prep) { sqlite3_finalize(prep->stmt); prep = prep->next; } sqlite3_close(handle->conn); #if APR_HAS_THREADS apr_thread_mutex_destroy(handle->mutex); #endif return APR_SUCCESS; }
static apr_status_t sqlalias_cleanup(void *p) { if (sqlalias_db_handler) { #ifdef SQLALIAS_DEBUG server_rec *s = (server_rec *) p; DEBUG_MSG(s, "sqlalias: Database connection closed. (pid:%d)", getpid()); #endif /* SQLALIAS_DEBUG */ mysql_close(sqlalias_db_handler); sqlalias_db_handler = NULL; } if (sqlalias_mutex) { apr_thread_mutex_destroy(sqlalias_mutex); sqlalias_mutex = NULL; } mysql_library_end(); return APR_SUCCESS; }
APT_DECLARE(apt_bool_t) apt_log_file_close() { apt_log_file_data_t *file_data; if(!apt_logger || !apt_logger->file_data) { return FALSE; } file_data = apt_logger->file_data; if(file_data->file) { /* close log file */ fclose(file_data->file); file_data->file = NULL; /* destroy mutex */ apr_thread_mutex_destroy(file_data->mutex); file_data->mutex = NULL; } apt_logger->file_data = NULL; return TRUE; }
static void lost_signal(abts_case *tc, void *data) { apr_status_t rv; apr_thread_cond_t *cond = NULL; apr_thread_mutex_t *mutex = NULL; rv = apr_thread_mutex_create(&mutex, APR_THREAD_MUTEX_DEFAULT, p); ABTS_SUCCESS(rv); ABTS_PTR_NOTNULL(tc, mutex); rv = apr_thread_cond_create(&cond, p); ABTS_SUCCESS(rv); ABTS_PTR_NOTNULL(tc, cond); rv = apr_thread_cond_signal(cond); ABTS_SUCCESS(rv); rv = apr_thread_mutex_lock(mutex); ABTS_SUCCESS(rv); rv = apr_thread_cond_timedwait(cond, mutex, 10000); ABTS_INT_EQUAL(tc, 1, APR_STATUS_IS_TIMEUP(rv)); rv = apr_thread_mutex_unlock(mutex); ABTS_SUCCESS(rv); rv = apr_thread_cond_broadcast(cond); ABTS_SUCCESS(rv); rv = apr_thread_mutex_lock(mutex); ABTS_SUCCESS(rv); rv = apr_thread_cond_timedwait(cond, mutex, 10000); ABTS_INT_EQUAL(tc, 1, APR_STATUS_IS_TIMEUP(rv)); rv = apr_thread_mutex_unlock(mutex); ABTS_SUCCESS(rv); rv = apr_thread_cond_destroy(cond); ABTS_SUCCESS(rv); rv = apr_thread_mutex_destroy(mutex); ABTS_SUCCESS(rv); }
APT_DECLARE(apt_bool_t) apt_log_file_open(const char *dir_path, const char *file_name, apr_size_t max_file_size, apr_size_t max_file_count, apr_pool_t *pool) { const char *log_file_path; apt_log_file_data_t *file_data; if(!apt_logger || !dir_path || !file_name) { return FALSE; } if(apt_logger->file_data) { return FALSE; } file_data = apr_palloc(pool,sizeof(apt_log_file_data_t)); file_data->log_dir_path = dir_path; file_data->log_file_name = file_name; file_data->cur_file_index = 0; file_data->cur_size = 0; file_data->max_file_count = max_file_count; file_data->max_size = max_file_size; file_data->mutex = NULL; file_data->pool = pool; if(!file_data->max_size) { file_data->max_file_count = MAX_LOG_FILE_SIZE; } if(!file_data->max_file_count) { file_data->max_file_count = MAX_LOG_FILE_COUNT; } /* create mutex */ if(apr_thread_mutex_create(&file_data->mutex,APR_THREAD_MUTEX_DEFAULT,pool) != APR_SUCCESS) { return FALSE; } /* open log file */ log_file_path = apt_log_file_path_make(file_data); file_data->file = fopen(log_file_path,"wb"); if(!file_data->file) { apr_thread_mutex_destroy(file_data->mutex); return FALSE; } apt_logger->file_data = file_data; return TRUE; }
/* * Dynamic lock destruction callback */ static void ssl_dyn_destroy_function(struct CRYPTO_dynlock_value *l, const char *file, int line) { apr_status_t rv; ap_log_perror(file, line, APLOG_MODULE_INDEX, APLOG_TRACE1, 0, l->pool, "Destroying dynamic lock %s:%d", l->file, l->line); rv = apr_thread_mutex_destroy(l->mutex); if (rv != APR_SUCCESS) { ap_log_perror(file, line, APLOG_MODULE_INDEX, APLOG_ERR, rv, l->pool, APLOGNO(02192) "Failed to destroy mutex for dynamic " "lock %s:%d", l->file, l->line); } /* Trust that whomever owned the CRYPTO_dynlock_value we were * passed has no future use for it... */ apr_pool_destroy(l->pool); }
static apr_status_t file_cleanup(wapr_file_t *file) { apr_status_t rv = APR_SUCCESS; int rc; rc = lkl_sys_close(file->filedes); if (0 == rc) { file->filedes = -1; if (file->flags & APR_DELONCLOSE) lkl_sys_unlink(file->fname); if (file->thlock) rv = apr_thread_mutex_destroy(file->thlock); } else rv = -rc; return rv; }
void ll_cleanup_apr() { LL_INFOS("APR") << "Cleaning up APR" << LL_ENDL; if (gLogMutexp) { // Clean up the logging mutex // All other threads NEED to be done before we clean up APR, so this is okay. apr_thread_mutex_destroy(gLogMutexp); gLogMutexp = NULL; } if (gAPRPoolp) { apr_pool_destroy(gAPRPoolp); gAPRPoolp = NULL; } apr_terminate(); }
void gop_dummy_destroy() { apr_status_t tstat; //** Signal a shutdown apr_thread_mutex_lock(gd_lock); gd_shutdown = 1; apr_thread_cond_broadcast(gd_cond); apr_thread_mutex_unlock(gd_lock); //** Wait for the thread to complete apr_thread_join(&tstat, gd_thread); //** Clean up; free_stack(gd_stack, 0); apr_thread_mutex_destroy(gd_lock); apr_thread_cond_destroy(gd_cond); apr_pool_destroy(gd_pool); }
APR_DECLARE(apr_status_t) apr_file_setaside(apr_file_t **new_file, apr_file_t *old_file, apr_pool_t *p) { *new_file = (apr_file_t *)apr_palloc(p, sizeof(apr_file_t)); memcpy(*new_file, old_file, sizeof(apr_file_t)); (*new_file)->pool = p; if (old_file->buffered) { (*new_file)->buffer = apr_palloc(p, old_file->bufsize); (*new_file)->bufsize = old_file->bufsize; if (old_file->direction == 1) { memcpy((*new_file)->buffer, old_file->buffer, old_file->bufpos); } else { memcpy((*new_file)->buffer, old_file->buffer, old_file->dataRead); } #if APR_HAS_THREADS if (old_file->thlock) { apr_thread_mutex_create(&((*new_file)->thlock), APR_THREAD_MUTEX_DEFAULT, p); apr_thread_mutex_destroy(old_file->thlock); } #endif /* APR_HAS_THREADS */ } if (old_file->fname) { (*new_file)->fname = apr_pstrdup(p, old_file->fname); } if (!(old_file->flags & APR_FOPEN_NOCLEANUP)) { apr_pool_cleanup_register(p, (void *)(*new_file), apr_unix_file_cleanup, ((*new_file)->flags & APR_INHERIT) ? apr_pool_cleanup_null : apr_unix_child_file_cleanup); } old_file->filedes = -1; apr_pool_cleanup_kill(old_file->pool, (void *)old_file, apr_unix_file_cleanup); #ifndef WAITIO_USES_POLL (*new_file)->pollset = NULL; #endif return APR_SUCCESS; }
APR_DECLARE(apr_status_t) apr_file_setaside(apr_file_t **new_file, apr_file_t *old_file, apr_pool_t *p) { *new_file = (apr_file_t *)apr_palloc(p, sizeof(apr_file_t)); memcpy(*new_file, old_file, sizeof(apr_file_t)); (*new_file)->pool = p; if (old_file->buffered) { (*new_file)->buffer = apr_palloc(p, old_file->bufsize); (*new_file)->bufsize = old_file->bufsize; if (old_file->direction == 1) { memcpy((*new_file)->buffer, old_file->buffer, old_file->bufpos); } else { memcpy((*new_file)->buffer, old_file->buffer, old_file->dataRead); } } if (old_file->mutex) { apr_thread_mutex_create(&((*new_file)->mutex), APR_THREAD_MUTEX_DEFAULT, p); apr_thread_mutex_destroy(old_file->mutex); } if (old_file->fname) { (*new_file)->fname = apr_pstrdup(p, old_file->fname); } if (!(old_file->flags & APR_FOPEN_NOCLEANUP)) { apr_pool_cleanup_register(p, (void *)(*new_file), file_cleanup, file_cleanup); } old_file->filehand = INVALID_HANDLE_VALUE; apr_pool_cleanup_kill(old_file->pool, (void *)old_file, file_cleanup); #if APR_FILES_AS_SOCKETS /* Create a pollset with room for one descriptor. */ /* ### check return codes */ (void) apr_pollset_create(&(*new_file)->pollset, 1, p, 0); #endif return APR_SUCCESS; }
APT_DECLARE(apt_bool_t) apt_log_file_open(const char *file_path, apr_size_t max_size, apr_pool_t *pool) { if(!pool) { return FALSE; } /* create mutex */ if(apr_thread_mutex_create(&apt_logger.mutex,APR_THREAD_MUTEX_DEFAULT,pool) != APR_SUCCESS) { return FALSE; } /* open log file */ apt_logger.file = fopen(file_path,"w"); if(!apt_logger.file) { apr_thread_mutex_destroy(apt_logger.mutex); return FALSE; } apt_logger.cur_size = 0; apt_logger.max_size = max_size; return TRUE; }
static apr_status_t queue_info_cleanup(void *data_) { fd_queue_info_t *qi = data_; apr_thread_cond_destroy(qi->wait_for_idler); apr_thread_mutex_destroy(qi->idlers_mutex); /* Clean up any pools in the recycled list */ for (;;) { struct recycled_pool *first_pool = qi->recycled_pools; if (first_pool == NULL) { break; } if (apr_atomic_casptr((void*)&(qi->recycled_pools), first_pool->next, first_pool) == first_pool) { apr_pool_destroy(first_pool->pool); } } return APR_SUCCESS; }
/*! \brief Cleanup already allocated data */ static void uni_recog_cleanup(uni_speech_t *uni_speech) { if(uni_speech->speech_base) { uni_speech->speech_base->data = NULL; } if(uni_speech->mutex) { apr_thread_mutex_destroy(uni_speech->mutex); uni_speech->mutex = NULL; } if(uni_speech->wait_object) { apr_thread_cond_destroy(uni_speech->wait_object); uni_speech->wait_object = NULL; } if(uni_speech->media_buffer) { mpf_frame_buffer_destroy(uni_speech->media_buffer); uni_speech->media_buffer = NULL; } mrcp_application_session_destroy(uni_speech->session); }
static apr_status_t file_cleanup(apr_file_t *file, int is_child) { apr_status_t rv = APR_SUCCESS; int fd = file->filedes; /* Set file descriptor to -1 before close(), so that there is no * chance of returning an already closed FD from apr_os_file_get(). */ file->filedes = -1; if (close(fd) == 0) { /* Only the parent process should delete the file! */ if (!is_child && (file->flags & APR_DELONCLOSE)) { unlink(file->fname); } #if APR_HAS_THREADS if (file->thlock) { rv = apr_thread_mutex_destroy(file->thlock); } #endif } else { /* Restore, close() was not successful. */ file->filedes = fd; /* Are there any error conditions other than EINTR or EBADF? */ rv = errno; } #ifndef WAITIO_USES_POLL if (file->pollset != NULL) { apr_status_t pollset_rv = apr_pollset_destroy(file->pollset); /* If the file close failed, return its error value, * not apr_pollset_destroy()'s. */ if (rv == APR_SUCCESS) { rv = pollset_rv; } } #endif /* !WAITIO_USES_POLL */ return rv; }