From 94d0a4949755d303444e0ca2fc535622b8db6760 Mon Sep 17 00:00:00 2001 From: Juliusz Sosinowicz Date: Wed, 10 Jun 2026 02:46:02 +0000 Subject: [PATCH] Address review: harden dtls_bench time source and -z usage Fail loudly if clock_gettime() ever fails instead of computing throughput from uninitialized stack, and warn when -z is combined with -s since the sink-send only applies to the client. --- examples/benchmark/dtls_bench.c | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/examples/benchmark/dtls_bench.c b/examples/benchmark/dtls_bench.c index f523a5a9b9..346a7b3208 100644 --- a/examples/benchmark/dtls_bench.c +++ b/examples/benchmark/dtls_bench.c @@ -116,7 +116,10 @@ typedef struct cfg { static double now_sec(void) { struct timespec ts; - (void)clock_gettime(CLOCK_MONOTONIC, &ts); + if (clock_gettime(CLOCK_MONOTONIC, &ts) != 0) { + perror("clock_gettime"); + exit(EXIT_FAILURE); + } return (double)ts.tv_sec + (double)ts.tv_nsec / 1e9; } @@ -240,6 +243,11 @@ static int parse_args(int argc, char** argv, cfg_t* c) fprintf(stderr, "MTU must be between 64 and 16384\n"); return -1; } + if (c->isServer && c->sinkSend) { + fprintf(stderr, "warning: -z only applies to the client (the send " + "side); ignoring it in server mode\n"); + c->sinkSend = 0; + } if (c->recordSz < 1) { fprintf(stderr, "record size must be > 0\n"); return -1;