Merge ~alfonsosanchezbeato/snappy-hwe-snaps/+git/network-manager:tweak-timeouts into ~snappy-hwe-team/snappy-hwe-snaps/+git/network-manager:network-manager/xenial/1.2.2

Proposed by Alfonso Sanchez-Beato
Status: Merged
Approved by: Tony Espy
Approved revision: 344e3d6e3ae9bd2923821a3a6f736bc0ddf49583
Merged at revision: b56257274aea44e357b2a783960c9c24d240a02e
Proposed branch: ~alfonsosanchezbeato/snappy-hwe-snaps/+git/network-manager:tweak-timeouts
Merge into: ~snappy-hwe-team/snappy-hwe-snaps/+git/network-manager:network-manager/xenial/1.2.2
Diff against target: 101 lines (+28/-6)
1 file modified
src/nm-policy.c (+28/-6)
Reviewer Review Type Date Requested Status
Tony Espy Approve
System Enablement Bot continuous-integration Approve
Review via email: mp+336819@code.launchpad.net

Description of the change

Delay reconnect retries for modems: for modems it is better to wait a bit before re-trying to connect, to give a chance for network conditions to change.

To post a comment you must log in.
Revision history for this message
System Enablement Bot (system-enablement-ci-bot) wrote :
review: Approve (continuous-integration)
Revision history for this message
Tony Espy (awe) wrote :

OK, looks almost identical to our original vivid-touch NM patch:

https://git.launchpad.net/network-manager/tree/debian/patches/Add-modem-reconnect-delay-to-policy.patch?id=665fc317b0c8a06afaeb830215296621a5505845

The only difference being the wait interval was bumped from 5s to 10s.

Did this change ever get up-streamed? If not, we should make sure to submit it this time.

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1diff --git a/src/nm-policy.c b/src/nm-policy.c
2index 07bcce8..200c357 100644
3--- a/src/nm-policy.c
4+++ b/src/nm-policy.c
5@@ -56,6 +56,9 @@
6 _NM_UTILS_MACRO_REST (__VA_ARGS__)); \
7 } G_STMT_END
8
9+/* Time between retrying to connect, for modems */
10+#define MODEM_DELAY_RETRY_S 10
11+
12 typedef struct _NMPolicyPrivate NMPolicyPrivate;
13
14 struct _NMPolicyPrivate {
15@@ -931,7 +934,7 @@ sleeping_changed (NMManager *manager, GParamSpec *pspec, gpointer user_data)
16 }
17
18 static void
19-schedule_activate_check (NMPolicy *self, NMDevice *device)
20+schedule_activate_check (NMPolicy *self, NMDevice *device, guint delay)
21 {
22 NMPolicyPrivate *priv = NM_POLICY_GET_PRIVATE (self);
23 ActivateData *data;
24@@ -960,7 +963,10 @@ schedule_activate_check (NMPolicy *self, NMDevice *device)
25 data = g_slice_new0 (ActivateData);
26 data->policy = self;
27 data->device = g_object_ref (device);
28- data->autoactivate_id = g_idle_add (auto_activate_device, data);
29+ if (delay)
30+ data->autoactivate_id = g_timeout_add_seconds (delay, auto_activate_device, data);
31+ else
32+ data->autoactivate_id = g_idle_add (auto_activate_device, data);
33 priv->pending_activation_checks = g_slist_append (priv->pending_activation_checks, data);
34 }
35
36@@ -1155,6 +1161,7 @@ device_state_changed (NMDevice *device,
37 NMIP4Config *ip4_config;
38 NMIP6Config *ip6_config;
39 NMSettingConnection *s_con = NULL;
40+ guint delay = 0;
41
42 switch (new_state) {
43 case NM_DEVICE_STATE_FAILED:
44@@ -1184,6 +1191,11 @@ device_state_changed (NMDevice *device,
45 if (!priv->reset_retries_id) {
46 gint32 retry_time = nm_settings_connection_get_autoconnect_retry_time (connection);
47
48+ gint32 actual_time = MAX (0, retry_time - nm_utils_get_monotonic_timestamp_s ());
49+ _LOGI (LOGD_DEVICE, "Disabling autoconnect for connection '%s'; "
50+ "setting retry of %d secs.",
51+ nm_connection_get_id (NM_CONNECTION (connection)), actual_time);
52+
53 g_warn_if_fail (retry_time != 0);
54 priv->reset_retries_id = g_timeout_add_seconds (MAX (0, retry_time - nm_utils_get_monotonic_timestamp_s ()), reset_connections_retries, self);
55 }
56@@ -1250,7 +1262,17 @@ device_state_changed (NMDevice *device,
57 update_routing_and_dns (self, FALSE);
58
59 /* Device is now available for auto-activation */
60- schedule_activate_check (self, device);
61+ if (nm_device_get_device_type (device) == NM_DEVICE_TYPE_MODEM)
62+ delay = MODEM_DELAY_RETRY_S;
63+
64+ if (connection)
65+ _LOGI (LOGD_DEVICE, "Connection '%s' disconnected, scheduling activate_check in %u seconds.",
66+ nm_connection_get_id (NM_CONNECTION (connection)), delay);
67+ else
68+ _LOGI (LOGD_DEVICE, "Device '%s' has no connection; scheduling activate_check in %u seconds.",
69+ nm_device_get_iface (device), delay);
70+
71+ schedule_activate_check (self, device, delay);
72 break;
73
74 case NM_DEVICE_STATE_PREPARE:
75@@ -1363,7 +1385,7 @@ device_autoconnect_changed (NMDevice *device,
76 NMPolicy *self = priv->self;
77
78 if (nm_device_autoconnect_allowed (device))
79- schedule_activate_check (self, device);
80+ schedule_activate_check (self, device, 0);
81 }
82
83 static void
84@@ -1372,7 +1394,7 @@ device_recheck_auto_activate (NMDevice *device, gpointer user_data)
85 NMPolicyPrivate *priv = user_data;
86 NMPolicy *self = priv->self;
87
88- schedule_activate_check (self, device);
89+ schedule_activate_check (self, device, 0);
90 }
91
92 static void
93@@ -1586,7 +1608,7 @@ schedule_activate_all (NMPolicy *self)
94 const GSList *iter;
95
96 for (iter = nm_manager_get_devices (priv->manager); iter; iter = g_slist_next (iter))
97- schedule_activate_check (self, NM_DEVICE (iter->data));
98+ schedule_activate_check (self, NM_DEVICE (iter->data), 0);
99 }
100
101 static void

Subscribers

People subscribed via source and target branches