Check if fd has been closed for sanity
parent
6bdd818b59
commit
c077a38649
|
@ -115,11 +115,11 @@ M: buffered-port dispose*
|
||||||
[ [ [ buffer-free ] when* f ] change-buffer drop ]
|
[ [ [ buffer-free ] when* f ] change-buffer drop ]
|
||||||
bi ;
|
bi ;
|
||||||
|
|
||||||
HOOK: cancel-io io-backend ( port -- )
|
GENERIC: cancel-io ( handle -- )
|
||||||
|
|
||||||
M: port timed-out cancel-io ;
|
M: port timed-out handle>> cancel-io ;
|
||||||
|
|
||||||
M: port dispose* [ cancel-io ] [ handle>> dispose ] bi ;
|
M: port dispose* handle>> [ cancel-io ] [ dispose ] bi ;
|
||||||
|
|
||||||
: <ports> ( read-handle write-handle -- input-port output-port )
|
: <ports> ( read-handle write-handle -- input-port output-port )
|
||||||
[
|
[
|
||||||
|
|
|
@ -25,7 +25,7 @@ TUPLE: fd fd disposed ;
|
||||||
|
|
||||||
M: fd dispose* fd>> close-file ;
|
M: fd dispose* fd>> close-file ;
|
||||||
|
|
||||||
M: fd handle-fd fd>> ;
|
M: fd handle-fd dup check-disposed fd>> ;
|
||||||
|
|
||||||
! I/O multiplexers
|
! I/O multiplexers
|
||||||
TUPLE: mx fd reads writes ;
|
TUPLE: mx fd reads writes ;
|
||||||
|
@ -62,11 +62,14 @@ GENERIC: wait-for-events ( ms mx -- )
|
||||||
: output-available ( fd mx -- )
|
: output-available ( fd mx -- )
|
||||||
remove-output-callbacks [ resume ] each ;
|
remove-output-callbacks [ resume ] each ;
|
||||||
|
|
||||||
M: unix cancel-io ( port -- )
|
M: fd cancel-io ( fd -- )
|
||||||
handle>> handle-fd mx get-global
|
dup disposed>> [ drop ] [
|
||||||
|
fd>>
|
||||||
|
mx get-global
|
||||||
[ remove-input-callbacks [ t swap resume-with ] each ]
|
[ remove-input-callbacks [ t swap resume-with ] each ]
|
||||||
[ remove-output-callbacks [ t swap resume-with ] each ]
|
[ remove-output-callbacks [ t swap resume-with ] each ]
|
||||||
2bi ;
|
2bi
|
||||||
|
] if ;
|
||||||
|
|
||||||
SYMBOL: +retry+ ! just try the operation again without blocking
|
SYMBOL: +retry+ ! just try the operation again without blocking
|
||||||
SYMBOL: +input+
|
SYMBOL: +input+
|
||||||
|
|
|
@ -64,6 +64,9 @@ M: ssl-handle drain
|
||||||
SSL_write
|
SSL_write
|
||||||
check-write-response ;
|
check-write-response ;
|
||||||
|
|
||||||
|
M: ssl-handle cancel-io
|
||||||
|
file>> cancel-io ;
|
||||||
|
|
||||||
! Client sockets
|
! Client sockets
|
||||||
: <ssl-socket> ( fd -- ssl )
|
: <ssl-socket> ( fd -- ssl )
|
||||||
[ fd>> BIO_NOCLOSE BIO_new_socket dup ssl-error ] keep <ssl-handle>
|
[ fd>> BIO_NOCLOSE BIO_new_socket dup ssl-error ] keep <ssl-handle>
|
||||||
|
|
|
@ -71,8 +71,8 @@ M: winnt add-completion ( win32-handle -- )
|
||||||
resume-callback t
|
resume-callback t
|
||||||
] if ;
|
] if ;
|
||||||
|
|
||||||
M: winnt cancel-io
|
M: win32-handle cancel-io
|
||||||
handle>> handle>> CancelIo drop ;
|
handle>> CancelIo drop ;
|
||||||
|
|
||||||
M: winnt io-multiplex ( ms -- )
|
M: winnt io-multiplex ( ms -- )
|
||||||
handle-overlapped [ 0 io-multiplex ] when ;
|
handle-overlapped [ 0 io-multiplex ] when ;
|
||||||
|
|
Loading…
Reference in New Issue