From: Maryam Tahhan Date: Tue, 7 Jun 2016 11:46:52 +0000 (+0100) Subject: dpdkstat: refactored pipe error checking X-Git-Tag: collectd-5.7.0~73^2~12 X-Git-Url: https://git.tokkee.org/?a=commitdiff_plain;h=b9c8aeaa70b15792a10a694fcb8e4304a8330715;p=collectd.git 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 --- 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)); }