summaryrefslogtreecommitdiffstats
path: root/src/network/socket/qnativesocketengine_win.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/network/socket/qnativesocketengine_win.cpp')
-rw-r--r--src/network/socket/qnativesocketengine_win.cpp17
1 files changed, 13 insertions, 4 deletions
diff --git a/src/network/socket/qnativesocketengine_win.cpp b/src/network/socket/qnativesocketengine_win.cpp
index 81bffd9..7088a57 100644
--- a/src/network/socket/qnativesocketengine_win.cpp
+++ b/src/network/socket/qnativesocketengine_win.cpp
@@ -994,9 +994,9 @@ qint64 QNativeSocketEnginePrivate::nativeWrite(const char *data, qint64 len)
{
Q_Q(QNativeSocketEngine);
qint64 ret = 0;
- // don't send more than 49152 per call to WSASendTo to avoid getting a WSAENOBUFS
+ qint64 bytesToSend = len;
+
for (;;) {
- qint64 bytesToSend = qMin<qint64>(49152, len - ret);
WSABUF buf;
buf.buf = (char*)data + ret;
buf.len = bytesToSend;
@@ -1007,15 +1007,21 @@ qint64 QNativeSocketEnginePrivate::nativeWrite(const char *data, qint64 len)
ret += qint64(bytesWritten);
+ int err;
if (socketRet != SOCKET_ERROR) {
if (ret == len)
break;
else
continue;
- } else if (WSAGetLastError() == WSAEWOULDBLOCK) {
+ } else if ((err = WSAGetLastError()) == WSAEWOULDBLOCK) {
break;
+ } else if (err == WSAENOBUFS) {
+ // this function used to not send more than 49152 per call to WSASendTo
+ // to avoid getting a WSAENOBUFS. However this is a performance regression
+ // and we think it only appears with old windows versions. We now handle the
+ // WSAENOBUFS and hope it never appears anyway.
+ // just go on, the next loop run we will try a smaller number
} else {
- int err = WSAGetLastError();
WS_ERROR_DEBUG(err);
switch (err) {
case WSAECONNRESET:
@@ -1029,6 +1035,9 @@ qint64 QNativeSocketEnginePrivate::nativeWrite(const char *data, qint64 len)
}
break;
}
+
+ // for next send:
+ bytesToSend = qMin<qint64>(49152, len - ret);
}
#if defined (QNATIVESOCKETENGINE_DEBUG)