From 3b46a398b1dcaad78aaf237bc3e6c200de452650 Mon Sep 17 00:00:00 2001 From: Pierre Ossman Date: Fri, 29 Apr 2016 13:37:55 +0200 Subject: [PATCH] Remove Windows 98 socket workaround We haven't supported such an old version of Windows for some time. --- common/rdr/FdOutStream.cxx | 48 +++++++++++++++++--------------------- 1 file changed, 22 insertions(+), 26 deletions(-) diff --git a/common/rdr/FdOutStream.cxx b/common/rdr/FdOutStream.cxx index f4299030..520853ff 100644 --- a/common/rdr/FdOutStream.cxx +++ b/common/rdr/FdOutStream.cxx @@ -183,38 +183,34 @@ int FdOutStream::writeWithTimeout(const void* data, int length, int timeoutms) int n; do { + fd_set fds; + struct timeval tv; + struct timeval* tvp = &tv; - do { - fd_set fds; - struct timeval tv; - struct timeval* tvp = &tv; - - if (timeoutms != -1) { - tv.tv_sec = timeoutms / 1000; - tv.tv_usec = (timeoutms % 1000) * 1000; - } else { - tvp = 0; - } + if (timeoutms != -1) { + tv.tv_sec = timeoutms / 1000; + tv.tv_usec = (timeoutms % 1000) * 1000; + } else { + tvp = NULL; + } - FD_ZERO(&fds); - FD_SET(fd, &fds); - n = select(fd+1, 0, &fds, 0, tvp); - } while (n < 0 && errno == EINTR); + FD_ZERO(&fds); + FD_SET(fd, &fds); + n = select(fd+1, 0, &fds, 0, tvp); + } while (n < 0 && errno == EINTR); - if (n < 0) throw SystemException("select",errno); + if (n < 0) + throw SystemException("select", errno); - if (n == 0) return 0; + if (n == 0) + return 0; - do { - n = ::write(fd, data, length); - } while (n < 0 && (errno == EINTR)); - - // NB: This outer loop simply fixes a broken Winsock2 EWOULDBLOCK - // condition, found only under Win98 (first edition), with slow - // network connections. Should in fact never ever happen... - } while (n < 0 && (errno == EWOULDBLOCK)); + do { + n = ::write(fd, data, length); + } while (n < 0 && (errno == EINTR)); - if (n < 0) throw SystemException("write",errno); + if (n < 0) + throw SystemException("write", errno); gettimeofday(&lastWrite, NULL); -- 2.39.5