Win32 performance fix (WSAEWOULDBLOCK hack issue)

This commit is contained in:
Ron Pedde 2007-10-19 03:35:24 +00:00
parent 43c234e666
commit 31bbea6109

View File

@ -2148,9 +2148,6 @@ int io_listen_accept(IO_PRIVHANDLE *phandle, IO_PRIVHANDLE *pchild,
struct sockaddr_in client; struct sockaddr_in client;
SOCKET_T child_fd; SOCKET_T child_fd;
IO_SOCKET_PRIV *priv; IO_SOCKET_PRIV *priv;
#ifdef WIN32
long blocking = 0;
#endif
ASSERT(phandle); ASSERT(phandle);
ASSERT(pchild); ASSERT(pchild);
@ -2179,12 +2176,6 @@ int io_listen_accept(IO_PRIVHANDLE *phandle, IO_PRIVHANDLE *pchild,
return FALSE; return FALSE;
} }
#ifdef WIN32
if(ioctlsocket(child_fd,FIONBIO,&blocking)) {
io_err_printf(IO_LOG_LOG,"Couldn't set socket to blocking\n");
}
#endif
io_err_printf(IO_LOG_DEBUG,"Got listen socket %d\n",child_fd); io_err_printf(IO_LOG_DEBUG,"Got listen socket %d\n",child_fd);
/* copy host, if passed a buffer */ /* copy host, if passed a buffer */
@ -2289,6 +2280,7 @@ int io_socket_write(IO_PRIVHANDLE *phandle, unsigned char *buf,uint32_t *len) {
ssize_t byteswritten=0; ssize_t byteswritten=0;
uint32_t totalbytes; uint32_t totalbytes;
unsigned char *bufp; unsigned char *bufp;
long blocking = 0;
ASSERT(phandle); ASSERT(phandle);
ASSERT(phandle->private); ASSERT(phandle->private);
@ -2321,9 +2313,11 @@ int io_socket_write(IO_PRIVHANDLE *phandle, unsigned char *buf,uint32_t *len) {
#ifdef WIN32 #ifdef WIN32
if(WSAGetLastError() == WSAEWOULDBLOCK) { if(WSAGetLastError() == WSAEWOULDBLOCK) {
io_err_printf(IO_LOG_DEBUG,"WSAEWOULDBLOCK hack\n");
byteswritten = 0; byteswritten = 0;
Sleep(50);
if(ioctlsocket(priv->fd,FIONBIO,&blocking)) {
io_err_printf(IO_LOG_LOG,"Couldn't set socket to blocking\n");
}
} }
#endif #endif
if((byteswritten == -1 ) && (errno != EINTR)) { if((byteswritten == -1 ) && (errno != EINTR)) {