ecore_con: fix _ecore_con_server_flush on Windows.
authorGuillaume Friloux <guillaume.friloux@gmail.com>
Fri, 30 Jan 2015 10:21:03 +0000 (11:21 +0100)
committerCedric BAIL <cedric@osg.samsung.com>
Wed, 11 Feb 2015 16:03:37 +0000 (17:03 +0100)
@fix

src/lib/ecore_con/ecore_con.c

index b56535c..0bf16c0 100644 (file)
@@ -2461,19 +2461,49 @@ _ecore_con_server_flush(Ecore_Con_Server *obj)
      }
 
    if (svr->ecs_state || (!(svr->type & ECORE_CON_SSL)))
+#ifdef _WIN32
+     count = send(svr->fd, (const char *)buf + *buf_offset, num, 0);
+#else
      count = write(svr->fd, buf + *buf_offset, num);
+#endif
    else
      count = ecore_con_ssl_server_write(obj, buf + *buf_offset, num);
 
-   if (count < 0)
+#ifdef _WIN32
+   if (count == SOCKET_ERROR)
      {
-        if ((errno != EAGAIN) && (errno != EINTR))
+        switch (WSAGetLastError())
           {
-             ecore_con_event_server_error(obj, strerror(errno));
-             _ecore_con_server_kill(obj);
+           case WSAEINTR:
+           case WSAEINPROGRESS:
+           case WSAEWOULDBLOCK:
+             break;
+           default:
+             {
+                LPTSTR s;
+
+                FormatMessage(FORMAT_MESSAGE_ALLOCATE_BUFFER |
+                              FORMAT_MESSAGE_FROM_SYSTEM     |
+                              FORMAT_MESSAGE_FROM_STRING,
+                              NULL, WSAGetLastError(), (DWORD)NULL, s, 0, NULL);
+                ecore_con_event_server_error(svr, (char *)s);
+                free(s);
+                _ecore_con_server_kill(svr);
+             }
           }
-        return;
      }
+#else
+   if (count < 0)
+     {
+         if ((errno != EAGAIN) && (errno != EINTR))
+           {
+              ecore_con_event_server_error(svr, strerror(errno));
+              _ecore_con_server_kill(svr);
+           }
+         return;
+     }
+#endif
+
 
    if (count && (!svr->ecs_state)) ecore_con_event_server_write(obj, count);