diff options
author | Jay Jayatheerthan <jay.jayatheerthan@intel.com> | 2019-12-20 09:55:26 +0100 |
---|---|---|
committer | Alexei Starovoitov <ast@kernel.org> | 2019-12-21 01:10:39 +0100 |
commit | 695255882bdf63da240db33d0f2aa9ccca1cbe67 (patch) | |
tree | b0d2e401f806f62d302ac9f359d2090631f808aa /samples/bpf | |
parent | samples/bpf: xdpsock: Add duration option to specify how long to run (diff) | |
download | linux-695255882bdf63da240db33d0f2aa9ccca1cbe67.tar.xz linux-695255882bdf63da240db33d0f2aa9ccca1cbe67.zip |
samples/bpf: xdpsock: Use common code to handle signal and main exit
Add code to do cleanup for signals and application completion in a unified
fashion. The signal handler sets benckmark_done flag terminating the
threads. The cleanup is called before returning from main() function.
Signed-off-by: Jay Jayatheerthan <jay.jayatheerthan@intel.com>
Signed-off-by: Alexei Starovoitov <ast@kernel.org>
Link: https://lore.kernel.org/bpf/20191220085530.4980-3-jay.jayatheerthan@intel.com
Diffstat (limited to 'samples/bpf')
-rw-r--r-- | samples/bpf/xdpsock_user.c | 9 |
1 files changed, 7 insertions, 2 deletions
diff --git a/samples/bpf/xdpsock_user.c b/samples/bpf/xdpsock_user.c index e188a79a9c31..7febc3d519a1 100644 --- a/samples/bpf/xdpsock_user.c +++ b/samples/bpf/xdpsock_user.c @@ -210,6 +210,11 @@ static void remove_xdp_program(void) static void int_exit(int sig) { + benchmark_done = true; +} + +static void xdpsock_cleanup(void) +{ struct xsk_umem *umem = xsks[0]->umem->umem; int i; @@ -218,8 +223,6 @@ static void int_exit(int sig) xsk_socket__delete(xsks[i]->xsk); (void)xsk_umem__delete(umem); remove_xdp_program(); - - exit(EXIT_SUCCESS); } static void __exit_with_error(int error, const char *file, const char *func, @@ -893,5 +896,7 @@ int main(int argc, char **argv) pthread_join(pt, NULL); + xdpsock_cleanup(); + return 0; } |