diff options
author | Thomas Haller <thaller@redhat.com> | 2023-04-05 11:12:46 +0200 |
---|---|---|
committer | Thomas Haller <thaller@redhat.com> | 2023-04-27 08:35:28 +0200 |
commit | 3c59c6b393c1ffb92ff3d2a4e471f8c6b740336a (patch) | |
tree | d23e1e5a5e44b20da3add1f3d76e2721077f4d7a | |
parent | aa2569a9cdff9e9a0afbe99a394b5f351a7b1506 (diff) | |
download | NetworkManager-3c59c6b393c1ffb92ff3d2a4e471f8c6b740336a.tar.gz |
core: drop NM_DEVICE_RECHECK_AUTO_ACTIVATE signal and call policy directly
GObject signals don't make the code easier to understand, on the
contrary. They may have their purpose, when objects truly must/should
not be aware of each other, and need to be composed very loosely. That
is not the case here.
There really is only one subscriber to NM_DEVICE_RECHECK_AUTO_ACTIVATE
signal, and it only makes sense this way. Instead of going through a
signal invocation, just call the well known method directly. It becomes
clearer who calls this code (and it has a lower overhead).
When using cscope/ctags it also is easier to follow the code because the
tools understand function calls.
-rw-r--r-- | src/core/devices/nm-device.c | 13 | ||||
-rw-r--r-- | src/core/devices/nm-device.h | 1 | ||||
-rw-r--r-- | src/core/nm-manager.c | 10 | ||||
-rw-r--r-- | src/core/nm-manager.h | 2 | ||||
-rw-r--r-- | src/core/nm-policy.c | 13 |
5 files changed, 13 insertions, 26 deletions
diff --git a/src/core/devices/nm-device.c b/src/core/devices/nm-device.c index 6edc74b3f2..482b57e94a 100644 --- a/src/core/devices/nm-device.c +++ b/src/core/devices/nm-device.c @@ -335,7 +335,6 @@ enum { IP6_PREFIX_DELEGATED, IP6_SUBNET_NEEDED, REMOVED, - RECHECK_AUTO_ACTIVATE, RECHECK_ASSUME, DNS_LOOKUP_DONE, PLATFORM_ADDRESS_CHANGED, @@ -9251,7 +9250,7 @@ nm_device_queue_recheck_available(NMDevice *self, void nm_device_emit_recheck_auto_activate(NMDevice *self) { - g_signal_emit(self, signals[RECHECK_AUTO_ACTIVATE], 0); + nm_manager_device_recheck_auto_activate_schedule(nm_device_get_manager(self), self); } void @@ -18729,16 +18728,6 @@ nm_device_class_init(NMDeviceClass *klass) G_TYPE_NONE, 0); - signals[RECHECK_AUTO_ACTIVATE] = g_signal_new(NM_DEVICE_RECHECK_AUTO_ACTIVATE, - G_OBJECT_CLASS_TYPE(object_class), - G_SIGNAL_RUN_FIRST, - 0, - NULL, - NULL, - NULL, - G_TYPE_NONE, - 0); - signals[RECHECK_ASSUME] = g_signal_new(NM_DEVICE_RECHECK_ASSUME, G_OBJECT_CLASS_TYPE(object_class), G_SIGNAL_RUN_FIRST, diff --git a/src/core/devices/nm-device.h b/src/core/devices/nm-device.h index 4794d9af87..266a371159 100644 --- a/src/core/devices/nm-device.h +++ b/src/core/devices/nm-device.h @@ -75,7 +75,6 @@ #define NM_DEVICE_IP6_PREFIX_DELEGATED "ip6-prefix-delegated" #define NM_DEVICE_IP6_SUBNET_NEEDED "ip6-subnet-needed" #define NM_DEVICE_REMOVED "removed" -#define NM_DEVICE_RECHECK_AUTO_ACTIVATE "recheck-auto-activate" #define NM_DEVICE_RECHECK_ASSUME "recheck-assume" #define NM_DEVICE_STATE_CHANGED "state-changed" #define NM_DEVICE_LINK_INITIALIZED "link-initialized" diff --git a/src/core/nm-manager.c b/src/core/nm-manager.c index f6902b9786..93290771e0 100644 --- a/src/core/nm-manager.c +++ b/src/core/nm-manager.c @@ -3105,6 +3105,16 @@ _rfkill_update_from_user(NMManager *self, NMRfkillType rtype, gboolean enabled) /*****************************************************************************/ +void +nm_manager_device_recheck_auto_activate_schedule(NMManager *self, NMDevice *device) +{ + g_return_if_fail(NM_IS_MANAGER(self)); + + nm_policy_device_recheck_auto_activate_schedule(NM_MANAGER_GET_PRIVATE(self)->policy, device); +} + +/*****************************************************************************/ + static void device_auth_done_cb(NMAuthChain *chain, GDBusMethodInvocation *context, gpointer user_data) { diff --git a/src/core/nm-manager.h b/src/core/nm-manager.h index fe78eb2687..a251ecb70c 100644 --- a/src/core/nm-manager.h +++ b/src/core/nm-manager.h @@ -123,6 +123,8 @@ NMSettingsConnection **nm_manager_get_activatable_connections(NMManager *manager void nm_manager_deactivate_ac(NMManager *self, NMSettingsConnection *connection); +void nm_manager_device_recheck_auto_activate_schedule(NMManager *self, NMDevice *device); + void nm_manager_write_device_state_all(NMManager *manager); gboolean nm_manager_write_device_state(NMManager *manager, NMDevice *device, int *out_ifindex); diff --git a/src/core/nm-policy.c b/src/core/nm-policy.c index bbf498f5d1..c5864967cc 100644 --- a/src/core/nm-policy.c +++ b/src/core/nm-policy.c @@ -2272,15 +2272,6 @@ device_autoconnect_changed(NMDevice *device, GParamSpec *pspec, gpointer user_da } static void -device_recheck_auto_activate(NMDevice *device, gpointer user_data) -{ - NMPolicyPrivate *priv = user_data; - NMPolicy *self = _PRIV_TO_SELF(priv); - - nm_policy_device_recheck_auto_activate_schedule(self, device); -} - -static void devices_list_unregister(NMPolicy *self, NMDevice *device) { NMPolicyPrivate *priv = NM_POLICY_GET_PRIVATE(self); @@ -2312,10 +2303,6 @@ devices_list_register(NMPolicy *self, NMDevice *device) "notify::" NM_DEVICE_AUTOCONNECT, G_CALLBACK(device_autoconnect_changed), priv); - g_signal_connect(device, - NM_DEVICE_RECHECK_AUTO_ACTIVATE, - G_CALLBACK(device_recheck_auto_activate), - priv); } static void |