2
src/NetworkManagerDbus.c | 55 ++++++++++++++++++++++++++++++++---------------
3
1 file changed, 38 insertions(+), 17 deletions(-)
5
Index: network-manager.debian/src/NetworkManagerDbus.c
6
===================================================================
7
--- network-manager.debian.orig/src/NetworkManagerDbus.c
8
+++ network-manager.debian/src/NetworkManagerDbus.c
12
dbus_connection_unref (data->dbus_connection);
13
data->dbus_connection = NULL;
14
nm_dhcp_manager_dispose (data->dhcp_manager);
15
g_thread_create ((GThreadFunc) nm_dbus_reinit, (gpointer) data, FALSE, NULL);
18
+ else if (dbus_message_is_signal (message, DBUS_INTERFACE_DBUS, "NameLost"))
20
+ g_warning("NetworkManagerDBus Lost the primary service name ownership ... shutting down!");
21
+ write (nm_get_sigterm_pipe (), "X", 1);
24
else if (dbus_message_is_signal (message, DBUS_INTERFACE_DBUS, "NameOwnerChanged"))
30
if (dbus_message_get_args (message, &error, DBUS_TYPE_STRING, &service, DBUS_TYPE_STRING, &old_owner,
31
DBUS_TYPE_STRING, &new_owner, DBUS_TYPE_INVALID))
33
DBusConnection *nm_dbus_init (NMData *data)
36
DBusConnection * connection;
37
DBusObjectPathVTable nm_vtable = {NULL, &nm_dbus_nm_message_handler, NULL, NULL, NULL, NULL};
38
DBusObjectPathVTable devices_vtable = {NULL, &nm_dbus_devices_message_handler, NULL, NULL, NULL, NULL};
39
DBusObjectPathVTable vpn_vtable = {NULL, &nm_dbus_vpn_message_handler, NULL, NULL, NULL, NULL};
44
dbus_connection_set_change_sigpipe (TRUE);
46
dbus_error_init (&error);
47
connection = dbus_bus_get (DBUS_BUS_SYSTEM, &error);
48
if ((connection == NULL) || dbus_error_is_set (&error))
50
nm_warning ("nm_dbus_init() could not get the system bus. Make sure the message bus daemon is running!");
53
char *match = get_nmi_match_string (owner);
55
dbus_bus_add_match (connection, match, NULL);
60
- dbus_error_init (&error);
61
+ for (i=0; i < 10; i++) {
62
+ dbus_error_init (&error);
63
#if (DBUS_VERSION_MAJOR == 0) && (DBUS_VERSION_MINOR < 60)
64
- flags = DBUS_NAME_FLAG_PROHIBIT_REPLACEMENT;
66
+ flags = DBUS_NAME_FLAG_REPLACE_EXISTING;
70
- flags = DBUS_NAME_FLAG_DO_NOT_QUEUE;
71
+ flags = DBUS_NAME_FLAG_ALLOW_REPLACEMENT | DBUS_NAME_FLAG_DO_NOT_QUEUE;
73
+ flags |= DBUS_NAME_FLAG_REPLACE_EXISTING; // we want to QUEUE in case the previous NetworkManager didn't yet terminate.
75
- ret = dbus_bus_request_name (connection, NM_DBUS_SERVICE, flags, &error);
76
- if (dbus_error_is_set (&error))
78
- nm_warning ("nm_dbus_init() could not acquire the NetworkManager service.\n Message: '%s'", error.message);
82
- else if (ret != DBUS_REQUEST_NAME_REPLY_PRIMARY_OWNER)
84
- nm_warning ("nm_dbus_init() could not acquire the NetworkManager service as it is already taken (ret=%d). Is the daemon already running?",
88
+ ret = dbus_bus_request_name (connection, NM_DBUS_SERVICE, flags, &error);
89
+ if (dbus_error_is_set (&error))
91
+ nm_warning ("nm_dbus_init() could not acquire the NetworkManager service.\n Message: '%s'", error.message);
95
+ else if (ret != DBUS_REQUEST_NAME_REPLY_PRIMARY_OWNER && ret != DBUS_REQUEST_NAME_REPLY_ALREADY_OWNER)
97
+ nm_info ("nm_dbus_init() could not acquire the NetworkManager service as PRIMARY_OWNER (ret=%d). This happens if NetworkManager daemon is already/still running?",
99
+ if (dbus_error_is_set (&error))
100
+ dbus_error_free (&error);
106
+ g_usleep (G_USEC_PER_SEC);
113
if (dbus_error_is_set (&error))
114
dbus_error_free (&error);