Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
mpegts tables: protect more mt structure in open/close, fix memory le…
…ak (missing release), enhance traces
  • Loading branch information
perexg committed Oct 21, 2014
1 parent 250666e commit e1d8c2a
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 1 deletion.
5 changes: 5 additions & 0 deletions src/input/mpegts/mpegts_mux.c
Expand Up @@ -776,6 +776,7 @@ mpegts_mux_open_table ( mpegts_mux_t *mm, mpegts_table_t *mt, int subscribe )
mi = mm->mm_active->mmi_input;
LIST_INSERT_HEAD(&mm->mm_tables, mt, mt_link);
mm->mm_num_tables++;
mpegts_table_grab(mt);
pthread_mutex_unlock(&mm->mm_tables_lock);
pthread_mutex_lock(&mi->mi_output_lock);
if (subscribe) {
Expand All @@ -784,6 +785,7 @@ mpegts_mux_open_table ( mpegts_mux_t *mm, mpegts_table_t *mt, int subscribe )
}
pthread_mutex_unlock(&mi->mi_output_lock);
pthread_mutex_lock(&mm->mm_tables_lock);
mpegts_table_release(mt);
}

void
Expand All @@ -797,6 +799,7 @@ mpegts_mux_close_table ( mpegts_mux_t *mm, mpegts_table_t *mt )
if (mt->mt_defer_cmd) {
TAILQ_REMOVE(&mm->mm_defer_tables, mt, mt_defer_link);
mt->mt_defer_cmd = 0;
mpegts_table_release(mt);
}
mt->mt_subscribed = 0;
LIST_REMOVE(mt, mt_link);
Expand All @@ -822,6 +825,7 @@ mpegts_mux_close_table ( mpegts_mux_t *mm, mpegts_table_t *mt )
mi = mm->mm_active->mmi_input;
LIST_REMOVE(mt, mt_link);
mm->mm_num_tables--;
mpegts_table_grab(mt);
pthread_mutex_unlock(&mm->mm_tables_lock);
pthread_mutex_lock(&mi->mi_output_lock);
if (mt->mt_subscribed) {
Expand All @@ -830,6 +834,7 @@ mpegts_mux_close_table ( mpegts_mux_t *mm, mpegts_table_t *mt )
}
pthread_mutex_unlock(&mi->mi_output_lock);
pthread_mutex_lock(&mm->mm_tables_lock);
mpegts_table_release(mt);
}

/* **************************************************************************
Expand Down
5 changes: 4 additions & 1 deletion src/input/mpegts/mpegts_table.c
Expand Up @@ -139,6 +139,9 @@ mpegts_table_release_ ( mpegts_table_t *mt )
RB_REMOVE(&mt->mt_state, st, link);
free(st);
}
tvhtrace("mpegts", "table: free %s %02X/%02X (%d) pid %04X (%d)",
mt->mt_name, mt->mt_table, mt->mt_mask, mt->mt_table,
mt->mt_pid, mt->mt_pid);
if (mt->mt_destroy)
mt->mt_destroy(mt);
free(mt->mt_name);
Expand Down Expand Up @@ -213,7 +216,7 @@ mpegts_table_add
pthread_mutex_unlock(&mm->mm_tables_lock);
return mt;
}
tvhtrace("mpegts", "add %s table %02X/%02X (%d) pid %04X (%d)",
tvhtrace("mpegts", "table: %s add %02X/%02X (%d) pid %04X (%d)",
name, tableid, mask, tableid, pid, pid);

/* Create */
Expand Down

0 comments on commit e1d8c2a

Please sign in to comment.