d_bus_signal_handler, signal, NULL);
if (!(signal->subscription_id)) {
_E("Failed to subscribe signal %s", name);
+ free(signal);
return RESOURCED_ERROR_FAIL;
}
handle->node_info = g_dbus_node_info_new_for_xml(xml, &err);
if (!handle->node_info) {
_E("Failed to make node_info : %s", err->message);
+ free(handle);
return RESOURCED_ERROR_FAIL;
}
path, handle->node_info->interfaces[0], &vtable, (gpointer)handle, NULL, &err);
if (!handle->subscription_id) {
_E("Failed to register gdbus methods with path %s : %s", path, err->message);
+ free(handle);
return RESOURCED_ERROR_FAIL;
} else
dbus_method_handle_list = g_list_append(dbus_method_handle_list, (gpointer)handle);
NULL, logging_free_db_value);
if (!(module->db_list)) {
_E("Fail to create HEART-%s DB table", name);
- return RESOURCED_ERROR_FAIL;
+ ret = RESOURCED_ERROR_FAIL;
+ goto error;
}
snprintf(db_path, LOGGING_BUF_MAX, SYSTEM_OWN_DB_NAME, name);
if (logging_create_default_db(db_path, &db_file)
!= RESOURCED_ERROR_NONE) {
_E("Fail to create %s", db_path);
- g_hash_table_unref(module->db_list);
- return RESOURCED_ERROR_DB_FAILED;
+ ret = RESOURCED_ERROR_DB_FAILED;
+ goto error;
}
db_elem = (struct logging_db*)malloc(sizeof(struct logging_db));
db_elem->path = strndup(db_path, sizeof(db_path));
case USER_OWN:
if (logging_update_user_db_list(name, USER_OWN, &(module->db_list))) {
_E("Fail to create HEART-%s DB", name);
- return RESOURCED_ERROR_FAIL;
+ ret = RESOURCED_ERROR_FAIL;
+ goto error;
}
break;
default:
_E("Unknown DB type");
- return RESOURCED_ERROR_INVALID_PARAMETER;
- break;
+ ret = RESOURCED_ERROR_INVALID_PARAMETER;
+ goto error;
}
snprintf(buf, LOGGING_BUF_MAX, CREATE_QUERY, name);
if (ret != SQLITE_OK) {
_E("create %s table failed %s", name, sqlite3_errmsg(db_file));
sqlite3_finalize(stmt);
- return RESOURCED_ERROR_DB_FAILED;
+ ret = RESOURCED_ERROR_DB_FAILED;
+ goto error;
}
if (sqlite3_step(stmt) != SQLITE_DONE) {
_E("create %s table failed %s", name, sqlite3_errmsg(db_file));
sqlite3_finalize(stmt);
- return RESOURCED_ERROR_DB_FAILED;
+ ret = RESOURCED_ERROR_DB_FAILED;
+ goto error;
}
sqlite3_finalize(stmt);
if (asprintf(&(module->name), "%s", name) < 0) {
_E("asprintf failed");
- free(module);
- return RESOURCED_ERROR_OUT_OF_MEMORY;
+ ret = RESOURCED_ERROR_OUT_OF_MEMORY;
+ goto error;
}
module->max_period = max_period;
if (pthread_mutex_init(&module->cache_mutex, NULL) < 0) {
_E("%s module mutex_init failed %d", name, errno);
- free(module->name);
- free(module);
- return RESOURCED_ERROR_FAIL;
+ ret = RESOURCED_ERROR_FAIL;
+ goto error;
}
module->cache = g_queue_new();
if (!module->cache) {
_E("g_queue_new failed");
- free(module->name);
- free(module);
- return RESOURCED_ERROR_OUT_OF_MEMORY;
+ ret = RESOURCED_ERROR_OUT_OF_MEMORY;
+ goto error;
}
g_queue_init(module->cache);
g_array_append_val(logging_modules, module);
return RESOURCED_ERROR_NONE;
+
+error:
+ if (module->name)
+ free(module->name);
+ if (module->db_list && (db_type == SYSTEM_OWN || db_type == USER_OWN))
+ g_hash_table_unref(module->db_list);
+ if (module)
+ free(module);
+
+ return ret;
}
int logging_module_exit(void)