Check if fd has been closed for sanity

db4
Slava Pestov 2008-05-20 18:52:11 -05:00
parent 6bdd818b59
commit c077a38649
4 changed files with 17 additions and 11 deletions

View File

@ -115,11 +115,11 @@ M: buffered-port dispose*
[ [ [ buffer-free ] when* f ] change-buffer drop ]
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 )
[

View File

@ -25,7 +25,7 @@ TUPLE: fd fd disposed ;
M: fd dispose* fd>> close-file ;
M: fd handle-fd fd>> ;
M: fd handle-fd dup check-disposed fd>> ;
! I/O multiplexers
TUPLE: mx fd reads writes ;
@ -62,11 +62,14 @@ GENERIC: wait-for-events ( ms mx -- )
: output-available ( fd mx -- )
remove-output-callbacks [ resume ] each ;
M: unix cancel-io ( port -- )
handle>> handle-fd mx get-global
[ remove-input-callbacks [ t swap resume-with ] each ]
[ remove-output-callbacks [ t swap resume-with ] each ]
2bi ;
M: fd cancel-io ( fd -- )
dup disposed>> [ drop ] [
fd>>
mx get-global
[ remove-input-callbacks [ t swap resume-with ] each ]
[ remove-output-callbacks [ t swap resume-with ] each ]
2bi
] if ;
SYMBOL: +retry+ ! just try the operation again without blocking
SYMBOL: +input+

View File

@ -64,6 +64,9 @@ M: ssl-handle drain
SSL_write
check-write-response ;
M: ssl-handle cancel-io
file>> cancel-io ;
! Client sockets
: <ssl-socket> ( fd -- ssl )
[ fd>> BIO_NOCLOSE BIO_new_socket dup ssl-error ] keep <ssl-handle>

View File

@ -71,8 +71,8 @@ M: winnt add-completion ( win32-handle -- )
resume-callback t
] if ;
M: winnt cancel-io
handle>> handle>> CancelIo drop ;
M: win32-handle cancel-io
handle>> CancelIo drop ;
M: winnt io-multiplex ( ms -- )
handle-overlapped [ 0 io-multiplex ] when ;