Skip to content
This repository was archived by the owner on Jun 18, 2021. It is now read-only.

Commit 218cc99

Browse files
committed
fixup: fix nits and timer handling
1 parent d9a350a commit 218cc99

File tree

1 file changed

+13
-8
lines changed

1 file changed

+13
-8
lines changed

src/node_report.cc

+13-8
Original file line numberDiff line numberDiff line change
@@ -613,18 +613,23 @@ static void walkHandle(uv_handle_t* h, void* arg) {
613613
break;
614614
}
615615
case UV_TIMER: {
616-
type = "timer";
617-
data << "repeat: " << uv_timer_get_repeat(&(handle->timer));
618-
// TODO timeout is not actually public however it is present in
619-
// all current versions of libuv. Once uv_timer_get_timeout is
616+
// TODO timeout/due is not actually public however it is present
617+
// in all current versions of libuv. Once uv_timer_get_timeout is
620618
// in a supported level of libuv we should test for it with dlsym
621619
// and use it instead, in case timeout moves in the future.
622-
data << ", timeout in: "
623620
#ifdef _WIN32
624-
<< (handle->timer.due - uv_now(handle->timer.loop)) << " ms";
621+
uint64_t due = handle->timer.due;
625622
#else
626-
<< (handle->timer.timeout - uv_now(handle->timer.loop)) << " ms";
623+
uint64_t due = handle->timer.timeout;
627624
#endif
625+
uint64_t now = uv_now(handle->timer.loop);
626+
type = "timer";
627+
data << "repeat: " << uv_timer_get_repeat(&(handle->timer));
628+
if (due > now) {
629+
data << ", timeout in: " << (due - now) << " ms";
630+
} else {
631+
data << ", timeout expired: " << (now - due) << " ms ago";
632+
}
628633
break;
629634
}
630635
case UV_TTY: {
@@ -701,7 +706,7 @@ static void walkHandle(uv_handle_t* h, void* arg) {
701706

702707
if (h->type == UV_TCP || h->type == UV_NAMED_PIPE || h->type == UV_TTY) {
703708

704-
data << ", write queue size "
709+
data << ", write queue size: "
705710
<< handle->stream.write_queue_size;
706711
data << (uv_is_readable(&handle->stream) ? ", readable" : "")
707712
<< (uv_is_writable(&handle->stream) ? ", writable": "");

0 commit comments

Comments
 (0)