io: fix socket/fd port custodian registration

Register the port, not the file descriptor, especially since a TCP
connection can have ports that share a file descriptor. Also, I think
a weak reference in the custodian doesn't work as intended (visible
through finalization) if the file descriptor is referenced with a
callback that closes over the port.
This commit is contained in:
Matthew Flatt 2019-04-30 13:59:32 -06:00
parent cf08436e05
commit 11789ff8b0
2 changed files with 3 additions and 2 deletions

View File

@ -4,6 +4,7 @@
"../host/rktio.rkt"
"../security/main.rkt"
"../sandman/main.rkt"
"../format/main.rkt"
"port-number.rkt"
"address.rkt"
"error.rkt")

View File

@ -432,9 +432,9 @@
(define (register-fd-close custodian fd fd-refcount flush-handle port)
(unsafe-custodian-register custodian
fd
port
;; in atomic mode
(lambda (fd)
(lambda (port)
(when flush-handle
(plumber-flush-handle-remove! flush-handle))
(if (input-port? port)