summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorThomas Haller <thaller@redhat.com>2016-09-15 14:44:35 +0200
committerThomas Haller <thaller@redhat.com>2016-09-15 14:51:49 +0200
commit7e55fc66157854b25edcfdbab5e22f806a7ad574 (patch)
tree0cabd80795aee8fbdc8a9d46f95045542c567114
parent73c649f365010eb22d9e574d7c9471dcd9776a24 (diff)
downloadNetworkManager-th/dhcp-helper-eagain.tar.gz
dhcp-helper: retry connecting to private D-Bus socket on EAGAINth/dhcp-helper-eagain
Seems that the backlog of the private D-Bus socket can fill up and connect() fails with EAGAIN: NM_DHCP_HELPER=/usr/libexec/nm-dhcp-helper for i in `seq 1 500`; do $NM_DHCP_HELPER & done In strace we see: connect(4, {sa_family=AF_UNIX, sun_path="/var/run/NetworkManager/private-dhcp"}, 110) = -1 EAGAIN (Resource temporarily unavailable) and the nm-dhcp-helper exits with: <error> [1473943658.5404] could not connect to NetworkManager D-Bus socket: Could not connect: Resource temporarily unavailable Avoid that by retrying.
-rw-r--r--src/dhcp-manager/nm-dhcp-helper.c14
1 files changed, 13 insertions, 1 deletions
diff --git a/src/dhcp-manager/nm-dhcp-helper.c b/src/dhcp-manager/nm-dhcp-helper.c
index 9c6f69b839..90149be12c 100644
--- a/src/dhcp-manager/nm-dhcp-helper.c
+++ b/src/dhcp-manager/nm-dhcp-helper.c
@@ -131,15 +131,26 @@ main (int argc, char *argv[])
gs_unref_variant GVariant *parameters = NULL;
gs_unref_variant GVariant *result = NULL;
gboolean success = FALSE;
- guint try_count = 0;
+ guint try_count;
gint64 time_end;
nm_g_type_init ();
+ try_count = 0;
+do_connect:
+ try_count++;
connection = g_dbus_connection_new_for_address_sync ("unix:path=" NMRUNDIR "/private-dhcp",
G_DBUS_CONNECTION_FLAGS_AUTHENTICATION_CLIENT,
NULL, NULL, &error);
if (!connection) {
+ if ( try_count < 10
+ && g_error_matches (error, G_IO_ERROR, G_IO_ERROR_WOULD_BLOCK)) {
+ _LOGi ("could not connect to NetworkManager D-Bus socket: %s (retry %u)",
+ error->message, try_count);
+ g_clear_error (&error);
+ g_usleep (1000);
+ goto do_connect;
+ }
g_dbus_error_strip_remote_error (error);
_LOGE ("could not connect to NetworkManager D-Bus socket: %s",
error->message);
@@ -150,6 +161,7 @@ main (int argc, char *argv[])
time_end = g_get_monotonic_time () + (200 * 1000L); /* retry for at most 200 milliseconds */
+ try_count = 0;
do_notify:
try_count++;
result = g_dbus_connection_call_sync (connection,