summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBeniamino Galvani <bgalvani@redhat.com>2020-04-17 22:30:44 +0200
committerBeniamino Galvani <bgalvani@redhat.com>2020-04-17 22:30:44 +0200
commit20748f19bdca8fc1fb4958e0e97dac5ec518d88d (patch)
treee9786887921412011d76b29a791faf8eff373d02
parentd6345e4ed12e497a842da2a6de36f99ddc831e24 (diff)
downloadNetworkManager-bg/dhcp-helper-reconnect-rh1821594.tar.gz
fixup! dhcp-helper: retry in case of failure connecting to D-Bus unix socketbg/dhcp-helper-reconnect-rh1821594
-rw-r--r--src/dhcp/nm-dhcp-helper.c12
1 files changed, 10 insertions, 2 deletions
diff --git a/src/dhcp/nm-dhcp-helper.c b/src/dhcp/nm-dhcp-helper.c
index 92223c78a5..f6a4b548e0 100644
--- a/src/dhcp/nm-dhcp-helper.c
+++ b/src/dhcp/nm-dhcp-helper.c
@@ -136,12 +136,16 @@ do_connect:
if (!connection) {
if (g_error_matches (error, G_IO_ERROR, G_IO_ERROR_WOULD_BLOCK)) {
gint64 time_remaining = time_end - g_get_monotonic_time ();
+ gulong interval;
if (time_remaining > 0) {
_LOGi ("failure to connect: %s (retry %u, waited %lld ms)",
error->message, try_count,
(long long) (time_end - time_remaining - time_start) / 1000);
- g_usleep (NM_MIN (NM_CLAMP ((gint64) (100L * (1L << try_count)), 5000, 100000), time_remaining));
+ interval = NM_CLAMP ((gint64) (100L * (1L << NM_MIN (try_count, 31))),
+ 5000,
+ 100000);
+ g_usleep (NM_MIN (interval, time_remaining));
g_clear_error (&error);
goto do_connect;
}
@@ -177,6 +181,7 @@ do_notify:
s_err = g_dbus_error_get_remote_error (error);
if (NM_IN_STRSET (s_err, "org.freedesktop.DBus.Error.UnknownMethod")) {
gint64 remaining_time = time_end - g_get_monotonic_time ();
+ gulong interval;
/* I am not sure that a race can actually happen, as we register the object
* on the server side during GDBusServer:new-connection signal.
@@ -185,7 +190,10 @@ do_notify:
* do some retry. */
if (remaining_time > 0) {
_LOGi ("failure to call notify: %s (retry %u)", error->message, try_count);
- g_usleep (NM_MIN (NM_CLAMP ((gint64) (100L * (1L << try_count)), 5000, 25000), remaining_time));
+ interval = NM_CLAMP ((gint64) (100L * (1L << NM_MIN (try_count, 31))),
+ 5000,
+ 25000);
+ g_usleep (NM_MIN (interval, remaining_time));
g_clear_error (&error);
goto do_notify;
}