X-Loop: help-debbugs@HIDDEN Subject: bug#24818: Clean up socket files set up by --listen=/path/to/socket-file Resent-From: Christopher Allan Webber <cwebber@HIDDEN> Original-Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org> Resent-CC: bug-guile@HIDDEN Resent-Date: Sat, 29 Oct 2016 16:39:02 +0000 Resent-Message-ID: <handler.24818.B.147775912415675 <at> debbugs.gnu.org> Resent-Sender: help-debbugs@HIDDEN X-GNU-PR-Message: report 24818 X-GNU-PR-Package: guile X-GNU-PR-Keywords: To: 24818 <at> debbugs.gnu.org X-Debbugs-Original-To: bug-guile@HIDDEN Received: via spool by submit <at> debbugs.gnu.org id=B.147775912415675 (code B ref -1); Sat, 29 Oct 2016 16:39:02 +0000 Received: (at submit) by debbugs.gnu.org; 29 Oct 2016 16:38:44 +0000 Received: from localhost ([127.0.0.1]:36767 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>) id 1c0Wea-00044k-1V for submit <at> debbugs.gnu.org; Sat, 29 Oct 2016 12:38:44 -0400 Received: from eggs.gnu.org ([208.118.235.92]:51552) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from <cwebber@HIDDEN>) id 1c0WeY-00044R-Fz for submit <at> debbugs.gnu.org; Sat, 29 Oct 2016 12:38:43 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from <cwebber@HIDDEN>) id 1c0WeS-0003fs-Cb for submit <at> debbugs.gnu.org; Sat, 29 Oct 2016 12:38:37 -0400 X-Spam-Checker-Version: SpamAssassin 3.3.2 (2011-06-06) on eggs.gnu.org X-Spam-Level: X-Spam-Status: No, score=0.8 required=5.0 tests=BAYES_50 autolearn=disabled version=3.3.2 Received: from lists.gnu.org ([2001:4830:134:3::11]:55339) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from <cwebber@HIDDEN>) id 1c0WeS-0003fi-9C for submit <at> debbugs.gnu.org; Sat, 29 Oct 2016 12:38:36 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:42493) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from <cwebber@HIDDEN>) id 1c0WeQ-000097-ST for bug-guile@HIDDEN; Sat, 29 Oct 2016 12:38:36 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from <cwebber@HIDDEN>) id 1c0WeM-0003da-7d for bug-guile@HIDDEN; Sat, 29 Oct 2016 12:38:34 -0400 Received: from dustycloud.org ([50.116.34.160]:55276) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from <cwebber@HIDDEN>) id 1c0WeM-0003dN-1H for bug-guile@HIDDEN; Sat, 29 Oct 2016 12:38:30 -0400 Received: from oolong (localhost [127.0.0.1]) by dustycloud.org (Postfix) with ESMTPS id 28F3B265F2 for <bug-guile@HIDDEN>; Sat, 29 Oct 2016 12:38:29 -0400 (EDT) User-agent: mu4e 0.9.16; emacs 25.1.1 From: Christopher Allan Webber <cwebber@HIDDEN> Date: Sat, 29 Oct 2016 11:38:23 -0500 Message-ID: <87oa236rgg.fsf@HIDDEN> MIME-Version: 1.0 Content-Type: multipart/signed; boundary="==-=-="; micalg=pgp-sha256; protocol="application/pgp-signature" X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6.x X-Received-From: 2001:4830:134:3::11 X-Spam-Score: -4.0 (----) X-BeenThere: debbugs-submit <at> debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: <debbugs-submit.debbugs.gnu.org> List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe> List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/> List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org> List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help> List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe> Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org> X-Spam-Score: -4.0 (----) --==-=-= Content-Type: multipart/mixed; boundary="=-=-=" --=-=-= Content-Type: text/plain In light of the recent security vulnerability on using localhost + port, I've been using socket files for live hacking. Unfortunately, these socket files stay around after closing guile, which means this can happen: $ guile --listen=/tmp/guile-socket scheme@(guile-user)> ,q $ guile --listen=/tmp/guile-socket ERROR: In procedure bind: ERROR: In procedure bind: Address already in use That's not very nice! I really don't like having to clean up these files by hand.... Guile should do it for me. Fortunately, here's a patch that does just that! It uses dynamic-wind and cleans up the socket file, if it exists. (But it doesn't break if it doesn't!) --=-=-= Content-Type: text/x-patch Content-Disposition: inline; filename=0001-Clean-up-socket-file-set-up-by-listen.patch Content-Transfer-Encoding: quoted-printable From=2012a1c24890448ec9a2d33cabff7f70f6332dbb4f Mon Sep 17 00:00:00 2001 From: Christopher Allan Webber <cwebber@HIDDEN> Date: Sat, 29 Oct 2016 11:28:05 -0500 Subject: [PATCH] Clean up socket file set up by --listen * module/ice-9/command-line.scm (compile-shell-switches): Clean up socket file set up by --listen on exit, if it exists. =2D-- module/ice-9/command-line.scm | 80 ++++++++++++++++++++++++---------------= ---- 1 file changed, 44 insertions(+), 36 deletions(-) diff --git a/module/ice-9/command-line.scm b/module/ice-9/command-line.scm index 98d3855..cdc5427 100644 =2D-- a/module/ice-9/command-line.scm +++ b/module/ice-9/command-line.scm @@ -199,6 +199,7 @@ If FILE begins with `-' the -s switch is mandatory. (user-load-compiled-path '()) (user-extensions '()) (interactive? #t) + (clean-socket-file #f) (inhibit-user-init? #f) (turn-on-debugging? #f) (turn-off-debugging? #f)) @@ -387,6 +388,7 @@ If FILE begins with `-' the -s switch is mandatory. ((@@ (system repl server) make-tcp-server-soc= ket) #:port ,port)) (error "invalid port for --listen")))) ((string-prefix? "/" where) ; --listen=3D/PATH/TO/SOCKET + (set! clean-socket-file where) `((@@ (system repl server) spawn-server) ((@@ (system repl server) make-unix-domain-server-sock= et) #:path ,where))) (else @@ -430,42 +432,48 @@ If FILE begins with `-' the -s switch is mandatory. `(;; It would be nice not to load up (ice-9 control), but the ;; default-prompt-handler is nontrivial. (@ (ice-9 control) %) =2D (begin =2D ;; If we didn't end with a -c or a -s and didn't supply a -q, = load =2D ;; the user's customization file. =2D ,@(if (and interactive? (not inhibit-user-init?)) =2D '((load-user-init)) =2D '()) =2D =2D ;; Use-specified extensions. =2D ,@(map (lambda (ext) =2D `(set! %load-extensions (cons ,ext %load-extensions))) =2D user-extensions) =2D =2D ;; Add the user-specified load paths here, so they won't be in =2D ;; effect during the loading of the user's customization file. =2D ,@(map (lambda (path) =2D `(set! %load-path (cons ,path %load-path))) =2D user-load-path) =2D ,@(map (lambda (path) =2D `(set! %load-compiled-path =2D (cons ,path %load-compiled-path))) =2D user-load-compiled-path) =2D =2D ;; Put accumulated actions in their correct order. =2D ,@(reverse! out) =2D =2D ;; Handle the `-e' switch, if it was specified. =2D ,@(if entry-point =2D `((,entry-point (command-line))) =2D '()) =2D ,(if interactive? =2D ;; If we didn't end with a -c or a -s, start the =2D ;; repl. =2D '((@ (ice-9 top-repl) top-repl)) =2D ;; Otherwise, after doing all the other actions =2D ;; prescribed by the command line, quit. =2D '(quit))))) + (dynamic-wind + (const #f) ; no-op + (lambda () + ;; If we didn't end with a -c or a -s and didn't supply a -q, = load + ;; the user's customization file. + ,@(if (and interactive? (not inhibit-user-init?)) + '((load-user-init)) + '()) + + ;; Use-specified extensions. + ,@(map (lambda (ext) + `(set! %load-extensions (cons ,ext %load-extensions))) + user-extensions) + + ;; Add the user-specified load paths here, so they won't be in + ;; effect during the loading of the user's customization file. + ,@(map (lambda (path) + `(set! %load-path (cons ,path %load-path))) + user-load-path) + ,@(map (lambda (path) + `(set! %load-compiled-path + (cons ,path %load-compiled-path))) + user-load-compiled-path) + + ;; Put accumulated actions in their correct order. + ,@(reverse! out) + + ;; Handle the `-e' switch, if it was specified. + ,@(if entry-point + `((,entry-point (command-line))) + '()) + ,(if interactive? + ;; If we didn't end with a -c or a -s, start the + ;; repl. + '((@ (ice-9 top-repl) top-repl)) + ;; Otherwise, after doing all the other actions + ;; prescribed by the command line, quit. + '(quit))) + (lambda () + (when (and ,clean-socket-file + (file-exists? ,clean-socket-file)) + (delete-file ,clean-socket-file)))))) =20 (if (pair? args) (begin =2D-=20 2.10.1 --=-=-=-- --==-=-= Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- Version: GnuPG v2 iQIcBAEBCAAGBQJYFNB/AAoJEEvAJZJf+PTT2AgQAINjtmd/DJCMPDjWR30k92sZ qothbxxHqaEaL7iX5n9KMrVfqKxtVZoH5RYioj/fMcn9jgrssUbZNWYIuTcFbNZC Mx09SqRo87cSZ0PLYrP8iVeY1YhW0OJQPja3ovSnWPuL0nzQDN6BpcrOCwdcPCpI Lp6rinvDEFYpgohTGBdtt6B9o1govLTrt78WSiF075QphAYP9qEmVKI4qvZTnZNa OD/C/+tLQMC7do599XJ5MV9Q8srVASgO+S4fhTVyJr7bv3nMtDXbGdg3dH2hsiDe 7idPNu/zbcGHklsKphIdf/xGq7DNN0KUfmlvfC51RY1saBeA00v8GmMbbVHfotY6 OyWUkU33pmCQAf3Mt59D3mknguWhjf10DznwY/Wm7Yl3qoqvdMALEv6dhn0Gucv7 qnFwkaBtNxaBFzatDJ6p4W+CM8VQHuILYPkxYnLVcA4pbUODZk3tMaiZnHma8ejJ LwZ6YIo77KtW+QYlnsl8iPhAuYMsFS8nzzGI8VZwRELx75MXhJTFuENrcCicFtkA +fYE+/PerKYSok1oVqcy+rMeqpCRIbxzQrevoz/4xoXlcEEcFd7JwUx+370PCNi2 qRiP7Y1y+m+a3Wk48feV0yB1TuHfKH/HwTDh+8xWFcqqQOXjV0Cjp1jMSSwbSa55 vBEVzHVdvb8hPd3LKZyg =r9vF -----END PGP SIGNATURE----- --==-=-=--
Content-Disposition: inline Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 X-Mailer: MIME-tools 5.505 (Entity 5.505) Content-Type: text/plain; charset=utf-8 X-Loop: help-debbugs@HIDDEN From: help-debbugs@HIDDEN (GNU bug Tracking System) To: Christopher Allan Webber <cwebber@HIDDEN> Subject: bug#24818: Acknowledgement (Clean up socket files set up by --listen=/path/to/socket-file) Message-ID: <handler.24818.B.147775912415675.ack <at> debbugs.gnu.org> References: <87oa236rgg.fsf@HIDDEN> X-Gnu-PR-Message: ack 24818 X-Gnu-PR-Package: guile Reply-To: 24818 <at> debbugs.gnu.org Date: Sat, 29 Oct 2016 16:39:02 +0000 Thank you for filing a new bug report with debbugs.gnu.org. This is an automatically generated reply to let you know your message has been received. Your message is being forwarded to the package maintainers and other interested parties for their attention; they will reply in due course. Your message has been sent to the package maintainer(s): bug-guile@HIDDEN If you wish to submit further information on this problem, please send it to 24818 <at> debbugs.gnu.org. Please do not send mail to help-debbugs@HIDDEN unless you wish to report a problem with the Bug-tracking system. --=20 24818: http://debbugs.gnu.org/cgi/bugreport.cgi?bug=3D24818 GNU Bug Tracking System Contact help-debbugs@HIDDEN with problems
Received: (at control) by debbugs.gnu.org; 9 Jan 2017 22:16:07 +0000 From debbugs-submit-bounces <at> debbugs.gnu.org Mon Jan 09 17:16:07 2017 Received: from localhost ([127.0.0.1]:48221 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>) id 1cQiEZ-0008BX-L0 for submit <at> debbugs.gnu.org; Mon, 09 Jan 2017 17:16:07 -0500 Received: from dustycloud.org ([50.116.34.160]:50516) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from <cwebber@HIDDEN>) id 1cQiEY-0008BQ-Ln for control <at> debbugs.gnu.org; Mon, 09 Jan 2017 17:16:06 -0500 Received: from oolong (localhost [127.0.0.1]) by dustycloud.org (Postfix) with ESMTPS id CF4B126625 for <control <at> debbugs.gnu.org>; Mon, 9 Jan 2017 17:16:05 -0500 (EST) Date: Mon, 09 Jan 2017 16:16:05 -0600 Message-Id: <87h957g9qy.fsf@HIDDEN> To: control <at> debbugs.gnu.org From: Christopher Allan Webber <cwebber@HIDDEN> Subject: control message for bug #24818 X-Spam-Score: -3.2 (---) X-Debbugs-Envelope-To: control X-BeenThere: debbugs-submit <at> debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: <debbugs-submit.debbugs.gnu.org> List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe> List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/> List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org> List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help> List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe> Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org> X-Spam-Score: -3.2 (---) tags 24818 patch
X-Loop: help-debbugs@HIDDEN Subject: bug#24818: Clean up socket files set up by --listen=/path/to/socket-file Resent-From: Andy Wingo <wingo@HIDDEN> Original-Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org> Resent-CC: bug-guile@HIDDEN Resent-Date: Wed, 01 Mar 2017 13:35:01 +0000 Resent-Message-ID: <handler.24818.B24818.148837528229492 <at> debbugs.gnu.org> Resent-Sender: help-debbugs@HIDDEN X-GNU-PR-Message: followup 24818 X-GNU-PR-Package: guile X-GNU-PR-Keywords: patch To: Christopher Allan Webber <cwebber@HIDDEN> Cc: 24818 <at> debbugs.gnu.org Received: via spool by 24818-submit <at> debbugs.gnu.org id=B24818.148837528229492 (code B ref 24818); Wed, 01 Mar 2017 13:35:01 +0000 Received: (at 24818) by debbugs.gnu.org; 1 Mar 2017 13:34:42 +0000 Received: from localhost ([127.0.0.1]:32982 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>) id 1cj4Ow-0007fc-GV for submit <at> debbugs.gnu.org; Wed, 01 Mar 2017 08:34:42 -0500 Received: from pb-sasl2.pobox.com ([64.147.108.67]:58757 helo=sasl.smtp.pobox.com) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from <wingo@HIDDEN>) id 1cj4Ou-0007fU-9H for 24818 <at> debbugs.gnu.org; Wed, 01 Mar 2017 08:34:40 -0500 Received: from sasl.smtp.pobox.com (unknown [127.0.0.1]) by pb-sasl2.pobox.com (Postfix) with ESMTP id E3D3865842; Wed, 1 Mar 2017 08:34:37 -0500 (EST) DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=pobox.com; h=from:to:cc :subject:references:date:in-reply-to:message-id:mime-version :content-type; s=sasl; bh=3KziSduwgcTDT+DUN+ysGVz4inQ=; b=M8RQ6s AoxMjipXhqj1RGMuqXdSYj5GpSlTRJyzwUaUMWhBPYl1hTbzhzk/uJ5sQqn6l7wJ Nw/ujS0Tmztnlee/uAEmnv+a5o42GOakiDK+tKwfAydbD6B9zVFo0K16cpbqps+X uiewrwVJ0LEuC7i/XzB28wHN46TvJwgCxbV/8= DomainKey-Signature: a=rsa-sha1; c=nofws; d=pobox.com; h=from:to:cc :subject:references:date:in-reply-to:message-id:mime-version :content-type; q=dns; s=sasl; b=Vf4VD/uth2BXlrg/tP8gBRE3nd75T3uD N+25GbosDcsmk7VUnDpLH3QAvf5zEvPOW+JzQ1N7IadOM3PPAwPBP2kKfaUPTZeW XGQKzDk06Z73JAaf1/Q87zQ9h9GSh0dHI/NaZy1QYLxhSQFm4Rr/SJToAEqaMamT EuZ57l3hYNo= Received: from pb-sasl2.nyi.icgroup.com (unknown [127.0.0.1]) by pb-sasl2.pobox.com (Postfix) with ESMTP id DDAAB65841; Wed, 1 Mar 2017 08:34:37 -0500 (EST) Received: from clucks (unknown [109.190.228.233]) (using TLSv1 with cipher ECDHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by pb-sasl2.pobox.com (Postfix) with ESMTPSA id 3A26265840; Wed, 1 Mar 2017 08:34:37 -0500 (EST) From: Andy Wingo <wingo@HIDDEN> References: <87oa236rgg.fsf@HIDDEN> Date: Wed, 01 Mar 2017 14:34:29 +0100 In-Reply-To: <87oa236rgg.fsf@HIDDEN> (Christopher Allan Webber's message of "Sat, 29 Oct 2016 11:38:23 -0500") Message-ID: <87o9xlgly2.fsf@HIDDEN> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/25.1 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain X-Pobox-Relay-ID: D082F966-FE83-11E6-92EE-85AB91A0D1B0-02397024!pb-sasl2.pobox.com X-Spam-Score: 0.0 (/) X-BeenThere: debbugs-submit <at> debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: <debbugs-submit.debbugs.gnu.org> List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe> List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/> List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org> List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help> List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe> Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org> X-Spam-Score: 0.0 (/) On Sat 29 Oct 2016 18:38, Christopher Allan Webber <cwebber@HIDDEN> writes: > In light of the recent security vulnerability on using localhost + port, > I've been using socket files for live hacking. Unfortunately, these > socket files stay around after closing guile, which means this can happen: > > $ guile --listen=/tmp/guile-socket > scheme@(guile-user)> ,q > $ guile --listen=/tmp/guile-socket > ERROR: In procedure bind: > ERROR: In procedure bind: Address already in use > > That's not very nice! I really don't like having to clean up these > files by hand.... Guile should do it for me. I agree :) Thanks for the patch! The patch goes in a direction that I'm a bit hesitant about though -- this command-line processing is getting a bit intense. Would it be possible to add a #:cleanup? argument to the spawn-server function instead? My only doubt would be whether all threads unwind when the program ends. (And if they don't, is that a bug? I am not sure but I would guess so; dunno.) Andy
X-Loop: help-debbugs@HIDDEN Subject: bug#24818: Clean up socket files set up by --listen=/path/to/socket-file Resent-From: Christopher Allan Webber <cwebber@HIDDEN> Original-Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org> Resent-CC: bug-guile@HIDDEN Resent-Date: Wed, 08 Mar 2017 19:41:02 +0000 Resent-Message-ID: <handler.24818.B24818.148900202915458 <at> debbugs.gnu.org> Resent-Sender: help-debbugs@HIDDEN X-GNU-PR-Message: followup 24818 X-GNU-PR-Package: guile X-GNU-PR-Keywords: patch To: Andy Wingo <wingo@HIDDEN> Cc: 24818 <at> debbugs.gnu.org Received: via spool by 24818-submit <at> debbugs.gnu.org id=B24818.148900202915458 (code B ref 24818); Wed, 08 Mar 2017 19:41:02 +0000 Received: (at 24818) by debbugs.gnu.org; 8 Mar 2017 19:40:29 +0000 Received: from localhost ([127.0.0.1]:46687 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>) id 1clhRl-00041F-0d for submit <at> debbugs.gnu.org; Wed, 08 Mar 2017 14:40:29 -0500 Received: from dustycloud.org ([50.116.34.160]:40490) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from <cwebber@HIDDEN>) id 1clhRi-000415-To for 24818 <at> debbugs.gnu.org; Wed, 08 Mar 2017 14:40:27 -0500 Received: from oolong (localhost [127.0.0.1]) by dustycloud.org (Postfix) with ESMTPS id 4A2AD2664C; Wed, 8 Mar 2017 14:40:24 -0500 (EST) References: <87oa236rgg.fsf@HIDDEN> <87o9xlgly2.fsf@HIDDEN> User-agent: mu4e 0.9.18; emacs 25.1.1 From: Christopher Allan Webber <cwebber@HIDDEN> In-reply-to: <87o9xlgly2.fsf@HIDDEN> Date: Wed, 08 Mar 2017 13:40:16 -0600 Message-ID: <8760jjblr3.fsf@HIDDEN> MIME-Version: 1.0 Content-Type: multipart/signed; boundary="==-=-="; micalg=pgp-sha256; protocol="application/pgp-signature" X-Spam-Score: -0.0 (/) X-BeenThere: debbugs-submit <at> debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: <debbugs-submit.debbugs.gnu.org> List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe> List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/> List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org> List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help> List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe> Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org> X-Spam-Score: -0.0 (/) --==-=-= Content-Type: multipart/mixed; boundary="=-=-=" --=-=-= Content-Type: text/plain Andy Wingo writes: > I agree :) Thanks for the patch! > > The patch goes in a direction that I'm a bit hesitant about though -- > this command-line processing is getting a bit intense. Would it be > possible to add a #:cleanup? argument to the spawn-server function > instead? I agree that my previous patch makes things more complicated, so I tried the route you suggested, but... > My only doubt would be whether all threads unwind when the program > ends. (And if they don't, is that a bug? I am not sure but I would > guess so; dunno.) ... and it doesn't seem to work for that reason. The thread never seems to unwind. I put a print statement (not in this patch) at the very part of the out guard but it never seems to run. Too bad... So I guess the question is whether or not addressing the thread issue as a potential bug should be done or applying the previous patch version which worked but made the command line processing more complex? Or something else? --=-=-= Content-Type: text/x-patch Content-Disposition: inline; filename=0001-Clean-up-socket-file-set-up-by-listen.patch Content-Transfer-Encoding: quoted-printable From=2079ab483a872638abe311c521c3467c060566b39c Mon Sep 17 00:00:00 2001 From: Christopher Allan Webber <cwebber@HIDDEN> Date: Wed, 8 Mar 2017 12:04:55 -0600 Subject: [PATCH] Clean up socket file set up by --listen [Unfortunately, this patch does not work because the thread doesn't seem to unwind. Submitted for demonstrative purposes, or in the hope that could be fixed.] * module/ice-9/command-line.scm (compile-shell-switches): * module/system/repl/server.scm (run-server, run-server*, spawn-server): Clean up socket file set up by --listen on exit, if it exists. =2D-- module/ice-9/command-line.scm | 3 ++- module/system/repl/server.scm | 44 +++++++++++++++++++++++++++------------= ---- 2 files changed, 30 insertions(+), 17 deletions(-) diff --git a/module/ice-9/command-line.scm b/module/ice-9/command-line.scm index 98d385569..3305c671d 100644 =2D-- a/module/ice-9/command-line.scm +++ b/module/ice-9/command-line.scm @@ -388,7 +388,8 @@ If FILE begins with `-' the -s switch is mandatory. (error "invalid port for --listen")))) ((string-prefix? "/" where) ; --listen=3D/PATH/TO/SOCKET `((@@ (system repl server) spawn-server) =2D ((@@ (system repl server) make-unix-domain-server-so= cket) #:path ,where))) + ((@@ (system repl server) make-unix-domain-server-sock= et) #:path ,where) + #:cleanup? #t)) (else (error "unknown argument to --listen")))) out))) diff --git a/module/system/repl/server.scm b/module/system/repl/server.scm index 725eb4eda..1ced8e8d1 100644 =2D-- a/module/system/repl/server.scm +++ b/module/system/repl/server.scm @@ -21,6 +21,7 @@ =20 (define-module (system repl server) #:use-module (system repl repl) + #:use-module (ice-9 and-let-star) #:use-module (ice-9 threads) #:use-module (ice-9 rdelim) #:use-module (ice-9 match) @@ -84,11 +85,12 @@ (bind sock AF_UNIX path) sock)) =20 =2D(define* (run-server #:optional (server-socket (make-tcp-server-socket))) =2D (run-server* server-socket serve-client)) +(define* (run-server #:optional (server-socket (make-tcp-server-socket)) + #:key (cleanup? #f)) + (run-server* server-socket serve-client #:cleanup? cleanup?)) =20 ;; Note: although not exported, this is used by (system repl coop-server) =2D(define (run-server* server-socket serve-client) +(define* (run-server* server-socket serve-client #:key (cleanup? #f)) ;; We use a pipe to notify the server when it should shut down. (define shutdown-pipes (pipe)) (define shutdown-read-pipe (car shutdown-pipes)) @@ -122,19 +124,29 @@ (sigaction SIGPIPE SIG_IGN) (add-open-socket! server-socket shutdown-server) (listen server-socket 5) =2D (let lp () =2D (match (accept-new-client) =2D (#f =2D ;; If client is false, we are shutting down. =2D (close shutdown-write-pipe) =2D (close shutdown-read-pipe) =2D (close server-socket)) =2D ((client-socket . client-addr) =2D (make-thread serve-client client-socket client-addr) =2D (lp))))) =2D =2D(define* (spawn-server #:optional (server-socket (make-tcp-server-socket= ))) =2D (make-thread run-server server-socket)) + (dynamic-wind + (const #f) + (lambda () + (let lp () + (match (accept-new-client) + (#f + ;; If client is false, we are shutting down. + (close shutdown-write-pipe) + (close shutdown-read-pipe) + (close server-socket)) + ((client-socket . client-addr) + (make-thread serve-client client-socket client-addr) + (lp))))) + (lambda () + (and-let* (cleanup? + (sa (getsockname server-socket)) + (path (sockaddr:path sa)) + ((file-exists? path))) + (delete-file path))))) + +(define* (spawn-server #:optional (server-socket (make-tcp-server-socket)) + #:key (cleanup? #f)) + (make-thread run-server server-socket #:cleanup? cleanup?)) =20 (define (serve-client client addr) =20 =2D-=20 2.11.0 --=-=-=-- --==-=-= Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- iQIzBAEBCAAdFiEEUQqGKOKndniPjHCcS8Alkl/49NMFAljAXiEACgkQS8Alkl/4 9NNVtA//fqxYkzn5eKjZc+MSSjQOwQq1lG1d5qNcmJcWkd9bwqhnmzjeZ27VBWq6 GEPf7iGlGaYO/fUSMuPJdhXWtO5MBfHsLjoOSyX2x+5zN3YkDBNTm3pSkWJNOHSL 0OYxaQSPJLM7RCOKep4Wh8ge3edQsIWyp/Dtk+j+gqIHsEXxDyuCU4GTrZFVcusA PRu4hh7SQkSjbjpbq23cRbcXK7qaj3sxlPNnC8Dtfp/8uIP0kfB+KAWraYjJFstJ Qxeae16+b0l37fFqGplVqWvCBfdahHL/u/CtBJI6YaFxAcSPsZnPXx3t1CbKgOXO 5fw300b61oQpENEld6zdZm8YjucQX3ozkerTRSIfkkq2Y7E+sWQI+tAuCpkCP8rH YYsKnF+YI55RB8v1mk2TjQsf60hMAXk3U98SRhHKhWIb87Hikbro5dXJicBOlcDv ylijUou91SupgvJ1sZlrCcGa4yBUOBGbek3KDtPYaCJjwSTPDAA6roxzHPhsTj+l R9UCE9b78DFTRpJQZmSsE1jsoASgSi+oHPFuiMpiAAZ0FZgLyRbBdr/pkMsJ836g QWD3AUohgiFb5/yuQRCJO9D9dTjWR49AgJN5nBOQdFqB4RhTK2ufBHF7w5aTZEa1 XvxQPrhbz3wjVBqH+AZdnHbhBwe5mPZ7mrCbfycPj/XW62jn4Wk= =rV8H -----END PGP SIGNATURE----- --==-=-=--
GNU bug tracking system
Copyright (C) 1999 Darren O. Benham,
1997 nCipher Corporation Ltd,
1994-97 Ian Jackson.