Browse Source

TT#28300 add cleanup of global interface structs

Change-Id: I326d72c88505c532b19e98165666f10d4692fafc
changes/01/40801/4
Richard Fuchs 6 years ago
parent
commit
2a4dbd8d37
3 changed files with 53 additions and 0 deletions
  1. +1
    -0
      daemon/main.c
  2. +51
    -0
      daemon/media_socket.c
  3. +1
    -0
      include/media_socket.h

+ 1
- 0
daemon/main.c View File

@ -944,6 +944,7 @@ int main(int argc, char **argv) {
unfill_initial_rtpe_cfg(&initial_rtpe_config);
options_free();
interfaces_free();
return 0;
}

+ 51
- 0
daemon/media_socket.c View File

@ -2099,3 +2099,54 @@ void play_buffered(struct jb_packet *cp) {
stream_packet(&phc);
jb_packet_free(&cp);
}
void interfaces_free(void) {
struct local_intf *ifc;
GList *ll;
while ((ifc = g_queue_pop_head(&all_local_interfaces))) {
free(ifc->ice_foundation.s);
g_slice_free1(sizeof(*ifc), ifc);
}
ll = g_hash_table_get_values(__logical_intf_name_family_hash);
for (GList *l = ll; l; l = l->next) {
struct logical_intf *lif = l->data;
g_hash_table_destroy(lif->addr_hash);
g_hash_table_destroy(lif->rr_specs);
g_queue_clear(&lif->list);
g_slice_free1(sizeof(*lif), lif);
}
g_list_free(ll);
g_hash_table_destroy(__logical_intf_name_family_hash);
ll = g_hash_table_get_values(__local_intf_addr_type_hash);
for (GList *l = ll; l; l = l->next) {
GList *k = l->data;
g_list_free(k);
}
g_list_free(ll);
g_hash_table_destroy(__local_intf_addr_type_hash);
ll = g_hash_table_get_values(__intf_spec_addr_type_hash);
for (GList *l = ll; l; l = l->next) {
struct intf_spec *spec = l->data;
struct port_pool *pp = &spec->port_pool;
g_queue_clear(&pp->free_list);
g_slice_free1(sizeof(*spec), spec);
}
g_list_free(ll);
g_hash_table_destroy(__intf_spec_addr_type_hash);
ll = g_hash_table_get_values(__logical_intf_name_family_rr_hash);
for (GList *l = ll; l; l = l->next) {
struct intf_rr *rr = l->data;
g_queue_clear(&rr->logical_intfs);
g_slice_free1(sizeof(*rr), rr);
}
g_list_free(ll);
g_hash_table_destroy(__logical_intf_name_family_rr_hash);
for (int i = 0; i < G_N_ELEMENTS(__preferred_lists_for_family); i++)
g_queue_clear(&__preferred_lists_for_family[i]);
}

+ 1
- 0
include/media_socket.h View File

@ -147,6 +147,7 @@ extern GQueue all_local_interfaces; // read-only during runtime
void interfaces_init(GQueue *interfaces);
void interfaces_free(void);
struct logical_intf *get_logical_interface(const str *name, sockfamily_t *fam, int num_ports);
struct local_intf *get_interface_address(const struct logical_intf *lif, sockfamily_t *fam);


Loading…
Cancel
Save