void unreference() { switch_mutex_destroy(_mutex); if (_can_delete_pool) switch_core_destroy_memory_pool(&_pool); }
//SavedCondition(const SavedCondition &); ~SavedCondition() { switch_thread_cond_destroy(_condition); switch_mutex_destroy(_mutex); if(_can_delete_pool) switch_core_destroy_memory_pool(&_pool); }
WSClientParser::~WSClientParser() { // TODO Auto-generated destructor stub DestroyCall(); switch_mutex_destroy(clientMutex); switch_core_destroy_memory_pool(&mpPool); mpPool = NULL; }
void mongo_connection_pool_destroy(mongo_connection_pool_t **conn_pool) { mongo_connection_pool_t *cpool = *conn_pool; void *data = NULL; switch_assert(cpool != NULL); while (switch_queue_trypop(cpool->connections, &data) == SWITCH_STATUS_SUCCESS) { mongo_connection_destroy((DBClientBase **)&data); } switch_mutex_destroy(cpool->mutex); switch_core_destroy_memory_pool(&cpool->pool); *conn_pool = NULL; }
SWITCH_DECLARE(void) switch_ssl_destroy_ssl_locks(void) { int i; if (ssl_count == 1) { CRYPTO_set_locking_callback(NULL); for (i = 0; i < CRYPTO_num_locks(); i++) { if (ssl_mutexes[i]) { switch_mutex_destroy(ssl_mutexes[i]); } } OPENSSL_free(ssl_mutexes); ssl_count--; } }
void WSClientParser::DestroyChannel(WSChannel* wsChannel) { switch_log_printf( SWITCH_CHANNEL_UUID_LOG(this->GetUUID()), SWITCH_LOG_INFO, "WSClientParser::DestroyChannel( " "this : %p, " "wsChannel : %p " ") \n", this, mpChannel ); if( wsChannel ) { // Audio if (switch_core_codec_ready(&wsChannel->read_codec)) { switch_core_codec_destroy(&wsChannel->read_codec); } if (switch_core_codec_ready(&wsChannel->write_codec)) { switch_core_codec_destroy(&wsChannel->write_codec); } // Video if (switch_core_codec_ready(&wsChannel->video_read_codec)) { switch_core_codec_destroy(&wsChannel->video_read_codec); } if (switch_core_codec_ready(&wsChannel->video_write_codec)) { switch_core_codec_destroy(&wsChannel->video_write_codec); } if( wsChannel->video_readbuf_mutex ) { switch_mutex_destroy(wsChannel->video_readbuf_mutex); wsChannel->video_readbuf_mutex = NULL; } if( wsChannel->session ) { switch_media_handle_destroy(wsChannel->session); wsChannel->session = NULL; } if( wsChannel->video_readbuf ) { switch_buffer_destroy(&wsChannel->video_readbuf); wsChannel->video_readbuf = NULL; } } }
static inline void free_context(shout_context_t *context) { int ret; if (context) { switch_mutex_lock(context->audio_mutex); context->err++; switch_mutex_unlock(context->audio_mutex); if (context->stream_url) { int sanity = 0; while (context->thread_running) { switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Waiting for stream to terminate: %s\n", context->stream_url); switch_yield(500000); if (++sanity > 10) { switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Giving up waiting for stream to terminate: %s\n", context->stream_url); break; } } } switch_thread_rwlock_wrlock(context->rwlock); if (context->mh) { mpg123_close(context->mh); mpg123_delete(context->mh); } if (context->fp) { unsigned char mp3buffer[8192]; int len; int16_t blank[2048] = { 0 }, *r = NULL; if (context->channels == 2) { r = blank; } len = lame_encode_buffer(context->gfp, blank, r, sizeof(blank) / 2, mp3buffer, sizeof(mp3buffer)); if (len) { ret = fwrite(mp3buffer, 1, len, context->fp); } while ((len = lame_encode_flush(context->gfp, mp3buffer, sizeof(mp3buffer))) > 0) { ret = fwrite(mp3buffer, 1, len, context->fp); if (ret < 0) { break; } } lame_mp3_tags_fid(context->gfp, context->fp); fclose(context->fp); context->fp = NULL; } if (context->shout) { shout_close(context->shout); context->shout = NULL; } if (context->gfp) { lame_close(context->gfp); context->gfp = NULL; } if (context->audio_buffer) { switch_buffer_destroy(&context->audio_buffer); } switch_mutex_destroy(context->audio_mutex); switch_thread_rwlock_unlock(context->rwlock); switch_thread_rwlock_destroy(context->rwlock); } }
static switch_status_t unbind_fetch_agent(switch_xml_binding_t **binding) { ei_xml_agent_t *agent; ei_xml_client_t *client; /* get a pointer to our user_data */ agent = (ei_xml_agent_t *)switch_xml_get_binding_user_data(*binding); /* unbind from the switch */ switch_xml_unbind_search_function(binding); /* LOCK ALL THE THINGS */ switch_thread_rwlock_wrlock(agent->lock); switch_mutex_lock(agent->current_client_mutex); switch_mutex_lock(agent->replies_mutex); /* cleanly destroy each client */ client = agent->clients; while(client != NULL) { ei_xml_client_t *tmp_client = client; fetch_handler_t *fetch_handler; fetch_handler = client->fetch_handlers; while(fetch_handler != NULL) { fetch_handler_t *tmp_fetch_handler = fetch_handler; switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Removed %s XML handler %s <%d.%d.%d>\n" ,xml_section_to_string(agent->section) ,fetch_handler->pid.node ,fetch_handler->pid.creation ,fetch_handler->pid.num ,fetch_handler->pid.serial); fetch_handler = fetch_handler->next; switch_safe_free(tmp_fetch_handler); } client = client->next; switch_safe_free(tmp_client); } /* keep the pointers clean, even if its just for a moment */ agent->clients = NULL; agent->current_client = NULL; /* release the locks! */ switch_thread_rwlock_unlock(agent->lock); switch_mutex_unlock(agent->current_client_mutex); switch_mutex_unlock(agent->replies_mutex); switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Unbound from %s XML requests\n" ,xml_section_to_string(agent->section)); /* cleanly destroy the bindings */ switch_thread_rwlock_destroy(agent->lock); switch_mutex_destroy(agent->current_client_mutex); switch_mutex_destroy(agent->replies_mutex); switch_thread_cond_destroy(agent->new_reply); switch_core_destroy_memory_pool(&agent->pool); return SWITCH_STATUS_SUCCESS; }
static switch_status_t load_config(switch_memory_pool_t *pool) { switch_status_t status = SWITCH_STATUS_SUCCESS; char *cf = "cdr_pg_csv.conf", *ptr; switch_xml_t cfg, xml, schema, field; const char *attr; int num_fields = 0; switch_size_t len = 0; cdr_field_t *cdr_field; if (globals.db_online) { PQfinish(globals.db_connection); switch_mutex_destroy(globals.db_mutex); globals.db_online = 0; } memset(&globals, 0, sizeof(globals)); switch_core_hash_init(&globals.fd_hash, pool); switch_mutex_init(&globals.db_mutex, SWITCH_MUTEX_NESTED, pool); globals.pool = pool; if (switch_xml_config_parse_module_settings(cf, SWITCH_FALSE, config_settings) != SWITCH_STATUS_SUCCESS) { return SWITCH_STATUS_FALSE; } if ((xml = switch_xml_open_cfg(cf, &cfg, NULL))) { if ((schema = switch_xml_child(cfg, "schema"))) { /* Count fields in schema so we can calculate required buffer size */ for (field = switch_xml_child(schema, "field"); field; field = field->next) { if (switch_xml_attr(field, "var")) { num_fields++; } } globals.db_schema = switch_core_alloc(pool, (num_fields + 1) * sizeof(cdr_field_t)); cdr_field = globals.db_schema->fields; for (field = switch_xml_child(schema, "field"); field; field = field->next) { if ((attr = switch_xml_attr(field, "var"))) { cdr_field->var_name = switch_core_strdup(pool, attr); /* Assume SQL column name is the same as FreeSWITCH channel var name, unless specified otherwise */ if ((attr = switch_xml_attr(field, "column"))) { cdr_field->col_name = switch_core_strdup(pool, attr); } else { cdr_field->col_name = switch_core_strdup(pool, cdr_field->var_name); } /* Assume all fields should be quoted (treated as strings), unless specified otherwise */ if ((attr = switch_xml_attr(field, "quote")) && !strncmp(attr, "false", 5)) { cdr_field->quote = SWITCH_FALSE; } else { cdr_field->quote = SWITCH_TRUE; } /* Assume all fields allow SQL nulls, unless specified otherwise */ if ((attr = switch_xml_attr(field, "not-null")) && !strncmp(attr, "true", 4)) { cdr_field->not_null = SWITCH_TRUE; } else { cdr_field->not_null = SWITCH_FALSE; } len += strlen(cdr_field->col_name) + 1; cdr_field++; } } cdr_field->var_name = 0; globals.db_schema->columns = switch_core_alloc(pool, len); ptr = globals.db_schema->columns; for (cdr_field = globals.db_schema->fields; cdr_field->col_name; cdr_field++) { len = strlen(cdr_field->col_name); memcpy(ptr, cdr_field->col_name, len); ptr += len; *ptr = ','; ptr++; } *--ptr = '\0'; } switch_xml_free(xml); } return status; }