Skip to content

Commit

Permalink
deps: update libuv to 1.49.2
Browse files Browse the repository at this point in the history
Fixes: #56137
Refs: #56223
PR-URL: #56224
Reviewed-By: Santiago Gimeno <santiago.gimeno@gmail.com>
Reviewed-By: Richard Lau <rlau@redhat.com>
  • Loading branch information
lpinca authored and aduh95 committed Dec 18, 2024
1 parent 3298ef4 commit 4e9113e
Show file tree
Hide file tree
Showing 15 changed files with 69 additions and 176 deletions.
2 changes: 2 additions & 0 deletions deps/uv/AUTHORS
Original file line number Diff line number Diff line change
Expand Up @@ -588,3 +588,5 @@ Raihaan Shouhell <raihaanhimself@gmail.com>
Rialbat <miha-wead@mail.ru>
Adam <adam@NetBSD.org>
Poul T Lomholt <ptlomholt@users.noreply.github.com>
dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Thad House <ThadHouse@users.noreply.github.com>
20 changes: 19 additions & 1 deletion deps/uv/ChangeLog
Original file line number Diff line number Diff line change
@@ -1,4 +1,22 @@
2024.10.11, Version 1.49.1 (Stable)
2024.10.18, Version 1.49.2 (Stable)

Changes since version 1.49.1:

* win,fs: remove trailing slash in junctions (Hüseyin Açacak)

* Revert "linux: eliminate a read on eventfd per wakeup" (Ben Noordhuis)

* win: Fix linked list logic in getaddrinfo (Thad House)

* win: fix compilation against Windows 24H2 SDK (Thad House)

* win: remap ERROR_NOACCESS and ERROR_BUFFER_OVERFLOW (Jameson Nash)

* win,fs: match trailing slash presence in junctions to user input (Jameson
Nash)


2024.10.11, Version 1.49.1 (Stable), 8be336f4ee296d20e1c071a44d6adf279e202236

Changes since version 1.49.0:

Expand Down
2 changes: 1 addition & 1 deletion deps/uv/configure.ac
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
# OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.

