From 7b2ba5339a27af67c74cb5966918f52b9772e4da Mon Sep 17 00:00:00 2001 From: Richard Fuchs Date: Tue, 12 Dec 2023 14:59:42 -0500 Subject: [PATCH] MT#55283 use typed G* for call members Change-Id: Idcd7d703952d5559d3e13bf681cf7342e6768f12 --- daemon/call.c | 67 +++++++++++++++++++--------------------- daemon/call_interfaces.c | 37 +++++++++++----------- daemon/cdr.c | 3 +- daemon/cli.c | 9 ++---- daemon/dtmf.c | 17 +++++----- daemon/mqtt.c | 2 +- daemon/recording.c | 2 +- daemon/redis.c | 12 +++---- daemon/statistics.c | 3 +- include/call.h | 15 ++++++--- t/test-transcode.c | 8 ++--- 11 files changed, 85 insertions(+), 90 deletions(-) diff --git a/daemon/call.c b/daemon/call.c index c19d9723c..2478fd087 100644 --- a/daemon/call.c +++ b/daemon/call.c @@ -83,7 +83,6 @@ static void __subscribe_medias_both_ways(struct call_media * a, struct call_medi /* called with call->master_lock held in R */ static int call_timer_delete_monologues(call_t *c) { - GList *i; struct call_monologue *ml; int ret = 0; time_t min_deleted = 0; @@ -93,7 +92,7 @@ static int call_timer_delete_monologues(call_t *c) { rwlock_unlock_r(&c->master_lock); rwlock_lock_w(&c->master_lock); - for (i = c->monologues.head; i; i = i->next) { + for (__auto_type i = c->monologues.head; i; i = i->next) { ml = i->data; if (!ml->deleted) @@ -151,7 +150,7 @@ static void call_timer_iterator(call_t *c, struct iterator_helper *hlp) { if (rtpe_config.final_timeout && rtpe_now.tv_sec >= (c->created.tv_sec + rtpe_config.final_timeout)) { ilog(LOG_INFO, "Closing call due to final timeout"); tmp_t_reason = FINAL_TIMEOUT; - for (GList *it = c->monologues.head; it; it = it->next) { + for (__auto_type it = c->monologues.head; it; it = it->next) { ml = it->data; gettimeofday(&(ml->terminated),NULL); ml->term_reason = tmp_t_reason; @@ -222,7 +221,7 @@ next: ; } - for (GList *it = c->medias.head; it; it = it->next) { + for (__auto_type it = c->medias.head; it; it = it->next) { struct call_media *media = it->data; if (rtpe_config.measure_rtp) { media_update_stats(media); @@ -239,7 +238,7 @@ next: if (c->ml_deleted) goto out; - for (GList *it = c->monologues.head; it; it = it->next) { + for (__auto_type it = c->monologues.head; it; it = it->next) { ml = it->data; gettimeofday(&(ml->terminated),NULL); ml->term_reason = tmp_t_reason; @@ -376,7 +375,6 @@ fault: void kill_calls_timer(GSList *list, const char *url) { call_t *ca; - GList *csl; struct call_monologue *cm; char *url_prefix = NULL, *url_suffix = NULL; struct xmlrpc_helper *xh = NULL; @@ -429,7 +427,7 @@ void kill_calls_timer(GSList *list, const char *url) { switch (rtpe_config.fmt) { case XF_SEMS: - for (csl = ca->monologues.head; csl; csl = csl->next) { + for (__auto_type csl = ca->monologues.head; csl; csl = csl->next) { cm = csl->data; if (!cm->tag.s || !cm->tag.len) continue; @@ -442,7 +440,7 @@ void kill_calls_timer(GSList *list, const char *url) { g_queue_push_tail(&xh->strings, str_dup(&ca->callid)); break; case XF_KAMAILIO: - for (csl = ca->monologues.head; csl; csl = csl->next) { + for (__auto_type csl = ca->monologues.head; csl; csl = csl->next) { cm = csl->data; if (!cm->tag.s || !cm->tag.len) continue; @@ -601,7 +599,7 @@ void call_free(void) { struct call_media *call_media_new(call_t *call) { struct call_media *med; - med = uid_slice_alloc0(med, &call->medias); + med = uid_slice_alloc0(med, &call->medias.q); med->call = call; codec_store_init(&med->codecs, med); med->media_subscribers_ht = g_hash_table_new(g_direct_hash, g_direct_equal); @@ -3567,7 +3565,7 @@ static void __call_cleanup(call_t *c) { t_queue_clear_full(&ps->rtp_mirrors, free_sink_handler); } - for (GList *l = c->medias.head; l; l = l->next) { + for (__auto_type l = c->medias.head; l; l = l->next) { struct call_media *md = l->data; ice_shutdown(&md->ice_agent); media_stop(md); @@ -3575,7 +3573,7 @@ static void __call_cleanup(call_t *c) { audio_player_free(md); } - for (GList *l = c->monologues.head; l; l = l->next) { + for (__auto_type l = c->monologues.head; l; l = l->next) { struct call_monologue *ml = l->data; __monologue_stop(ml); media_player_put(&ml->player); @@ -3598,7 +3596,7 @@ static void __call_cleanup(call_t *c) { /* called lock-free, but must hold a reference to the call */ void call_destroy(call_t *c) { struct packet_stream *ps=0; - GList *l, *ll; + GList *ll; struct call_monologue *ml; struct call_media *md; GList *k; @@ -3647,7 +3645,7 @@ void call_destroy(call_t *c) { ilog(LOG_INFO, "Final packet stats:"); - for (l = c->monologues.head; l; l = l->next) { + for (__auto_type l = c->monologues.head; l; l = l->next) { ml = l->data; // stats output only - no cleanups @@ -3894,12 +3892,12 @@ static void __call_free(void *p) { mqtt_timer_stop(&c->mqtt_timer); while (c->monologues.head) { - m = g_queue_pop_head(&c->monologues); + m = t_queue_pop_head(&c->monologues); __monologue_free(m); } while (c->medias.head) { - md = g_queue_pop_head(&c->medias); + md = t_queue_pop_head(&c->medias); call_media_free(&md); } @@ -3910,8 +3908,8 @@ static void __call_free(void *p) { g_slice_free1(sizeof(*em), em); } - g_hash_table_destroy(c->tags); - g_hash_table_destroy(c->viabranches); + t_hash_table_destroy(c->tags); + t_hash_table_destroy(c->viabranches); t_hash_table_destroy(c->labels); while (c->streams.head) { @@ -3941,8 +3939,8 @@ static call_t *call_create(const str *callid) { mutex_init(&c->buffer_lock); call_buffer_init(&c->buffer); rwlock_init(&c->master_lock); - c->tags = g_hash_table_new(str_hash, str_equal); - c->viabranches = g_hash_table_new(str_hash, str_equal); + c->tags = tags_ht_new(); + c->viabranches = tags_ht_new(); c->labels = labels_ht_new(); call_str_cpy(c, &c->callid, callid); c->created = rtpe_now; @@ -4076,7 +4074,7 @@ struct call_monologue *__monologue_create(call_t *call) { struct call_monologue *ret; __C_DBG("creating new monologue"); - ret = uid_slice_alloc0(ret, &call->monologues); + ret = uid_slice_alloc0(ret, &call->monologues.q); ret->call = call; ret->created = rtpe_now.tv_sec; @@ -4102,9 +4100,9 @@ void __monologue_tag(struct call_monologue *ml, const str *tag) { __C_DBG("tagging monologue with '"STR_FORMAT"'", STR_FMT(tag)); if (ml->tag.s) - g_hash_table_remove(call->tags, &ml->tag); /* remove tag from tags of the call object */ + t_hash_table_remove(call->tags, &ml->tag); /* remove tag from tags of the call object */ call_str_cpy(call, &ml->tag, tag); - g_hash_table_insert(call->tags, &ml->tag, ml); /* and insert a new one */ + t_hash_table_insert(call->tags, &ml->tag, ml); /* and insert a new one */ } void __monologue_viabranch(struct call_monologue *ml, const str *viabranch) { @@ -4115,9 +4113,9 @@ void __monologue_viabranch(struct call_monologue *ml, const str *viabranch) { __C_DBG("tagging monologue with viabranch '"STR_FORMAT"'", STR_FMT(viabranch)); if (ml->viabranch.s) - g_hash_table_remove(call->viabranches, &ml->viabranch); + t_hash_table_remove(call->viabranches, &ml->viabranch); call_str_cpy(call, &ml->viabranch, viabranch); - g_hash_table_insert(call->viabranches, &ml->viabranch, ml); + t_hash_table_insert(call->viabranches, &ml->viabranch, ml); } static void __unconfirm_sinks(sink_handler_q *q, const char *reason) { @@ -4232,9 +4230,9 @@ void monologue_destroy(struct call_monologue *monologue) { __monologue_unconfirm(monologue, "destroying monologue"); __tags_unassociate_all(monologue); - g_hash_table_remove(call->tags, &monologue->tag); + t_hash_table_remove(call->tags, &monologue->tag); if (monologue->viabranch.s) - g_hash_table_remove(call->viabranches, &monologue->viabranch); + t_hash_table_remove(call->viabranches, &monologue->viabranch); // close sockets for (unsigned int i = 0; i < monologue->medias->len; i++) { @@ -4312,7 +4310,7 @@ static bool monologue_delete_iter(struct call_monologue *a, int delete_delay) { * Must be called with call->master_lock held in W. */ struct call_monologue *call_get_monologue(call_t *call, const str *fromtag) { - return g_hash_table_lookup(call->tags, fromtag); + return t_hash_table_lookup(call->tags, fromtag); } /** @@ -4349,7 +4347,7 @@ static void __tags_associate(struct call_monologue *a, struct call_monologue *b) * Check whether the call object contains some other monologues, which can have own associations. */ static bool call_monologues_associations_left(call_t * c) { - for (GList * l = c->monologues.head; l; l = l->next) + for (__auto_type l = c->monologues.head; l; l = l->next) { struct call_monologue * ml = l->data; if (g_hash_table_size(ml->associated_tags) > 0) @@ -4511,7 +4509,7 @@ static int call_get_monologue_new(struct call_monologue *monologues[2], call_t * if (!viabranch || call_viabranch_intact_monologue(viabranch, ret)) { goto monologues_intact; } else { - os = g_hash_table_lookup(call->viabranches, viabranch); + os = t_hash_table_lookup(call->viabranches, viabranch); if (os) { /* previously seen branch, use it */ __monologue_unconfirm(os, "dialogue/branch association changed"); @@ -4613,7 +4611,7 @@ static int call_get_dialogue(struct call_monologue *monologues[2], call_t *call, } else { /* viabranch */ if (viabranch) - ft = g_hash_table_lookup(call->viabranches, viabranch); + ft = t_hash_table_lookup(call->viabranches, viabranch); /* top most subscription of tt */ if (!ft) { struct call_media *media = tt->medias->pdata[0]; @@ -4725,13 +4723,12 @@ int call_delete_branch(call_t *c, const str *branch, struct call_monologue *ml; int ret; const str *match_tag; - GList *i; bool update = false; if (delete_delay < 0) delete_delay = rtpe_config.delete_delay; - for (i = c->monologues.head; i; i = i->next) { + for (__auto_type i = c->monologues.head; i; i = i->next) { ml = i->data; gettimeofday(&(ml->terminated), NULL); ml->term_reason = REGULAR; @@ -4742,7 +4739,7 @@ int call_delete_branch(call_t *c, const str *branch, if ((!totag || !totag->len) && branch && branch->len) { // try a via-branch match - ml = g_hash_table_lookup(c->viabranches, branch); + ml = t_hash_table_lookup(c->viabranches, branch); if (ml) goto do_delete; } @@ -4753,7 +4750,7 @@ int call_delete_branch(call_t *c, const str *branch, if (!ml) { if (branch && branch->len) { // also try a via-branch match here - ml = g_hash_table_lookup(c->viabranches, branch); + ml = t_hash_table_lookup(c->viabranches, branch); if (ml) goto do_delete; } @@ -4808,7 +4805,7 @@ do_delete: goto success_unlock; del_all: - for (i = c->monologues.head; i; i = i->next) { + for (__auto_type i = c->monologues.head; i; i = i->next) { ml = i->data; monologue_stop(ml, false); } diff --git a/daemon/call_interfaces.c b/daemon/call_interfaces.c index 6fc555cab..0545adecf 100644 --- a/daemon/call_interfaces.c +++ b/daemon/call_interfaces.c @@ -2459,7 +2459,6 @@ void ng_call_stats(call_t *call, const str *fromtag, const str *totag, bencode_i { bencode_item_t *tags = NULL, *dict; const str *match_tag; - GList *l; struct call_monologue *ml; struct call_stats t_b; bencode_item_t *ssrc = NULL; @@ -2484,7 +2483,7 @@ stats: match_tag = (totag && totag->s && totag->len) ? totag : fromtag; if (!match_tag || !match_tag->len) { - for (l = call->monologues.head; l; l = l->next) { + for (__auto_type l = call->monologues.head; l; l = l->next) { ml = l->data; ng_stats_monologue(tags, ml, totals, ssrc); } @@ -2678,7 +2677,7 @@ static const char *media_block_match1(call_t *call, struct call_monologue **mono if (sockaddr_parse_any_str(&addr, &flags->address)) return "Failed to parse network address"; // walk our structures to find a matching stream - for (GList *l = call->monologues.head; l; l = l->next) { + for (__auto_type l = call->monologues.head; l; l = l->next) { *monologue = l->data; for (unsigned int k = 0; k < (*monologue)->medias->len; k++) { struct call_media *media = (*monologue)->medias->pdata[k]; @@ -2755,7 +2754,7 @@ static const char *media_block_match_mult(call_t **call, GQueue *medias, return "Unknown call-ID"; if (flags->all == ALL_ALL) { - for (GList *l = (*call)->medias.head; l; l = l->next) { + for (__auto_type l = (*call)->medias.head; l; l = l->next) { struct call_media *media = l->data; if (!media || (media->monologue->tagtype != FROM_TAG && media->monologue->tagtype != TO_TAG)) @@ -2856,7 +2855,7 @@ const char *call_stop_forwarding_ng(bencode_item_t *input, bencode_item_t *outpu ilog(LOG_INFO, "Stop forwarding (entire call)"); CALL_CLEAR(call, REC_FORWARDING); if (flags.all == ALL_ALL) { - for (GList *l = call->monologues.head; l; l = l->next) { + for (__auto_type l = call->monologues.head; l; l = l->next) { monologue = l->data; ML_CLEAR(monologue, REC_FORWARDING); } @@ -2947,7 +2946,7 @@ const char *call_block_dtmf_ng(bencode_item_t *input, bencode_item_t *output) { if (monologue) call_monologue_set_block_mode(monologue, &flags); else { - for (GList *l = call->monologues.head; l; l = l->next) { + for (__auto_type l = call->monologues.head; l; l = l->next) { struct call_monologue *ml = l->data; call_monologue_set_block_mode(ml, &flags); } @@ -2990,7 +2989,7 @@ const char *call_unblock_dtmf_ng(bencode_item_t *input, bencode_item_t *output) enum block_dtmf_mode prev_mode = call->block_dtmf; call->block_dtmf = BLOCK_DTMF_OFF; if (flags.all == ALL_ALL || is_dtmf_replace_mode(prev_mode) || flags.delay_buffer >= 0) { - for (GList *l = call->monologues.head; l; l = l->next) { + for (__auto_type l = call->monologues.head; l; l = l->next) { monologue = l->data; enum block_dtmf_mode prev_ml_mode = BLOCK_DTMF_OFF; if (flags.all == ALL_ALL) { @@ -3032,7 +3031,7 @@ static const char *call_block_silence_media(bencode_item_t *input, bool on_off, if (monologue) { g_auto(GQueue) sinks = G_QUEUE_INIT; if (flags.to_tag.len) { - struct call_monologue *sink = g_hash_table_lookup(call->tags, &flags.to_tag); + struct call_monologue *sink = t_hash_table_lookup(call->tags, &flags.to_tag); if (!sink) { ilog(LOG_WARN, "Media flow '" STR_FORMAT_M "' -> '" STR_FORMAT_M "' doesn't " "exist for media %s (to-tag not found)", @@ -3137,7 +3136,7 @@ static const char *call_block_silence_media(bencode_item_t *input, bool on_off, if (!on_off) { ilog(LOG_INFO, "%s media (entire call and participants)", ucase_verb); if (flags.all == ALL_ALL) { - for (GList *l = call->monologues.head; l; l = l->next) { + for (__auto_type l = call->monologues.head; l; l = l->next) { monologue = l->data; bf_set_clear(&monologue->ml_flags, ml_flag, on_off); } @@ -3172,22 +3171,22 @@ const char *call_unsilence_media_ng(bencode_item_t *input, bencode_item_t *outpu #ifdef WITH_TRANSCODING -static const char *play_media_select_party(call_t **call, GQueue *monologues, +static const char *play_media_select_party(call_t **call, monologues_q *monologues, bencode_item_t *input, sdp_ng_flags *flags) { struct call_monologue *monologue; - g_queue_init(monologues); + t_queue_init(monologues); const char *err = media_block_match(call, &monologue, flags, input, OP_OTHER); if (err) return err; if (flags->all == ALL_ALL) - g_queue_append(monologues, &(*call)->monologues); + t_queue_append(monologues, &(*call)->monologues); else if (!monologue) return "No participant party specified"; else - g_queue_push_tail(monologues, monologue); + t_queue_push_tail(monologues, monologue); return NULL; } #endif @@ -3196,7 +3195,7 @@ static const char *play_media_select_party(call_t **call, GQueue *monologues, const char *call_play_media_ng(bencode_item_t *input, bencode_item_t *output) { #ifdef WITH_TRANSCODING g_autoptr(call_t) call = NULL; - g_auto(GQueue) monologues; + g_auto(monologues_q) monologues; const char *err = NULL; g_auto(sdp_ng_flags) flags; @@ -3206,7 +3205,7 @@ const char *call_play_media_ng(bencode_item_t *input, bencode_item_t *output) { flags.opmode = OP_PLAY_MEDIA; - for (GList *l = monologues.head; l; l = l->next) { + for (__auto_type l = monologues.head; l; l = l->next) { struct call_monologue *monologue = l->data; // if mixing is enabled, codec handlers of all sources must be updated @@ -3251,7 +3250,7 @@ const char *call_play_media_ng(bencode_item_t *input, bencode_item_t *output) { const char *call_stop_media_ng(bencode_item_t *input, bencode_item_t *output) { #ifdef WITH_TRANSCODING g_autoptr(call_t) call = NULL; - g_auto(GQueue) monologues; + g_auto(monologues_q) monologues; const char *err = NULL; long long last_frame_pos = 0; g_auto(sdp_ng_flags) flags; @@ -3260,7 +3259,7 @@ const char *call_stop_media_ng(bencode_item_t *input, bencode_item_t *output) { if (err) return err; - for (GList *l = monologues.head; l; l = l->next) { + for (__auto_type l = monologues.head; l; l = l->next) { struct call_monologue *monologue = l->data; if (!monologue->player) @@ -3284,7 +3283,7 @@ const char *call_stop_media_ng(bencode_item_t *input, bencode_item_t *output) { const char *call_play_dtmf_ng(bencode_item_t *input, bencode_item_t *output) { #ifdef WITH_TRANSCODING g_autoptr(call_t) call = NULL; - g_auto(GQueue) monologues; + g_auto(monologues_q) monologues; const char *err = NULL; g_auto(sdp_ng_flags) flags; @@ -3330,7 +3329,7 @@ const char *call_play_dtmf_ng(bencode_item_t *input, bencode_item_t *output) { if (flags.volume > 0) flags.volume *= -1; - for (GList *l = monologues.head; l; l = l->next) { + for (__auto_type l = monologues.head; l; l = l->next) { struct call_monologue *monologue = l->data; // find a usable output media diff --git a/daemon/cdr.c b/daemon/cdr.c index 4da44a8cf..1ea4c544b 100644 --- a/daemon/cdr.c +++ b/daemon/cdr.c @@ -36,7 +36,6 @@ static const char * get_term_reason_text(enum termination_reason t) { } void cdr_update_entry(call_t * c) { - GList *l; struct call_monologue *ml; struct timeval tim_result_duration; int cdrlinecnt = 0; @@ -56,7 +55,7 @@ void cdr_update_entry(call_t * c) { g_string_append_printf(cdr, "tos=%u, ", (unsigned int)c->tos); } - for (l = c->monologues.head; l; l = l->next) { + for (__auto_type l = c->monologues.head; l; l = l->next) { ml = l->data; if (!ml->terminated.tv_sec) { diff --git a/daemon/cli.c b/daemon/cli.c index a2a1abe8b..93ab9329a 100644 --- a/daemon/cli.c +++ b/daemon/cli.c @@ -227,7 +227,6 @@ static void cli_handler_do(const cli_handler_t *handlers, str *instr, static void destroy_own_foreign_calls(bool foreign_call, unsigned int uint_keyspace_db) { struct call_monologue *ml = NULL; GQueue call_list = G_QUEUE_INIT; - GList *i; ITERATE_CALL_LIST_START(CALL_ITERATOR_MAIN, c); // match foreign_call flag @@ -252,7 +251,7 @@ next:; call_t *c = NULL; while ((c = g_queue_pop_head(&call_list))) { if (!c->ml_deleted) { - for (i = c->monologues.head; i; i = i->next) { + for (__auto_type i = c->monologues.head; i; i = i->next) { ml = i->data; gettimeofday(&(ml->terminated), NULL); ml->term_reason = FORCED; @@ -606,7 +605,6 @@ static void cli_incoming_list_callid(str *instr, struct cli_writer *cw) { static void cli_list_call_info(struct cli_writer *cw, call_t *c) { struct call_monologue *ml; - GList *l; cw->cw_printf(cw, "\ncallid: %s\ndeletionmark: %s\ncreated: %i\nproxy: %s\ntos: %u\nlast_signal: %llu\n" @@ -615,7 +613,7 @@ static void cli_list_call_info(struct cli_writer *cw, call_t *c) { (unsigned int) c->tos, (unsigned long long) c->last_signal, c->redis_hosted_db, IS_FOREIGN_CALL(c) ? "yes" : "no"); - for (l = c->monologues.head; l; l = l->next) { + for (__auto_type l = c->monologues.head; l; l = l->next) { ml = l->data; cli_list_tag_info(cw, ml); } @@ -996,7 +994,6 @@ static void cli_incoming_params(str *instr, struct cli_writer *cw) { static void cli_incoming_terminate(str *instr, struct cli_writer *cw) { call_t * c=0; struct call_monologue *ml; - GList *i; if (str_shift(instr, 1)) { cw->cw_printf(cw, "%s\n", "More parameters required."); @@ -1049,7 +1046,7 @@ static void cli_incoming_terminate(str *instr, struct cli_writer *cw) { } if (!c->ml_deleted) { - for (i = c->monologues.head; i; i = i->next) { + for (__auto_type i = c->monologues.head; i; i = i->next) { ml = i->data; gettimeofday(&(ml->terminated), NULL); ml->term_reason = FORCED; diff --git a/daemon/dtmf.c b/daemon/dtmf.c index a9fd24e16..6e0ede131 100644 --- a/daemon/dtmf.c +++ b/daemon/dtmf.c @@ -59,12 +59,11 @@ static void dtmf_bencode_and_notify(struct call_media *media, unsigned int event bencode_dictionary_add_string_len(data, "source_label", ml->label.s, ml->label.len); } - GList *tag_values = g_hash_table_get_values(call->tags); - for (GList *tag_it = tag_values; tag_it; tag_it = tag_it->next) { - struct call_monologue *tml = tag_it->data; + tags_ht_iter iter; + t_hash_table_iter_init(&iter, call->tags); + struct call_monologue *tml; + while (t_hash_table_iter_next(&iter, NULL, &tml)) bencode_list_add_str(tags, &tml->tag); - } - g_list_free(tag_values); bencode_dictionary_add_string(data, "type", "DTMF"); bencode_dictionary_add_string(data, "source_ip", sockaddr_print_buf(&fsin->address)); @@ -99,17 +98,17 @@ static GString *dtmf_json_print(struct call_media *media, unsigned int event, un STR_FMT(&ml->tag), STR_FMT(ml->label.s ? &ml->label : &STR_EMPTY)); - GList *tag_values = g_hash_table_get_values(call->tags); + tags_ht_iter iter; + t_hash_table_iter_init(&iter, call->tags); int i = 0; - for (GList *tag_it = tag_values; tag_it; tag_it = tag_it->next) { - struct call_monologue *tml = tag_it->data; + struct call_monologue *tml; + while (t_hash_table_iter_next(&iter, NULL, &tml)) { if (i != 0) g_string_append(buf, ","); g_string_append_printf(buf, "\"" STR_FORMAT "\"", STR_FMT(&tml->tag)); i++; } - g_list_free(tag_values); g_string_append_printf(buf, "]," "\"type\":\"DTMF\",\"timestamp\":%lu,\"source_ip\":\"%s\"," diff --git a/daemon/mqtt.c b/daemon/mqtt.c index d1506a188..33bdaa92e 100644 --- a/daemon/mqtt.c +++ b/daemon/mqtt.c @@ -436,7 +436,7 @@ static void mqtt_full_call(call_t *call, JsonBuilder *json) { json_builder_set_member_name(json, "legs"); json_builder_begin_array(json); - for (GList *l = call->monologues.head; l; l = l->next) { + for (__auto_type l = call->monologues.head; l; l = l->next) { struct call_monologue *ml = l->data; json_builder_begin_object(json); diff --git a/daemon/recording.c b/daemon/recording.c index 5f102ff6d..6e0ea2b36 100644 --- a/daemon/recording.c +++ b/daemon/recording.c @@ -383,7 +383,7 @@ void recording_stop(call_t *call) { return; } - for (GList *l = call->monologues.head; l; l = l->next) { + for (__auto_type l = call->monologues.head; l; l = l->next) { struct call_monologue *ml = l->data; if (ML_ISSET(ml, REC_FORWARDING)) { recording_update_flags(call, true); diff --git a/daemon/redis.c b/daemon/redis.c index 0f31a9eef..c79acc028 100644 --- a/daemon/redis.c +++ b/daemon/redis.c @@ -2354,8 +2354,8 @@ char* redis_encode_json(call_t *c) { JSON_SET_SIMPLE("deleted","%ld", (long int) c->deleted); JSON_SET_SIMPLE("num_sfds","%u", t_queue_get_length(&c->stream_fds)); JSON_SET_SIMPLE("num_streams","%u", t_queue_get_length(&c->streams)); - JSON_SET_SIMPLE("num_medias","%u", g_queue_get_length(&c->medias)); - JSON_SET_SIMPLE("num_tags","%u", g_queue_get_length(&c->monologues)); + JSON_SET_SIMPLE("num_medias","%u", t_queue_get_length(&c->medias)); + JSON_SET_SIMPLE("num_tags","%u", t_queue_get_length(&c->monologues)); JSON_SET_SIMPLE("num_maps","%u", t_queue_get_length(&c->endpoint_maps)); JSON_SET_SIMPLE("ml_deleted","%ld", (long int) c->ml_deleted); JSON_SET_SIMPLE_CSTR("created_from", c->created_from); @@ -2466,7 +2466,7 @@ char* redis_encode_json(call_t *c) { } - for (GList *l = c->monologues.head; l; l = l->next) { + for (__auto_type l = c->monologues.head; l; l = l->next) { struct call_monologue *ml = l->data; snprintf(tmp, sizeof(tmp), "tag-%u", ml->unique_id); @@ -2498,7 +2498,7 @@ char* redis_encode_json(call_t *c) { } // --- for monologues.head - for (GList *l = c->monologues.head; l; l = l->next) { + for (__auto_type l = c->monologues.head; l; l = l->next) { struct call_monologue *ml = l->data; // -- we do it again here since the jsonbuilder is linear straight forward // XXX these should all go into the above loop @@ -2551,7 +2551,7 @@ char* redis_encode_json(call_t *c) { rwlock_unlock_r(&ml->ssrc_hash->lock); } - for (GList *l = c->medias.head; l; l = l->next) { + for (__auto_type l = c->medias.head; l; l = l->next) { struct call_media *media = l->data; if (!media) @@ -2603,7 +2603,7 @@ char* redis_encode_json(call_t *c) { // -- we do it again here since the jsonbuilder is linear straight forward // XXX can this be moved into the above json object? - for (GList *l = c->medias.head; l; l = l->next) { + for (__auto_type l = c->medias.head; l; l = l->next) { struct call_media *media = l->data; snprintf(tmp, sizeof(tmp), "streams-%u", media->unique_id); diff --git a/daemon/statistics.c b/daemon/statistics.c index 263f2f322..3ea456b48 100644 --- a/daemon/statistics.c +++ b/daemon/statistics.c @@ -120,14 +120,13 @@ void statistics_update_foreignown_inc(call_t * c) { void statistics_update_oneway(call_t * c) { struct call_monologue *ml; struct call_media *md; - GList *l; if (IS_OWN_CALL(c)) { // --- for statistics getting one way stream or no relay at all unsigned int total_nopacket_relayed_sess = 0; struct packet_stream *ps, *ps2; - for (l = c->monologues.head; l; l = l->next) { + for (__auto_type l = c->monologues.head; l; l = l->next) { ml = l->data; // --- go through partner ml and search the RTP diff --git a/include/call.h b/include/call.h index 68feb2a03..662c262fb 100644 --- a/include/call.h +++ b/include/call.h @@ -502,6 +502,7 @@ struct call_media { }; TYPED_GPTRARRAY(medias_arr, struct call_media) +TYPED_GQUEUE(medias, struct call_media) struct media_subscription { @@ -573,6 +574,10 @@ struct call_monologue { volatile unsigned int ml_flags; }; +TYPED_GQUEUE(monologues, struct call_monologue) +G_DEFINE_AUTO_CLEANUP_CLEAR_FUNC(monologues_q, monologues_q_clear) +TYPED_GHASHTABLE(tags_ht, str, struct call_monologue, str_hash, str_equal, NULL, NULL) + struct call_iterator_list { GList *first; mutex_t lock; // protects .first and every entry's .data @@ -670,10 +675,10 @@ struct call { rwlock_t master_lock; /* everything below is protected by the master_lock */ - GQueue monologues; /* call_monologue */ - GQueue medias; /* call_media */ - GHashTable *tags; - GHashTable *viabranches; + monologues_q monologues; /* call_monologue */ + medias_q medias; /* call_media */ + tags_ht tags; + tags_ht viabranches; labels_ht labels; packet_stream_q streams; stream_fd_q stream_fds; /* stream_fd */ @@ -841,7 +846,7 @@ INLINE str *call_str_init_dup(call_t *c, char *s) { return call_str_dup(c, &t); } INLINE void __call_unkernelize(call_t *call, const char *reason) { - for (GList *l = call->monologues.head; l; l = l->next) { + for (__auto_type l = call->monologues.head; l; l = l->next) { struct call_monologue *ml = l->data; __monologue_unconfirm(ml, reason); } diff --git a/t/test-transcode.c b/t/test-transcode.c index 67d4c2146..ea1bfda12 100644 --- a/t/test-transcode.c +++ b/t/test-transcode.c @@ -56,7 +56,7 @@ static void __cleanup(void) { t_queue_clear_full(&flags.codec_accept, str_free); t_queue_clear_full(&flags.codec_consume, str_free); t_queue_clear_full(&flags.codec_mask, str_free); - g_queue_clear(&call.monologues); + t_queue_clear(&call.monologues); codec_store_cleanup(&rtp_types_sp.codecs); memset(&flags, 0, sizeof(flags)); @@ -83,7 +83,7 @@ static void __start(const char *file, int line) { ssrc_B = 2345; ZERO(call); obj_hold(&call); - call.tags = g_hash_table_new(g_str_hash, g_str_equal); + call.tags = tags_ht_new(); str_init(&call.callid, "test-call"); bencode_buffer_init(&call.buffer); ml_A = __monologue_create(&call); @@ -371,8 +371,8 @@ static void end(void) { call_media_free(&media_A); call_media_free(&media_B); bencode_buffer_free(&call.buffer); - g_hash_table_destroy(call.tags); - g_queue_clear(&call.medias); + t_hash_table_destroy(call.tags); + t_queue_clear(&call.medias); if (ml_A) __monologue_free(ml_A); if (ml_B)