Skip to content

Commit 85e60d8

Browse files
committed
Fix memory leak: dispatcher async handle
1 parent 0629955 commit 85e60d8

File tree

2 files changed

+8
-1
lines changed

2 files changed

+8
-1
lines changed

src/callbacks.cc

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -74,10 +74,16 @@ void Dispatcher::Activate() {
7474
}
7575
}
7676

77+
void Dispatcher::AsyncHandleCloseCallback(uv_handle_t *handle) {
78+
uv_async_t *a = reinterpret_cast<uv_async_t *>(handle);
79+
delete a;
80+
}
81+
7782
// Should be able to run this regardless of whether it is active or not
7883
void Dispatcher::Deactivate() {
7984
if (async) {
80-
uv_close(reinterpret_cast<uv_handle_t*>(async), NULL);
85+
uv_close(reinterpret_cast<uv_handle_t *>(async),
86+
Dispatcher::AsyncHandleCloseCallback);
8187
async = NULL;
8288
}
8389
}

src/callbacks.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,7 @@ class Dispatcher {
5353
static_cast<Dispatcher*>(async->data);
5454
dispatcher->Flush();
5555
}
56+
static void AsyncHandleCloseCallback(uv_handle_t *);
5657

5758
uv_async_t *async;
5859
};

0 commit comments

Comments
 (0)