[Edge] Fix checking return value of the poll().
authorgichan <gichan2.jang@samsung.com>
Tue, 4 Oct 2022 06:47:53 +0000 (15:47 +0900)
committerjaeyun-jung <39614140+jaeyun-jung@users.noreply.github.com>
Tue, 4 Oct 2022 12:08:46 +0000 (21:08 +0900)
Since the timeout of the poll is set to 0, let's not check the return value of 0.

Signed-off-by: gichan <gichan2.jang@samsung.com>
src/libnnstreamer-edge/nnstreamer-edge-internal.c

index 459d2a0b6f7e796a730dbc8c6f6610feb3595166..970b9b2d86c6776b7d7bbfad087ffb8197a35b73 100644 (file)
@@ -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;
   }