From: Christopher Allan Webber Date: Tue, 1 Dec 2015 15:36:08 +0000 (-0600) Subject: irc: shut down properly when the server does too X-Git-Tag: v0.1.0~26 X-Git-Url: https://jxself.org/git/?a=commitdiff_plain;h=eecf751958934a26ac6d17948392db21ee07a8e1;p=8sync.git irc: shut down properly when the server does too Formerly things would busyloop on irc disconnect; changed to prevent that situation. * 8sync/systems/irc.scm (make-basic-irc-handler): remove ports and don't break when the connection closes. --- diff --git a/8sync/systems/irc.scm b/8sync/systems/irc.scm index 1333c3c..80d4ce1 100755 --- a/8sync/systems/irc.scm +++ b/8sync/systems/irc.scm @@ -229,7 +229,9 @@ (define (reset-buffer) (set! buffer '())) (define (should-read-char socket) - (and (char-ready? socket) (not (eof-object? (peek-char socket))))) + (and (not (port-closed? socket)) + (char-ready? socket) + (not (eof-object? (peek-char socket))))) (define (irc-handler socket) (while (should-read-char socket) (set! buffer (cons (read-char socket) buffer)) @@ -243,7 +245,17 @@ socket ready-line username)))) - (_ #f)))) + (_ #f))) + ;; I need to shut things down on EOF object + (cond + ((port-closed? socket) + (display "port closed time\n") + (port-remove-request socket)) + ((and (char-ready? socket) + (eof-object? (peek-char socket))) + (display "port eof time\n") + (close socket) + (port-remove-request socket)))) irc-handler)) (define default-line-handler (make-handle-line))