Skip to content

Commit

Permalink
[dbus] Tune error recovery paths
Browse files Browse the repository at this point in the history
Fix a memory leak in config_reset_dbus_cb() error path and simplify error
handling in dbus_acquire_services().
  • Loading branch information
spiiroin committed Oct 2, 2015
1 parent 03e2ef5 commit 04db62d
Showing 1 changed file with 8 additions and 9 deletions.
17 changes: 8 additions & 9 deletions mce-dbus.c
Expand Up @@ -1437,6 +1437,7 @@ static gboolean config_reset_dbus_cb(DBusMessage *const msg)
dbus_send_message(reply), reply = 0;

NOREPLY:
dbus_error_free(&error);
return TRUE;
}

Expand Down Expand Up @@ -2290,25 +2291,23 @@ void mce_dbus_owner_monitor_remove_all(GSList **monitor_list)
static gboolean dbus_acquire_services(void)
{
gboolean status = FALSE;
DBusError error = DBUS_ERROR_INIT;
int ret;
DBusError error;

/* Register error channel */
dbus_error_init(&error);

ret = dbus_bus_request_name(dbus_connection, MCE_SERVICE, 0, &error);

if (ret == DBUS_REQUEST_NAME_REPLY_PRIMARY_OWNER) {
mce_log(LL_DEBUG, "Service %s acquired", MCE_SERVICE);
} else {
mce_log(LL_CRIT, "Cannot acquire service: %s", error.message);
dbus_error_free(&error);
if( ret != DBUS_REQUEST_NAME_REPLY_PRIMARY_OWNER ) {
mce_log(LL_CRIT, "Cannot acquire service %s: %s: %s",
MCE_SERVICE, error.name, error.message);
goto EXIT;
}

mce_log(LL_DEBUG, "Service %s acquired", MCE_SERVICE);

status = TRUE;

EXIT:
dbus_error_free(&error);
return status;
}

Expand Down

0 comments on commit 04db62d

Please sign in to comment.