diff options
author | Peter Hartmann <peter.hartmann@nokia.com> | 2009-09-15 11:04:11 (GMT) |
---|---|---|
committer | Peter Hartmann <peter.hartmann@nokia.com> | 2009-09-15 12:25:11 (GMT) |
commit | 14b0db1a93deb0fd13dd27c1d6bda9d78b544b68 (patch) | |
tree | b765b6154906776c06e91cd7ed9818ed020b2797 /src/network/socket | |
parent | d9597782202b2be117874330ceee95040c7365cb (diff) | |
download | Qt-14b0db1a93deb0fd13dd27c1d6bda9d78b544b68.zip Qt-14b0db1a93deb0fd13dd27c1d6bda9d78b544b68.tar.gz Qt-14b0db1a93deb0fd13dd27c1d6bda9d78b544b68.tar.bz2 |
QNativeSocketEngine on Windows: don't bail out on non-fatal error
receiving the WSAEMSGSIZE error means we could not read all the data
because the buffer was too small, but still we should return the number
of bytes read and not return -1
Reviewed-by: Marius Storm-Olsen
Diffstat (limited to 'src/network/socket')
-rw-r--r-- | src/network/socket/qnativesocketengine_win.cpp | 12 |
1 files changed, 9 insertions, 3 deletions
diff --git a/src/network/socket/qnativesocketengine_win.cpp b/src/network/socket/qnativesocketengine_win.cpp index 3478130..63fe78e 100644 --- a/src/network/socket/qnativesocketengine_win.cpp +++ b/src/network/socket/qnativesocketengine_win.cpp @@ -917,9 +917,15 @@ qint64 QNativeSocketEnginePrivate::nativeReceiveDatagram(char *data, qint64 maxL int wsaRet = ::WSARecvFrom(socketDescriptor, &buf, 1, &bytesRead, &flags, &aa.a, &sz,0,0); if (wsaRet == SOCKET_ERROR) { int err = WSAGetLastError(); - WS_ERROR_DEBUG(err); - setError(QAbstractSocket::NetworkError, ReceiveDatagramErrorString); - ret = -1; + if (err == WSAEMSGSIZE) { + // it is ok the buffer was to small if bytesRead is larger than + // maxLength then assume bytes read is really maxLenth + ret = qint64(bytesRead) > maxLength ? maxLength : qint64(bytesRead); + } else { + WS_ERROR_DEBUG(err); + setError(QAbstractSocket::NetworkError, ReceiveDatagramErrorString); + ret = -1; + } } else { ret = qint64(bytesRead); } |