Commit Graph

68 Commits

Author SHA1 Message Date
Refael Ackermann
37da57b695
win,test: de-flake fs_event_watch_dir_short_path
New versions of Windows ship with 8.3 short-names disabled.
This commit adds 8.3 detection logic in the
fs_event_watch_dir_short_path test.

PR-URL: https://github.com/libuv/libuv/pull/2103
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
Reviewed-By: Bartosz Sosnowski <bartosz@janeasystems.com>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
2019-01-15 10:25:18 -05:00
Jameson Nash
2d2af382ce fsevents: really watch files with fsevents on macos 10.7+
In the original PR, the ifdef conditional was reversed,
leading to the old code-path still being used.
This also reduces some of the redundancy in the conditional checks,
by factoring out the common test.
And fixes a divergence in functionality kFSEventsRenamed =>
kFSEventStreamEventFlagItemRenamed
And actually includes the part of the original PR to kqueue that enabled
watching files with fsevents!

Fixes: https://github.com/libuv/libuv/pull/387
PR-URL: https://github.com/libuv/libuv/pull/2082
Refs: https://github.com/libuv/libuv/pull/1572
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
2019-01-04 13:14:10 -05:00
Nikolai Vavilov
7e865b680a win: use long directory name for handle->dirw
`uv_relative_path` assumes `dir` is a prefix of `filename`, which is not
the case when `handle->dirw` is a short path.

Refs: https://github.com/nodejs/node/issues/19170
PR-URL: https://github.com/libuv/libuv/pull/1769
Reviewed-By: Bartosz Sosnowski <bartosz@janeasystems.com>
2018-03-19 10:20:56 +01:00
cjihrig
974a5bf30e
test: fix incorrect asserts
This commit fixes two assertions of the form
(events == UV_CHANGE || UV_RENAME) which always passed because
UV_RENAME is 1.

Refs: https://github.com/libuv/help/issues/41
PR-URL: https://github.com/libuv/libuv/pull/1722
Reviewed-By: Santiago Gimeno <santiago.gimeno@gmail.com>
Reviewed-By: Saúl Ibarra Corretgé <saghul@gmail.com>
2018-01-22 09:49:28 -05:00
John Barboza
b01de7341f
zos: implement uv_fs_event* functions
This commit uses the Register File Interest feature on z/OS
to enable users to monitor file system events.
The poll call is used to check for file descriptors as well
as a message queue that z/OS will report file system events
on. The last item on the list used by poll will contain the
message queue id instead of a file descriptor.

Limitation:
Writes to a directory (that is, file creation and deletion)
do not generate a change message for a registered directory.

PR-URL: https://github.com/libuv/libuv/pull/1311
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
2017-12-15 11:04:16 +01:00
Brad King
f4f1f57e7c test: factor out fsevents skip explanation
Factor out a dedicated test macro for use on platforms that
do not support fsevents instead of duplicating the os390
platform condition and explanation text.

PR-URL: https://github.com/libuv/libuv/pull/1312
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
Reviewed-By: Santiago Gimeno <santiago.gimeno@gmail.com>
2017-05-21 16:12:08 +02:00
John Barboza
cb0cc7346d
zos: implement uv__io_fork, skip fs event tests
Basic implementation of uv__io_fork on z/OS.
As of now, since filesystem events are not supported,
skip all of those tests on z/OS.

PR-URL: https://github.com/libuv/libuv/pull/1303
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
2017-05-03 11:58:16 +02:00
cjihrig
463800ffc1 win,sunos: stop handle on uv_fs_event_start() err
This commit stops the handle in uv_fs_event_start() when an
error occurs.

Fixes: https://github.com/libuv/libuv/issues/1253
PR-URL: https://github.com/libuv/libuv/pull/1257
Reviewed-By: Santiago Gimeno <santiago.gimeno@gmail.com>
2017-03-21 10:35:53 -04:00
Bartosz Sosnowski
468d44620a win, test: fix fs_event_watch_dir_recursive
Under Windows uv_fs_event_start with UV_FS_EVENT_RECURSIVE will report new file
creation and file deletion twice - once with the name of the file, and second
time with the name of the directory itself. This will filter out callbacks with
directory name, making observed callbacks count match expected values.

