Browse Source

TT#74651 fix several mem/resource leaks

fix cleanup being skipped on redis slaves

fixes an SDES related Redis mem leak

adds a hash for the ports free list to avoid duplicate entries

fixes #898

Change-Id: I34aad67290ff5ef8824142682aac03cb600d0ecb
changes/47/37047/4
Richard Fuchs 6 years ago
parent
commit
c70b3f6369
4 changed files with 31 additions and 8 deletions
  1. +23
    -7
      daemon/call.c
  2. +6
    -1
      daemon/media_socket.c
  3. +1
    -0
      daemon/redis.c
  4. +1
    -0
      include/media_socket.h

+ 23
- 7
daemon/call.c View File

@ -2152,11 +2152,15 @@ void call_destroy(struct call *c) {
if (!IS_OWN_CALL(c))
goto no_stats_output;
///// stats output
ilog(LOG_INFO, "Final packet stats:");
for (l = c->monologues.head; l; l = l->next) {
ml = l->data;
// stats output only - no cleanups
ilog(LOG_INFO, "--- Tag '" STR_FORMAT_M "'%s"STR_FORMAT"%s, created "
"%u:%02u ago for branch '" STR_FORMAT_M "', in dialogue with '" STR_FORMAT_M "'",
STR_FMT_M(&ml->tag),
@ -2174,6 +2178,8 @@ void call_destroy(struct call *c) {
for (k = ml->medias.head; k; k = k->next) {
md = k->data;
// stats output only - no cleanups
rtp_pt = __rtp_stats_codec(md);
#define MLL_PREFIX "------ Media #%u ("STR_FORMAT" over %s) using " /* media log line prefix */
#define MLL_COMMON /* common args */ \
@ -2189,7 +2195,7 @@ void call_destroy(struct call *c) {
for (o = md->streams.head; o; o = o->next) {
ps = o->data;
send_timer_put(&ps->send_timer);
// stats output only - no cleanups
if (PS_ISSET(ps, FALLBACK_RTCP))
continue;
@ -2210,20 +2216,16 @@ void call_destroy(struct call *c) {
rtpe_now.tv_sec - atomic64_get(&ps->last_packet));
statistics_update_totals(ps);
}
ice_shutdown(&md->ice_agent);
}
media_player_stop(ml->player);
media_player_put(&ml->player);
}
k = g_hash_table_get_values(c->ssrc_hash->ht);
for (l = k; l; l = l->next) {
struct ssrc_entry_call *se = l->data;
// stats output only - no cleanups
if (!se->stats_blocks.length || !se->lowest_mos || !se->highest_mos)
continue;
@ -2245,6 +2247,8 @@ void call_destroy(struct call *c) {
g_list_free(k);
no_stats_output:
// cleanups
statistics_update_oneway(c);
cdr_update_entry(c);
@ -2252,6 +2256,7 @@ no_stats_output:
for (l = c->streams.head; l; l = l->next) {
ps = l->data;
send_timer_put(&ps->send_timer);
__unkernelize(ps);
dtls_shutdown(ps);
ps->selected_sfd = NULL;
@ -2262,6 +2267,17 @@ no_stats_output:
ps->rtcp_sink = NULL;
}
for (l = c->medias.head; l; l = l->next) {
md = l->data;
ice_shutdown(&md->ice_agent);
}
for (l = c->monologues.head; l; l = l->next) {
ml = l->data;
media_player_stop(ml->player);
media_player_put(&ml->player);
}
while (c->stream_fds.head) {
sfd = g_queue_pop_head(&c->stream_fds);
poller_del_item(rtpe_poller, sfd->socket.fd);


+ 6
- 1
daemon/media_socket.c View File

@ -760,7 +760,10 @@ static void release_port(socket_t *r, struct intf_spec *spec) {
g_atomic_int_inc(&pp->free_ports);
if ((port & 1) == 0) {
mutex_lock(&pp->free_list_lock);
g_queue_push_tail(&pp->free_list, GUINT_TO_POINTER(port));
if (!bit_array_isset(pp->free_list_used, port)) {
g_queue_push_tail(&pp->free_list, GUINT_TO_POINTER(port));
bit_array_set(pp->free_list_used, port);
}
mutex_unlock(&pp->free_list_lock);
}
} else {
@ -807,6 +810,8 @@ int __get_consecutive_ports(GQueue *out, unsigned int num_ports, unsigned int wa
__C_DBG("port %d is USED in port pool", port);
mutex_lock(&pp->free_list_lock);
unsigned int fport = GPOINTER_TO_UINT(g_queue_pop_head(&pp->free_list));
if (fport)
bit_array_clear(pp->free_list_used, fport);
mutex_unlock(&pp->free_list_lock);
if (fport) {
port = fport;


+ 1
- 0
daemon/redis.c View File

@ -1105,6 +1105,7 @@ static int redis_hash_get_sdes_params(GQueue *out, const struct redis_hash *h, c
return -1;
}
g_queue_push_tail(out, cps);
snprintf(key, sizeof(key), "%s-%u", k, iter++);
kk = key;
}


+ 1
- 0
include/media_socket.h View File

@ -78,6 +78,7 @@ struct port_pool {
mutex_t free_list_lock;
GQueue free_list;
BIT_ARRAY_DECLARE(free_list_used, 0x10000);
};
struct intf_address {
socktype_t *type;


Loading…
Cancel
Save