Fix Linux monitors
parent
0fc4c99eb1
commit
f25c2e80f9
|
@ -7,7 +7,7 @@ splitting math.parser classes.tuple continuations
|
||||||
continuations.private combinators generic.math
|
continuations.private combinators generic.math
|
||||||
classes.builtin classes compiler.units generic.standard vocabs
|
classes.builtin classes compiler.units generic.standard vocabs
|
||||||
threads threads.private init kernel.private libc io.encodings
|
threads threads.private init kernel.private libc io.encodings
|
||||||
mirrors accessors math.order ;
|
mirrors accessors math.order destructors ;
|
||||||
IN: debugger
|
IN: debugger
|
||||||
|
|
||||||
GENERIC: error. ( error -- )
|
GENERIC: error. ( error -- )
|
||||||
|
@ -300,6 +300,8 @@ M: bad-create summary drop "Bad parameters to create" ;
|
||||||
|
|
||||||
M: attempt-all-error summary drop "Nothing to attempt" ;
|
M: attempt-all-error summary drop "Nothing to attempt" ;
|
||||||
|
|
||||||
|
M: already-disposed summary drop "Attempting to operate on disposed object" ;
|
||||||
|
|
||||||
<PRIVATE
|
<PRIVATE
|
||||||
|
|
||||||
: init-debugger ( -- )
|
: init-debugger ( -- )
|
||||||
|
|
|
@ -89,5 +89,6 @@ os { winnt linux macosx } member? [
|
||||||
] with-monitors
|
] with-monitors
|
||||||
|
|
||||||
! Out-of-scope disposal should not fail
|
! Out-of-scope disposal should not fail
|
||||||
[ "" resource-path t <monitor> ] with-monitors dispose
|
[ ] [ [ "" resource-path f <monitor> ] with-monitors dispose ] unit-test
|
||||||
|
[ ] [ [ "" resource-path t <monitor> ] with-monitors dispose ] unit-test
|
||||||
] when
|
] when
|
||||||
|
|
|
@ -5,7 +5,7 @@ io.files io.buffers io.monitors io.ports io.timeouts
|
||||||
io.unix.backend io.unix.select io.encodings.utf8
|
io.unix.backend io.unix.select io.encodings.utf8
|
||||||
unix.linux.inotify assocs namespaces threads continuations init
|
unix.linux.inotify assocs namespaces threads continuations init
|
||||||
math math.bitfields sets alien alien.strings alien.c-types
|
math math.bitfields sets alien alien.strings alien.c-types
|
||||||
vocabs.loader accessors system hashtables ;
|
vocabs.loader accessors system hashtables destructors ;
|
||||||
IN: io.unix.linux.monitors
|
IN: io.unix.linux.monitors
|
||||||
|
|
||||||
SYMBOL: watches
|
SYMBOL: watches
|
||||||
|
@ -23,9 +23,9 @@ TUPLE: linux-monitor < monitor wd inotify watches disposed ;
|
||||||
: wd>monitor ( wd -- monitor ) watches get at ;
|
: wd>monitor ( wd -- monitor ) watches get at ;
|
||||||
|
|
||||||
: <inotify> ( -- port/f )
|
: <inotify> ( -- port/f )
|
||||||
inotify_init dup 0 < [ drop f ] [ <input-port> ] if ;
|
inotify_init dup 0 < [ drop f ] [ <fd> <input-port> ] if ;
|
||||||
|
|
||||||
: inotify-fd inotify get handle>> ;
|
: inotify-fd inotify get handle>> handle-fd ;
|
||||||
|
|
||||||
: check-existing ( wd -- )
|
: check-existing ( wd -- )
|
||||||
watches get key? [
|
watches get key? [
|
||||||
|
@ -57,8 +57,10 @@ M: linux (monitor) ( path recursive? mailbox -- monitor )
|
||||||
M: linux-monitor dispose* ( monitor -- )
|
M: linux-monitor dispose* ( monitor -- )
|
||||||
[ [ wd>> ] [ watches>> ] bi delete-at ]
|
[ [ wd>> ] [ watches>> ] bi delete-at ]
|
||||||
[
|
[
|
||||||
[ inotify>> handle>> ] [ wd>> ] bi
|
dup inotify>> disposed>> [ drop ] [
|
||||||
|
[ inotify>> handle>> handle-fd ] [ wd>> ] bi
|
||||||
inotify_rm_watch io-error
|
inotify_rm_watch io-error
|
||||||
|
] if
|
||||||
] bi ;
|
] bi ;
|
||||||
|
|
||||||
: ignore-flags? ( mask -- ? )
|
: ignore-flags? ( mask -- ? )
|
||||||
|
@ -108,6 +110,7 @@ M: linux-monitor dispose* ( monitor -- )
|
||||||
] if ;
|
] if ;
|
||||||
|
|
||||||
: inotify-read-loop ( port -- )
|
: inotify-read-loop ( port -- )
|
||||||
|
dup check-disposed
|
||||||
dup wait-to-read
|
dup wait-to-read
|
||||||
0 over buffer>> parse-file-notifications
|
0 over buffer>> parse-file-notifications
|
||||||
0 over buffer>> buffer-reset
|
0 over buffer>> buffer-reset
|
||||||
|
|
Loading…
Reference in New Issue