summaryrefslogtreecommitdiff
path: root/src/js_native_api_v8.cc
diff options
context:
space:
mode:
authorGabriel Schulhof <gabriel.schulhof@intel.com>2020-04-06 10:16:15 -0700
committerGabriel Schulhof <gabriel.schulhof@intel.com>2020-04-09 02:41:28 -0700
commitaeb7084fe6446350ec032e9819746126811bf44f (patch)
treeb1173c9ecd5c049f5af7298c181e587b437cd60d /src/js_native_api_v8.cc
parentb82d72c199e70a0c9fbeb6c06715ef8120b3de2f (diff)
downloadnode-new-aeb7084fe6446350ec032e9819746126811bf44f.tar.gz
n-api: detect deadlocks in thread-safe function
We introduce status `napi_would_deadlock` to be used as a return status by `napi_call_threadsafe_function` if the call is made with `napi_tsfn_blocking` on the main thread and the queue is full. PR-URL: https://github.com/nodejs/node/pull/32689 Fixes: https://github.com/nodejs/node/issues/32615 Signed-off-by: Gabriel Schulhof <gabriel.schulhof@intel.com> Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Anna Henningsen <anna@addaleax.net> Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: David Carlier <devnexen@gmail.com> Reviewed-By: Chengzhong Wu <legendecas@gmail.com> Reviewed-By: Michael Dawson <michael_dawson@ca.ibm.com>
Diffstat (limited to 'src/js_native_api_v8.cc')
-rw-r--r--src/js_native_api_v8.cc3
1 files changed, 2 insertions, 1 deletions
diff --git a/src/js_native_api_v8.cc b/src/js_native_api_v8.cc
index 422eff6d7c..ef25c92e06 100644
--- a/src/js_native_api_v8.cc
+++ b/src/js_native_api_v8.cc
@@ -740,6 +740,7 @@ const char* error_messages[] = {nullptr,
"A date was expected",
"An arraybuffer was expected",
"A detachable arraybuffer was expected",
+ "Main thread would deadlock",
};
napi_status napi_get_last_error_info(napi_env env,
@@ -751,7 +752,7 @@ napi_status napi_get_last_error_info(napi_env env,
// message in the `napi_status` enum each time a new error message is added.
// We don't have a napi_status_last as this would result in an ABI
// change each time a message was added.
- const int last_status = napi_detachable_arraybuffer_expected;
+ const int last_status = napi_would_deadlock;
static_assert(
NAPI_ARRAYSIZE(error_messages) == last_status + 1,