Fixes: https://github.com/libuv/libuv/issues/1009
PR-URL: https://github.com/libuv/libuv/pull/1061
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Saúl Ibarra Corretgé <saghul@gmail.com>
2016-09-20 00:14:36 +02:00
Santiago Gimeno
29138058a5 test: fix fs_event_watch_dir flakiness on arm
Increase the time between file creations, so all the events are
emitted.

PR-URL: https://github.com/libuv/libuv/pull/1038
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
Reviewed-By: Saúl Ibarra Corretgé <saghul@gmail.com>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
2016-09-12 08:33:44 +02:00
Julien Gilli
ad20b96a8f test: refactor fs_event_close_in_callback
This change refactors the `fs_event_close_in_callback` test so that:

1. It creates directory entries instead of modifying them. This allows
the test to work on operating systems that use event ports to handle fs
events (e.g SmartOS and Solaris). When using event ports, watching
only a directory does not allow to receive events for files modified
within that directory, but events will be received for files _created_
within that directory.

2. it generates fs events _after_ the process entered the libuv event
loop. This is also needed to make the test work on operating systems
that use event ports to handle fs events (e.g SmartOS and Solaris),
because events are polled as part of running the event loop. That also
makes the test work on systems based on Kqueue and on AIX.

Fixes: https://github.com/libuv/libuv/pull/808
PR-URL: https://github.com/libuv/libuv/pull/1011
Reviewed-By: Saúl Ibarra Corretgé <saghul@gmail.com>
2016-08-25 10:12:49 +01:00
Jeffrey Clark
0a4b51fcb4 build: GNU/kFreeBSD support
autotools support only, gvp does not support kfreebsd detection.

PR-URL: https://github.com/libuv/libuv/pull/960
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
Reviewed-By: Saúl Ibarra Corretgé <saghul@gmail.com>
2016-08-20 08:55:30 +02:00
John Barboza
1cff5b7557 zos: add support for new platform
- zos: disable test cases not applicable
- zos: build options
- zos: semaphore implementation
- zos: use compare and swap builtins
- zos: struct rusage not the same as other platforms
- zos: backlog<=0 produces undefined behaviour
    Will redefine backlog in the following way
    * if backlog == 0, set it to 1
    * if backlog < 0, set it to SOMAXCONN
- zos: define IMAXBEL as empty flag and implement uv__tty_make_raw
- zos: use udp multicast operations from aix
- zos: ESC in ebcdic
- zos: use LIBPATH for dynamic linker path
- zos: uv_udp_set_ttl only works for ipv6
- zos: increase pthread stack size by factor of 4
- zos: return ENODEV instead of ENXIO errors for setsockopt
- zos: use uv_cond_init the same way as aix
- test: enable oob test for zos
- zos: return EINVAL for zos error code EOPNOTSUPP

PR-URL: https://github.com/libuv/libuv/pull/937
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
Reviewed-By: Saúl Ibarra Corretgé <saghul@gmail.com>
2016-08-19 01:34:29 +02:00
cjihrig
77c8abae33 win: compare entire filename in watch events
This commit causes Window file watching events to compare the
entire file path when filtering events. This fixes a bug where
incomplete path comparisons would cause invalid events to be
raised.

Refs: https://github.com/libuv/libuv/pull/682
PR-URL: https://github.com/libuv/libuv/pull/924
Reviewed-By: Saúl Ibarra Corretgé <saghul@gmail.com>
2016-06-24 10:36:04 -04:00
Imran Iqbal
faea76d81d test: skip fs_event_close_in_callback on AIX
The file descriptor that you receive from ahafs has to be part of the
pollset_poll set of interest in order to receive events. This does not
happen until we are in the event loop causing the test to hang and
therefore timeout.

