unofficial mirror of bug-guile@gnu.org 
 help / color / mirror / Atom feed
From: Dale Mellor <no-reply@rdmp.org>
To: 74871@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	[thread overview]
Message-ID: <ac73f4cd10190857e8bab697acbac6995a446d9c.camel@rdmp.org> (raw)
In-Reply-To: 17cfe670b5adc0736985a593991d5adee99eeddb.camel@rdmp.org

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


           reply	other threads:[~2024-12-14 15:38 UTC|newest]

Thread overview: expand[flat|nested]  mbox.gz  Atom feed
 [parent not found: <17cfe670b5adc0736985a593991d5adee99eeddb.camel@rdmp.org>]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.gnu.org/software/guile/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=ac73f4cd10190857e8bab697acbac6995a446d9c.camel@rdmp.org \
    --to=no-reply@rdmp.org \
    --cc=74871@debbugs.gnu.org \
    --cc=guile-qf1qmg@rdmp.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).