From mboxrd@z Thu Jan 1 00:00:00 1970 From: Cyprien Nicolas Subject: dmd: [PATCH] Improve socket connection errors handling. Date: Thu, 10 Apr 2014 10:14:46 +0200 Message-ID: <20140410081446.GF9248@kubera.prv.maison> Mime-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha1; protocol="application/pgp-signature"; boundary="Pgaa2uWPnPrfixyx" Return-path: Received: from eggs.gnu.org ([2001:4830:134:3::10]:45435) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WYA8S-0001UO-Ij for guix-devel@gnu.org; Thu, 10 Apr 2014 04:15:06 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1WYA8N-0000ON-0j for guix-devel@gnu.org; Thu, 10 Apr 2014 04:15:00 -0400 Received: from cubran.fulax.net ([91.224.149.126]:49507) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WYA8M-0000N3-IQ for guix-devel@gnu.org; Thu, 10 Apr 2014 04:14:54 -0400 Received: from kubera.inria.fr (kubera.inria.fr [138.96.195.162]) by cubran.fulax.net (Postfix) with ESMTPSA id 70AE89609B for ; Thu, 10 Apr 2014 08:14:49 +0000 (UTC) Content-Disposition: inline List-Id: "Development of GNU Guix and the GNU System distribution." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: guix-devel-bounces+gcggd-guix-devel=m.gmane.org@gnu.org Sender: guix-devel-bounces+gcggd-guix-devel=m.gmane.org@gnu.org To: guix-devel@gnu.org --Pgaa2uWPnPrfixyx Content-Type: multipart/mixed; boundary="MIdTMoZhcV1D07fI" Content-Disposition: inline --MIdTMoZhcV1D07fI Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable 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. --=20 Cyprien/Fulax --MIdTMoZhcV1D07fI Content-Type: text/x-diff; charset=us-ascii Content-Disposition: attachment; filename="0001-Improve-socket-connection-errors-handling.patch" Content-Transfer-Encoding: quoted-printable =46rom 6e8f871198b661b631a319f3abaef71bc6269fb7 Mon Sep 17 00:00:00 2001 =46rom: Cyprien Nicolas 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))) =20 (define (read-command port) --=20 1.8.5.4 --MIdTMoZhcV1D07fI-- --Pgaa2uWPnPrfixyx Content-Type: application/pgp-signature; name="signature.asc" Content-Description: Digital signature -----BEGIN PGP SIGNATURE----- Version: GnuPG v2.0.22 (GNU/Linux) iQEcBAEBAgAGBQJTRlL2AAoJEGeOLLwllM0zpWYIAIIOufnrTr5mFCm3QMjUG38Y UJ6LtcSTKg0NMoAZsteeTGKi+aoKq1RWkhTa6DtsCxrwROKP0cWqGlRCCzfFe3nU jpFwq6fgxyNUzU2y01xY/1Xdm3uagSpVkuV5VdTI1oXvUGKsjaJlAXCBURjafAZp Y6NR9sjlvFwUTXwEZcuN7Xzi8hXQOIghhmq8hcwbQ0YPbK8Nsv65dtitk0ek0dcy i6EZTnl++biGktmj7/y/7v7dgzWIpGs+b5ot41O8mOlKlWdK8q2qTONNJOWm6v/3 VKaWq+DjW+nwRL0oelfahrKnGoPXnX2wDO58e9goj5XTYxHSlCml2EfKMxDtLD8= =OJxw -----END PGP SIGNATURE----- --Pgaa2uWPnPrfixyx--