diff options
author | Anna Henningsen <anna@addaleax.net> | 2020-05-18 07:50:14 +0300 |
---|---|---|
committer | Ruben Bridgewater <ruben@bridgewater.de> | 2020-05-23 18:45:42 +0300 |
commit | b18d8dde847e1bff188c6cfb2d65a96209146c2c (patch) | |
tree | 1c33882dfbdeeb7fadebbac62a5d84bb20d6b9fc /doc/api/n-api.md | |
parent | f14229e7040b376b4934f8d0c98520bb3ed798fc (diff) |
Revert "n-api: detect deadlocks in thread-safe function"
This reverts commit d26ca06c16f497ffa5ac4845a27922d5058a9318 because
it breaks running the tests in debug mode, as
`v8::Isolate::GetCurrent()` is not allowed if no `Isolate` is active
on the current thread.
Refs: https://github.com/nodejs/node/pull/33276
Refs: https://github.com/nodejs/node/pull/32860
PR-URL: https://github.com/nodejs/node/pull/33453
Reviewed-By: Daniel Bevenius <daniel.bevenius@gmail.com>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: David Carlier <devnexen@gmail.com>
Reviewed-By: Gireesh Punathil <gpunathi@in.ibm.com>
Reviewed-By: Gabriel Schulhof <gabriel.schulhof@intel.com>
Diffstat (limited to 'doc/api/n-api.md')
-rw-r--r-- | doc/api/n-api.md | 31 |
1 files changed, 13 insertions, 18 deletions
diff --git a/doc/api/n-api.md b/doc/api/n-api.md index 2af31d3de03..f654685a040 100644 --- a/doc/api/n-api.md +++ b/doc/api/n-api.md @@ -462,7 +462,7 @@ typedef enum { napi_date_expected, napi_arraybuffer_expected, napi_detachable_arraybuffer_expected, - napi_would_deadlock, + napi_would_deadlock, /* unused */ } napi_status; ``` @@ -5124,18 +5124,9 @@ preventing data from being successfully added to the queue. If set to `napi_call_threadsafe_function()` never blocks if the thread-safe function was created with a maximum queue size of 0. -As a special case, when `napi_call_threadsafe_function()` is called from a -JavaScript thread, it will return `napi_would_deadlock` if the queue is full -and it was called with `napi_tsfn_blocking`. The reason for this is that the -JavaScript thread is responsible for removing items from the queue, thereby -reducing their number. Thus, if it waits for room to become available on the -queue, then it will deadlock. - -`napi_call_threadsafe_function()` will also return `napi_would_deadlock` if the -thread-safe function created on one JavaScript thread is called from another -JavaScript thread. The reason for this is to prevent a deadlock arising from the -possibility that the two JavaScript threads end up waiting on one another, -thereby both deadlocking. +`napi_call_threadsafe_function()` should not be called with `napi_tsfn_blocking` +from a JavaScript thread, because, if the queue is full, it may cause the +JavaScript thread to deadlock. The actual call into JavaScript is controlled by the callback given via the `call_js_cb` parameter. `call_js_cb` is invoked on the main thread once for each @@ -5276,6 +5267,10 @@ This API may be called from any thread which makes use of `func`. added: v10.6.0 napiVersion: 4 changes: + - version: REPLACEME + pr-url: https://github.com/nodejs/node/pull/33453 + description: > + Support for `napi_would_deadlock` has been reverted. - version: v14.1.0 pr-url: https://github.com/nodejs/node/pull/32689 description: > @@ -5298,13 +5293,13 @@ napi_call_threadsafe_function(napi_threadsafe_function func, `napi_tsfn_nonblocking` to indicate that the call should return immediately with a status of `napi_queue_full` whenever the queue is full. -This API will return `napi_would_deadlock` if called with `napi_tsfn_blocking` -from the main thread and the queue is full. +This API should not be called with `napi_tsfn_blocking` from a JavaScript +thread, because, if the queue is full, it may cause the JavaScript thread to +deadlock. This API will return `napi_closing` if `napi_release_threadsafe_function()` was -called with `abort` set to `napi_tsfn_abort` from any thread. - -The value is only added to the queue if the API returns `napi_ok`. +called with `abort` set to `napi_tsfn_abort` from any thread. The value is only +added to the queue if the API returns `napi_ok`. This API may be called from any thread which makes use of `func`. |