Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Misc cleanup of node_report_utils.cc #25960

Merged
merged 3 commits into from
Feb 8, 2019
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
34 changes: 12 additions & 22 deletions src/node_report_utils.cc
Original file line number Diff line number Diff line change
Expand Up @@ -16,14 +16,12 @@ void ReportEndpoints(uv_handle_t* h, std::ostringstream& out) {
int rc = -1;

switch (h->type) {
case UV_UDP: {
case UV_UDP:
rc = uv_udp_getsockname(&(handle->udp), addr, &addr_size);
break;
}
case UV_TCP: {
case UV_TCP:
rc = uv_tcp_getsockname(&(handle->tcp), addr, &addr_size);
break;
}
default:
break;
}
Expand Down Expand Up @@ -70,28 +68,24 @@ void ReportPath(uv_handle_t* h, std::ostringstream& out) {
uv_any_handle* handle = reinterpret_cast<uv_any_handle*>(h);
// First call to get required buffer size.
switch (h->type) {
case UV_FS_EVENT: {
case UV_FS_EVENT:
rc = uv_fs_event_getpath(&(handle->fs_event), buffer.data, &size);
break;
}
case UV_FS_POLL: {
case UV_FS_POLL:
rc = uv_fs_poll_getpath(&(handle->fs_poll), buffer.data, &size);
break;
}
default:
break;
}
if (rc == UV_ENOBUFS) {
buffer = MallocedBuffer<char>(size);
switch (h->type) {
case UV_FS_EVENT: {
case UV_FS_EVENT:
rc = uv_fs_event_getpath(&(handle->fs_event), buffer.data, &size);
break;
}
case UV_FS_POLL: {
case UV_FS_POLL:
rc = uv_fs_poll_getpath(&(handle->fs_poll), buffer.data, &size);
break;
}
default:
break;
}
Expand Down Expand Up @@ -141,16 +135,12 @@ void WalkHandle(uv_handle_t* h, void* arg) {
}
break;
}
case UV_SIGNAL: {
case UV_SIGNAL:
// SIGWINCH is used by libuv so always appears.
// See http://docs.libuv.org/en/v1.x/signal.html
data << "signum: " << handle->signal.signum
#ifndef _WIN32
<< " (" << node::signo_string(handle->signal.signum) << ")"
#endif
<< "";
data << "signum: " << handle->signal.signum << " (" <<
node::signo_string(handle->signal.signum) << ")";
break;
}
default:
break;
}
Expand All @@ -173,12 +163,12 @@ void WalkHandle(uv_handle_t* h, void* arg) {
<< ", recv buffer size: " << recv_size;
}

#ifndef _WIN32
if (h->type == UV_TCP || h->type == UV_NAMED_PIPE || h->type == UV_TTY ||
h->type == UV_UDP || h->type == UV_POLL) {
uv_os_fd_t fd_v;
int rc = uv_fileno(h, &fd_v);
// uv_os_fd_t is an int on Unix and HANDLE on Windows.
#ifndef _WIN32

if (rc == 0) {
switch (fd_v) {
case 0:
Expand All @@ -195,8 +185,8 @@ void WalkHandle(uv_handle_t* h, void* arg) {
break;
}
}
#endif
}
#endif

if (h->type == UV_TCP || h->type == UV_NAMED_PIPE || h->type == UV_TTY) {
data << ", write queue size: " << handle->stream.write_queue_size;
Expand Down