Richard W.M. Jones
2021-Feb-04 18:10 UTC
[Libguestfs] [PATCH libnbd 2/2] generator: Print a better error message if connect(2) returns EAGAIN.
The new error message is:
nbd_connect_unix: connect: server backlog overflowed, see
https://bugzilla.redhat.com/1925045: Resource temporarily unavailable
Fixes: https://bugzilla.redhat.com/1925045
---
generator/states-connect.c | 16 ++++++++++++++++
1 file changed, 16 insertions(+)
diff --git a/generator/states-connect.c b/generator/states-connect.c
index 03b34c7..98c26e5 100644
--- a/generator/states-connect.c
+++ b/generator/states-connect.c
@@ -70,6 +70,22 @@ STATE_MACHINE {
if (r == 0 || (r == -1 && errno == EINPROGRESS))
return 0;
assert (r == -1);
+#ifdef __linux__
+ if (errno == EAGAIN && family == AF_UNIX) {
+ /* This can happen on Linux when connecting to a Unix domain
+ * socket, if the server's backlog is full. Unfortunately there
+ * is nothing good we can do on the client side when this happens
+ * since any solution would involve sleeping or busy-waiting. The
+ * only solution is on the server side, increasing the backlog.
+ * But at least improve the error message.
+ * https://bugzilla.redhat.com/1925045
+ */
+ SET_NEXT_STATE (%.DEAD);
+ set_error (errno, "connect: server backlog overflowed, "
+ "see https://bugzilla.redhat.com/1925045");
+ return 0;
+ }
+#endif
SET_NEXT_STATE (%.DEAD);
set_error (errno, "connect");
return 0;
--
2.29.0.rc2
Martin Kletzander
2021-Feb-08 19:47 UTC
[Libguestfs] [PATCH libnbd 2/2] generator: Print a better error message if connect(2) returns EAGAIN.
On Thu, Feb 04, 2021 at 06:10:50PM +0000, Richard W.M. Jones wrote:>The new error message is: > >nbd_connect_unix: connect: server backlog overflowed, see https://bugzilla.redhat.com/1925045: Resource temporarily unavailable > >Fixes: https://bugzilla.redhat.com/1925045 >--- > generator/states-connect.c | 16 ++++++++++++++++ > 1 file changed, 16 insertions(+) > >diff --git a/generator/states-connect.c b/generator/states-connect.c >index 03b34c7..98c26e5 100644 >--- a/generator/states-connect.c >+++ b/generator/states-connect.c >@@ -70,6 +70,22 @@ STATE_MACHINE { > if (r == 0 || (r == -1 && errno == EINPROGRESS)) > return 0; > assert (r == -1); >+#ifdef __linux__ >+ if (errno == EAGAIN && family == AF_UNIX) { >+ /* This can happen on Linux when connecting to a Unix domain >+ * socket, if the server's backlog is full. Unfortunately there >+ * is nothing good we can do on the client side when this happens >+ * since any solution would involve sleeping or busy-waiting. TheAlso thanks to the passthrough of the errno any retry procedure can be done in the client that uses libnbd. So for both patches: Reviewed-by: Martin Kletzander <mkletzan at redhat.com>>+ * only solution is on the server side, increasing the backlog. >+ * But at least improve the error message. >+ * https://bugzilla.redhat.com/1925045 >+ */ >+ SET_NEXT_STATE (%.DEAD); >+ set_error (errno, "connect: server backlog overflowed, " >+ "see https://bugzilla.redhat.com/1925045"); >+ return 0; >+ } >+#endif > SET_NEXT_STATE (%.DEAD); > set_error (errno, "connect"); > return 0; >-- >2.29.0.rc2 > >_______________________________________________ >Libguestfs mailing list >Libguestfs at redhat.com >https://www.redhat.com/mailman/listinfo/libguestfs-------------- next part -------------- A non-text attachment was scrubbed... Name: signature.asc Type: application/pgp-signature Size: 833 bytes Desc: not available URL: <http://listman.redhat.com/archives/libguestfs/attachments/20210208/f2a3d64b/attachment.sig>