]> git.ipfire.org Git - fireperf.git/commitdiff
Avoid closing timerfd when it has never been opened
authorMichael Tremer <michael.tremer@ipfire.org>
Thu, 4 Feb 2021 15:59:45 +0000 (15:59 +0000)
committerMichael Tremer <michael.tremer@ipfire.org>
Thu, 4 Feb 2021 15:59:45 +0000 (15:59 +0000)
Signed-off-by: Michael Tremer <michael.tremer@ipfire.org>
src/main.c

index 7d16aa9545a20dfad624ad8329e48ed4a96a367b..1e1f80827acf2ded9293eb716795c9ca8d318051 100644 (file)
@@ -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;