Fix resource leak if flush on close fails
parent
60e197448f
commit
39ee1a7e3f
extra/io
|
@ -1,6 +1,7 @@
|
|||
USING: io io.pipes io.streams.string io.encodings.utf8
|
||||
io.streams.duplex io.encodings io.timeouts namespaces
|
||||
continuations tools.test kernel calendar destructors ;
|
||||
continuations tools.test kernel calendar destructors
|
||||
accessors debugger math ;
|
||||
IN: io.pipes.tests
|
||||
|
||||
[ "Hello" ] [
|
||||
|
@ -31,3 +32,13 @@ IN: io.pipes.tests
|
|||
stream-readln
|
||||
] with-disposal
|
||||
] must-fail
|
||||
|
||||
[ ] [
|
||||
1000 [
|
||||
utf8 <pipe> [
|
||||
[ in>> dispose ]
|
||||
[ out>> "hi" over stream-write dispose ]
|
||||
bi
|
||||
] curry ignore-errors
|
||||
] times
|
||||
] unit-test
|
||||
|
|
|
@ -108,7 +108,9 @@ M: output-port stream-flush ( port -- )
|
|||
[ check-disposed ] [ port-flush ] bi ;
|
||||
|
||||
M: output-port dispose*
|
||||
[ port-flush ] [ call-next-method ] bi ;
|
||||
[
|
||||
[ handle>> &dispose drop ] [ port-flush ] bi
|
||||
] with-destructors ;
|
||||
|
||||
M: buffered-port dispose*
|
||||
[ call-next-method ]
|
||||
|
@ -119,7 +121,7 @@ GENERIC: cancel-io ( handle -- )
|
|||
|
||||
M: port timed-out handle>> cancel-io ;
|
||||
|
||||
M: port dispose* handle>> [ cancel-io ] [ dispose ] bi ;
|
||||
M: port dispose* handle>> dispose ;
|
||||
|
||||
: <ports> ( read-handle write-handle -- input-port output-port )
|
||||
[
|
||||
|
|
|
@ -23,7 +23,8 @@ TUPLE: fd fd disposed ;
|
|||
[ f fd boa ]
|
||||
tri ;
|
||||
|
||||
M: fd dispose* fd>> close-file ;
|
||||
M: fd dispose*
|
||||
[ cancel-io ] [ fd>> close-file ] bi ;
|
||||
|
||||
M: fd handle-fd dup check-disposed fd>> ;
|
||||
|
||||
|
|
|
@ -24,6 +24,9 @@ TUPLE: win32-file < win32-handle ptr ;
|
|||
: <win32-file> ( handle -- win32-file )
|
||||
win32-file new-win32-handle ;
|
||||
|
||||
M: win32-file dispose*
|
||||
[ cancel-io ] [ call-next-method ] bi ;
|
||||
|
||||
HOOK: CreateFile-flags io-backend ( DWORD -- DWORD )
|
||||
HOOK: FileArgs-overlapped io-backend ( port -- overlapped/f )
|
||||
HOOK: add-completion io-backend ( port -- )
|
||||
|
|
Loading…
Reference in New Issue