summaryrefslogtreecommitdiff
path: root/src/node.h
diff options
context:
space:
mode:
authorAnna Henningsen <anna@addaleax.net>2017-10-23 00:52:55 +0200
committerAnna Henningsen <anna@addaleax.net>2017-11-12 14:02:11 +0100
commit2cedff9c32e6260dbb655c8cf7104380f9bb2ef2 (patch)
tree292b7f1ba7e7a4cb8bb1295a7ea842de03162c57 /src/node.h
parentc7ad729072186594521f5d1033ebb101bfdd36f7 (diff)
downloadandroid-node-v8-2cedff9c32e6260dbb655c8cf7104380f9bb2ef2.tar.gz
android-node-v8-2cedff9c32e6260dbb655c8cf7104380f9bb2ef2.tar.bz2
android-node-v8-2cedff9c32e6260dbb655c8cf7104380f9bb2ef2.zip
src: cancel pending delayed platform tasks on exit
Worker threads need an event loop without active libuv handles in order to shut down. One source of handles that was previously not accounted for were delayed V8 tasks; these create timers that would be standing in the way of clearing the event loop. To solve this, keep track of the scheduled tasks in a list and close their timer handles before the corresponding isolate/loop is removed from the platform. It is not clear from the V8 documentation what the expectation is with respect to pending background tasks at the end of the isolate lifetime; however, an alternative approach of executing these scheduled tasks when flushing them led to an infinite loop of tasks scheduling each other; so it seems safe to assume that the behaviour implemented in this patch is at least acceptable. Original-PR-URL: https://github.com/ayojs/ayo/pull/120 Original-Reviewed-By: Stephen Belanger <admin@stephenbelanger.com> PR-URL: https://github.com/nodejs/node/pull/16700 Reviewed-By: James M Snell <jasnell@gmail.com>
Diffstat (limited to 'src/node.h')
-rw-r--r--src/node.h1
1 files changed, 1 insertions, 0 deletions
diff --git a/src/node.h b/src/node.h
index 0656428c0b..3cf5692f6b 100644
--- a/src/node.h
+++ b/src/node.h
@@ -214,6 +214,7 @@ class MultiIsolatePlatform : public v8::Platform {
public:
virtual ~MultiIsolatePlatform() { }
virtual void DrainBackgroundTasks(v8::Isolate* isolate) = 0;
+ virtual void CancelPendingDelayedTasks(v8::Isolate* isolate) = 0;
// These will be called by the `IsolateData` creation/destruction functions.
virtual void RegisterIsolate(IsolateData* isolate_data,