Changes since version 1.44.1: * Add SHA to ChangeLog (Jameson Nash) * aix, ibmi: handle server hang when remote sends TCP RST (V-for-Vasili) * build: make CI a bit noisier (Jameson Nash) * process: reset the signal mask if the fork fails (Jameson Nash) * zos: implement cmpxchgi() using assembly (Shuowang (Wayne) Zhang) * build: AC_SUBST for AM_CFLAGS (Claes Nästén) * ibmi: Implement UDP disconnect (V-for-Vasili) * doc: update active maintainers list (Ben Noordhuis) * build: fix kFreeBSD build (James McCoy) * build: remove Windows 2016 workflows (Darshan Sen) * Revert "win,errors: remap ERROR_ACCESS_DENIED to UV_EACCES" (Darshan Sen) * unix: simplify getpwuid call (Jameson Nash) * build: filter CI by paths and branches (Jameson Nash) * build: add iOS to macos CI (Jameson Nash) * build: re-enable CI for windows changes (Jameson Nash) * process,iOS: fix build breakage in process.c (Denny C. Dai) * test: remove unused declarations in tcp_rst test (V-for-Vasili) * core: add thread-safe strtok implementation (Guilherme Íscaro) * win: fix incompatible-types warning (twosee) * test: fix flaky file watcher test (Ben Noordhuis) * build: fix AIX xlc autotools build (V-for-Vasili) * unix,win: fix UV_RUN_ONCE + uv_idle_stop loop hang (Ben Noordhuis) * win: fix unexpected ECONNRESET error on TCP socket (twosee) * doc: make sample cross-platform build (gengjiawen) * test: separate some static variables by test cases (Hannah Shi) * sunos: fs-event callback can be called after uv_close() (Andy Fiddaman) * uv: re-register interest in a file after change (Shuowang (Wayne) Zhang) * uv: register UV_RENAME event for _RFIM_UNLINK (Shuowang (Wayne) Zhang) * uv: register __rfim_event 156 as UV_RENAME (Shuowang (Wayne) Zhang) * doc: remove smartos from supported platforms (Ben Noordhuis) * macos: avoid posix_spawnp() cwd bug (Jameson Nash) * release: check versions of autogen scripts are newer (Jameson Nash) * test: rewrite embed test (Ben Noordhuis) * openbsd: use utimensat instead of lutimes (tuftedocelot) * doc: fix link to uvwget example main() function (blogdaren) * unix: use MSG_CMSG_CLOEXEC where supported (Ben Noordhuis) * test: remove disabled callback_order test (Ben Noordhuis) * win,pipe: fix bugs with pipe resource lifetime management (Jameson Nash) * loop: better align order-of-events behavior between platforms (Jameson Nash) * aix,test: uv_backend_fd is not supported by poll (V-for-Vasili) * kqueue: skip EVFILT_PROC when invalidating fds (chucksilvers) * darwin: fix atomic-ops.h ppc64 build (Sergey Fedorov) * zos: don't err when killing a zombie process (Shuowang (Wayne) Zhang) * zos: avoid fs event callbacks after uv_close() (Shuowang (Wayne) Zhang) * zos: correctly format interface addresses names (Shuowang (Wayne) Zhang) * zos: add uv_interface_addresses() netmask support (Shuowang (Wayne) Zhang) * zos: improve memory management of ip addresses (Shuowang (Wayne) Zhang) * tcp,pipe: fail `bind` or `listen` after `close` (theanarkh) * zos: implement uv_available_parallelism() (Shuowang (Wayne) Zhang) * udp,win: fix UDP compiler warning (Jameson Nash) * zos: fix early exit of epoll_wait() (Shuowang (Wayne) Zhang) * unix,tcp: fix errno handling in uv__tcp_bind() (Samuel Cabrero) * shutdown,unix: reduce code duplication (Jameson Nash) * unix: fix c99 comments (Ben Noordhuis) * unix: retry tcgetattr/tcsetattr() on EINTR (Ben Noordhuis) * docs: update introduction.rst (Ikko Ashimine) * unix,stream: optimize uv_shutdown() codepath (Jameson Nash) * zos: delay signal handling until after normal i/o (Shuowang (Wayne) Zhang) * stream: uv__drain() always needs to stop POLLOUT (Jameson Nash) * unix,tcp: allow EINVAL errno from setsockopt in uv_tcp_close_reset() (Stacey Marshall) * win,shutdown: improve how shutdown is dispatched (Jameson Nash) -----BEGIN PGP SIGNATURE----- iQIzBAABCgAdFiEEz7ucqaW+r9cOKzxaeaZ8VaNnnIsFAmLNnoYACgkQeaZ8VaNn nIsPiRAApE7tNUEknH+7SJ//K910PA0GM8E9/tz8PFN5LDsVlIDa9p40IezhbjMu O3CbA9rPZfugohV8LJ+tDxAEqzPQmb4tLZ1jyzrTCm2RSS56MtJKhPXKKchITzb2 bAV4PNRsnzmZfMd/nJfVpTsBCf/rGOhJwFDChVVHkZgj+BibsYaipMUUwbm3XjCP fdzmhxh0EbCBsMWi8dxuV2R/FliaaH4PoZjvwJvk35mxN4H6ZhU/09Q9mvduljM8 fK3pgqGwge7D0dVoybeAkMDfhMpPkGBEhH6Zif8EkLLdUB1u4EO4lxlPjr4t6aL+ 2VoHqBAWcLk3MGFh9cIRtSWG41RnEtPFJPC5SXBzqMpF28bKGb3DYc9pxl+OkrHW 74UaDiXt446ccMlC3aF6kUbwNAHjYx6pthGPuKTxiPQPn38LE0KZbLH+G7dsRqQ/ DP3+s/UJR4D4IV8rrE3ys6UgTQrCU42gsA2psk6KLYGPaZw/boc7f+X8JOsP8W0g 2zwtmb27ustJQ/06MFhL2wC3J9x4cP9wdZyGSTwTbyXZ5pPQphrSinP/J8KFl5D+ gOEQjuGcyy1beLIsq5sHQz6HCkLGekMTEdz37PqU2+TMd/4VcBmzGvHx1ACPRZdF ljx3dbCE3w9lSbpOxM9DYONuRmfLSeroItLrhxEBL9xKbpKOZ2I= =C1zG -----END PGP SIGNATURE----- Merge tag 'v1.44.2' into merge_1.44.2
182 lines
4.3 KiB
C
182 lines
4.3 KiB
C
/* 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 <stdio.h>
|
|
#include <stdlib.h>
|
|
#include <string.h>
|
|
|
|
|
|
#ifdef _WIN32
|
|
# define BAD_PIPENAME "bad-pipe"
|
|
#else
|
|
# define BAD_PIPENAME "/path/to/unix/socket/that/really/should/not/be/there"
|
|
#endif
|
|
|
|
|
|
static int close_cb_called = 0;
|
|
|
|
|
|
static void close_cb(uv_handle_t* handle) {
|
|
ASSERT_NOT_NULL(handle);
|
|
close_cb_called++;
|
|
}
|
|
|
|
|
|
TEST_IMPL(pipe_bind_error_addrinuse) {
|
|
uv_pipe_t server1, server2;
|
|
int r;
|
|
|
|
r = uv_pipe_init(uv_default_loop(), &server1, 0);
|
|
ASSERT(r == 0);
|
|
r = uv_pipe_bind(&server1, TEST_PIPENAME);
|
|
ASSERT(r == 0);
|
|
|
|
r = uv_pipe_init(uv_default_loop(), &server2, 0);
|
|
ASSERT(r == 0);
|
|
r = uv_pipe_bind(&server2, TEST_PIPENAME);
|
|
ASSERT(r == UV_EADDRINUSE);
|
|
|
|
r = uv_listen((uv_stream_t*)&server1, SOMAXCONN, NULL);
|
|
ASSERT(r == 0);
|
|
r = uv_listen((uv_stream_t*)&server2, SOMAXCONN, NULL);
|
|
ASSERT(r == UV_EINVAL);
|
|
|
|
uv_close((uv_handle_t*)&server1, close_cb);
|
|
uv_close((uv_handle_t*)&server2, close_cb);
|
|
|
|
uv_run(uv_default_loop(), UV_RUN_DEFAULT);
|
|
|
|
ASSERT(close_cb_called == 2);
|
|
|
|
MAKE_VALGRIND_HAPPY();
|
|
return 0;
|
|
}
|
|
|
|
|
|
TEST_IMPL(pipe_bind_error_addrnotavail) {
|
|
uv_pipe_t server;
|
|
int r;
|
|
|
|
r = uv_pipe_init(uv_default_loop(), &server, 0);
|
|
ASSERT(r == 0);
|
|
|
|
r = uv_pipe_bind(&server, BAD_PIPENAME);
|
|
ASSERT(r == UV_EACCES);
|
|
|
|
uv_close((uv_handle_t*)&server, close_cb);
|
|
|
|
uv_run(uv_default_loop(), UV_RUN_DEFAULT);
|
|
|
|
ASSERT(close_cb_called == 1);
|
|
|
|
MAKE_VALGRIND_HAPPY();
|
|
return 0;
|
|
}
|
|
|
|
|
|
TEST_IMPL(pipe_bind_error_inval) {
|
|
uv_pipe_t server;
|
|
int r;
|
|
|
|
r = uv_pipe_init(uv_default_loop(), &server, 0);
|
|
ASSERT(r == 0);
|
|
r = uv_pipe_bind(&server, TEST_PIPENAME);
|
|
ASSERT(r == 0);
|
|
r = uv_pipe_bind(&server, TEST_PIPENAME_2);
|
|
ASSERT(r == UV_EINVAL);
|
|
|
|
uv_close((uv_handle_t*)&server, close_cb);
|
|
|
|
uv_run(uv_default_loop(), UV_RUN_DEFAULT);
|
|
|
|
ASSERT(close_cb_called == 1);
|
|
|
|
MAKE_VALGRIND_HAPPY();
|
|
return 0;
|
|
}
|
|
|
|
|
|
TEST_IMPL(pipe_listen_without_bind) {
|
|
#if defined(NO_SELF_CONNECT)
|
|
RETURN_SKIP(NO_SELF_CONNECT);
|
|
#endif
|
|
uv_pipe_t server;
|
|
int r;
|
|
|
|
r = uv_pipe_init(uv_default_loop(), &server, 0);
|
|
ASSERT(r == 0);
|
|
|
|
r = uv_listen((uv_stream_t*)&server, SOMAXCONN, NULL);
|
|
ASSERT(r == UV_EINVAL);
|
|
|
|
uv_close((uv_handle_t*)&server, close_cb);
|
|
|
|
uv_run(uv_default_loop(), UV_RUN_DEFAULT);
|
|
|
|
ASSERT(close_cb_called == 1);
|
|
|
|
MAKE_VALGRIND_HAPPY();
|
|
return 0;
|
|
}
|
|
|
|
|
|
TEST_IMPL(pipe_bind_error_long_path) {
|
|
char path[2048];
|
|
uv_pipe_t server;
|
|
int r;
|
|
|
|
memset(path, '.', sizeof(path) - 1);
|
|
path[sizeof(path) - 1] = '\0';
|
|
|
|
r = uv_pipe_init(uv_default_loop(), &server, 0);
|
|
ASSERT(r == 0);
|
|
r = uv_pipe_bind(&server, path);
|
|
ASSERT(r == UV_ENAMETOOLONG);
|
|
|
|
uv_close((uv_handle_t*)&server, close_cb);
|
|
|
|
uv_run(uv_default_loop(), UV_RUN_DEFAULT);
|
|
|
|
ASSERT(close_cb_called == 1);
|
|
|
|
MAKE_VALGRIND_HAPPY();
|
|
return 0;
|
|
}
|
|
|
|
|
|
TEST_IMPL(pipe_bind_or_listen_error_after_close) {
|
|
uv_pipe_t server;
|
|
|
|
ASSERT_EQ(uv_pipe_init(uv_default_loop(), &server, 0), 0);
|
|
uv_close((uv_handle_t*) &server, NULL);
|
|
|
|
ASSERT_EQ(uv_pipe_bind(&server, TEST_PIPENAME), UV_EINVAL);
|
|
|
|
ASSERT_EQ(uv_listen((uv_stream_t*) &server, SOMAXCONN, NULL), UV_EINVAL);
|
|
|
|
ASSERT_EQ(uv_run(uv_default_loop(), UV_RUN_DEFAULT), 0);
|
|
|
|
MAKE_VALGRIND_HAPPY();
|
|
return 0;
|
|
}
|