ecs: fix socket write error on Windows
authorJinhyung Choi <jinh0.choi@samsung.com>
Wed, 10 Aug 2016 12:34:16 +0000 (21:34 +0900)
committerSeokYeon Hwang <syeon.hwang@samsung.com>
Fri, 12 Aug 2016 05:09:03 +0000 (14:09 +0900)
Posix API write() does not work properly,
so it is changed send().

Change-Id: I4ac7c8a725326bb419fb4494d09400381c5583d0
Signed-off-by: Jinhyung Choi <jinh0.choi@samsung.com>
tizen/src/ecs/ecs.c

index 4284583..c77b6c0 100644 (file)
@@ -91,18 +91,28 @@ int ecs_write(int fd, const uint8_t *buf, int len)
 {
     int ret, remain;
 
-    LOG_TRACE("write buflen : %d, buf : %s\n", len, (char *)buf);
+    LOG_TRACE("write fd: %d, buflen : %d, buf : %s\n", fd, len, (char *)buf);
     if (fd < 0) {
+        LOG_SEVERE("fd is corrupted : %d\n", fd);
         return -1;
     }
 
     remain = len;
     while (len > 0) {
-        ret = write(fd, buf, remain);
+        ret = send(fd, buf, remain, 0);
         if (ret < 0) {
+#ifdef _WIN32
+            errno = WSAGetLastError();
+            if (errno != WSAEWOULDBLOCK) {
+                LOG_SEVERE("write error: %d\n", errno);
+                return -1;
+            }
+#else
             if (errno != EINTR && errno != EAGAIN) {
+                LOG_SEVERE("write error: %d\n", errno);
                 return -1;
             }
+#endif
         } else if (ret == 0) {
             break;
         } else {
@@ -398,6 +408,7 @@ static void ecs_read(ECS_Client *cli)
         LOG_SEVERE("client is null.\n");
         return;
     }
+
 #ifndef __WIN32
     if (ioctl(cli->client_fd, FIONREAD, &to_read_bytes) < 0) {
         LOG_SEVERE("ioctl failed\n");