diff options
| author | Gabriel Schulhof <gabriel.schulhof@intel.com> | 2020-04-16 07:23:31 -0700 |
|---|---|---|
| committer | Gabriel Schulhof <gabriel.schulhof@intel.com> | 2020-04-16 12:52:12 -0700 |
| commit | d3d5eca657474f25fab47036fef9469efc211d8a (patch) | |
| tree | 26e7f0f73143337933b939b60ec15054683ccf46 /test/node-api/test_threadsafe_function | |
| parent | a9da65699a43f81076a1560e09ae97ad5630c35f (diff) | |
| download | node-new-d3d5eca657474f25fab47036fef9469efc211d8a.tar.gz | |
Revert "n-api: detect deadlocks in thread-safe function"
This reverts commit aeb7084fe6446350ec032e9819746126811bf44f.
The solution creates incorrect behaviour on Windows.
Re: https://github.com/nodejs/node-addon-api/pull/697#issuecomment-612993476
Signed-off-by: Gabriel Schulhof <gabriel.schulhof@intel.com>
PR-URL: https://github.com/nodejs/node/pull/32880
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Gireesh Punathil <gpunathi@in.ibm.com>
Reviewed-By: Chengzhong Wu <legendecas@gmail.com>
Reviewed-By: Gerhard Stöbich <deb2001-github@yahoo.de>
Diffstat (limited to 'test/node-api/test_threadsafe_function')
| -rw-r--r-- | test/node-api/test_threadsafe_function/binding.c | 55 | ||||
| -rw-r--r-- | test/node-api/test_threadsafe_function/binding.gyp | 5 | ||||
| -rw-r--r-- | test/node-api/test_threadsafe_function/test.js | 11 |
3 files changed, 4 insertions, 67 deletions
diff --git a/test/node-api/test_threadsafe_function/binding.c b/test/node-api/test_threadsafe_function/binding.c index 9f2fa5f9bd..c9c5261538 100644 --- a/test/node-api/test_threadsafe_function/binding.c +++ b/test/node-api/test_threadsafe_function/binding.c @@ -267,60 +267,6 @@ static napi_value StartThreadNoJsFunc(napi_env env, napi_callback_info info) { /** block_on_full */true, /** alt_ref_js_cb */true); } -static void DeadlockTestDummyMarshaller(napi_env env, - napi_value empty0, - void* empty1, - void* empty2) {} - -static napi_value TestDeadlock(napi_env env, napi_callback_info info) { - napi_threadsafe_function tsfn; - napi_status status; - napi_value async_name; - napi_value return_value; - - // Create an object to store the returned information. - NAPI_CALL(env, napi_create_object(env, &return_value)); - - // Create a string to be used with the thread-safe function. - NAPI_CALL(env, napi_create_string_utf8(env, - "N-API Thread-safe Function Deadlock Test", - NAPI_AUTO_LENGTH, - &async_name)); - - // Create the thread-safe function with a single queue slot and a single thread. - NAPI_CALL(env, napi_create_threadsafe_function(env, - NULL, - NULL, - async_name, - 1, - 1, - NULL, - NULL, - NULL, - DeadlockTestDummyMarshaller, - &tsfn)); - - // Call the threadsafe function. This should succeed and fill the queue. - NAPI_CALL(env, napi_call_threadsafe_function(tsfn, NULL, napi_tsfn_blocking)); - - // Call the threadsafe function. This should not block, but return - // `napi_would_deadlock`. We save the resulting status in an object to be - // returned. - status = napi_call_threadsafe_function(tsfn, NULL, napi_tsfn_blocking); - add_returned_status(env, - "deadlockTest", - return_value, - "Main thread would deadlock", - napi_would_deadlock, - status); - - // Clean up the thread-safe function before returning. - NAPI_CALL(env, napi_release_threadsafe_function(tsfn, napi_tsfn_release)); - - // Return the result. - return return_value; -} - // Module init static napi_value Init(napi_env env, napi_value exports) { size_t index; @@ -359,7 +305,6 @@ static napi_value Init(napi_env env, napi_value exports) { DECLARE_NAPI_PROPERTY("StopThread", StopThread), DECLARE_NAPI_PROPERTY("Unref", Unref), DECLARE_NAPI_PROPERTY("Release", Release), - DECLARE_NAPI_PROPERTY("TestDeadlock", TestDeadlock), }; NAPI_CALL(env, napi_define_properties(env, exports, diff --git a/test/node-api/test_threadsafe_function/binding.gyp b/test/node-api/test_threadsafe_function/binding.gyp index 34587eed3d..b60352e05a 100644 --- a/test/node-api/test_threadsafe_function/binding.gyp +++ b/test/node-api/test_threadsafe_function/binding.gyp @@ -2,10 +2,7 @@ 'targets': [ { 'target_name': 'binding', - 'sources': [ - 'binding.c', - '../../js-native-api/common.c' - ] + 'sources': ['binding.c'] } ] } diff --git a/test/node-api/test_threadsafe_function/test.js b/test/node-api/test_threadsafe_function/test.js index f5afe225f0..3603d79ee6 100644 --- a/test/node-api/test_threadsafe_function/test.js +++ b/test/node-api/test_threadsafe_function/test.js @@ -210,13 +210,8 @@ new Promise(function testWithoutJSMarshaller(resolve) { })) .then((result) => assert.strictEqual(result.indexOf(0), -1)) -// Start a child process to test rapid teardown. +// Start a child process to test rapid teardown .then(() => testUnref(binding.MAX_QUEUE_SIZE)) -// Start a child process with an infinite queue to test rapid teardown. -.then(() => testUnref(0)) - -// Test deadlock prevention. -.then(() => assert.deepStrictEqual(binding.TestDeadlock(), { - deadlockTest: 'Main thread would deadlock' -})); +// Start a child process with an infinite queue to test rapid teardown +.then(() => testUnref(0)); |
