[gnome-screensaver] Make sure it cannot be running twice
- From: William Jon McCann <mccann src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-screensaver] Make sure it cannot be running twice
- Date: Sun, 6 Mar 2011 06:29:40 +0000 (UTC)
commit 85d22a5d784b2b8201054257f8696138de1e1b70
Author: Marc Deslauriers <marc deslauriers ubuntu com>
Date: Wed Feb 16 08:40:15 2011 -0500
Make sure it cannot be running twice
It is currently possible to start gnome-screensaver twice because
of a race condition. This change makes sure that we bail out if
we cannot become the primary owner of the bus name.
https://bugzilla.gnome.org/show_bug.cgi?id=642462
src/gs-listener-dbus.c | 19 ++++++++++++++-----
1 files changed, 14 insertions(+), 5 deletions(-)
---
diff --git a/src/gs-listener-dbus.c b/src/gs-listener-dbus.c
index 6d0d4e5..e11c7fc 100644
--- a/src/gs-listener-dbus.c
+++ b/src/gs-listener-dbus.c
@@ -1169,7 +1169,7 @@ gboolean
gs_listener_acquire (GSListener *listener,
GError **error)
{
- gboolean acquired;
+ int res;
DBusError buserror;
gboolean is_connected;
@@ -1213,9 +1213,10 @@ gs_listener_acquire (GSListener *listener,
return FALSE;
}
- acquired = dbus_bus_request_name (listener->priv->connection,
- GS_LISTENER_SERVICE,
- 0, &buserror) != -1;
+ res = dbus_bus_request_name (listener->priv->connection,
+ GS_LISTENER_SERVICE,
+ DBUS_NAME_FLAG_DO_NOT_QUEUE,
+ &buserror);
if (dbus_error_is_set (&buserror)) {
g_set_error (error,
GS_LISTENER_ERROR,
@@ -1223,6 +1224,14 @@ gs_listener_acquire (GSListener *listener,
"%s",
buserror.message);
}
+ if (res == DBUS_REQUEST_NAME_REPLY_EXISTS) {
+ g_set_error (error,
+ GS_LISTENER_ERROR,
+ GS_LISTENER_ERROR_ACQUISITION_FAILURE,
+ "%s",
+ _("screensaver already running in this session"));
+ return FALSE;
+ }
dbus_error_free (&buserror);
@@ -1263,7 +1272,7 @@ gs_listener_acquire (GSListener *listener,
NULL);
}
- return acquired;
+ return (res != -1);
}
static char *
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]