diff options
author | Kai Koehne <kai.koehne@theqtcompany.com> | 2015-04-22 08:42:18 +0200 |
---|---|---|
committer | Kai Koehne <kai.koehne@theqtcompany.com> | 2015-04-24 09:48:27 +0000 |
commit | f80d02863a3da43ce4a5c37b2c187f21e4645a23 (patch) | |
tree | 7704227a35c4ee7877132e6979a76963da807675 | |
parent | 82b427b777e2999bf1f6cb3520b72f5103341185 (diff) |
Fix hang and errors when sending big packages over the socket
The assumption that packages of arbitrary size can be send is
apparently wrong on Windows. Also, one has sometimes to call
waitForBytesWritten, otherwise the data is never transferred.
Task-number: QTBUG-45625
Change-Id: I8b5a2584d4d42cf33d1d6688b0e17c44c325ac53
Reviewed-by: Karsten Heimrich <karsten.heimrich@theqtcompany.com>
-rw-r--r-- | src/libs/installer/protocol.cpp | 12 |
1 files changed, 9 insertions, 3 deletions
diff --git a/src/libs/installer/protocol.cpp b/src/libs/installer/protocol.cpp index c252af07a..ba19c38ee 100644 --- a/src/libs/installer/protocol.cpp +++ b/src/libs/installer/protocol.cpp @@ -58,9 +58,15 @@ void sendPacket(QIODevice *device, const QByteArray &command, const QByteArray & packet.append('\0'); packet.append(data); - qint64 written = device->write(packet); - Q_ASSERT(written == packet.size()); // we assume we can write it all at once - Q_UNUSED(written); + forever { + const int bytesWritten = device->write(packet); + Q_ASSERT(bytesWritten >= 0); + if (bytesWritten == packet.size()) + break; + packet.remove(0, bytesWritten); + } + // needed for big packages over TCP on Windows + device->waitForBytesWritten(-1); } /*! |