Files
electron/patches/node/feat_add_uv_loop_watcher_queue_code.patch
electron-roller[bot] fb990ba1eb chore: bump node to v16.7.0 (main) (#30350)
* chore: bump node in DEPS to v16.6.0

* chore: bump node in DEPS to v16.6.1

* crypto: fix generateKeyPair with encoding 'jwk'

https://github.com/nodejs/node/pull/39319

* build: add library_files to gyp variables

https://github.com/nodejs/node/pull/39293

* debugger: rename internal module

https://github.com/nodejs/node/pull/39378

* chore: fixup patch indices

* deps: extract gtest source files to deps/googletest

https://github.com/nodejs/node/pull/39386

* crypto: fix generateKeyPair with encoding 'jwk'

https://github.com/nodejs/node/pull/39319

* deps: bump HdrHistogram_C to 0.11.2

https://github.com/nodejs/node/pull/39462

* fixup! deps: extract gtest source files to deps/googletest

* chore: bump node in DEPS to v16.6.2

* chore: update patches

* deps: reflect c-ares source tree

https://github.com/nodejs/node/pull/39653

* deps: update c-ares to 1.17.2

https://github.com/nodejs/node/pull/39724

* fix: _ReadBarrier undefined symbol error on WOA arm64

* chore: update patches

* chore: bump node in DEPS to v16.7.0

* deps: upgrade to libuv 1.42.0

https://github.com/nodejs/node/pull/39525

* chore: update filenames

* src: remove extra semicolons outside fns

* chore: fixup patch filenames

* chore: sort and alphabetize disabled tests

Co-authored-by: electron-roller[bot] <84116207+electron-roller[bot]@users.noreply.github.com>
Co-authored-by: Shelley Vohr <shelley.vohr@gmail.com>
Co-authored-by: PatchUp <73610968+patchup[bot]@users.noreply.github.com>
2021-08-20 19:25:50 +02:00

60 lines
2.6 KiB
Diff

From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: Shelley Vohr <shelley.vohr@gmail.com>
Date: Mon, 30 Jul 2018 10:34:54 -0700
Subject: feat: add uv_loop watcher_queue code
Electron's Node Integration works by listening to Node's backend file descriptor in a separate thread; when an event is ready the backend file descriptor will trigger a new event for it, and the main thread will then iterate the libuv loop. For certain operations (ex. adding a timeout task) the backend file descriptor isn't informed, & as a result the main thread doesn't know it needs to iterate the libuv loop so the timeout task will never execute until something else trigger a new event. This commit should be removed when https://github.com/libuv/libuv/pull/1921 is merged
diff --git a/deps/uv/include/uv.h b/deps/uv/include/uv.h
index 77503bde9f28e4769ae3832fb2117e632e9c9268..49930027bdad013d8fcbc375c534d67cc5201bc7 100644
--- a/deps/uv/include/uv.h
+++ b/deps/uv/include/uv.h
@@ -1802,6 +1802,8 @@ union uv_any_req {
struct uv_loop_s {
/* User data - use this for whatever. */
void* data;
+ /* Callback when loop's watcher queue updates. */
+ void (*on_watcher_queue_updated)(uv_loop_t*);
/* Loop reference counting. */
unsigned int active_handles;
void* handle_queue[2];
diff --git a/deps/uv/src/unix/core.c b/deps/uv/src/unix/core.c
index 71e9c525c4a77b8b5322e8516c58329100a8d951..a6425294086ff2f1435fdd6866380d3aaaf68200 100644
--- a/deps/uv/src/unix/core.c
+++ b/deps/uv/src/unix/core.c
@@ -906,8 +906,11 @@ void uv__io_start(uv_loop_t* loop, uv__io_t* w, unsigned int events) {
return;
#endif
- if (QUEUE_EMPTY(&w->watcher_queue))
+ if (QUEUE_EMPTY(&w->watcher_queue)) {
QUEUE_INSERT_TAIL(&loop->watcher_queue, &w->watcher_queue);
+ if (loop->on_watcher_queue_updated)
+ loop->on_watcher_queue_updated(loop);
+ }
if (loop->watchers[w->fd] == NULL) {
loop->watchers[w->fd] = w;
@@ -942,8 +945,11 @@ void uv__io_stop(uv_loop_t* loop, uv__io_t* w, unsigned int events) {
loop->nfds--;
}
}
- else if (QUEUE_EMPTY(&w->watcher_queue))
+ else if (QUEUE_EMPTY(&w->watcher_queue)) {
QUEUE_INSERT_TAIL(&loop->watcher_queue, &w->watcher_queue);
+ if (loop->on_watcher_queue_updated)
+ loop->on_watcher_queue_updated(loop);
+ }
}
@@ -960,6 +966,8 @@ void uv__io_close(uv_loop_t* loop, uv__io_t* w) {
void uv__io_feed(uv_loop_t* loop, uv__io_t* w) {
if (QUEUE_EMPTY(&w->pending_queue))
QUEUE_INSERT_TAIL(&loop->pending_queue, &w->pending_queue);
+ if (loop->on_watcher_queue_updated)
+ loop->on_watcher_queue_updated(loop);
}