summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorAnna Henningsen <anna@addaleax.net>2019-01-21 15:35:17 +0100
committerAnna Henningsen <anna@addaleax.net>2019-01-24 20:36:34 +0100
commit58606140b558ea1fd4b62c45e0ac7fd76e16c7c3 (patch)
tree8eaad3894ef59501754821f7c8a4aa824499e53b /src
parent69ce113a7c793891cd1a4c7e0986a1bfb81b2f5b (diff)
downloadnode-new-58606140b558ea1fd4b62c45e0ac7fd76e16c7c3.tar.gz
report: use `uv_handle_type_name()` to get handle type
PR-URL: https://github.com/nodejs/node/pull/25610 Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: Richard Lau <riclau@uk.ibm.com>
Diffstat (limited to 'src')
-rw-r--r--src/node_report_utils.cc65
1 files changed, 7 insertions, 58 deletions
diff --git a/src/node_report_utils.cc b/src/node_report_utils.cc
index 309cf81660..2cd92599b0 100644
--- a/src/node_report_utils.cc
+++ b/src/node_report_utils.cc
@@ -105,65 +105,26 @@ void ReportPath(uv_handle_t* h, std::ostringstream& out) {
// Utility function to walk libuv handles.
void WalkHandle(uv_handle_t* h, void* arg) {
- std::string type;
+ const char* type = uv_handle_type_name(h->type);
std::ostringstream data;
JSONWriter* writer = static_cast<JSONWriter*>(arg);
uv_any_handle* handle = reinterpret_cast<uv_any_handle*>(h);
- // List all the types so we get a compile warning if we've missed one,
- // (using default: supresses the compiler warning).
switch (h->type) {
- case UV_UNKNOWN_HANDLE:
- type = "unknown";
- break;
- case UV_ASYNC:
- type = "async";
- break;
- case UV_CHECK:
- type = "check";
- break;
- case UV_FS_EVENT: {
- type = "fs_event";
- ReportPath(h, data);
- break;
- }
- case UV_FS_POLL: {
- type = "fs_poll";
+ case UV_FS_EVENT:
+ case UV_FS_POLL:
ReportPath(h, data);
break;
- }
- case UV_HANDLE:
- type = "handle";
- break;
- case UV_IDLE:
- type = "idle";
- break;
- case UV_NAMED_PIPE:
- type = "pipe";
- break;
- case UV_POLL:
- type = "poll";
- break;
- case UV_PREPARE:
- type = "prepare";
- break;
- case UV_PROCESS: {
- type = "process";
+ case UV_PROCESS:
data << "pid: " << handle->process.pid;
break;
- }
- case UV_STREAM:
- type = "stream";
- break;
- case UV_TCP: {
- type = "tcp";
+ case UV_TCP:
+ case UV_UDP:
ReportEndpoints(h, data);
break;
- }
case UV_TIMER: {
uint64_t due = handle->timer.timeout;
uint64_t now = uv_now(handle->timer.loop);
- type = "timer";
data << "repeat: " << uv_timer_get_repeat(&(handle->timer));
if (due > now) {
data << ", timeout in: " << (due - now) << " ms";
@@ -174,22 +135,15 @@ void WalkHandle(uv_handle_t* h, void* arg) {
}
case UV_TTY: {
int height, width, rc;
- type = "tty";
rc = uv_tty_get_winsize(&(handle->tty), &width, &height);
if (rc == 0) {
data << "width: " << width << ", height: " << height;
}
break;
}
- case UV_UDP: {
- type = "udp";
- ReportEndpoints(h, data);
- break;
- }
case UV_SIGNAL: {
// SIGWINCH is used by libuv so always appears.
// See http://docs.libuv.org/en/v1.x/signal.html
- type = "signal";
data << "signum: " << handle->signal.signum
#ifndef _WIN32
<< " (" << node::signo_string(handle->signal.signum) << ")"
@@ -197,12 +151,7 @@ void WalkHandle(uv_handle_t* h, void* arg) {
<< "";
break;
}
- case UV_FILE:
- type = "file";
- break;
- // We shouldn't see "max" type
- case UV_HANDLE_TYPE_MAX:
- type = "max";
+ default:
break;
}