diff options
-rw-r--r-- | devkit-power-gobject/dkp-client.c | 24 |
1 files changed, 22 insertions, 2 deletions
diff --git a/devkit-power-gobject/dkp-client.c b/devkit-power-gobject/dkp-client.c index 045c6d7..859a8be 100644 --- a/devkit-power-gobject/dkp-client.c +++ b/devkit-power-gobject/dkp-client.c @@ -137,11 +137,21 @@ dkp_client_suspend (DkpClient *client, GError **error) ret = dbus_g_proxy_call (client->priv->proxy, "Suspend", &error_local, G_TYPE_INVALID, G_TYPE_INVALID); if (!ret) { + /* DBus might time out, which is okay */ + if (g_error_matches (error_local, DBUS_GERROR, DBUS_GERROR_NO_REPLY)) { + g_debug ("DBUS timed out, but recovering"); + ret = TRUE; + goto out; + } + + /* an actual error */ g_warning ("Couldn't suspend: %s", error_local->message); if (error != NULL) *error = g_error_new (1, 0, "%s", error_local->message); - g_error_free (error_local); } +out: + if (error_local != NULL) + g_error_free (error_local); return ret; } @@ -160,11 +170,21 @@ dkp_client_hibernate (DkpClient *client, GError **error) ret = dbus_g_proxy_call (client->priv->proxy, "Hibernate", &error_local, G_TYPE_INVALID, G_TYPE_INVALID); if (!ret) { + /* DBus might time out, which is okay */ + if (g_error_matches (error_local, DBUS_GERROR, DBUS_GERROR_NO_REPLY)) { + g_debug ("DBUS timed out, but recovering"); + ret = TRUE; + goto out; + } + + /* an actual error */ g_warning ("Couldn't hibernate: %s", error_local->message); if (error != NULL) *error = g_error_new (1, 0, "%s", error_local->message); - g_error_free (error_local); } +out: + if (error_local != NULL) + g_error_free (error_local); return ret; } |