Handle EINTR error 90/309490/1
authorHwankyu Jhun <h.jhun@samsung.com>
Thu, 11 Apr 2024 10:19:47 +0000 (19:19 +0900)
committerHwankyu Jhun <h.jhun@samsung.com>
Thu, 11 Apr 2024 10:19:47 +0000 (19:19 +0900)
Currently, the socket mode is blocking. We should handle EINTR error to
receive the data properly.

Change-Id: I3d3687658a0d2f2349e22bfc5494cdea502123f8
Signed-off-by: Hwankyu Jhun <h.jhun@samsung.com>
src/client-socket-internal.cc
src/port-internal.cc

index 08b2ae9a3b69b389eba21c5a00d8a2fd86125901..241e52d99a3c71cc3b4121f219f31f5e280c9438 100644 (file)
@@ -115,6 +115,11 @@ int ClientSocket::Receive(void* buf, unsigned int size) {
       return -EIO;  // LCOV_EXCL_STOP
     }
 
+    if (errno == EINTR) {
+      usleep(100 * 1000);
+      continue;
+    }
+
     if (bytes < 0)
       return -errno;  // LCOV_EXCL_LINE
 
index a8c6ec75d6bbbf989addf3a2f15811e36b9dc2a2..c32d5fb13371cc20f711873e702fcab6e895f7c3 100644 (file)
@@ -147,7 +147,10 @@ int Port::Read(void* buf, unsigned int size) {
     }
 
     if (nb == -1) {
-      if (errno == EINTR) continue;
+      if (errno == EINTR) {
+        usleep(100 * 1000);
+        continue;
+      }
 
       _E("read_socket: ...error fd %d: errno %d\n", fd_, errno);
       fcntl(fd_, F_SETFL, flags);