GNU bug report logs - #74871
[PATCH] When socket bind or connect fails with a string address, display that address in the error message.

Previous Next

Package: guile;

Reported by: guile-qf1qmg <at> rdmp.org

Date: Sat, 14 Dec 2024 16:28:03 UTC

Severity: normal

Tags: patch

Full log


View this message in rfc822 format

From: Dale Mellor <no-reply <at> rdmp.org>
To: 74871 <at> debbugs.gnu.org
Subject: bug#74871: [PATCH] When socket bind or connect fails with a string address, display that address in the error message.
Date: Sat, 14 Dec 2024 15:38:52 +0000
Too often the message 'connect: no such file or directory' appears deep
in network code, and it is very hard to figure out where it is coming
from.  At least seeing the path (for example, in the case of a UNIX
socket) will help the user to debug their code.

 * libguile/socket.c: extra error handling in scm_bind and scm_connect
                      functions.
---
 libguile/socket.c | 28 ++++++++++++++++++++++++++--
 1 file changed, 26 insertions(+), 2 deletions(-)

diff --git a/libguile/socket.c b/libguile/socket.c
index 101afd80d..9deecb48c 100644
--- a/libguile/socket.c
+++ b/libguile/socket.c
@@ -932,7 +932,19 @@ SCM_DEFINE (scm_connect, "connect", 2, 1, 1,
       errno = save_errno;
       if (errno == EINPROGRESS || errno == EAGAIN)
         return SCM_BOOL_F;
-      SCM_SYSERROR;
+      if (scm_is_string (address))
+        {
+          SCM_SYSERROR_MSG
+            ("'~A': ~A",
+             scm_cons (address,
+                       scm_cons (scm_strerror (scm_from_int (errno)),
+                                 SCM_EOL)),
+             errno);
+        }
+      else
+        {
+          SCM_SYSERROR;
+        }
     }
   free (soka);
   return SCM_BOOL_T;
@@ -1002,7 +1014,19 @@ SCM_DEFINE (scm_bind, "bind", 2, 1, 1,
 
     free (soka);
     errno = save_errno;
-    SCM_SYSERROR;
+    if (scm_is_string (address))
+      {
+        SCM_SYSERROR_MSG
+          ("'~A': ~A",
+           scm_cons (address,
+                     scm_cons (scm_strerror (scm_from_int (errno)),
+                               SCM_EOL)),
+           errno);
+      }
+    else
+      {
+        SCM_SYSERROR;
+      }
   }
   free (soka);
   return SCM_UNSPECIFIED;
-- 
2.46.0


This bug report was last modified 182 days ago.

Previous Next


GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson.