Skip to content

Commit 94d0a49

Browse files
committed
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.
1 parent 000d407 commit 94d0a49

1 file changed

Lines changed: 9 additions & 1 deletion

File tree

examples/benchmark/dtls_bench.c

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -116,7 +116,10 @@ typedef struct cfg {
116116
static double now_sec(void)
117117
{
118118
struct timespec ts;
119-
(void)clock_gettime(CLOCK_MONOTONIC, &ts);
119+
if (clock_gettime(CLOCK_MONOTONIC, &ts) != 0) {
120+
perror("clock_gettime");
121+
exit(EXIT_FAILURE);
122+
}
120123
return (double)ts.tv_sec + (double)ts.tv_nsec / 1e9;
121124
}
122125

@@ -240,6 +243,11 @@ static int parse_args(int argc, char** argv, cfg_t* c)
240243
fprintf(stderr, "MTU must be between 64 and 16384\n");
241244
return -1;
242245
}
246+
if (c->isServer && c->sinkSend) {
247+
fprintf(stderr, "warning: -z only applies to the client (the send "
248+
"side); ignoring it in server mode\n");
249+
c->sinkSend = 0;
250+
}
243251
if (c->recordSz < 1) {
244252
fprintf(stderr, "record size must be > 0\n");
245253
return -1;

0 commit comments

Comments
 (0)