Changes since version 1.45.0: * Add SHA to ChangeLog (Santiago Gimeno) * misc: update readthedocs config (Jameson Nash) * test: remove erroneous RETURN_SKIP (Ben Noordhuis) * android: disable io_uring support (Ben Noordhuis) * linux: add some more iouring backed fs ops (Santiago Gimeno) * build: add autoconf option for disable-maintainer-mode (Jameson Nash) * fs: use WTF-8 on Windows (Stefan Karpinski) * unix,win: replace QUEUE with struct uv__queue (Ben Noordhuis) * linux: fs_read to use io_uring if iovcnt > IOV_MAX (Santiago Gimeno) * ios: fix uv_getrusage() ru_maxrss calculation (Ben Noordhuis) * include: update outdated code comment (Ben Noordhuis) * linux: support abstract unix sockets (Ben Noordhuis) * unix,win: add UV_PIPE_NO_TRUNCATE flag (Ben Noordhuis) * unix: add loongarch support (liuxiang88) * doc: add DPS8M to LINKS.md (Jeffrey H. Johnson) * include: add EUNATCH errno mapping (Abdirahim Musse) * src: don't run timers if loop is stopped/unref'd (Trevor Norris) * win: fix -Wpointer-to-int-cast warning (Ben Noordhuis) * test,win: fix -Wunused-variable warning (Ben Noordhuis) * test,win: fix -Wformat warning (Ben Noordhuis) * linux: work around io_uring IORING_OP_CLOSE bug (Ben Noordhuis) * win: remove unused functions (Ben Noordhuis) * bench: add bench to check uv_loop_alive (Trevor Norris) * test: add uv_cancel test for threadpool (Trevor Norris) * unix: skip prohibited syscalls on tvOS and watchOS (小明) * unix,fs: make no_pwritev access thread-safe (Santiago Gimeno) * unix: fix build for lower versions of Android (小明) -----BEGIN PGP SIGNATURE----- iQIzBAABCgAdFiEEYS8OrZQBYiN530QC8ow8jaM8A74FAmSfH5cACgkQ8ow8jaM8 A77NnBAAkAE2anAM7xLaTaz9bdFLMH8eegpDRKcwcui6Z4gf84whgLBSWrJ34JVe wDKMmwB1fDQfV+GeZY7AI8Z9V7v+1T1FRwT/Gb63dG+Z+sHBTBl/olGIj8jxRDV4 p42M0MBUW03NVeGdxsXHNy8mgbM0oDU7Ko+QU8X41hCT+2wQ2NOp+BBImMeNRAKQ wb1766zocxuR0nmasIf2sg8WC87H5YSzpqJ/0yftBy9dBbcd3EU2IJfHGWWuijuA cT8ohREb+TAIL/m0iKfEc2Ft4iWDaziabC/d62VwrVzKEokvCZwf7Uqjm/J+U7iT ovGxq/dL+5/+7R2upm9Y8+6yiTDSuvpfJS/REEdMfKocaB2KhIG2CHuc2ejKyxo1 7rxEziJ481f1CS6wMH5qsvnUvcb+WtHoLXgzBabBTg8ul/zwTxgNdXCZCzjS1+tv PjL/zLJGeDMIibZ5oEoKc8Ce080YpH5rxFZRJn3Aheqp+ZXkoFNygdYSs3oD+rGU V32FnRXQmWCcZjsgS7LWk/ufCJm/lw9z4cyN/YkINEmgdMzrTVk7e/SIW4AdnkJ7 CyBwOH5m96dLfwTXExfUm1x+2pmzq1CX10iVbe+180n53i1rf++DU5eA8Dr0LCRF jcB+0UrMAq/eYB/+JfQVUflvPlduFsFlLffnOCMv4HPbjKdkOoU= =LjtZ -----END PGP SIGNATURE----- Merge tag 'v1.46.0' into merge_1.46.0
206 lines
5.1 KiB
C
206 lines
5.1 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(uv_default_loop());
|
|
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(uv_default_loop());
|
|
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(uv_default_loop());
|
|
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(uv_default_loop());
|
|
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(uv_default_loop());
|
|
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(uv_default_loop());
|
|
return 0;
|
|
}
|
|
|
|
TEST_IMPL(pipe_overlong_path) {
|
|
char path[512];
|
|
uv_pipe_t pipe;
|
|
uv_connect_t req;
|
|
|
|
memset(path, '@', sizeof(path));
|
|
ASSERT_OK(uv_pipe_init(uv_default_loop(), &pipe, 0));
|
|
ASSERT_EQ(UV_ENAMETOOLONG,
|
|
uv_pipe_bind2(&pipe, path, sizeof(path), UV_PIPE_NO_TRUNCATE));
|
|
ASSERT_EQ(UV_ENAMETOOLONG,
|
|
uv_pipe_connect2(&req,
|
|
&pipe,
|
|
path,
|
|
sizeof(path),
|
|
UV_PIPE_NO_TRUNCATE,
|
|
(uv_connect_cb) abort));
|
|
uv_close((uv_handle_t*) &pipe, NULL);
|
|
ASSERT_OK(uv_run(uv_default_loop(), UV_RUN_DEFAULT));
|
|
|
|
MAKE_VALGRIND_HAPPY(uv_default_loop());
|
|
return 0;
|
|
|
|
}
|