Skip to content

Commit 4df3ac2

Browse files
addaleaxtargos
authored andcommitted
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 0faaa7c commit 4df3ac2

File tree

2 files changed

+7
-5
lines changed

2 files changed

+7
-5
lines changed

src/node_worker.cc

+7-4
Original file line numberDiff line numberDiff line change
@@ -140,10 +140,10 @@ class WorkerThreadData {
140140
uv_err_name_r(ret, err_buf, sizeof(err_buf));
141141
w->custom_error_ = "ERR_WORKER_INIT_FAILED";
142142
w->custom_error_str_ = err_buf;
143-
w->loop_init_failed_ = true;
144143
w->stopped_ = true;
145144
return;
146145
}
146+
loop_init_failed_ = false;
147147

148148
std::shared_ptr<ArrayBufferAllocator> allocator =
149149
ArrayBufferAllocator::Create();
@@ -199,6 +199,7 @@ class WorkerThreadData {
199199
}
200200

201201
if (isolate != nullptr) {
202+
CHECK(!loop_init_failed_);
202203
bool platform_finished = false;
203204

204205
isolate_data_.reset();
@@ -217,18 +218,20 @@ class WorkerThreadData {
217218

218219
// Wait until the platform has cleaned up all relevant resources.
219220
while (!platform_finished) {
220-
CHECK(!w_->loop_init_failed_);
221221
uv_run(&loop_, UV_RUN_ONCE);
222222
}
223223
}
224-
if (!w_->loop_init_failed_) {
224+
if (!loop_init_failed_) {
225225
CheckedUvLoopClose(&loop_);
226226
}
227227
}
228228

229+
bool loop_is_usable() const { return !loop_init_failed_; }
230+
229231
private:
230232
Worker* const w_;
231233
uv_loop_t loop_;
234+
bool loop_init_failed_ = true;
232235
DeleteFnPtr<IsolateData, FreeIsolateData> isolate_data_;
233236

234237
friend class Worker;
@@ -258,7 +261,7 @@ void Worker::Run() {
258261

259262
WorkerThreadData data(this);
260263
if (isolate_ == nullptr) return;
261-
CHECK(!data.w_->loop_init_failed_);
264+
CHECK(data.loop_is_usable());
262265

263266
Debug(this, "Starting worker with id %llu", thread_id_);
264267
{

src/node_worker.h

-1
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,6 @@ class Worker : public AsyncWrap {
8686
bool thread_joined_ = true;
8787
const char* custom_error_ = nullptr;
8888
std::string custom_error_str_;
89-
bool loop_init_failed_ = false;
9089
int exit_code_ = 0;
9190
uint64_t thread_id_ = -1;
9291
uintptr_t stack_base_ = 0;

0 commit comments

Comments
 (0)