Skip to content

Commit

Permalink
report: add queue info for udp
Browse files Browse the repository at this point in the history
  • Loading branch information
theanarkh committed Aug 22, 2022
1 parent 937520a commit 3bc2c6f
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 1 deletion.
9 changes: 8 additions & 1 deletion src/node_report_utils.cc
Original file line number Diff line number Diff line change
Expand Up @@ -261,7 +261,14 @@ void WalkHandle(uv_handle_t* h, void* arg) {
writer->json_keyvalue("writable",
static_cast<bool>(uv_is_writable(&handle->stream)));
}

if (h->type == UV_UDP) {
writer->json_keyvalue(
"writeQueueSize",
uv_udp_get_send_queue_size(reinterpret_cast<uv_udp_t*>(h)));
writer->json_keyvalue(
"writeQueueCount",
uv_udp_get_send_queue_count(reinterpret_cast<uv_udp_t*>(h)));
}
writer->json_end();
}

Expand Down
15 changes: 15 additions & 0 deletions test/report/test-report-fields.js
Original file line number Diff line number Diff line change
@@ -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();
}

0 comments on commit 3bc2c6f

Please sign in to comment.