From 3bc2c6f896f9cec4586100ab3de03cacfe330e83 Mon Sep 17 00:00:00 2001 From: theanarkh Date: Mon, 22 Aug 2022 23:38:58 +0800 Subject: [PATCH] report: add queue info for udp --- src/node_report_utils.cc | 9 ++++++++- test/report/test-report-fields.js | 15 +++++++++++++++ 2 files changed, 23 insertions(+), 1 deletion(-) create mode 100644 test/report/test-report-fields.js diff --git a/src/node_report_utils.cc b/src/node_report_utils.cc index 322bc7d5d8579a..b8f32beb203f6d 100644 --- a/src/node_report_utils.cc +++ b/src/node_report_utils.cc @@ -261,7 +261,14 @@ void WalkHandle(uv_handle_t* h, void* arg) { writer->json_keyvalue("writable", static_cast(uv_is_writable(&handle->stream))); } - + if (h->type == UV_UDP) { + writer->json_keyvalue( + "writeQueueSize", + uv_udp_get_send_queue_size(reinterpret_cast(h))); + writer->json_keyvalue( + "writeQueueCount", + uv_udp_get_send_queue_count(reinterpret_cast(h))); + } writer->json_end(); } diff --git a/test/report/test-report-fields.js b/test/report/test-report-fields.js new file mode 100644 index 00000000000000..fd8a3b7111bce9 --- /dev/null +++ b/test/report/test-report-fields.js @@ -0,0 +1,15 @@ +'use strict'; +require('../common'); +const assert = require('assert'); +const helper = require('../common/report'); +const dgram = require('dgram'); +{ + const socket = dgram.createSocket('udp4'); + const report = process.report.getReport(); + helper.validateContent(report); + const udp = report.libuv.filter((item) => item.type === 'udp'); + assert.strictEqual(udp.length > 0, true); + assert.strictEqual(udp[0].writeQueueSize, 0); + assert.strictEqual(udp[0].writeQueueCount, 0); + socket.close(); +}