Skip to content
Snippets Groups Projects
Commit 3ac9d6f3 authored by Oto Šťáva's avatar Oto Šťáva
Browse files

Report unanswered requests' latency always as timed-out

parent 20fea47c
No related branches found
No related tags found
1 merge request!75Support for DNS-over-QUIC
......@@ -197,11 +197,14 @@ void _output_dnssim_close_request(_output_dnssim_request_t* req)
req->state = _OUTPUT_DNSSIM_REQ_CLOSING;
req->dnssim->ongoing--;
/* Calculate latency. */
/* Calculate latency. It is set to the timeout value if the request was
* closed prematurely as well. */
uint64_t latency;
req->ended_at = uv_now(&((_output_dnssim_t*)req->dnssim)->loop);
latency = req->ended_at - req->created_at;
if (latency > req->dnssim->timeout_ms) {
if (req->answered) {
req->ended_at = uv_now(&((_output_dnssim_t*)req->dnssim)->loop);
latency = req->ended_at - req->created_at;
}
if (!req->answered || latency > req->dnssim->timeout_ms) {
req->ended_at = req->created_at + req->dnssim->timeout_ms;
latency = req->dnssim->timeout_ms;
}
......@@ -274,6 +277,7 @@ void _output_dnssim_request_answered(_output_dnssim_request_t* req, core_object_
mlassert(req, "req is nil");
mlassert(msg, "msg is nil");
req->answered = true;
req->dnssim->stats_sum->answers++;
req->stats->answers++;
if (is_early) {
......
......@@ -133,6 +133,9 @@ struct _output_dnssim_request {
_OUTPUT_DNSSIM_REQ_CLOSING
} state;
/* When `true`, the request has been answered properly. */
bool answered;
/* Statistics interval in which this request is tracked. */
output_dnssim_stats_t* stats;
};
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment