Commit Graph

88 Commits

Author SHA1 Message Date
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
Ben Noordhuis
4741a112ad test: disable fs_event_close_in_callback on kqueue-based systems 2012-04-12 02:33:14 +02:00
Bert Belder
6e0ca3aa8f Merge branch 'v0.6'
Conflicts:
	src/unix/linux/inotify.c
2012-03-27 23:46:23 +02:00
Bert Belder
aff078390f Test: verify that uv_close from an fs event callback works properly 2012-03-27 23:00:26 +02:00
Bert Belder
732cf91d6d Test: verify that no callbacks are made after closing an fs event watcher 2012-03-27 23:00:26 +02:00
Bert Belder
89303f365e Fs event tests: don't fail if a previously failed test left stray files 2012-03-27 23:00:25 +02:00
Bert Belder
7e8fe3ece7 test-fs-event.c: style 2012-03-27 23:00:25 +02:00
Ben Noordhuis
ac218a7ed5 test: add lots of refcount tests 2012-01-14 00:22:20 +01:00
Ben Noordhuis
38fc6ad839 unix: unref fs event watcher
Watchers were being ref-counted twice which wasn't harmful in itself but stopped
uv_unref() from working like you'd expect it to.
2012-01-02 10:42:27 +01:00
Ben Noordhuis
2bd181a8d2 unix: properly disarm kqueue fs watcher
Fixes "Assertion failed: (revents == EV_LIBUV_KQUEUE_HACK),
function uv__fs_event, file ../src/unix/kqueue.c, line 58."
2011-11-18 01:40:11 +01:00
Bert Belder
1997e10b50 Add flags to uv_fs_event_init 2011-11-05 01:42:08 +01:00
Igor Zinkovsky
0fb3769586 windows: don't emit fs-event callback after uv_fs_event handle is closed 2011-11-02 19:10:04 -07:00
Ben Noordhuis
8e9a3384c9 unix: implement kqueue file watcher API
kqueue fds are not embeddable into other pollsets (select, poll, kqueue).
Hack the libev event loop to receive kqueue events with filter flags intact.
2011-10-04 23:28:36 +02:00
Ben Noordhuis
71f6c0edb8 Merge remote-tracking branch 'origin/v0.6'
Conflicts:
	src/win/util.c
2012-01-16 18:07:49 +01:00
Ryan Dahl
51ea46de45 Merge remote branch 'origin/v0.6' 2012-01-09 11:31:13 -08:00
Ben Noordhuis
5728bd4549 test: touching a file should generate only one fs event 2011-11-21 18:01:01 +00:00
Ben Noordhuis
1e0aab06c9 unix: properly disarm kqueue fs watcher
Fixes "Assertion failed: (revents == EV_LIBUV_KQUEUE_HACK),
function uv__fs_event, file ../src/unix/kqueue.c, line 58."
2011-11-18 01:39:30 +01:00
Ben Noordhuis
2a1c32a60c linux: implement file watcher API 2011-09-21 13:23:49 -07:00
Igor Zinkovsky
1e0757ffda windows: file watcher 2011-09-21 13:13:34 -07:00