diff options
| author | Michael Biebl <biebl@debian.org> | 2018-06-04 00:08:31 +0200 |
|---|---|---|
| committer | Michael Biebl <biebl@debian.org> | 2018-06-04 00:08:31 +0200 |
| commit | 0dd9df69fdbd475c48a0c8d5b0a1882550fe7321 (patch) | |
| tree | 249cf25643b1fe408e10679bb61613bc6540e894 /src/nm-dbus-manager.c | |
| parent | 2e94a3b93171ab3fb95bf689aab1664d23988809 (diff) | |
| parent | 04bc9e1cd3544445d883ad29ea108c1645c8e7b7 (diff) | |
Update upstream source from tag 'upstream/1.11.4'
Update to upstream version '1.11.4' with Debian dir d0638aa2e32d5bae4e8daa021b9a66b7c4d6647e
Diffstat (limited to 'src/nm-dbus-manager.c')
| -rw-r--r-- | src/nm-dbus-manager.c | 79 |
1 files changed, 63 insertions, 16 deletions
diff --git a/src/nm-dbus-manager.c b/src/nm-dbus-manager.c index 3e369129..7f1121f6 100644 --- a/src/nm-dbus-manager.c +++ b/src/nm-dbus-manager.c @@ -83,6 +83,8 @@ typedef struct { GDBusConnection *connection; GDBusProxy *proxy; guint objmgr_registration_id; + bool started:1; + bool shutting_down:1; } NMDBusManagerPrivate; struct _NMDBusManager { @@ -787,6 +789,8 @@ dbus_vtable_method_call (GDBusConnection *connection, GDBusMethodInvocation *invocation, gpointer user_data) { + NMDBusManager *self; + NMDBusManagerPrivate *priv; RegistrationData *reg_data = user_data; NMDBusObject *obj = reg_data->obj; const NMDBusInterfaceInfoExtended *interface_info = _reg_data_get_interface_info (reg_data); @@ -799,13 +803,14 @@ dbus_vtable_method_call (GDBusConnection *connection, if ( !on_same_interface && nm_streq (interface_name, DBUS_INTERFACE_PROPERTIES) && nm_streq (method_name, "Set")) { - NMDBusManager *self = nm_dbus_object_get_manager (obj); - NMDBusManagerPrivate *priv = NM_DBUS_MANAGER_GET_PRIVATE (self); const NMDBusPropertyInfoExtended *property_info = NULL; const char *property_interface; const char *property_name; gs_unref_variant GVariant *value = NULL; + self = nm_dbus_object_get_manager (obj); + priv = NM_DBUS_MANAGER_GET_PRIVATE (self); + g_variant_get (parameters, "(&s&sv)", &property_interface, &property_name, &value); nm_assert (nm_streq (property_interface, interface_info->parent.name)); @@ -850,6 +855,17 @@ dbus_vtable_method_call (GDBusConnection *connection, return; } + self = nm_dbus_object_get_manager (obj); + priv = NM_DBUS_MANAGER_GET_PRIVATE (self); + if ( priv->shutting_down + && !method_info->allow_during_shutdown) { + g_dbus_method_invocation_return_error_literal (invocation, + G_DBUS_ERROR, + G_DBUS_ERROR_FAILED, + "NetworkManager is exiting"); + return; + } + method_info->handle (reg_data->obj, interface_info, method_info, @@ -930,6 +946,7 @@ _obj_register (NMDBusManager *self, nm_assert (c_list_is_empty (&obj->internal.registration_lst_head)); nm_assert (priv->connection); + nm_assert (priv->started); n_klasses = 0; gtype = G_OBJECT_TYPE (obj); @@ -1107,7 +1124,7 @@ _nm_dbus_manager_obj_export (NMDBusObject *obj) nm_assert_not_reached (); c_list_link_tail (&priv->objects_lst_head, &obj->internal.objects_lst); - if (priv->connection) + if (priv->connection && priv->started) _obj_register (self, obj); } @@ -1306,7 +1323,7 @@ _nm_dbus_manager_obj_emit_signal (NMDBusObject *obj, self = obj->internal.bus_manager; priv = NM_DBUS_MANAGER_GET_PRIVATE (self); - if (!priv->connection) { + if (!priv->connection || !priv->started) { nm_g_variant_unref_floating (args); return; } @@ -1453,29 +1470,41 @@ static const GDBusInterfaceInfo interface_info_objmgr = NM_DEFINE_GDBUS_INTERFAC /*****************************************************************************/ -gboolean +void nm_dbus_manager_start (NMDBusManager *self, NMDBusManagerSetPropertyHandler set_property_handler, gpointer set_property_handler_data) { NMDBusManagerPrivate *priv; + NMDBusObject *obj; + + g_return_if_fail (NM_IS_DBUS_MANAGER (self)); + priv = NM_DBUS_MANAGER_GET_PRIVATE (self); + g_return_if_fail (priv->connection); + + priv->set_property_handler = set_property_handler; + priv->set_property_handler_data = set_property_handler_data; + priv->started = TRUE; + + c_list_for_each_entry (obj, &priv->objects_lst_head, internal.objects_lst) + _obj_register (self, obj); +} + +gboolean +nm_dbus_manager_acquire_bus (NMDBusManager *self) +{ + NMDBusManagerPrivate *priv; gs_free_error GError *error = NULL; gs_unref_variant GVariant *ret = NULL; gs_unref_object GDBusConnection *connection = NULL; gs_unref_object GDBusProxy *proxy = NULL; guint32 result; guint registration_id; - NMDBusObject *obj; g_return_val_if_fail (NM_IS_DBUS_MANAGER (self), FALSE); priv = NM_DBUS_MANAGER_GET_PRIVATE (self); - priv->set_property_handler = set_property_handler; - priv->set_property_handler_data = set_property_handler_data; - - g_return_val_if_fail (!priv->connection, FALSE); - /* we will create the D-Bus connection and registering the name synchronously. * The reason why that is necessary is because: * (1) if we are unable to create a D-Bus connection, it means D-Bus is not @@ -1527,7 +1556,7 @@ nm_dbus_manager_start (NMDBusManager *self, NULL, &error); if (!ret) { - _LOGE ("fatal failure to aquire D-Bus service \"%s"": %s", + _LOGE ("fatal failure to acquire D-Bus service \"%s"": %s", NM_DBUS_SERVICE, error->message); return FALSE; } @@ -1555,14 +1584,32 @@ nm_dbus_manager_start (NMDBusManager *self, priv->connection = g_steal_pointer (&connection); priv->proxy = g_steal_pointer (&proxy); - _LOGI ("aquired D-Bus service \"%s\"", NM_DBUS_SERVICE); - - c_list_for_each_entry (obj, &priv->objects_lst_head, internal.objects_lst) - _obj_register (self, obj); + _LOGI ("acquired D-Bus service \"%s\"", NM_DBUS_SERVICE); return TRUE; } +void +nm_dbus_manager_stop (NMDBusManager *self) +{ + NMDBusManagerPrivate *priv = NM_DBUS_MANAGER_GET_PRIVATE (self); + + priv->shutting_down = TRUE; + + /* during shutdown we also clear the set-property-handler. It's no longer + * possible to set a property, because doing so would require authorization, + * which is async, which is just complicated to get right. No more property + * setting from now on. */ + priv->set_property_handler = NULL; + priv->set_property_handler_data = NULL; +} + +gboolean +nm_dbus_manager_is_stopping (NMDBusManager *self) +{ + return NM_DBUS_MANAGER_GET_PRIVATE (self)->shutting_down; +} + /*****************************************************************************/ static void |