Skip to content

Commit

Permalink
async: remove racey uv_ref()/uv_unref()
Browse files Browse the repository at this point in the history
`uv_ref()` can't be called from the non-event-loop thread. Furthermore,
it is not necessary in `async.h`, because open `uv_async_t` is already
holding the event loop from exiting.

See: #702
  • Loading branch information
indutny committed Sep 6, 2016
1 parent 7322ea7 commit 553c6ea
Showing 1 changed file with 0 additions and 11 deletions.
11 changes: 0 additions & 11 deletions src/async.h
Original file line number Diff line number Diff line change
Expand Up @@ -36,11 +36,6 @@ template <class Item, class Parent> class Async {
rows.swap(async->data);
NODE_SQLITE3_MUTEX_UNLOCK(&async->mutex)
for (unsigned int i = 0, size = rows.size(); i < size; i++) {
#if NODE_VERSION_AT_LEAST(0, 7, 9)
uv_unref((uv_handle_t *)&async->watcher);
#else
uv_unref(uv_default_loop());
#endif
async->callback(async->parent, rows[i]);
}
}
Expand All @@ -61,12 +56,6 @@ template <class Item, class Parent> class Async {
}

void add(Item* item) {
// Make sure node runs long enough to deliver the messages.
#if NODE_VERSION_AT_LEAST(0, 7, 9)
uv_ref((uv_handle_t *)&watcher);
#else
uv_ref(uv_default_loop());
#endif
NODE_SQLITE3_MUTEX_LOCK(&mutex);
data.push_back(item);
NODE_SQLITE3_MUTEX_UNLOCK(&mutex)
Expand Down

0 comments on commit 553c6ea

Please sign in to comment.