From e57c1d396e140e22d5d0213f863a66540a258c9d Mon Sep 17 00:00:00 2001 From: Guillaume Friloux Date: Fri, 30 Jan 2015 11:21:03 +0100 Subject: [PATCH] ecore_con: fix _ecore_con_server_flush on Windows. @fix --- src/lib/ecore_con/ecore_con.c | 40 +++++++++++++++++++++++++++++++++++----- 1 file changed, 35 insertions(+), 5 deletions(-) diff --git a/src/lib/ecore_con/ecore_con.c b/src/lib/ecore_con/ecore_con.c index b56535c..0bf16c0 100644 --- a/src/lib/ecore_con/ecore_con.c +++ b/src/lib/ecore_con/ecore_con.c @@ -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); -- 2.7.4