PR-URL: https://github.com/libuv/libuv/pull/838
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
2016-04-20 12:23:17 +02:00
Imran Iqbal
f28a11229f test: fix fs_event_watch_file_current_dir for AIX
PR-URL: https://github.com/libuv/libuv/pull/828
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
2016-04-13 11:39:00 +02:00
Saúl Ibarra Corretgé
e5f4b79809 unix, win: consistently null-terminate buffers
libuv has multiple functions which return buffers. Make them consistent
with the following rules: the returned size *does not* include the null
byte, but the buffer *is* null terminated.

There is only one exception to the above: Linux abstract sockets,
because null bytes are not used as string terminators in those.

Refs: https://github.com/libuv/libuv/pull/674
PR-URL: https://github.com/libuv/libuv/pull/690
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
2016-03-03 09:20:41 +01:00
Saúl Ibarra Corretgé
51c1a28d7e test,win: fix compilation warning
PR-URL: https://github.com/libuv/libuv/pull/700
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
2016-02-01 09:07:52 +01:00
Nikolai Vavilov
3c59ad6d95 win: fix watching root files
When passing "\\?\C:" to CreateFile, it opens the drive rather than the root
directory. So include the trailing backslash in the directory name.

Fixes: https://github.com/nodejs/node/issues/4643
PR-URL: https://github.com/libuv/libuv/pull/689
Reviewed-By: Saúl Ibarra Corretgé <saghul@gmail.com>
2016-01-26 09:58:49 +01:00
Joran Dirk Greef
e0250b7d5c win: fix path for removed and renamed fs events
Previous behavior on Windows was to set the path to NULL for removed
and renamed fs events. This was because the path provided by
ReadDirectoryChangesW might (in rare cases) be an 8.3 short name which
could then no longer be converted to a long name after the path had
been removed or renamed. This meant that the user had to detect which
path was actually deleted or renamed and required the user to rescan
the entire watched subtree, taking several seconds or more for large
subtrees.

However, ReadDirectoryChangesW is publicly documented to emit 8.3
short names if the original handle for the changed path was opened
using an 8.3 short name, and libuv may already emit 8.3 short names for
other events if the path cannot be explicitly resolved to a long name.

This commit fixes the path for removed and renamed fs events, and does
not set the path to NULL, even if the path might be an 8.3 short name.
This makes it possible for the user to do a partial scan of the
subtree, restricting the scan to paths which match the long form or 8.3
short name (even if some of these are false positive matches). This
means that deletes and renames can now be detected accurately on
Windows within a few milliseconds.

Fixes: https://github.com/libuv/libuv/issues/634
Refs: https://github.com/libuv/libuv/pull/199
PR-URL: https://github.com/libuv/libuv/pull/639
Reviewed-By: Saúl Ibarra Corretgé <saghul@gmail.com>
2015-12-07 16:16:46 +01:00
Santiago Gimeno
a0e30b551c test: fix fs_event_watch_file_currentdir flakiness
In FreeBSD 10.2 the test sometimes times out because the "touch file"
timer fires before the "watch file" event has been registered in the
kqueue. Increasing the timeout value seems to fix the issue.

PR-URL: https://github.com/libuv/libuv/pull/581
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
2015-10-21 00:19:18 +02:00
Jeremy Whitlock
83264701a7 tests: refactored fs watch_dir tests for stability
fs_event_watch_dir and fs_event_watch_dir_recursive could fail randomly
due to the way in which the tests were written.  Originally timers were
used to create, remove and recreate the test files but this could lead
to a race condition if the timeout used to delete the test files ran
before all file creation fs events were handled.  On top of that, the
file removal timer scheduled another timer to recreate the test files
and that timer's timeout could also lead to the same condition.

The refactoring removed timers for the removal/recreation of the test
files and instead the fs event callback was updated to have the
necessary logic to drive the test file removal.  We no longer recreate
the test files since it appears to be unnecessary.

Fixes: https://github.com/libuv/libuv/issues/30
PR-URL: https://github.com/libuv/libuv/pull/480
Reviewed-By: Saúl Ibarra Corretgé <saghul@gmail.com>
2015-08-19 22:13:51 +02:00
Ben Noordhuis
df62b54aa2 unix,windows: allow NULL loop for sync fs requests
Synchronous file operations don't need an event loop.  Permit NULL as
the event loop parameter.

Fixes: https://github.com/libuv/libuv/issues/469
PR-URL: https://github.com/libuv/libuv/pull/479
Reviewed-By: Saúl Ibarra Corretgé <saghul@gmail.com>
2015-08-18 15:39:21 +02:00
Santiago Gimeno
e18848059f test: fix compilation warning
file_prefix_in_subdir is only used in Windows and OSX. Fixes the
following warning, which shows up with Clang:

test/test-fs-event.c:40:19: warning: unused variable
'file_prefix_in_subdir' [-Wunused-const-variable]
static const char file_prefix_in_subdir[] = "subdir";

PR-URL: https://github.com/libuv/libuv/pull/450
Reviewed-By: Saúl Ibarra Corretgé <saghul@gmail.com>
2015-07-28 09:49:56 +02:00
Saúl Ibarra Corretgé
085b877ccb test: fix compilation warning
fs_event_cb_dir_multi_file_in_subdir is only used in
fs_event_watch_dir_recursive test, which is only compiled in OSX and Windows.
2015-07-15 19:34:46 +02:00
Saúl Ibarra Corretgé
188e0e94ac win: add support for recursive file watching
Original patch by @ghostoy, modified by @bpasero and yours truly.

Refs: https://github.com/joyent/libuv/pull/1473
Refs: https://github.com/libuv/libuv/pull/198
PR-URL: https://github.com/libuv/libuv/pull/421
Reviewed-By: Bert Belder <bertbelder@gmail.com>
2015-07-08 23:40:47 +02:00
Andrius Bentkus
1e59ab1d49 fs, pipe: no trailing terminator in exact sized buffers
uv_fs_poll_getpath, uv_pipe_getsockname, uv_fs_event_getpath used
to return the trailing null terminator, even though the functions
returned the size.

Fixes: https://github.com/libuv/libuv/issues/155
PR-URL: https://github.com/libuv/libuv/pull/159
Reviewed-By: Saúl Ibarra Corretgé <saghul@gmail.com>
2015-01-27 11:31:16 +01:00
Saúl Ibarra Corretgé
db2a9072bc unix, windows: removed unused status parameter
async, timer, prepare, idle and check handles don't need the status
parameter.
2014-03-17 21:42:36 +01:00
Saúl Ibarra Corretgé
a7ac2c462a unix, windows: add uv_fs_event_getpath 2014-02-24 22:08:23 +01:00
Benjamin Saunders
13dd3502a7 fs: vectored IO API for filesystem read/write
This improves API consistency with uv_read and uv_write and may
improve efficiency for some uses. Vectored IO is emulated when the
requisite system calls are unavailable.
2014-02-23 17:24:05 +01:00
Saúl Ibarra Corretgé
787f5fff92 unix, windows: add uv_loop_init and uv_loop_close
These functions supersede uv_loop_new and uv_loop_delete.
uv_loop_init initialized a user allocated loop and uv_loop_close
removes all associated resources a loop uses after it has finished
execution.

