Merge remote-tracking branch 'origin/v0.10'
Drops commit 3780e12 ("fsevents: support japaneese characters in path")
for being quite inapplicable to the master branch. Will be reworked
and applied in a follow-up commit.
Conflicts:
README.md
build.mk
src/unix/fsevents.c
src/unix/udp.c
This commit is contained in:
commit
2bb3326c48
@ -159,6 +159,7 @@ test/test-udp-open.c
|
|||||||
test/test-udp-options.c
|
test/test-udp-options.c
|
||||||
test/test-udp-send-and-recv.c
|
test/test-udp-send-and-recv.c
|
||||||
test/test-walk-handles.c
|
test/test-walk-handles.c
|
||||||
|
test/test-watcher-cross-stop.c
|
||||||
"
|
"
|
||||||
|
|
||||||
case `uname -s` in
|
case `uname -s` in
|
||||||
|
|||||||
@ -190,7 +190,7 @@ void uv__io_poll(uv_loop_t* loop, int timeout) {
|
|||||||
revents = 0;
|
revents = 0;
|
||||||
|
|
||||||
if (ev->filter == EVFILT_READ) {
|
if (ev->filter == EVFILT_READ) {
|
||||||
if (w->events & UV__POLLIN) {
|
if (w->pevents & UV__POLLIN) {
|
||||||
revents |= UV__POLLIN;
|
revents |= UV__POLLIN;
|
||||||
w->rcount = ev->data;
|
w->rcount = ev->data;
|
||||||
} else {
|
} else {
|
||||||
@ -204,7 +204,7 @@ void uv__io_poll(uv_loop_t* loop, int timeout) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (ev->filter == EVFILT_WRITE) {
|
if (ev->filter == EVFILT_WRITE) {
|
||||||
if (w->events & UV__POLLOUT) {
|
if (w->pevents & UV__POLLOUT) {
|
||||||
revents |= UV__POLLOUT;
|
revents |= UV__POLLOUT;
|
||||||
w->wcount = ev->data;
|
w->wcount = ev->data;
|
||||||
} else {
|
} else {
|
||||||
|
|||||||
@ -113,6 +113,7 @@ void uv__io_poll(uv_loop_t* loop, int timeout) {
|
|||||||
uv__io_t* w;
|
uv__io_t* w;
|
||||||
uint64_t base;
|
uint64_t base;
|
||||||
uint64_t diff;
|
uint64_t diff;
|
||||||
|
unsigned int masked_events;
|
||||||
int nevents;
|
int nevents;
|
||||||
int count;
|
int count;
|
||||||
int nfds;
|
int nfds;
|
||||||
@ -216,7 +217,15 @@ void uv__io_poll(uv_loop_t* loop, int timeout) {
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
w->cb(loop, w, pe->events);
|
/*
|
||||||
|
* Give users only events they're interested in. Prevents spurious
|
||||||
|
* callbacks when previous callback invocation in this loop has stopped
|
||||||
|
* the current watcher. Also, filters out events that users has not
|
||||||
|
* requested us to watch.
|
||||||
|
*/
|
||||||
|
masked_events = pe->events & w->pevents;
|
||||||
|
if (masked_events != 0)
|
||||||
|
w->cb(loop, w, masked_events);
|
||||||
nevents++;
|
nevents++;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -108,6 +108,7 @@ TEST_DECLARE (idle_starvation)
|
|||||||
TEST_DECLARE (loop_handles)
|
TEST_DECLARE (loop_handles)
|
||||||
TEST_DECLARE (get_loadavg)
|
TEST_DECLARE (get_loadavg)
|
||||||
TEST_DECLARE (walk_handles)
|
TEST_DECLARE (walk_handles)
|
||||||
|
TEST_DECLARE (watcher_cross_stop)
|
||||||
TEST_DECLARE (ref)
|
TEST_DECLARE (ref)
|
||||||
TEST_DECLARE (idle_ref)
|
TEST_DECLARE (idle_ref)
|
||||||
TEST_DECLARE (async_ref)
|
TEST_DECLARE (async_ref)
|
||||||
@ -394,6 +395,8 @@ TASK_LIST_START
|
|||||||
TEST_ENTRY (loop_handles)
|
TEST_ENTRY (loop_handles)
|
||||||
TEST_ENTRY (walk_handles)
|
TEST_ENTRY (walk_handles)
|
||||||
|
|
||||||
|
TEST_ENTRY (watcher_cross_stop)
|
||||||
|
|
||||||
TEST_ENTRY (active)
|
TEST_ENTRY (active)
|
||||||
|
|
||||||
TEST_ENTRY (embed)
|
TEST_ENTRY (embed)
|
||||||
|
|||||||
114
test/test-watcher-cross-stop.c
Normal file
114
test/test-watcher-cross-stop.c
Normal file
@ -0,0 +1,114 @@
|
|||||||
|
/* Copyright Joyent, Inc. and other Node contributors. All rights reserved.
|
||||||
|
*
|
||||||
|
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||||
|
* of this software and associated documentation files (the "Software"), to
|
||||||
|
* deal in the Software without restriction, including without limitation the
|
||||||
|
* rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
|
||||||
|
* sell copies of the Software, and to permit persons to whom the Software is
|
||||||
|
* furnished to do so, subject to the following conditions:
|
||||||
|
*
|
||||||
|
* The above copyright notice and this permission notice shall be included in
|
||||||
|
* all copies or substantial portions of the Software.
|
||||||
|
*
|
||||||
|
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||||
|
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||||
|
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||||
|
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||||
|
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
||||||
|
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
|
||||||
|
* IN THE SOFTWARE.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include "uv.h"
|
||||||
|
#include "task.h"
|
||||||
|
|
||||||
|
#include <string.h>
|
||||||
|
#include <errno.h>
|
||||||
|
|
||||||
|
#if !defined(_WIN32)
|
||||||
|
#include <sys/time.h>
|
||||||
|
#include <sys/resource.h> /* setrlimit() */
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/* NOTE: Number should be big enough to trigger this problem */
|
||||||
|
static uv_udp_t sockets[2500];
|
||||||
|
static uv_udp_send_t reqs[ARRAY_SIZE(sockets)];
|
||||||
|
static char slab[1];
|
||||||
|
static unsigned int recv_cb_called;
|
||||||
|
static unsigned int send_cb_called;
|
||||||
|
static unsigned int close_cb_called;
|
||||||
|
|
||||||
|
static void alloc_cb(uv_handle_t* handle, size_t size, uv_buf_t* buf) {
|
||||||
|
buf->base = slab;
|
||||||
|
buf->len = sizeof(slab);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
static void recv_cb(uv_udp_t* handle,
|
||||||
|
ssize_t nread,
|
||||||
|
const uv_buf_t* buf,
|
||||||
|
const struct sockaddr* addr,
|
||||||
|
unsigned flags) {
|
||||||
|
recv_cb_called++;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
static void send_cb(uv_udp_send_t* req, int status) {
|
||||||
|
send_cb_called++;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
static void close_cb(uv_handle_t* handle) {
|
||||||
|
close_cb_called++;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
TEST_IMPL(watcher_cross_stop) {
|
||||||
|
uv_loop_t* loop = uv_default_loop();
|
||||||
|
unsigned int i;
|
||||||
|
struct sockaddr_in addr;
|
||||||
|
uv_buf_t buf;
|
||||||
|
char big_string[1024];
|
||||||
|
|
||||||
|
#if !defined(_WIN32)
|
||||||
|
{
|
||||||
|
struct rlimit lim;
|
||||||
|
lim.rlim_cur = ARRAY_SIZE(sockets) + 32;
|
||||||
|
lim.rlim_max = ARRAY_SIZE(sockets) + 32;
|
||||||
|
if (setrlimit(RLIMIT_NOFILE, &lim))
|
||||||
|
RETURN_SKIP("File descriptor limit too low.");
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
ASSERT(0 == uv_ip4_addr("127.0.0.1", TEST_PORT, &addr));
|
||||||
|
memset(big_string, 'A', sizeof(big_string));
|
||||||
|
buf = uv_buf_init(big_string, sizeof(big_string));
|
||||||
|
|
||||||
|
for (i = 0; i < ARRAY_SIZE(sockets); i++) {
|
||||||
|
ASSERT(0 == uv_udp_init(loop, &sockets[i]));
|
||||||
|
ASSERT(0 == uv_udp_bind(&sockets[i], (const struct sockaddr*) &addr, 0));
|
||||||
|
ASSERT(0 == uv_udp_recv_start(&sockets[i], alloc_cb, recv_cb));
|
||||||
|
ASSERT(0 == uv_udp_send(&reqs[i],
|
||||||
|
&sockets[i],
|
||||||
|
&buf,
|
||||||
|
1,
|
||||||
|
(const struct sockaddr*) &addr,
|
||||||
|
send_cb));
|
||||||
|
}
|
||||||
|
|
||||||
|
while (recv_cb_called == 0)
|
||||||
|
uv_run(loop, UV_RUN_ONCE);
|
||||||
|
|
||||||
|
for (i = 0; i < ARRAY_SIZE(sockets); i++)
|
||||||
|
uv_close((uv_handle_t*) &sockets[i], close_cb);
|
||||||
|
|
||||||
|
ASSERT(0 < recv_cb_called && recv_cb_called <= ARRAY_SIZE(sockets));
|
||||||
|
ASSERT(ARRAY_SIZE(sockets) == send_cb_called);
|
||||||
|
|
||||||
|
uv_run(loop, UV_RUN_DEFAULT);
|
||||||
|
|
||||||
|
ASSERT(ARRAY_SIZE(sockets) == close_cb_called);
|
||||||
|
|
||||||
|
MAKE_VALGRIND_HAPPY();
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
1
uv.gyp
1
uv.gyp
@ -323,6 +323,7 @@
|
|||||||
'test/test-loop-handles.c',
|
'test/test-loop-handles.c',
|
||||||
'test/test-loop-stop.c',
|
'test/test-loop-stop.c',
|
||||||
'test/test-walk-handles.c',
|
'test/test-walk-handles.c',
|
||||||
|
'test/test-watcher-cross-stop.c',
|
||||||
'test/test-multiple-listen.c',
|
'test/test-multiple-listen.c',
|
||||||
'test/test-osx-select.c',
|
'test/test-osx-select.c',
|
||||||
'test/test-pass-always.c',
|
'test/test-pass-always.c',
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user