mirror of
https://gitee.com/openharmony/commonlibrary_ets_utils
synced 2024-11-23 07:20:14 +00:00
!1641 fix worker ut crash
Merge pull request !1641 from xusen/worker_20241111_ut
This commit is contained in:
commit
767774ba21
@ -951,6 +951,11 @@ public:
|
||||
static void ClearWorkerHandle(Worker* worker)
|
||||
{
|
||||
worker->CloseHostHandle();
|
||||
if (worker->isLimitedWorker_) {
|
||||
napi_remove_env_cleanup_hook(worker->hostEnv_, Worker::LimitedWorkerHostEnvCleanCallback, worker);
|
||||
} else {
|
||||
napi_remove_env_cleanup_hook(worker->hostEnv_, Worker::WorkerHostEnvCleanCallback, worker);
|
||||
}
|
||||
}
|
||||
protected:
|
||||
static thread_local NativeEngine *engine_;
|
||||
@ -3469,7 +3474,6 @@ HWTEST_F(WorkersTest, WorkerTest046, testing::ext::TestSize.Level0)
|
||||
std::string funcName = "GlobalCall";
|
||||
napi_value cb = nullptr;
|
||||
napi_value callResult = nullptr;
|
||||
// ------- workerEnv---------
|
||||
napi_create_function(workerEnv, funcName.c_str(), funcName.size(),
|
||||
Worker::GlobalCall, worker, &cb);
|
||||
UpdateWorkerState(worker, Worker::RunnerState::RUNNING);
|
||||
@ -3489,6 +3493,7 @@ HWTEST_F(WorkersTest, WorkerTest046, testing::ext::TestSize.Level0)
|
||||
napi_get_and_clear_last_exception(env, &exception);
|
||||
ASSERT_TRUE(exception == nullptr);
|
||||
worker->EraseWorker();
|
||||
SetLimitedWorker(worker, false);
|
||||
ClearWorkerHandle(worker);
|
||||
result = Worker_Terminate(env, global);
|
||||
ASSERT_TRUE(result != nullptr);
|
||||
|
Loading…
Reference in New Issue
Block a user