diff --git a/extra/io/pipes/pipes-tests.factor b/extra/io/pipes/pipes-tests.factor index d1c2e54bb0..5ece6cfdf3 100755 --- a/extra/io/pipes/pipes-tests.factor +++ b/extra/io/pipes/pipes-tests.factor @@ -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 [ + [ in>> dispose ] + [ out>> "hi" over stream-write dispose ] + bi + ] curry ignore-errors + ] times +] unit-test diff --git a/extra/io/ports/ports.factor b/extra/io/ports/ports.factor index e3c873e9d0..d8a99f81b8 100755 --- a/extra/io/ports/ports.factor +++ b/extra/io/ports/ports.factor @@ -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 ; : ( read-handle write-handle -- input-port output-port ) [ diff --git a/extra/io/unix/backend/backend.factor b/extra/io/unix/backend/backend.factor index 723ce8b255..70e5c9dd39 100755 --- a/extra/io/unix/backend/backend.factor +++ b/extra/io/unix/backend/backend.factor @@ -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>> ; diff --git a/extra/io/windows/windows.factor b/extra/io/windows/windows.factor index 30b72f3e2f..295a6119cb 100755 --- a/extra/io/windows/windows.factor +++ b/extra/io/windows/windows.factor @@ -24,6 +24,9 @@ TUPLE: win32-file < win32-handle ptr ; : ( 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 -- )