Check if the handle has been disposed. This can happen if we close one end of a duplex stream

db4
Slava Pestov 2008-07-08 15:50:12 -05:00
parent 26950d9830
commit 3b2f4d92d2
3 changed files with 7 additions and 3 deletions

View File

@ -125,7 +125,8 @@ M: fd refill
} cond ;
M: unix (wait-to-read) ( port -- )
dup dup handle>> refill dup
dup
dup handle>> dup check-disposed refill dup
[ dupd wait-for-port (wait-to-read) ] [ 2drop ] if ;
! Writers
@ -144,7 +145,9 @@ M: fd drain
} cond ;
M: unix (wait-to-write) ( port -- )
dup dup handle>> drain dup [ wait-for-port ] [ 2drop ] if ;
dup
dup handle>> dup check-disposed drain
dup [ wait-for-port ] [ 2drop ] if ;
M: unix io-multiplex ( ms/f -- )
mx get-global wait-for-events ;

View File

@ -61,6 +61,7 @@ C: <FileArgs> FileArgs
: make-FileArgs ( port -- <FileArgs> )
{
[ handle>> check-disposed ]
[ handle>> handle>> ]
[ buffer>> ]
[ buffer>> buffer-length ]

View File

@ -74,7 +74,7 @@ M: winnt add-completion ( win32-handle -- )
] if ;
M: win32-handle cancel-operation
handle>> CancelIo drop ;
[ check-disposed ] [ handle>> CancelIo drop ] bi ;
M: winnt io-multiplex ( ms -- )
handle-overlapped [ 0 io-multiplex ] when ;