io.monitors.windows: ADS pathnames crashing the monitors threads is the

real culprit. Back out change and print out the crash and error message instead of ignoring
errors!
db4
Doug Coleman 2015-11-02 21:19:12 -08:00
parent 51ecaa5ab4
commit acdd529983
2 changed files with 17 additions and 21 deletions

View File

@ -1,13 +1,11 @@
! Copyright (C) 2008 Doug Coleman, Slava Pestov. ! Copyright (C) 2008 Doug Coleman, Slava Pestov.
! See http://factorcode.org/license.txt for BSD license. ! See http://factorcode.org/license.txt for BSD license.
USING: alien alien.c-types alien.data alien.strings libc destructors USING: accessors alien alien.data arrays classes.struct
locals kernel math assocs namespaces make continuations sequences combinators continuations destructors io.backend
hashtables sorting arrays combinators math.bitwise strings io.encodings.string io.encodings.utf16n io.files.windows
system accessors threads splitting io.backend io.monitors io.pathnames io.ports kernel literals locals make
io.files.windows io.monitors io.ports math sequences system threads windows.errors windows.kernel32
io.buffers io.files io.timeouts io.encodings.string literals windows.types ;
io.encodings.utf16n io windows.errors windows.kernel32 windows.types
io.pathnames classes.struct ;
IN: io.monitors.windows IN: io.monitors.windows
: open-directory ( path -- handle ) : open-directory ( path -- handle )
@ -54,14 +52,9 @@ TUPLE: win32-monitor < monitor port ;
: memory>u16-string ( alien len -- string ) : memory>u16-string ( alien len -- string )
memory>byte-array utf16n decode ; memory>byte-array utf16n decode ;
! Files on an NTFS downloaded from the internet may contain an
! ADS (alternate data stream) such as foo.txt:Zone.Identifier
! which the win32 API reports as the filename. We wish to strip this off
! and instead work on the actual file contents instead of ADS data.
: parse-notify-record ( buffer -- path changed ) : parse-notify-record ( buffer -- path changed )
[ [
[ FileName>> ] [ FileNameLength>> ] bi [ FileName>> ] [ FileNameLength>> ] bi memory>u16-string
memory>u16-string ":Zone.Identifier" ?tail drop
] [ Action>> parse-action ] bi ; ] [ Action>> parse-action ] bi ;
: (file-notify-records) ( buffer -- buffer ) : (file-notify-records) ( buffer -- buffer )

View File

@ -1,10 +1,9 @@
! Copyright (C) 2008, 2010 Slava Pestov. ! Copyright (C) 2008, 2010 Slava Pestov.
! See http://factorcode.org/license.txt for BSD license. ! See http://factorcode.org/license.txt for BSD license.
USING: accessors assocs command-line concurrency.messaging USING: accessors command-line continuations fry init io
continuations init io.backend io.files io.monitors io.pathnames io.backend io.files io.monitors io.pathnames kernel namespaces
kernel libc namespaces sequences sets splitting threads fry prettyprint sequences splitting threads tr vocabs vocabs.cache
tr vocabs vocabs.loader vocabs.refresh vocabs.cache vocabs.loader vocabs.refresh ;
io.files.links ;
IN: vocabs.refresh.monitor IN: vocabs.refresh.monitor
TR: convert-separators "/\\" ".." ; TR: convert-separators "/\\" ".." ;
@ -43,8 +42,12 @@ TR: convert-separators "/\\" ".." ;
[ [ t <monitor> monitor-loop ] with-monitors ] [ drop ] if ; [ [ t <monitor> monitor-loop ] with-monitors ] [ drop ] if ;
: start-vocab-monitor ( vocab-root -- ) : start-vocab-monitor ( vocab-root -- )
[ '[ [ _ (start-vocab-monitor) ] ignore-errors ] ] [
[ "Root monitor: " prepend ] dup '[
[ _ (start-vocab-monitor) ]
[ [ _ "fatal error for monitor root ``" "``: " surround write . flush ] with-global ] recover
]
] [ "Root monitor: " prepend ]
bi spawn drop ; bi spawn drop ;
: init-vocab-monitor ( -- ) : init-vocab-monitor ( -- )