Skip to content

Commit 6952558

Browse files
vjayatheAlexei Starovoitov
authored andcommitted
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
1 parent d3f11b0 commit 6952558

1 file changed

Lines changed: 7 additions & 2 deletions

File tree

‎samples/bpf/xdpsock_user.c‎

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -209,6 +209,11 @@ static void remove_xdp_program(void)
209209
}
210210

211211
static void int_exit(int sig)
212+
{
213+
benchmark_done = true;
214+
}
215+
216+
static void xdpsock_cleanup(void)
212217
{
213218
struct xsk_umem *umem = xsks[0]->umem->umem;
214219
int i;
@@ -218,8 +223,6 @@ static void int_exit(int sig)
218223
xsk_socket__delete(xsks[i]->xsk);
219224
(void)xsk_umem__delete(umem);
220225
remove_xdp_program();
221-
222-
exit(EXIT_SUCCESS);
223226
}
224227

225228
static void __exit_with_error(int error, const char *file, const char *func,
@@ -893,5 +896,7 @@ int main(int argc, char **argv)
893896

894897
pthread_join(pt, NULL);
895898

899+
xdpsock_cleanup();
900+
896901
return 0;
897902
}

0 commit comments

Comments
 (0)