From 38e3c9de0f3713208ca0b71fd58febf4b7770fba Mon Sep 17 00:00:00 2001 From: Tony Garnock-Jones Date: Wed, 27 Jan 2016 21:46:20 -0500 Subject: [PATCH] Avoid double-fin (!). --- tcp.rkt | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/tcp.rkt b/tcp.rkt index 1aa461d..d726f31 100644 --- a/tcp.rkt +++ b/tcp.rkt @@ -536,10 +536,13 @@ ;; ConnState -> Transition (define (close-outbound-stream s) + (define b (conn-state-outbound s)) (transition - (struct-copy conn-state s - [outbound (struct-copy buffer (buffer-push (conn-state-outbound s) #"!") ;; dummy FIN byte - [finished? #t])]) + (if (buffer-finished? b) + s + (struct-copy conn-state s + [outbound (struct-copy buffer (buffer-push b #"!") ;; dummy FIN byte + [finished? #t])])) '())) (define (state-vector-behavior e s)