io: exn:fail:network for TCP-port errors
This commit is contained in:
parent
6a7f9773d1
commit
62a674fa80
|
@ -21,10 +21,12 @@
|
|||
(if (input-port? port)
|
||||
(lambda (fd name)
|
||||
(open-input-fd fd name
|
||||
#:extra-data (tcp-data #f #t)))
|
||||
#:extra-data (tcp-data #f #t)
|
||||
#:network-error? #t))
|
||||
(lambda (fd name)
|
||||
(open-output-fd fd name
|
||||
#:extra-data (tcp-data #t #f))))))
|
||||
#:extra-data (tcp-data #t #f)
|
||||
#:network-error? #t)))))
|
||||
|
||||
(define (open-input-output-tcp fd name #:close? [close? #t])
|
||||
(define refcount (box (if close? 2 3)))
|
||||
|
@ -37,7 +39,8 @@
|
|||
(lambda ()
|
||||
(unless (tcp-data-abandon-in? extra-data)
|
||||
(rktio_socket_shutdown rktio fd RKTIO_SHUTDOWN_READ)))
|
||||
#:fd-refcount refcount)
|
||||
#:fd-refcount refcount
|
||||
#:network-error? #t)
|
||||
(open-output-fd fd name
|
||||
#:extra-data extra-data
|
||||
#:on-close
|
||||
|
@ -46,7 +49,8 @@
|
|||
(unless (tcp-data-abandon-out? extra-data)
|
||||
(rktio_socket_shutdown rktio fd RKTIO_SHUTDOWN_WRITE)))
|
||||
#:fd-refcount refcount
|
||||
#:buffer-mode 'block)))
|
||||
#:buffer-mode 'block
|
||||
#:network-error? #t)))
|
||||
|
||||
(define (port-tcp-data p)
|
||||
(maybe-fd-data-extra
|
||||
|
|
|
@ -5,6 +5,7 @@
|
|||
"../host/pthread.rkt"
|
||||
"../sandman/main.rkt"
|
||||
"../file/error.rkt"
|
||||
"../network/error.rkt"
|
||||
"port.rkt"
|
||||
"input-port.rkt"
|
||||
"output-port.rkt"
|
||||
|
@ -57,7 +58,8 @@
|
|||
#:extra-data [extra-data #f]
|
||||
#:on-close [on-close void]
|
||||
#:fd-refcount [fd-refcount (box 1)]
|
||||
#:custodian [cust (current-custodian)])
|
||||
#:custodian [cust (current-custodian)]
|
||||
#:network-error? [network-error? #f])
|
||||
(define-values (port buffer-control)
|
||||
(open-input-peek-via-read
|
||||
#:name name
|
||||
|
@ -69,7 +71,9 @@
|
|||
(cond
|
||||
[(rktio-error? n)
|
||||
(end-atomic)
|
||||
(raise-filesystem-error #f n "error reading from stream port")]
|
||||
(if network-error?
|
||||
(raise-network-error #f n "error reading from stream port")
|
||||
(raise-filesystem-error #f n "error reading from stream port"))]
|
||||
[(eqv? n RKTIO_READ_EOF) eof]
|
||||
[(eqv? n 0) (wrap-evt (fd-evt fd RKTIO_POLL_READ (core-port-closed port))
|
||||
(lambda (v) 0))]
|
||||
|
@ -100,7 +104,8 @@
|
|||
#:fd-refcount [fd-refcount (box 1)]
|
||||
#:on-close [on-close void]
|
||||
#:plumber [plumber (current-plumber)]
|
||||
#:custodian [cust (current-custodian)])
|
||||
#:custodian [cust (current-custodian)]
|
||||
#:network-error? [network-error? #f])
|
||||
(define buffer (make-bytes 4096))
|
||||
(define buffer-start 0)
|
||||
(define buffer-end 0)
|
||||
|
@ -126,7 +131,9 @@
|
|||
(cond
|
||||
[(rktio-error? n)
|
||||
(end-atomic)
|
||||
(raise-filesystem-error #f n "error writing to stream port")]
|
||||
(if network-error?
|
||||
(raise-network-error #f n "error writing to stream port")
|
||||
(raise-filesystem-error #f n "error writing to stream port"))]
|
||||
[(zero? n)
|
||||
#f]
|
||||
[else
|
||||
|
@ -194,7 +201,9 @@
|
|||
(cond
|
||||
[(rktio-error? n)
|
||||
(end-atomic)
|
||||
(raise-filesystem-error #f n "error writing to stream port")]
|
||||
(if network-error?
|
||||
(raise-network-error #f n "error writing to stream port")
|
||||
(raise-filesystem-error #f n "error writing to stream port"))]
|
||||
[(zero? n) (wrap-evt evt (lambda (v) #f))]
|
||||
[else n])]))
|
||||
|
||||
|
|
Loading…
Reference in New Issue
Block a user