AC_PREREQ(2.57)
AC_INIT([libuv], [1.49.1], [https://github.com/libuv/libuv/issues])
AC_INIT([libuv], [1.49.2], [https://github.com/libuv/libuv/issues])
AC_CONFIG_MACRO_DIR([m4])
m4_include([m4/libuv-extra-automake-flags.m4])
m4_include([m4/as_case.m4])
Expand Down
2 changes: 1 addition & 1 deletion deps/uv/include/uv/version.h
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@

#define UV_VERSION_MAJOR 1
#define UV_VERSION_MINOR 49
#define UV_VERSION_PATCH 1
#define UV_VERSION_PATCH 2
#define UV_VERSION_IS_RELEASE 1
#define UV_VERSION_SUFFIX ""

Expand Down
132 changes: 16 additions & 116 deletions deps/uv/src/unix/async.c
Original file line number Diff line number Diff line change
Expand Up @@ -38,34 +38,6 @@
#include <sys/eventfd.h>
#endif

#if UV__KQUEUE_EVFILT_USER
static uv_once_t kqueue_runtime_detection_guard = UV_ONCE_INIT;
static int kqueue_evfilt_user_support = 1;


static void uv__kqueue_runtime_detection(void) {
int kq;
struct kevent ev[2];
struct timespec timeout = {0, 0};

/* Perform the runtime detection to ensure that kqueue with
* EVFILT_USER actually works. */
kq = kqueue();
EV_SET(ev, UV__KQUEUE_EVFILT_USER_IDENT, EVFILT_USER,
EV_ADD | EV_CLEAR, 0, 0, 0);
EV_SET(ev + 1, UV__KQUEUE_EVFILT_USER_IDENT, EVFILT_USER,
0, NOTE_TRIGGER, 0, 0);
if (kevent(kq, ev, 2, ev, 1, &timeout) < 1 ||
ev[0].filter != EVFILT_USER ||
ev[0].ident != UV__KQUEUE_EVFILT_USER_IDENT ||
ev[0].flags & EV_ERROR)
/* If we wind up here, we can assume that EVFILT_USER is defined but
* broken on the current system. */
kqueue_evfilt_user_support = 0;
uv__close(kq);
}
#endif

static void uv__async_send(uv_loop_t* loop);
static int uv__async_start(uv_loop_t* loop);
static void uv__cpu_relax(void);
Expand Down Expand Up @@ -158,23 +130,16 @@ void uv__async_close(uv_async_t* handle) {


static void uv__async_io(uv_loop_t* loop, uv__io_t* w, unsigned int events) {
#ifndef __linux__
char buf[1024];
ssize_t r;
#endif
struct uv__queue queue;
struct uv__queue* q;
uv_async_t* h;
_Atomic int *pending;

assert(w == &loop->async_io_watcher);

#ifndef __linux__
#if UV__KQUEUE_EVFILT_USER
for (;!kqueue_evfilt_user_support;) {
#else
for (;;) {
#endif
r = read(w->fd, buf, sizeof(buf));

if (r == sizeof(buf))
Expand All @@ -191,7 +156,6 @@ static void uv__async_io(uv_loop_t* loop, uv__io_t* w, unsigned int events) {

abort();
}
#endif /* !__linux__ */

uv__queue_move(&loop->async_handles, &queue);
while (!uv__queue_empty(&queue)) {
Expand All @@ -215,58 +179,34 @@ static void uv__async_io(uv_loop_t* loop, uv__io_t* w, unsigned int events) {


static void uv__async_send(uv_loop_t* loop) {
const void* buf;
ssize_t len;
int fd;
ssize_t r;
#ifdef __linux__
uint64_t val;

fd = loop->async_io_watcher.fd; /* eventfd */
for (val = 1; /* empty */; val = 1) {
r = write(fd, &val, sizeof(uint64_t));
if (r < 0) {
/* When EAGAIN occurs, the eventfd counter hits the maximum value of the unsigned 64-bit.
* We need to first drain the eventfd and then write again.
*
* Check out https://man7.org/linux/man-pages/man2/eventfd.2.html for details.
*/
if (errno == EAGAIN) {
/* It's ready to retry. */
if (read(fd, &val, sizeof(uint64_t)) > 0 || errno == EAGAIN) {
continue;
}
}
/* Unknown error occurs. */
break;
}
return;
}
#else
#if UV__KQUEUE_EVFILT_USER
struct kevent ev;

if (kqueue_evfilt_user_support) {
fd = loop->async_io_watcher.fd; /* magic number for EVFILT_USER */
EV_SET(&ev, fd, EVFILT_USER, 0, NOTE_TRIGGER, 0, 0);
r = kevent(loop->backend_fd, &ev, 1, NULL, 0, NULL);
if (r == 0)
return;
else
abort();
int r;

buf = "";
len = 1;
fd = loop->async_wfd;

#if defined(__linux__)
if (fd == -1) {
static const uint64_t val = 1;
buf = &val;
len = sizeof(val);
fd = loop->async_io_watcher.fd; /* eventfd */
}
#endif

fd = loop->async_wfd; /* write end of the pipe */
do
r = write(fd, "x", 1);
r = write(fd, buf, len);
while (r == -1 && errno == EINTR);

if (r == 1)
if (r == len)
return;

if (r == -1)
if (errno == EAGAIN || errno == EWOULDBLOCK)
return;
#endif

abort();
}
Expand All @@ -275,9 +215,6 @@ static void uv__async_send(uv_loop_t* loop) {
static int uv__async_start(uv_loop_t* loop) {
int pipefd[2];
int err;
#if UV__KQUEUE_EVFILT_USER
struct kevent ev;
#endif

if (loop->async_io_watcher.fd != -1)
return 0;
Expand All @@ -289,36 +226,6 @@ static int uv__async_start(uv_loop_t* loop) {

pipefd[0] = err;
pipefd[1] = -1;
#elif UV__KQUEUE_EVFILT_USER
uv_once(&kqueue_runtime_detection_guard, uv__kqueue_runtime_detection);
if (kqueue_evfilt_user_support) {
/* In order not to break the generic pattern of I/O polling, a valid
* file descriptor is required to take up a room in loop->watchers,
* thus we create one for that, but this fd will not be actually used,
* it's just a placeholder and magic number which is going to be closed
* during the cleanup, as other FDs. */
err = uv__open_cloexec("/dev/null", O_RDONLY);
if (err < 0)
return err;

pipefd[0] = err;
pipefd[1] = -1;

/* When using EVFILT_USER event to wake up the kqueue, this event must be
* registered beforehand. Otherwise, calling kevent() to issue an
* unregistered EVFILT_USER event will get an ENOENT.
* Since uv__async_send() may happen before uv__io_poll() with multi-threads,
* we can't defer this registration of EVFILT_USER event as we did for other
* events, but must perform it right away. */
EV_SET(&ev, err, EVFILT_USER, EV_ADD | EV_CLEAR, 0, 0, 0);
err = kevent(loop->backend_fd, &ev, 1, NULL, 0, NULL);
if (err < 0)
return UV__ERR(errno);
} else {
err = uv__make_pipe(pipefd, UV_NONBLOCK_PIPE);
if (err < 0)
return err;
}
#else
err = uv__make_pipe(pipefd, UV_NONBLOCK_PIPE);
if (err < 0)
Expand All @@ -329,13 +236,6 @@ static int uv__async_start(uv_loop_t* loop) {
uv__io_start(loop, &loop->async_io_watcher, POLLIN);
loop->async_wfd = pipefd[1];

#if UV__KQUEUE_EVFILT_USER
/* Prevent the EVFILT_USER event from being added to kqueue redundantly
* and mistakenly later in uv__io_poll(). */
if (kqueue_evfilt_user_support)
loop->async_io_watcher.events = loop->async_io_watcher.pevents;
#endif

return 0;
}

Expand Down
22 changes: 0 additions & 22 deletions deps/uv/src/unix/internal.h
Original file line number Diff line number Diff line change
Expand Up @@ -35,10 +35,6 @@
#include <sys/socket.h>
#include <sys/stat.h>
#include <sys/types.h>
#if defined(__APPLE__) || defined(__DragonFly__) || \
defined(__FreeBSD__) || defined(__NetBSD__)
#include <sys/event.h>
#endif

#define uv__msan_unpoison(p, n) \
do { \
Expand Down Expand Up @@ -508,22 +504,4 @@ int uv__get_constrained_cpu(uv__cpu_constraint* constraint);
#endif
#endif

#if defined(EVFILT_USER) && defined(NOTE_TRIGGER)
/* EVFILT_USER is available since OS X 10.6, DragonFlyBSD 4.0,
* FreeBSD 8.1, and NetBSD 10.0.
*
* Note that even though EVFILT_USER is defined on the current system,
* it may still fail to work at runtime somehow. In that case, we fall
* back to pipe-based signaling.
*/
#define UV__KQUEUE_EVFILT_USER 1
/* Magic number of identifier used for EVFILT_USER during runtime detection.
* There are no Google hits for this number when I create it. That way,
* people will be directed here if this number gets printed due to some
* kqueue error and they google for help. */
#define UV__KQUEUE_EVFILT_USER_IDENT 0x1e7e7711
#else
#define UV__KQUEUE_EVFILT_USER 0
#endif

#endif /* UV_UNIX_INTERNAL_H_ */
11 changes: 0 additions & 11 deletions deps/uv/src/unix/kqueue.c
Original file line number Diff line number Diff line change
Expand Up @@ -367,17 +367,6 @@ void uv__io_poll(uv_loop_t* loop, int timeout) {
continue;
}

#if UV__KQUEUE_EVFILT_USER
if (ev->filter == EVFILT_USER) {
w = &loop->async_io_watcher;
assert(fd == w->fd);
uv__metrics_update_idle_time(loop);
w->cb(loop, w, w->events);
nevents++;
continue;
}
#endif

if (ev->filter == EVFILT_VNODE) {
assert(w->events == POLLIN);
assert(w->pevents == POLLIN);
Expand Down
6 changes: 0 additions & 6 deletions deps/uv/src/unix/linux.c
Original file line number Diff line number Diff line change
Expand Up @@ -1414,12 +1414,6 @@ void uv__io_poll(uv_loop_t* loop, int timeout) {

w->events = w->pevents;
e.events = w->pevents;
if (w == &loop->async_io_watcher)
/* Enable edge-triggered mode on async_io_watcher(eventfd),
* so that we're able to eliminate the overhead of reading
* the eventfd via system call on each event loop wakeup.
*/
e.events |= EPOLLET;
e.data.fd = w->fd;
fd = w->fd;

Expand Down
4 changes: 2 additions & 2 deletions deps/uv/src/win/error.c
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,6 @@ int uv_translate_sys_error(int sys_errno) {
}

switch (sys_errno) {
case ERROR_NOACCESS: return UV_EACCES;
case WSAEACCES: return UV_EACCES;
case ERROR_ELEVATION_REQUIRED: return UV_EACCES;
case ERROR_CANT_ACCESS_FILE: return UV_EACCES;
Expand All @@ -96,7 +95,7 @@ int uv_translate_sys_error(int sys_errno) {
case WSAECONNRESET: return UV_ECONNRESET;
case ERROR_ALREADY_EXISTS: return UV_EEXIST;
case ERROR_FILE_EXISTS: return UV_EEXIST;
case ERROR_BUFFER_OVERFLOW: return UV_EFAULT;
case ERROR_NOACCESS: return UV_EFAULT;
case WSAEFAULT: return UV_EFAULT;
case ERROR_HOST_UNREACHABLE: return UV_EHOSTUNREACH;
case WSAEHOSTUNREACH: return UV_EHOSTUNREACH;
Expand Down Expand Up @@ -127,6 +126,7 @@ int uv_translate_sys_error(int sys_errno) {
case ERROR_TOO_MANY_OPEN_FILES: return UV_EMFILE;
case WSAEMFILE: return UV_EMFILE;
case WSAEMSGSIZE: return UV_EMSGSIZE;
case ERROR_BUFFER_OVERFLOW: return UV_ENAMETOOLONG;
case ERROR_FILENAME_EXCED_RANGE: return UV_ENAMETOOLONG;
case ERROR_NETWORK_UNREACHABLE: return UV_ENETUNREACH;
case WSAENETUNREACH: return UV_ENETUNREACH;
Expand Down
17 changes: 9 additions & 8 deletions deps/uv/src/win/fs.c
Original file line number Diff line number Diff line change
Expand Up @@ -2566,16 +2566,17 @@ static void fs__create_junction(uv_fs_t* req, const WCHAR* path,

path_buf[path_buf_len++] = path[i];
}
path_buf[path_buf_len++] = L'\\';
if (add_slash)
path_buf[path_buf_len++] = L'\\';
len = path_buf_len - start;

/* Insert null terminator */
path_buf[path_buf_len++] = L'\0';

/* Set the info about the substitute name */
buffer->MountPointReparseBuffer.SubstituteNameOffset = start * sizeof(WCHAR);
buffer->MountPointReparseBuffer.SubstituteNameLength = len * sizeof(WCHAR);

/* Insert null terminator */
path_buf[path_buf_len++] = L'\0';

/* Copy the print name of the target path */
start = path_buf_len;
add_slash = 0;
Expand All @@ -2593,18 +2594,18 @@ static void fs__create_junction(uv_fs_t* req, const WCHAR* path,
path_buf[path_buf_len++] = path[i];
}
len = path_buf_len - start;
if (len == 2) {
if (len == 2 || add_slash) {
path_buf[path_buf_len++] = L'\\';
len++;
}

/* Insert another null terminator */
path_buf[path_buf_len++] = L'\0';

/* Set the info about the print name */
buffer->MountPointReparseBuffer.PrintNameOffset = start * sizeof(WCHAR);
buffer->MountPointReparseBuffer.PrintNameLength = len * sizeof(WCHAR);

/* Insert another null terminator */
path_buf[path_buf_len++] = L'\0';

/* Calculate how much buffer space was actually used */
used_buf_size = FIELD_OFFSET(REPARSE_DATA_BUFFER, MountPointReparseBuffer.PathBuffer) +
path_buf_len * sizeof(WCHAR);
Expand Down
5 changes: 3 additions & 2 deletions deps/uv/src/win/getaddrinfo.c
Original file line number Diff line number Diff line change
Expand Up @@ -191,8 +191,9 @@ static void uv__getaddrinfo_done(struct uv__work* w, int status) {
if (addrinfow_ptr == NULL)
break;
cur_off = align_offset(cur_off, sizeof(void *));
addrinfo_ptr = (struct addrinfo *)(alloc_ptr + cur_off);
addrinfo_ptr->ai_next = addrinfo_ptr;
struct addrinfo *next_addrinfo_ptr = (struct addrinfo *)(alloc_ptr + cur_off);
addrinfo_ptr->ai_next = next_addrinfo_ptr;
addrinfo_ptr = next_addrinfo_ptr;
}
req->addrinfo = (struct addrinfo*)alloc_ptr;
} else {
Expand Down
Loading

0 comments on commit 4e9113e

Please sign in to comment.