uv_loop_new and uv_loop_delete are now deprecated.
2014-02-21 09:56:13 +01:00
Fedor Indutny
a03ea239db Revert "fs: vectored IO API for filesystem read/write"
This reverts commit 7df24583e5.
2014-02-18 21:48:13 +04:00
Benjamin Saunders
7df24583e5 fs: vectored IO API for filesystem read/write
This improves API consistency with uv_read and uv_write and may
improve efficiency for some uses. Vectored IO is emulated when the
requisite system calls are unavailable.
2014-02-18 12:30:20 +04:00
Fedor Indutny
86b5c1ef1c test: test fsevents error reporting
Create a lot of `FSEventStream`s to make `FSEventStreamStart()` fail.
Fetch the error code and verify that it is correct.
2013-11-13 18:18:56 +04:00
Fedor Indutny
0f5c28b684 fsevents: use FlagNoDefer for FSEventStreamCreate
Otherwise `FSEventStreamCreate()` will coalesce events, even if they're
happening in the interval, bigger than supplied `latency`. In other
words, if this flag is not set events will happen in separate callback
only if there was a delay bigger than `latency` between two consecutive
events.
2013-11-10 13:05:27 +04:00
Saúl Ibarra Corretgé
9d44d786ad unix, windows: add uv_fs_event_start/stop functions
Make uv_fs_event behave like other handles, that is, it's inactive after
init, and it's active between start and stop.
2013-10-12 20:37:05 +02:00
Fedor Indutny
429bb804ed fsevents: fix clever rescheduling
There're could be a situation, where one fsevents handle gets created
and another one is destroyed simultaneously. In such cases
`fsevent_need_reschedule` will be set to 1 twice and reset only once,
leaving handle destructor hanging in uv_sem_wait().
2013-10-05 22:18:06 +04:00
Ben Noordhuis
3ee4d3f183 unix, windows: return error codes directly
This commit changes the libuv API to return error codes directly rather
than storing them in a loop-global field.

A code snippet like this one:

    if (uv_foo(loop) < 0) {
      uv_err_t err = uv_last_error(loop);
      fprintf(stderr, "%s\n", uv_strerror(err));
    }

Should be rewritten like this:

    int err = uv_foo(loop);
    if (err < 0)
      fprintf(stderr, "%s\n", uv_strerror(err));

The rationale for this change is that it should make creating bindings
for other languages a lot easier: dealing with struct return values is
painful with most FFIs and often downright buggy.
2013-07-07 09:51:00 +02:00
Ben Noordhuis
ede83188f3 test: don't use S_IREAD and S_IWRITE
They're BSD-isms and obsolete ones at that. Replace with S_IRUSR and
S_IWUSR. Alias as _S_IREAD and _S_IWRITE on Windows because the '90s
never ended in Redmond, WA.
2013-05-31 12:50:19 +02:00
Ben Noordhuis
4ba03ddd56 unix, windows: rename uv_run2 to uv_run
This changes the prototype of uv_run() from:

  int uv_run(uv_loop_t* loop);

To:

  int uv_run(uv_loop_t* loop, uv_run_mode mode);

Where `mode` is UV_RUN_DEFAULT, UV_RUN_ONCE or UV_RUN_NOWAIT.

Fixes #683.
2013-01-16 23:35:29 +01:00
Ben Noordhuis
f24335d498 test: fix #if defined checks
Same as edd1007 but this time for the tests.
2013-01-06 22:36:54 +01:00
Ben Noordhuis
c6c5b7a901 Merge branch 'v0.8' 2012-12-14 12:07:31 +01:00
Andrew Shaffer
49977386e9 sunos: properly disarm PORT_LOADED fsevent watcher
Fixes a segmentation fault when the watched entity is changed after the watcher
has been closed.
2012-12-14 12:02:57 +01:00
Ben Noordhuis
d8a8379751 test: disable fs event test on dragonflybsd
Disable the fs_event_close_in_callback test on DragonFlyBSD, like we do on the
other BSDs.

The test doesn't work with kqueue-based file notifications, the event is
generated before the file is watched. Maybe we should remove it altogether.
2012-11-20 00:46:12 +01:00
Ben Noordhuis
3243e9ae67 test: fix (harmless) typo in function name 2012-11-12 18:17:13 +01:00
Bert Belder
47eb03490a test: move loop cleanup code to the individual tests 2012-10-17 01:24:49 +02:00
Ben Noordhuis
f89986b153 test: fix memory leaks in test-fs-event.c 2012-10-02 23:19:53 +02:00
Fedor Indutny
778144f0b5 darwin: emit relative path in fsevents 2012-09-18 00:29:29 +02:00
Fedor Indutny
f8e7513a06 darwin: use FSEvents to watch directory changes 2012-09-12 23:38:57 +02:00
Ben Noordhuis
b5b8ead808 test: add failing fs_event test
Watches the same file twice. Fails on Linux with a segmentation fault.
2012-07-28 14:40:03 +02:00