bpf.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Jay Jayatheerthan <jay.jayatheerthan@intel.com>
To: magnus.karlsson@intel.com, bjorn.topel@intel.com, ast@kernel.org,
	daniel@iogearbox.net, netdev@vger.kernel.org,
	jonathan.lemon@gmail.com
Cc: bpf@vger.kernel.org, Jay Jayatheerthan <jay.jayatheerthan@intel.com>
Subject: [PATCH bpf-next 2/6] samples/bpf: xdpsock: Use common code to handle signal and main exit
Date: Fri, 20 Dec 2019 14:25:26 +0530	[thread overview]
Message-ID: <20191220085530.4980-3-jay.jayatheerthan@intel.com> (raw)
In-Reply-To: <20191220085530.4980-1-jay.jayatheerthan@intel.com>

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>
---
 samples/bpf/xdpsock_user.c | 9 +++++++--
 1 file 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
@@ -209,6 +209,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;
 }
-- 
2.17.1


  parent reply	other threads:[~2019-12-20  8:55 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-12-20  8:55 [PATCH bpf-next 0/6] Enhancements to xdpsock application Jay Jayatheerthan
2019-12-20  8:55 ` [PATCH bpf-next 1/6] samples/bpf: xdpsock: Add duration option to specify how long to run Jay Jayatheerthan
2019-12-20  8:55 ` Jay Jayatheerthan [this message]
2019-12-20  8:55 ` [PATCH bpf-next 3/6] samples/bpf: xdpsock: Add option to specify batch size Jay Jayatheerthan
2019-12-20  8:55 ` [PATCH bpf-next 4/6] samples/bpf: xdpsock: Add option to specify number of packets to send Jay Jayatheerthan
2019-12-20  8:55 ` [PATCH bpf-next 5/6] samples/bpf: xdpsock: Add option to specify tx packet size Jay Jayatheerthan
2019-12-20  8:55 ` [PATCH bpf-next 6/6] samples/bpf: xdpsock: Add option to specify transmit fill pattern Jay Jayatheerthan
2019-12-20 10:04 ` [PATCH bpf-next 0/6] Enhancements to xdpsock application Björn Töpel
2019-12-21  0:12   ` Alexei Starovoitov

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20191220085530.4980-3-jay.jayatheerthan@intel.com \
    --to=jay.jayatheerthan@intel.com \
    --cc=ast@kernel.org \
    --cc=bjorn.topel@intel.com \
    --cc=bpf@vger.kernel.org \
    --cc=daniel@iogearbox.net \
    --cc=jonathan.lemon@gmail.com \
    --cc=magnus.karlsson@intel.com \
    --cc=netdev@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).