GIOCondition condition,
gpointer user_data);
+static void __free_system(stc_system_s *system)
+{
+ /* destroy monitored application tree */
+ if (system->apps)
+ g_hash_table_destroy(system->apps);
+ /* destroy restriction rules tree */
+ if (system->rstns)
+ g_hash_table_destroy(system->rstns);
+ FREE(system);
+}
+
static stc_error_e __close_and_reopen_contr_sock(stc_system_s *system)
{
GIOChannel *gio = NULL;
system->contr_sock = create_netlink(NETLINK_NETFILTER, 0);
if (system->contr_sock < 0) {
STC_LOGE("failed to open socket");
- FREE(system);
+ __free_system(system);
+ g_system = NULL;
return STC_ERROR_FAIL;
}
system->contr_sock = create_netlink(NETLINK_NETFILTER, 0);
if (system->contr_sock < 0) {
STC_LOGE("failed to open socket");
- FREE(system);
+ __free_system(system);
return STC_ERROR_FAIL;
}
g_system->contr_timer_id = 0;
}
- /* destroy monitored application tree */
- g_hash_table_destroy(g_system->apps);
- g_system->apps = NULL;
-
- /* destroy restriction rules tree */
- g_hash_table_destroy(g_system->rstns);
- g_system->rstns = NULL;
-
- FREE(g_system);
+ __free_system(g_system);
+ g_system = NULL;
return STC_ERROR_NONE;
}