mirror of
https://gitlab.freedesktop.org/NetworkManager/NetworkManager.git
synced 2026-05-05 01:47:58 +02:00
nm-checkpoint: emit signal on the Devices property when required
that is: when a Device gets unexported from DBus. In this way we will allow "Devices" property to be rechecked on get() returning an up-to-date "Devices" property value.
This commit is contained in:
parent
83ee0bbd6d
commit
6621820a70
1 changed files with 18 additions and 6 deletions
|
|
@ -47,6 +47,7 @@ typedef struct {
|
|||
bool activation_lifetime_bound_to_profile_visiblity:1;
|
||||
NMUnmanFlagOp unmanaged_explicit;
|
||||
NMActivationReason activation_reason;
|
||||
gulong dev_exported_change_id;
|
||||
} DeviceCheckpoint;
|
||||
|
||||
NM_GOBJECT_PROPERTIES_DEFINE (NMCheckpoint,
|
||||
|
|
@ -405,8 +406,15 @@ next_dev:
|
|||
return g_variant_new ("(a{su})", &builder);
|
||||
}
|
||||
|
||||
static void
|
||||
_dev_exported_changed (NMDBusObject *obj,
|
||||
NMCheckpoint *checkpoint)
|
||||
{
|
||||
_notify (checkpoint, PROP_DEVICES);
|
||||
}
|
||||
|
||||
static DeviceCheckpoint *
|
||||
device_checkpoint_create (NMDevice *device)
|
||||
device_checkpoint_create (NMCheckpoint *checkpoint, NMDevice *device)
|
||||
{
|
||||
DeviceCheckpoint *dev_checkpoint;
|
||||
NMConnection *applied_connection;
|
||||
|
|
@ -424,6 +432,10 @@ device_checkpoint_create (NMDevice *device)
|
|||
dev_checkpoint->original_dev_path = g_strdup (path);
|
||||
dev_checkpoint->state = nm_device_get_state (device);
|
||||
dev_checkpoint->realized = nm_device_is_real (device);
|
||||
dev_checkpoint->dev_exported_change_id = g_signal_connect (device,
|
||||
NM_DBUS_OBJECT_EXPORTED_CHANGED,
|
||||
G_CALLBACK (_dev_exported_changed),
|
||||
checkpoint);
|
||||
|
||||
if (nm_device_get_unmanaged_mask (device, NM_UNMANAGED_USER_EXPLICIT)) {
|
||||
dev_checkpoint->unmanaged_explicit = !!nm_device_get_unmanaged_flags (device,
|
||||
|
|
@ -452,6 +464,7 @@ device_checkpoint_destroy (gpointer data)
|
|||
{
|
||||
DeviceCheckpoint *dev_checkpoint = data;
|
||||
|
||||
nm_clear_g_signal_handler (dev_checkpoint->device, &dev_checkpoint->dev_exported_change_id);
|
||||
g_clear_object (&dev_checkpoint->applied_connection);
|
||||
g_clear_object (&dev_checkpoint->settings_connection);
|
||||
g_clear_object (&dev_checkpoint->device);
|
||||
|
|
@ -597,13 +610,12 @@ nm_checkpoint_new (NMManager *manager, GPtrArray *devices, guint32 rollback_time
|
|||
for (i = 0; i < devices->len; i++) {
|
||||
NMDevice *device = devices->pdata[i];
|
||||
|
||||
/* FIXME: as long as the check point instance exists, it won't let go
|
||||
* of the device. That is a bug, for example, if you have a ethernet
|
||||
* device that gets removed (rmmod), the checkpoint will reference
|
||||
* a non-existing D-Bus path of a device. */
|
||||
/* As long as the check point instance exists, it will keep a reference
|
||||
* to the device also if the device gets removed (by rmmod or by deleting
|
||||
* a connection profile for a software device). */
|
||||
g_hash_table_insert (priv->devices,
|
||||
device,
|
||||
device_checkpoint_create (device));
|
||||
device_checkpoint_create (self, device));
|
||||
}
|
||||
|
||||
return self;
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue