diff options
author | Gabriel Schulhof <gabriel.schulhof@intel.com> | 2020-04-06 20:16:15 +0300 |
---|---|---|
committer | Gabriel Schulhof <gabriel.schulhof@intel.com> | 2020-04-19 20:07:00 +0300 |
commit | d26ca06c16f497ffa5ac4845a27922d5058a9318 (patch) | |
tree | 1ebcc99e42c0cb6f3d98fc52d801f6abc81ed0d6 /src/js_native_api_types.h | |
parent | 250060a0509204031ae068a5aa90e3481c1a78ae (diff) |
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.
Fixes: https://github.com/nodejs/node/issues/32615
Signed-off-by: Gabriel Schulhof <gabriel.schulhof@intel.com>
PR-URL: https://github.com/nodejs/node/pull/32860
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
Reviewed-By: Michael Dawson <michael_dawson@ca.ibm.com>
Reviewed-By: Zeyu Yang <himself65@outlook.com>
Diffstat (limited to 'src/js_native_api_types.h')
-rw-r--r-- | src/js_native_api_types.h | 10 |
1 files changed, 7 insertions, 3 deletions
diff --git a/src/js_native_api_types.h b/src/js_native_api_types.h index 7a49fc9f719..c32c71c4d39 100644 --- a/src/js_native_api_types.h +++ b/src/js_native_api_types.h @@ -82,11 +82,15 @@ typedef enum { napi_date_expected, napi_arraybuffer_expected, napi_detachable_arraybuffer_expected, + napi_would_deadlock } napi_status; // Note: when adding a new enum value to `napi_status`, please also update -// `const int last_status` in `napi_get_last_error_info()' definition, -// in file js_native_api_v8.cc. Please also update the definition of -// `napi_status` in doc/api/n-api.md to reflect the newly added value(s). +// * `const int last_status` in the definition of `napi_get_last_error_info()' +// in file js_native_api_v8.cc. +// * `const char* error_messages[]` in file js_native_api_v8.cc with a brief +// message explaining the error. +// * the definition of `napi_status` in doc/api/n-api.md to reflect the newly +// added value(s). typedef napi_value (*napi_callback)(napi_env env, napi_callback_info info); |