diff options
Diffstat (limited to 'src/nm-dbus-manager.c')
-rw-r--r-- | src/nm-dbus-manager.c | 42 |
1 files changed, 39 insertions, 3 deletions
diff --git a/src/nm-dbus-manager.c b/src/nm-dbus-manager.c index 060ae81d83..7f1121f650 100644 --- a/src/nm-dbus-manager.c +++ b/src/nm-dbus-manager.c @@ -83,7 +83,8 @@ typedef struct { GDBusConnection *connection; GDBusProxy *proxy; guint objmgr_registration_id; - gboolean started; + bool started:1; + bool shutting_down:1; } NMDBusManagerPrivate; struct _NMDBusManager { @@ -788,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); @@ -800,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)); @@ -851,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, @@ -1574,6 +1589,27 @@ nm_dbus_manager_acquire_bus (NMDBusManager *self) 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 |