unofficial mirror of guix-devel@gnu.org 
 help / color / mirror / code / Atom feed
* dmd: [PATCH] Improve socket connection errors handling.
@ 2014-04-10  8:14 Cyprien Nicolas
  2014-04-10 14:52 ` Ludovic Courtès
  0 siblings, 1 reply; 3+ messages in thread
From: Cyprien Nicolas @ 2014-04-10  8:14 UTC (permalink / raw)
  To: guix-devel


[-- Attachment #1.1: Type: text/plain, Size: 284 bytes --]

My first patch for dmd :-)

I thought about moving the interior format call to support.scm
(caught-error), but I wanted to keep the patch simple, and not making
two differents changes in one patch (error handling, support
improvements).

Comments welcome.
-- 
Cyprien/Fulax

[-- Attachment #1.2: 0001-Improve-socket-connection-errors-handling.patch --]
[-- Type: text/x-diff, Size: 1395 bytes --]

From 6e8f871198b661b631a319f3abaef71bc6269fb7 Mon Sep 17 00:00:00 2001
From: Cyprien Nicolas <cyp@fulax.fr>
Date: Thu, 10 Apr 2014 10:07:06 +0200
Subject: [PATCH] Improve socket connection errors handling.

If the user running `deco' does not have the rights privileges to open
the unix socket, the raised exception produces a backtrace.

* modules/dmd/comm.scm (open-connection): Add a (catch
  'system-error...) guard around the connect function call.
  The handler will abort the program in case of error.
---
 modules/dmd/comm.scm | 9 ++++++++-
 1 file changed, 8 insertions(+), 1 deletion(-)

diff --git a/modules/dmd/comm.scm b/modules/dmd/comm.scm
index d3743e6..4a0d383 100644
--- a/modules/dmd/comm.scm
+++ b/modules/dmd/comm.scm
@@ -63,7 +63,14 @@ return the socket."
   (with-fluids ((%default-port-encoding "UTF-8"))
     (let ((sock    (socket PF_UNIX SOCK_STREAM 0))
           (address (make-socket-address PF_UNIX file)))
-      (connect sock address)
+      (catch 'system-error
+        (lambda ()
+          (connect sock address))
+        (lambda (key . args)
+          (display (format #f "Error: Cannot connect to socket `~a': ~a\n"
+                           file (apply format #f (cadr args) (caddr args)))
+                   (current-error-port))
+          (quit 1)))
       sock)))
 
 (define (read-command port)
-- 
1.8.5.4


[-- Attachment #2: Digital signature --]
[-- Type: application/pgp-signature, Size: 490 bytes --]

^ permalink raw reply related	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2014-04-10 15:16 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2014-04-10  8:14 dmd: [PATCH] Improve socket connection errors handling Cyprien Nicolas
2014-04-10 14:52 ` Ludovic Courtès
2014-04-10 15:16   ` Cyprien Nicolas

Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/guix.git

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).