Blame SOURCES/0003-generator-Print-a-better-error-message-if-connect-2-.patch

a81d13
From f094472efcf34cea8bf1f02a1c5c9442ffc4ca53 Mon Sep 17 00:00:00 2001
a81d13
From: "Richard W.M. Jones" <rjones@redhat.com>
a81d13
Date: Thu, 4 Feb 2021 18:02:46 +0000
a81d13
Subject: [PATCH] generator: Print a better error message if connect(2) returns
a81d13
 EAGAIN.
a81d13
a81d13
The new error message is:
a81d13
a81d13
nbd_connect_unix: connect: server backlog overflowed, see https://bugzilla.redhat.com/1925045: Resource temporarily unavailable
a81d13
a81d13
Fixes: https://bugzilla.redhat.com/1925045
a81d13
Thanks: Xin Long, Lukas Doktor, Eric Blake
a81d13
Reviewed-by: Martin Kletzander <mkletzan@redhat.com>
a81d13
(cherry picked from commit 85ed74960a658a82d7b61b0be07f43d1b2dcede9)
a81d13
---
a81d13
 generator/states-connect.c | 16 ++++++++++++++++
a81d13
 1 file changed, 16 insertions(+)
a81d13
a81d13
diff --git a/generator/states-connect.c b/generator/states-connect.c
a81d13
index 03b34c7..98c26e5 100644
a81d13
--- a/generator/states-connect.c
a81d13
+++ b/generator/states-connect.c
a81d13
@@ -70,6 +70,22 @@ STATE_MACHINE {
a81d13
   if (r == 0 || (r == -1 && errno == EINPROGRESS))
a81d13
     return 0;
a81d13
   assert (r == -1);
a81d13
+#ifdef __linux__
a81d13
+  if (errno == EAGAIN && family == AF_UNIX) {
a81d13
+    /* This can happen on Linux when connecting to a Unix domain
a81d13
+     * socket, if the server's backlog is full.  Unfortunately there
a81d13
+     * is nothing good we can do on the client side when this happens
a81d13
+     * since any solution would involve sleeping or busy-waiting.  The
a81d13
+     * only solution is on the server side, increasing the backlog.
a81d13
+     * But at least improve the error message.
a81d13
+     * https://bugzilla.redhat.com/1925045
a81d13
+     */
a81d13
+    SET_NEXT_STATE (%.DEAD);
a81d13
+    set_error (errno, "connect: server backlog overflowed, "
a81d13
+               "see https://bugzilla.redhat.com/1925045");
a81d13
+    return 0;
a81d13
+  }
a81d13
+#endif
a81d13
   SET_NEXT_STATE (%.DEAD);
a81d13
   set_error (errno, "connect");
a81d13
   return 0;
a81d13
-- 
a81d13
2.31.1
a81d13