diff --git a/daemon/codec.c b/daemon/codec.c index c98b99366..850cb9de2 100644 --- a/daemon/codec.c +++ b/daemon/codec.c @@ -151,7 +151,7 @@ static void __handler_shutdown(struct codec_handler *handler) { if (handler->stats_entry) { g_atomic_int_add(&handler->stats_entry->num_transcoders, -1); handler->stats_entry = NULL; - free(handler->stats_chain); + g_free(handler->stats_chain); } } @@ -255,28 +255,25 @@ reset: handler->ssrc_hash = create_ssrc_hash_full(__ssrc_handler_transcode_new, handler); // stats entry - if (asprintf(&handler->stats_chain, STR_FORMAT " -> " STR_FORMAT, + handler->stats_chain = g_strdup_printf(STR_FORMAT " -> " STR_FORMAT, STR_FMT(&handler->source_pt.encoding_with_params), - STR_FMT(&dest->encoding_with_params)) < 0) - ilog(LOG_ERR, "asprintf error"); - else { - mutex_lock(&rtpe_codec_stats_lock); - struct codec_stats *stats_entry = - g_hash_table_lookup(rtpe_codec_stats, handler->stats_chain); - if (!stats_entry) { - stats_entry = g_slice_alloc0(sizeof(*stats_entry)); - stats_entry->chain = strdup(handler->stats_chain); - g_hash_table_insert(rtpe_codec_stats, stats_entry->chain, stats_entry); - if (asprintf(&stats_entry->chain_brief, STR_FORMAT "_" STR_FORMAT, - STR_FMT(&handler->source_pt.encoding_with_params), - STR_FMT(&dest->encoding_with_params)) < 0) - stats_entry->chain_brief = "xxx"; - } - handler->stats_entry = stats_entry; - mutex_unlock(&rtpe_codec_stats_lock); - - g_atomic_int_inc(&stats_entry->num_transcoders); + STR_FMT(&dest->encoding_with_params)); + + mutex_lock(&rtpe_codec_stats_lock); + struct codec_stats *stats_entry = + g_hash_table_lookup(rtpe_codec_stats, handler->stats_chain); + if (!stats_entry) { + stats_entry = g_slice_alloc0(sizeof(*stats_entry)); + stats_entry->chain = strdup(handler->stats_chain); + g_hash_table_insert(rtpe_codec_stats, stats_entry->chain, stats_entry); + stats_entry->chain_brief = g_strdup_printf(STR_FORMAT "_" STR_FORMAT, + STR_FMT(&handler->source_pt.encoding_with_params), + STR_FMT(&dest->encoding_with_params)); } + handler->stats_entry = stats_entry; + mutex_unlock(&rtpe_codec_stats_lock); + + g_atomic_int_inc(&stats_entry->num_transcoders); check_output:; // check if we have multiple decoders transcoding to the same output PT diff --git a/daemon/main.c b/daemon/main.c index 6ac007bfa..c8195a89c 100644 --- a/daemon/main.c +++ b/daemon/main.c @@ -171,8 +171,11 @@ static void __find_if_name(char *s, struct ifaddrs *ifas, GQueue *addrs) { } else if (ifa->ifa_addr->sa_family == AF_INET6) { struct sockaddr_in6 *sin = (void *) ifa->ifa_addr; - if (sin->sin6_scope_id) - continue; // link-local + if (sin->sin6_scope_id) { + // link-local + g_slice_free1(sizeof(*addr), addr); + continue; + } addr->family = __get_socket_family_enum(SF_IP6); addr->u.ipv6 = sin->sin6_addr; } diff --git a/daemon/statistics.c b/daemon/statistics.c index 89f7123fd..eb2d6d6f9 100644 --- a/daemon/statistics.c +++ b/daemon/statistics.c @@ -679,6 +679,13 @@ void statistics_free() { g_hash_table_destroy(rtpe_codec_stats); } +static void codec_stats_free(void *p) { + struct codec_stats *stats_entry = p; + free(stats_entry->chain); + g_free(stats_entry->chain_brief); + g_slice_free1(sizeof(*stats_entry), stats_entry); +} + void statistics_init() { mutex_init(&rtpe_totalstats.total_average_lock); mutex_init(&rtpe_totalstats_interval.total_average_lock); @@ -700,7 +707,7 @@ void statistics_init() { mutex_init(&rtpe_totalstats_interval.deletes_ps.lock); mutex_init(&rtpe_codec_stats_lock); - rtpe_codec_stats = g_hash_table_new(g_str_hash, g_str_equal); + rtpe_codec_stats = g_hash_table_new_full(g_str_hash, g_str_equal, NULL, codec_stats_free); } const char *statistics_ng(bencode_item_t *input, bencode_item_t *output) {