Skip to content

Commit

Permalink
Merge remote-tracking branch 'upstream/v1.x' into v1.x
Browse files Browse the repository at this point in the history
  • Loading branch information
TheTechsTech committed Oct 20, 2024
2 parents feb0ded + 94e467a commit 470fb79
Show file tree
Hide file tree
Showing 25 changed files with 279 additions and 221 deletions.
1 change: 1 addition & 0 deletions .mailmap
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ David Carlier <[email protected]>
Devchandra Meetei Leishangthem <[email protected]>
Fedor Indutny <[email protected]> <[email protected]>
Frank Denis <[email protected]>
Hüseyin Açacak <[email protected]> <[email protected]>
Imran Iqbal <[email protected]> <[email protected]>
Isaac Z. Schlueter <[email protected]>
Jason Williams <[email protected]>
Expand Down
5 changes: 5 additions & 0 deletions AUTHORS
Original file line number Diff line number Diff line change
Expand Up @@ -585,3 +585,8 @@ Ian Butterworth <[email protected]>
Zuohui Yang <[email protected]>
Edigleysson Silva (Edy) <[email protected]>
Raihaan Shouhell <[email protected]>
Rialbat <[email protected]>
Adam <[email protected]>
Poul T Lomholt <[email protected]>
dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Thad House <[email protected]>
49 changes: 49 additions & 0 deletions ChangeLog
Original file line number Diff line number Diff line change
@@ -1,3 +1,52 @@
2024.10.18, Version 1.49.2 (Stable), e1095c7a4373ce00cd8874d8e820de5afb25776e

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:

* build: add darwin-syscalls.h to release tarball (Ben Noordhuis)

* linux: use IORING_SETUP_NO_SQARRAY when available (Ben Noordhuis)

* linux: use IORING_OP_FTRUNCATE when available (Ben Noordhuis)

* win: fix pNtQueryDirectoryFile check (Rialbat)

* win: fix WriteFile() error translation (Santiago Gimeno)

* win,fs: uv_fs_rmdir() to return ENOENT on file (Santiago Gimeno)

* win,pipe: ipc code does not support async read (Jameson Nash)

* netbsd: fix build (Adam)

* win,fs: fix bug in fs__readdir (Hüseyin Açacak)

* unix: workaround gcc bug on armv7 (Santiago Gimeno)

* unix: work around arm-linux-gnueabihf-gcc bug (Ben Noordhuis)

* unix: fix uv_tcp_keepalive in smartOS (Santiago Gimeno)

* unix: fix uv_getrusage ru_maxrss on solaris (Poul T Lomholt)


2024.09.25, Version 1.49.0 (Stable), d2e56a5e8d3e39947b78405ca6e4727c70f5568a

Changes since version 1.48.0:
Expand Down
4 changes: 0 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -343,10 +343,6 @@ after the process terminates unless the event loop is closed.

Use the `ipcrm` command to manually clear up System V resources.

## Known Issues

- A possible arm-linux-gnueabihf-gcc bug causing, sometimes, incorrect generated code on `armv7` when calling `preadv()`: https://github.com/libuv/libuv/issues/4532.

## Patches

See the [guidelines for contributing][].
Expand Down
2 changes: 1 addition & 1 deletion 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-dev], [https://github.com/libuv/libuv/issues])
AC_INIT([libuv], [1.49.3-dev], [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 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 3
#define UV_VERSION_IS_RELEASE 0
#define UV_VERSION_SUFFIX "dev"

Expand Down
132 changes: 16 additions & 116 deletions 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
6 changes: 3 additions & 3 deletions src/unix/core.c
Original file line number Diff line number Diff line change
Expand Up @@ -1034,7 +1034,7 @@ int uv_getrusage(uv_rusage_t* rusage) {
#if defined(__APPLE__)
rusage->ru_maxrss /= 1024; /* macOS and iOS report bytes. */
#elif defined(__sun)
rusage->ru_maxrss /= getpagesize() / 1024; /* Solaris reports pages. */
rusage->ru_maxrss *= getpagesize() / 1024; /* Solaris reports pages. */
#endif

return 0;
Expand Down Expand Up @@ -1882,13 +1882,13 @@ int uv__search_path(const char* prog, char* buf, size_t* buflen) {
#if defined(__linux__) || defined (__FreeBSD__)
# define uv__cpu_count(cpuset) CPU_COUNT(cpuset)
#elif defined(__NetBSD__)
static int uv__cpu_count(cpuset_t *cpuset) {
static int uv__cpu_count(cpuset_t* set) {
int rc;
cpuid_t i;

rc = 0;
for (i = 0;; i++) {
int r = cpuset_isset(cpu, set);
int r = cpuset_isset(i, set);
if (r < 0)
break;
if (r)
Expand Down
8 changes: 8 additions & 0 deletions src/unix/fs.c
Original file line number Diff line number Diff line change
Expand Up @@ -461,7 +461,12 @@ static ssize_t uv__pwritev_emul(int fd,

/* The function pointer cache is an uintptr_t because _Atomic void*
* doesn't work on macos/ios/etc...
* Disable optimization on armv7 to work around the bug described in
* https://github.com/libuv/libuv/issues/4532
*/
#if defined(__arm__) && (__ARM_ARCH == 7)
__attribute__((optimize("O0")))
#endif
static ssize_t uv__preadv_or_pwritev(int fd,
const struct iovec* bufs,
size_t nbufs,
Expand Down Expand Up @@ -1910,6 +1915,9 @@ int uv_fs_ftruncate(uv_loop_t* loop,
INIT(FTRUNCATE);
req->file = file;
req->off = off;
if (cb != NULL)
if (uv__iou_fs_ftruncate(loop, req))
return 0;
POST;
}

Expand Down
Loading

0 comments on commit 470fb79

Please sign in to comment.