summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMarkus Goetz <Markus.Goetz@nokia.com>2010-01-19 09:25:53 (GMT)
committerMarkus Goetz <Markus.Goetz@nokia.com>2010-01-19 10:33:23 (GMT)
commit26a0d799cd6e987666228afa9cfe017d226c4fdd (patch)
tree19fdecc382f2bff3b1ff4d428ae8c593ae56d8d1
parented5fed36f38b9de0452cc427db679266d249f216 (diff)
downloadQt-26a0d799cd6e987666228afa9cfe017d226c4fdd.zip
Qt-26a0d799cd6e987666228afa9cfe017d226c4fdd.tar.gz
Qt-26a0d799cd6e987666228afa9cfe017d226c4fdd.tar.bz2
QNativeSocketEngine windows: Fix performance degredation in write()
We had an hack in the code that chunked writes. Try to avoid this since the hack is probably only needed for older windows versions. Task-number: QTBUG-7344 Reviewed-by: Peter Hartmann
-rw-r--r--src/network/socket/qnativesocketengine_win.cpp13
1 files changed, 11 insertions, 2 deletions
diff --git a/src/network/socket/qnativesocketengine_win.cpp b/src/network/socket/qnativesocketengine_win.cpp
index 81bffd9..8257545 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;
@@ -1014,6 +1014,12 @@ qint64 QNativeSocketEnginePrivate::nativeWrite(const char *data, qint64 len)
continue;
} else if (WSAGetLastError() == WSAEWOULDBLOCK) {
break;
+ } else if (WSAGetLastError() == 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);
@@ -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)