Commit 00f2e0d8 authored by Colin Walters's avatar Colin Walters
Browse files

2004-11-11 Colin Walters <walters@verbum.org>

	* info-daemon/NetworkManagerInfoDbus.c (nmi_dbus_is_running):
	Delete.
	(nmi_dbus_service_init): Call dbus_bus_acquire_service with
	the DBUS_SERVICE_FLAG_PROHIBIT_REPLACEMENT flag, and
	then check the result for DBUS_SERVICE_REPLY_SERVICE_EXISTS.
	This avoids a race condition that made it pretty easily
	possible to get two NetworkManagerInfo daemons running.


git-svn-id: http://svn-archive.gnome.org/svn/NetworkManager/trunk@305 4912f4e0-d625-0410-9fb7-b9a5a253dbdc
parent 1d421e52
2004-11-11 Colin Walters <walters@verbum.org>
* info-daemon/NetworkManagerInfoDbus.c (nmi_dbus_is_running):
Delete.
(nmi_dbus_service_init): Call dbus_bus_acquire_service with
the DBUS_SERVICE_FLAG_PROHIBIT_REPLACEMENT flag, and
then check the result for DBUS_SERVICE_REPLY_SERVICE_EXISTS.
This avoids a race condition that made it pretty easily
possible to get two NetworkManagerInfo daemons running.
2004-11-11 Colin Walters <walters@verbum.org>
* src/NetworkManager.c (main): Use daemon(3).
* info-daemon/NetworkManagerInfo.c (main): Ditto.
......
......@@ -707,26 +707,6 @@ static DBusHandlerResult nmi_dbus_filter (DBusConnection *connection, DBusMessag
return (handled ? DBUS_HANDLER_RESULT_HANDLED : DBUS_HANDLER_RESULT_NOT_YET_HANDLED);
}
/*
* nmi_dbus_is_running
*
* Ask dbus whether or not another instance of NetworkManagerInfo is running
*
*/
static gboolean nmi_dbus_is_running (DBusConnection *connection)
{
DBusError error;
gboolean exists;
g_return_val_if_fail (connection != NULL, FALSE);
dbus_error_init (&error);
exists = dbus_bus_service_exists (connection, NMI_DBUS_SERVICE, &error);
if (dbus_error_is_set (&error))
dbus_error_free (&error);
return (exists);
}
/*
* nmi_dbus_nm_is_running
*
......@@ -757,19 +737,25 @@ int nmi_dbus_service_init (DBusConnection *dbus_connection, NMIAppInfo *info)
{
DBusError dbus_error;
DBusObjectPathVTable nmi_vtable = { &nmi_dbus_nmi_unregister_handler, &nmi_dbus_nmi_message_handler, NULL, NULL, NULL, NULL };
int acquisition;
/*return if we are already running in another instance*/
if (nmi_dbus_is_running (dbus_connection))
return (-1);
dbus_error_init (&dbus_error);
dbus_bus_acquire_service (dbus_connection, NMI_DBUS_SERVICE, 0, &dbus_error);
acquisition = dbus_bus_acquire_service (dbus_connection, NMI_DBUS_SERVICE,
DBUS_SERVICE_FLAG_PROHIBIT_REPLACEMENT,
&dbus_error);
if (dbus_error_is_set (&dbus_error))
{
syslog (LOG_ERR, "nmi_dbus_service_init() could not acquire its service. dbus_bus_acquire_service() says: '%s'", dbus_error.message);
dbus_error_free (&dbus_error);
return (-1);
}
if (acquisition & DBUS_SERVICE_REPLY_SERVICE_EXISTS) {
exit (0);
}
if (!nmi_dbus_nm_is_running (dbus_connection))
return (-1);
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment