Skip to content

Commit f558a76

Browse files
committed
src: remove loop_init_failed_ from Worker class
There’s no reason for this to not be stored alongside the loop data structure itself. PR-URL: #32562 Refs: #32344 Reviewed-By: Colin Ihrig <[email protected]> Reviewed-By: Denys Otrishko <[email protected]> Reviewed-By: James M Snell <[email protected]>
1 parent be87651 commit f558a76

File tree

2 files changed

+7
-5
lines changed

2 files changed

+7
-5
lines changed

src/node_worker.cc

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -135,10 +135,10 @@ class WorkerThreadData {
135135
uv_err_name_r(ret, err_buf, sizeof(err_buf));
136136
w->custom_error_ = "ERR_WORKER_INIT_FAILED";
137137
w->custom_error_str_ = err_buf;
138-
w->loop_init_failed_ = true;
139138
w->stopped_ = true;
140139
return;
141140
}
141+
loop_init_failed_ = false;
142142

143143
std::shared_ptr<ArrayBufferAllocator> allocator =
144144
ArrayBufferAllocator::Create();
@@ -194,6 +194,7 @@ class WorkerThreadData {
194194
}
195195

196196
if (isolate != nullptr) {
197+
CHECK(!loop_init_failed_);
197198
bool platform_finished = false;
198199

199200
isolate_data_.reset();
@@ -212,18 +213,20 @@ class WorkerThreadData {
212213

213214
// Wait until the platform has cleaned up all relevant resources.
214215
while (!platform_finished) {
215-
CHECK(!w_->loop_init_failed_);
216216
uv_run(&loop_, UV_RUN_ONCE);
217217
}
218218
}
219-
if (!w_->loop_init_failed_) {
219+
if (!loop_init_failed_) {
220220
CheckedUvLoopClose(&loop_);
221221
}
222222
}
223223

224+
bool loop_is_usable() const { return !loop_init_failed_; }
225+
224226
private:
225227
Worker* const w_;
226228
uv_loop_t loop_;
229+
bool loop_init_failed_ = true;
227230
DeleteFnPtr<IsolateData, FreeIsolateData> isolate_data_;
228231

229232
friend class Worker;
@@ -253,7 +256,7 @@ void Worker::Run() {
253256

254257
WorkerThreadData data(this);
255258
if (isolate_ == nullptr) return;
256-
CHECK(!data.w_->loop_init_failed_);
259+
CHECK(data.loop_is_usable());
257260

258261
Debug(this, "Starting worker with id %llu", thread_id_.id);
259262
{

src/node_worker.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,6 @@ class Worker : public AsyncWrap {
8383
bool thread_joined_ = true;
8484
const char* custom_error_ = nullptr;
8585
std::string custom_error_str_;
86-
bool loop_init_failed_ = false;
8786
int exit_code_ = 0;
8887
ThreadId thread_id_;
8988
uintptr_t stack_base_ = 0;

0 commit comments

Comments
 (0)