Changes since version 1.34.1: * misc: adjust stalebot deadlines (Jameson Nash) * test: fix env-vars flakiness (cjihrig) * test: avoid truncating output lines (Jameson Nash) * darwin: stop calling SetApplicationIsDaemon() (Ben Noordhuis) * ibmi: implement uv_interface_addresses() (Xu Meng) * osx,fsevent: fix race during uv_loop_close (Jameson Nash) * osx,fsevent: clear pointer when deleting it [NFCI] (Jameson Nash) * Revert "aix: replace ECONNRESET with EOF if already closed" (Jameson Nash) * unix: handle uv__open_cloexec return value correctly (Anna Henningsen) -----BEGIN PGP SIGNATURE----- Comment: GPGTools - https://gpgtools.org iQIzBAABCgAdFiEElK42Z1xGTWS6+mjddDQ5C9vpucUFAl4pq5MACgkQdDQ5C9vp ucWJxA//fZm/u46gxSeRdWeFu9W1r1CgkJqmWT6vHeeBphk28lAulHAO0AM/bbbd x2WsLS8q7cLk3chwpN4CgJkgS8acqcsuHBGEzqc8o5cd76rCkua7eHvOR83D4Ix4 c46hJH7WF3S4jnVV09iAU+mGplyUPF3F8HvmbTNZnbsuLKj2U88kDjm4nsxiSwdn aMeyZNtM6NdtqHRgIup+SqS4hNvaUt+gD7715efTlGPDwLR3KCJ8Mzd9F4JFrPrT wCjAGLiTFZXFcnwR/Ysx66jQNjfp/fZy7G/zU+7UFKwCjZdwZyybqzy4lmYXtV7N 2hmliaxm3UsYPSD06mA+iUTdD9vnk2/htCNL5OBS11b6lAliYtdNC3l9BQ2Y3TVp xobPcjiRWmvN5P0GIL9/DjK7nxpSdj7BFFyyVz21/+OsYX+NYI4L/Vb4RjezGeGy RMS26S530fOsPCbPlSyEUqvjbTHI95FiLK8Y008YlRRsWVsCxrdrhDjT964LHZ51 nFFPkR0Ghr/y0d9AzBsrsnjAi9g/K+dX3F72S8S2gS3LMkLVr6fLrEQ5AmclAa4f 62TZvnKY3MzjdzsBpslGHHVp3l+HsNdkI27bLCbYUAL/c+R0fl96mac34IHGL+KV b/99O3WMxGtq/Zdn709ryMOLnC+F5KTJpl2LckExfxvubPcu9UQ= =SjB7 -----END PGP SIGNATURE----- Merge tag 'v1.34.2' into merge_1.34.2 PR-URL: https://github.com/libuv/libuv/pull/2649 Reviewed-By: Saúl Ibarra Corretgé <saghul@gmail.com>
134 lines
4.1 KiB
C
134 lines
4.1 KiB
C
/* Copyright libuv project 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.
|
|
*/
|
|
|
|
#if defined(_WIN32) && !defined(USING_UV_SHARED)
|
|
|
|
#include "uv.h"
|
|
#include "task.h"
|
|
|
|
#include "../src/win/fs-fd-hash-inl.h"
|
|
|
|
|
|
#define HASH_MAX 1000000000
|
|
#define HASH_INC (1000 * UV__FD_HASH_SIZE + 2)
|
|
#define BUCKET_MAX (UV__FD_HASH_SIZE * UV__FD_HASH_GROUP_SIZE * 10)
|
|
#define BUCKET_INC UV__FD_HASH_SIZE
|
|
#define FD_DIFF 9
|
|
|
|
|
|
void assert_nonexistent(uv_os_fd_t fd) {
|
|
struct uv__fd_info_s info = { 0 };
|
|
ASSERT(!uv__fd_hash_get(fd, &info));
|
|
ASSERT(!uv__fd_hash_remove(fd, &info));
|
|
}
|
|
|
|
void assert_existent(uv_os_fd_t fd) {
|
|
struct uv__fd_info_s info = { 0 };
|
|
ASSERT(uv__fd_hash_get(fd, &info));
|
|
ASSERT(info.flags == (intptr_t) fd + FD_DIFF);
|
|
}
|
|
|
|
void assert_insertion(uv_os_fd_t fd) {
|
|
struct uv__fd_info_s info = { 0 };
|
|
assert_nonexistent(fd);
|
|
info.flags = (intptr_t) fd + FD_DIFF;
|
|
uv__fd_hash_add(fd, &info);
|
|
assert_existent(fd);
|
|
}
|
|
|
|
void assert_removal(uv_os_fd_t fd) {
|
|
struct uv__fd_info_s info = { 0 };
|
|
assert_existent(fd);
|
|
uv__fd_hash_remove(fd, &info);
|
|
ASSERT(info.flags == (intptr_t) fd + FD_DIFF);
|
|
assert_nonexistent(fd);
|
|
}
|
|
|
|
|
|
/* Run a function for a set of values up to a very high number */
|
|
#define RUN_HASH(function) \
|
|
do { \
|
|
for (fd = 0; fd < HASH_MAX; fd += HASH_INC) { \
|
|
function((uv_os_fd_t) fd); \
|
|
} \
|
|
} while (0)
|
|
|
|
/* Run a function for a set of values that will cause many collisions */
|
|
#define RUN_COLLISIONS(function) \
|
|
do { \
|
|
for (fd = 1; fd < BUCKET_MAX; fd += BUCKET_INC) { \
|
|
function((uv_os_fd_t) fd); \
|
|
} \
|
|
} while (0)
|
|
|
|
|
|
TEST_IMPL(fs_fd_hash) {
|
|
uintptr_t fd;
|
|
|
|
uv__fd_hash_init();
|
|
|
|
/* Empty table */
|
|
RUN_HASH(assert_nonexistent);
|
|
RUN_COLLISIONS(assert_nonexistent);
|
|
|
|
/* Fill up */
|
|
RUN_HASH(assert_insertion);
|
|
RUN_COLLISIONS(assert_insertion);
|
|
|
|
/* Full */
|
|
RUN_HASH(assert_existent);
|
|
RUN_COLLISIONS(assert_existent);
|
|
|
|
/* Update */
|
|
{
|
|
struct uv__fd_info_s info = { 0 };
|
|
info.flags = FD_DIFF + FD_DIFF;
|
|
uv__fd_hash_add(0, &info);
|
|
}
|
|
{
|
|
struct uv__fd_info_s info = { 0 };
|
|
ASSERT(uv__fd_hash_get((uv_os_fd_t) 0, &info));
|
|
ASSERT(info.flags == FD_DIFF + FD_DIFF);
|
|
}
|
|
{
|
|
/* Leave as it was, will be again tested below */
|
|
struct uv__fd_info_s info = { 0 };
|
|
info.flags = FD_DIFF;
|
|
uv__fd_hash_add(0, &info);
|
|
}
|
|
|
|
/* Remove all */
|
|
RUN_HASH(assert_removal);
|
|
RUN_COLLISIONS(assert_removal);
|
|
|
|
/* Empty table */
|
|
RUN_HASH(assert_nonexistent);
|
|
RUN_COLLISIONS(assert_nonexistent);
|
|
|
|
return 0;
|
|
}
|
|
|
|
#else
|
|
|
|
typedef int file_has_no_tests; /* ISO C forbids an empty translation unit. */
|
|
|
|
#endif /* ifndef _WIN32 */
|