Skip to content

Commit

Permalink
Merge pull request #88 from ejoerns/v0/topic/further-error-handling-f…
Browse files Browse the repository at this point in the history
…ixes

Fixes and extensions in service error handling
  • Loading branch information
jluebbe committed Jan 30, 2017
2 parents bbafc41 + 66c7288 commit 097ca75
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 10 deletions.
5 changes: 3 additions & 2 deletions src/context.c
Original file line number Diff line number Diff line change
Expand Up @@ -83,14 +83,15 @@ static void r_context_configure(void) {
res = load_config(context->configpath, &context->config, &error);
if (!res && error->domain==g_file_error_quark()) {
g_debug("system config not found, using default values");
g_clear_error(&error);
res = default_config(&context->config);
}
if (!res) {
g_error("failed to initialize context: %s", error->message);

g_clear_error(&error);
}

if (&context->config->systeminfo_handler &&
if (context->config->systeminfo_handler &&
g_file_test(context->config->systeminfo_handler, G_FILE_TEST_EXISTS)) {

GError *ierror = NULL;
Expand Down
14 changes: 10 additions & 4 deletions src/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -139,21 +139,27 @@ static gboolean install_start(int argc, char **argv)
if (ENABLE_SERVICE) {
installer = r_installer_proxy_new_for_bus_sync(G_BUS_TYPE_SYSTEM,
G_DBUS_PROXY_FLAGS_GET_INVALIDATED_PROPERTIES,
"de.pengutronix.rauc", "/", NULL, NULL);
"de.pengutronix.rauc", "/", NULL, &error);
if (installer == NULL) {
g_printerr("Error creating proxy: %s\n", error->message);
g_error_free (error);
goto out_loop;
}
if (g_signal_connect(installer, "g-properties-changed",
G_CALLBACK(on_installer_changed), args) <= 0) {
g_error("failed to connect properties-changed signal");
g_printerr("failed to connect properties-changed signal\n");
goto out_loop;
}
if (g_signal_connect(installer, "completed",
G_CALLBACK(on_installer_completed), args) <= 0) {
g_error("failed to connect completed signal");
g_printerr("failed to connect completed signal\n");
goto out_loop;
}
g_print("trying to contact rauc service\n");
if (!r_installer_call_install_sync(installer, bundlelocation, NULL,
&error)) {
g_warning("failed %s", error->message);
g_printerr("failed %s\n", error->message);
g_error_free (error);
goto out_loop;
}
} else {
Expand Down
15 changes: 11 additions & 4 deletions src/service.c
Original file line number Diff line number Diff line change
Expand Up @@ -208,6 +208,7 @@ static void send_progress_callback(gint percentage,
static void r_on_bus_acquired(GDBusConnection *connection,
const gchar *name,
gpointer user_data) {
GError *ierror = NULL;

r_installer = r_installer_skeleton_new();

Expand All @@ -224,8 +225,9 @@ static void r_on_bus_acquired(GDBusConnection *connection,
if (!g_dbus_interface_skeleton_export(G_DBUS_INTERFACE_SKELETON(r_installer),
connection,
"/",
NULL)) {
g_error("Failed to export interface");
&ierror)) {
g_error("Failed to export interface: %s", ierror->message);
g_error_free (ierror);
}

return;
Expand All @@ -234,7 +236,7 @@ static void r_on_bus_acquired(GDBusConnection *connection,
static void r_on_name_acquired(GDBusConnection *connection,
const gchar *name,
gpointer user_data) {
g_message("name acquired");
g_debug("name '%s' acquired", name);

if (r_context()->config->autoinstall_path)
auto_install(r_context()->config->autoinstall_path);
Expand All @@ -245,7 +247,12 @@ static void r_on_name_acquired(GDBusConnection *connection,
static void r_on_name_lost(GDBusConnection *connection,
const gchar *name,
gpointer user_data) {
g_message("name lost, stopping service");
if (connection == NULL) {
g_message("Connection to the bus can't be made for %s", name);
} else {
g_message("Failed to obtain name %s", name);
}

if (service_loop) {
g_main_loop_quit(service_loop);
}
Expand Down

0 comments on commit 097ca75

Please sign in to comment.