GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — src: do not persist fs_poll handle in stat_watcher · nodejs/node@4f01168

File tree

Expand file treeCollapse file tree
Open diff view settings
Filter options
  • src
    • node_stat_watcher.cc
Expand file treeCollapse file tree
Open diff view settings
Collapse file

‎src/node_stat_watcher.cc‎

Copy file name to clipboardExpand all lines: src/node_stat_watcher.cc
+8-8Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -77,19 +77,15 @@ void StatWatcher::Initialize(Environment* env, Local<Object> target) {
7777

7878
StatWatcher::StatWatcher(Environment* env, Local<Object> wrap, bool use_bigint)
7979
: AsyncWrap(env, wrap, AsyncWrap::PROVIDER_STATWATCHER),
80-
watcher_(new uv_fs_poll_t),
80+
watcher_(nullptr),
8181
use_bigint_(use_bigint) {
8282
MakeWeak();
83-
uv_fs_poll_init(env->event_loop(), watcher_);
84-
watcher_->data = static_cast<void*>(this);
8583
}
8684

8785

8886
StatWatcher::~StatWatcher() {
89-
if (IsActive()) {
87+
if (IsActive())
9088
Stop();
91-
}
92-
env()->CloseHandle(watcher_, [](uv_fs_poll_t* handle) { delete handle; });
9389
}
9490

9591

@@ -123,7 +119,7 @@ void StatWatcher::New(const FunctionCallbackInfo<Value>& args) {
123119
}
124120

125121
bool StatWatcher::IsActive() {
126-
return uv_is_active(reinterpret_cast<uv_handle_t*>(watcher_)) != 0;
122+
return watcher_ != nullptr;
127123
}
128124

129125
void StatWatcher::IsActive(const v8::FunctionCallbackInfo<v8::Value>& args) {
@@ -156,6 +152,9 @@ void StatWatcher::Start(const FunctionCallbackInfo<Value>& args) {
156152
CHECK(args[2]->IsUint32());
157153
const uint32_t interval = args[2].As<Uint32>()->Value();
158154

155+
wrap->watcher_ = new uv_fs_poll_t();
156+
CHECK_EQ(0, uv_fs_poll_init(wrap->env()->event_loop(), wrap->watcher_));
157+
wrap->watcher_->data = static_cast<void*>(wrap);
159158
// Safe, uv_ref/uv_unref are idempotent.
160159
if (persistent)
161160
uv_ref(reinterpret_cast<uv_handle_t*>(wrap->watcher_));
@@ -187,7 +186,8 @@ void StatWatcher::Stop(const FunctionCallbackInfo<Value>& args) {
187186

188187

189188
void StatWatcher::Stop() {
190-
uv_fs_poll_stop(watcher_);
189+
env()->CloseHandle(watcher_, [](uv_fs_poll_t* handle) { delete handle; });
190+
watcher_ = nullptr;
191191
MakeWeak();
192192
}
193193

0 commit comments

Comments
0 (0)
You are visitor 01402775 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.