From 7228fc0e82d14bb16592578d06527fee82924484 Mon Sep 17 00:00:00 2001 From: uid35759 Date: Wed, 4 Jul 2001 11:54:41 +0000 Subject: [PATCH] BIND-LISTEN-ACCEPT-LOOP: Close the socket when interrupted. --- scsh/network.scm | 26 ++++++++++++++++++-------- 1 file changed, 18 insertions(+), 8 deletions(-) diff --git a/scsh/network.scm b/scsh/network.scm index 7003ea5..e60a10f 100644 --- a/scsh/network.scm +++ b/scsh/network.scm @@ -86,14 +86,24 @@ (set-socket-option sock level/socket socket/reuse-address #t) (bind-socket sock addr) (listen-socket sock 5) - (let loop () - (with-errno-handler - ;; ECONNABORTED we just ignore - ((errno packet) ((errno/connaborted) (loop))) - (call-with-values - (lambda () (accept-connection sock)) - proc) - (loop))))) + (call-with-current-continuation + (lambda (exit) + (with-handler + (lambda (condition more) + (with-handler + (lambda (condition ignore) (more)) + (lambda () (close-socket sock))) + (exit 'interrupted)) + (lambda () + (let loop () + (with-errno-handler + ;; ECONNABORTED we just ignore + ((errno packet) + ((errno/connaborted) (loop))) + (call-with-values + (lambda () (accept-connection sock)) + proc) + (loop))))))))) ;;;-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=- ;;; Socket Record Structure