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

To reply to this bug, email your comments to 74871 AT debbugs.gnu.org.

Toggle the display of automated, internal messages from the tracker.

View this report as an mbox folder, status mbox, maintainer mbox


Report forwarded to bug-guile <at> gnu.org:
bug#74871; Package guile. (Sat, 14 Dec 2024 16:28:03 GMT) Full text and rfc822 format available.

Acknowledgement sent to guile-qf1qmg <at> rdmp.org:
New bug report received and forwarded. Copy sent to bug-guile <at> gnu.org. (Sat, 14 Dec 2024 16:28:04 GMT) Full text and rfc822 format available.

Message #5 received at submit <at> debbugs.gnu.org (full text, mbox):

From: Dale Mellor <no-reply <at> rdmp.org>
To: bug-guile <bug-guile <at> gnu.org>
Subject: [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 181 days ago.

Previous Next


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