Use default timeout 42/253142/3
authorHwankyu Jhun <h.jhun@samsung.com>
Fri, 5 Feb 2021 00:34:08 +0000 (09:34 +0900)
committerHwankyu Jhun <h.jhun@samsung.com>
Fri, 5 Feb 2021 00:42:18 +0000 (09:42 +0900)
if the timeout value is less than 0, the default timeout will be used.
The interval of the timeout is 5 seconds.

Change-Id: I0932c3b9572d8cbe37d83239f0e0d58baa2ac287
Signed-off-by: Hwankyu Jhun <h.jhun@samsung.com>
component_based/port/client.cc

index 47d1454354262070a89741953de2be800df5a5a3..5b60b76dccb8868e936655690bba63b67eb45e4b 100644 (file)
@@ -66,16 +66,19 @@ Client* Client::Create(const std::string& name, int timeout) {
     _W("Retry to connect to %s. count(%d)", path.c_str(), retry);
   }
 
-  if (timeout > 0) {
-    time_t sec = timeout / 1000;
-    suseconds_t usec = (timeout - sec * 1000) * 1000;
-    struct timeval tv = { sec, usec };
-    int ret = setsockopt(fd, SOL_SOCKET, SO_RCVTIMEO, &tv, sizeof(tv));
-    if (ret < 0) {
-      _E("setsockopt(SO_RCVTIMEO) is failed. fd(%d), errno(%d)", fd, errno);
-      close(fd);
-      return nullptr;
-    }
+  if (timeout <= 0) {
+    _W("Use default timeout");
+    timeout = 5000;
+  }
+
+  time_t sec = timeout / 1000;
+  suseconds_t usec = (timeout - sec * 1000) * 1000;
+  struct timeval tv = { sec, usec };
+  int ret = setsockopt(fd, SOL_SOCKET, SO_RCVTIMEO, &tv, sizeof(tv));
+  if (ret < 0) {
+    _E("setsockopt(SO_RCVTIMEO) is failed. fd(%d), errno(%d)", fd, errno);
+    close(fd);
+    return nullptr;
   }
 
   return new (std::nothrow) Client(fd);