diff options
author | Anna Henningsen <anna@addaleax.net> | 2019-12-06 02:59:19 +0300 |
---|---|---|
committer | Rich Trott <rtrott@gmail.com> | 2019-12-08 08:30:39 +0300 |
commit | d1f4936fab0a57282581da65d82411db96eb4108 (patch) | |
tree | 47a6595529f7fef36242074f011c32288fb2275b /src/debug_utils.cc | |
parent | a2cfb7dd8664c73385758c98966823fb80144d2c (diff) |
src: improve checked uv loop close output
Addon developers may run into this when not closing libuv handles
inside Workers.
Previously, output may have included unhelpful statements such as
`uv loop at ... has 0 active handles`, which may sound like
everything’s supposed to be fine actually.
So, instead of printing the active handle count, print the total
handle count and mark active handles individually.
Also, fix the test for this to work properly and make sure that
parsing finishes properly.
PR-URL: https://github.com/nodejs/node/pull/30814
Reviewed-By: Richard Lau <riclau@uk.ibm.com>
Reviewed-By: Rich Trott <rtrott@gmail.com>
Reviewed-By: David Carlier <devnexen@gmail.com>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
Diffstat (limited to 'src/debug_utils.cc')
-rw-r--r-- | src/debug_utils.cc | 13 |
1 files changed, 9 insertions, 4 deletions
diff --git a/src/debug_utils.cc b/src/debug_utils.cc index 4e52feb69d9..6168d9a968b 100644 --- a/src/debug_utils.cc +++ b/src/debug_utils.cc @@ -292,19 +292,21 @@ void PrintLibuvHandleInformation(uv_loop_t* loop, FILE* stream) { struct Info { std::unique_ptr<NativeSymbolDebuggingContext> ctx; FILE* stream; + size_t num_handles; }; - Info info { NativeSymbolDebuggingContext::New(), stream }; + Info info { NativeSymbolDebuggingContext::New(), stream, 0 }; - fprintf(stream, "uv loop at [%p] has %d active handles\n", - loop, loop->active_handles); + fprintf(stream, "uv loop at [%p] has open handles:\n", loop); uv_walk(loop, [](uv_handle_t* handle, void* arg) { Info* info = static_cast<Info*>(arg); NativeSymbolDebuggingContext* sym_ctx = info->ctx.get(); FILE* stream = info->stream; + info->num_handles++; - fprintf(stream, "[%p] %s\n", handle, uv_handle_type_name(handle->type)); + fprintf(stream, "[%p] %s%s\n", handle, uv_handle_type_name(handle->type), + uv_is_active(handle) ? " (active)" : ""); void* close_cb = reinterpret_cast<void*>(handle->close_cb); fprintf(stream, "\tClose callback: %p %s\n", @@ -328,6 +330,9 @@ void PrintLibuvHandleInformation(uv_loop_t* loop, FILE* stream) { first_field, sym_ctx->LookupSymbol(first_field).Display().c_str()); } }, &info); + + fprintf(stream, "uv loop at [%p] has %zu open handles in total\n", + loop, info.num_handles); } std::vector<std::string> NativeSymbolDebuggingContext::GetLoadedLibraries() { |