From 3d0d2c38e9534403e80398a10eed069b2f982575 Mon Sep 17 00:00:00 2001 From: Tony Garnock-Jones Date: Wed, 26 Oct 2011 19:14:45 -0400 Subject: [PATCH] Be less gratuitously noisy on socket close. --- ssh-session.rkt | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) diff --git a/ssh-session.rkt b/ssh-session.rkt index 79325bd..26a8a3c 100644 --- a/ssh-session.rkt +++ b/ssh-session.rkt @@ -769,10 +769,13 @@ ((arrived _) conn) ((and departure (departed who why)) - (disconnect-with-error/local-info - departure - SSH_DISCONNECT_CONNECTION_LOST - "I/O error")) + (if (zero? (hash-count (connection-channel-map conn))) + ;; No open or half-open channels. No point in complaining; just leave. + #f + ;; At least one channel. Make more of a noise. + (disconnect-with-error/local-info departure + SSH_DISCONNECT_CONNECTION_LOST + "I/O error"))) ((says _ amount 'output-byte-count) ;; writer reporting bytes transferred (bump-total amount conn)) @@ -854,7 +857,11 @@ (handle-evt (send (connection-session-room-handle conn) listen-evt) session-room-message-handler) (channel-events conn)))) - (loop (handler conn))))))) + (define new-conn (handler conn)) + ;; The handler is permitted to return #f to indicate that the session is to be + ;; gracefully shut down. + (when new-conn + (loop new-conn))))))) ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;; Session choreography