From: Michael Tremer Date: Thu, 4 Feb 2021 15:59:45 +0000 (+0000) Subject: Avoid closing timerfd when it has never been opened X-Git-Tag: 0.2.0~20 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=52386fb872816c8f30cb9ad1eccbb094c6c06be7;p=fireperf.git Avoid closing timerfd when it has never been opened Signed-off-by: Michael Tremer --- diff --git a/src/main.c b/src/main.c index 7d16aa9..1e1f808 100644 --- a/src/main.c +++ b/src/main.c @@ -253,6 +253,7 @@ int main(int argc, char* argv[]) { }; struct fireperf_stats stats = { 0 }; int r; + int timerfd = -1; // Parse command line r = parse_argv(argc, argv, &conf); @@ -276,7 +277,7 @@ int main(int argc, char* argv[]) { } // Create timerfd() to print statistics - int timerfd = timerfd_create(CLOCK_MONOTONIC, TFD_NONBLOCK|TFD_CLOEXEC); + timerfd = timerfd_create(CLOCK_MONOTONIC, TFD_NONBLOCK|TFD_CLOEXEC); if (timerfd < 0) { ERROR(&conf, "timerfd_create() failed: %s\n", strerror(errno)); r = 1; @@ -330,7 +331,6 @@ ERROR: return r; } - int fireperf_dump_stats(struct fireperf_config* conf, struct fireperf_stats* stats, int mode) { struct timespec now;