From b9c8aeaa70b15792a10a694fcb8e4304a8330715 Mon Sep 17 00:00:00 2001 From: Maryam Tahhan Date: Tue, 7 Jun 2016 12:46:52 +0100 Subject: [PATCH] dpdkstat: refactored pipe error checking This commit cleans up and fixes the pipe creation, and improves the error checking. Change-Id: I53de4a7ff450aea349971f58fe5cce8904da1e89 Signed-off-by: Harry van Haaren --- src/dpdkstat.c | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/src/dpdkstat.c b/src/dpdkstat.c index 903523f2..e5aafdeb 100644 --- a/src/dpdkstat.c +++ b/src/dpdkstat.c @@ -342,11 +342,16 @@ static int dpdk_helper_spawn(enum DPDK_HELPER_ACTION action) return -1; } - int pipe0_flags = fcntl(g_configuration->helper_pipes[1], F_GETFL, 0); - int pipe1_flags = fcntl(g_configuration->helper_pipes[0], F_GETFL, 0); - int p1err = fcntl(g_configuration->helper_pipes[1], F_SETFL, pipe1_flags | O_NONBLOCK); - int p2err = fcntl(g_configuration->helper_pipes[0], F_SETFL, pipe0_flags | O_NONBLOCK); - if (pipe0_flags == -1 || pipe1_flags == -1 || p1err == -1 || p2err == -1) { + int pipe0_flags = fcntl(g_configuration->helper_pipes[0], F_GETFL, 0); + int pipe1_flags = fcntl(g_configuration->helper_pipes[1], F_GETFL, 0); + if (pipe0_flags == -1 || pipe1_flags == -1) { + ERROR("dpdkstat: error setting up pipe flags: %s\n", strerror(errno)); + } + int pipe0_err = fcntl(g_configuration->helper_pipes[0], F_SETFL, pipe1_flags + | O_NONBLOCK); + int pipe1_err = fcntl(g_configuration->helper_pipes[1], F_SETFL, pipe0_flags + | O_NONBLOCK); + if (pipe0_err == -1 || pipe1_err == -1) { ERROR("dpdkstat: error setting up pipes: %s\n", strerror(errno)); } -- 2.11.0