cs: remove plumber flush callback when custodian closes fd output port

Previously, the following program would print "error writing to
stream port" on program exit.

  (define cust (make-custodian))
  (define out
    (parameterize ((current-custodian cust))
      (open-output-file "test.data" #:exists 'truncate)))
  (write-string "This needs flushing...\n" out)
  (custodian-shutdown-all cust)
  (exit 0)
This commit is contained in:
Ryan Culpepper 2018-10-23 18:15:58 +02:00
parent ddba2812ba
commit e8832fbcc7

View File

@ -87,7 +87,7 @@
[() (buffer-control)]
[(pos) (buffer-control pos)]))))
(define custodian-reference
(register-fd-close cust fd fd-refcount port))
(register-fd-close cust fd fd-refcount #f port))
port)
;; ----------------------------------------
@ -230,7 +230,7 @@
[(mode) (set! buffer-mode mode)])))
(define custodian-reference
(register-fd-close cust fd fd-refcount port))
(register-fd-close cust fd fd-refcount flush-handle port))
(set-fd-evt-closed! evt (core-port-closed port))
@ -331,12 +331,14 @@
;; ----------------------------------------
(define (register-fd-close custodian fd fd-refcount port)
(define (register-fd-close custodian fd fd-refcount flush-handle port)
(define closed (core-port-closed port))
(unsafe-custodian-register custodian
fd
;; in atomic mode
(lambda (fd)
(when flush-handle
(plumber-flush-handle-remove! flush-handle))
(fd-close fd fd-refcount)
(set-closed-state! closed))
#f