From f11f1eaa4a41af596b20ab7ff65eb77d928b7eda Mon Sep 17 00:00:00 2001 From: gichan Date: Tue, 4 Oct 2022 15:47:53 +0900 Subject: [PATCH] [Edge] Fix checking return value of the poll(). Since the timeout of the poll is set to 0, let's not check the return value of 0. Signed-off-by: gichan --- src/libnnstreamer-edge/nnstreamer-edge-internal.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/libnnstreamer-edge/nnstreamer-edge-internal.c b/src/libnnstreamer-edge/nnstreamer-edge-internal.c index 459d2a0..970b9b2 100644 --- a/src/libnnstreamer-edge/nnstreamer-edge-internal.c +++ b/src/libnnstreamer-edge/nnstreamer-edge-internal.c @@ -208,8 +208,13 @@ _nns_edge_check_connection (nns_edge_conn_s * conn) poll_fd.events = POLLIN | POLLOUT | POLLPRI | POLLERR | POLLHUP; poll_fd.revents = 0; + /** Timeout zero means that the poll() is returned immediately. */ n = poll (&poll_fd, 1, 0); - if (n <= 0 || poll_fd.revents & (POLLERR | POLLHUP)) { + /** + * Return value zero indicates that the system call timed out. + * let's skip the check `n == 0` because timeout is set to 0. + */ + if (n < 0 || poll_fd.revents & (POLLERR | POLLHUP)) { nns_edge_logw ("Socket is not available, possibly closed."); return false; } -- 2.34.1