Browse Source

clean up codec stats on shutdown

Change-Id: Iac082cda84c62be4a340448ef7c97c2f94e2992f
pull/1093/head
Richard Fuchs 5 years ago
parent
commit
18a3b9df0f
3 changed files with 31 additions and 24 deletions
  1. +18
    -21
      daemon/codec.c
  2. +5
    -2
      daemon/main.c
  3. +8
    -1
      daemon/statistics.c

+ 18
- 21
daemon/codec.c View File

@ -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);
}
}
@ -256,28 +256,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


+ 5
- 2
daemon/main.c View File

@ -172,8 +172,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;
}


+ 8
- 1
daemon/statistics.c View File

@ -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) {


Loading…
Cancel
Save