diff options
author | Kai Koehne <kai.koehne@theqtcompany.com> | 2015-02-16 10:20:07 +0100 |
---|---|---|
committer | Kai Koehne <kai.koehne@theqtcompany.com> | 2015-02-20 10:22:31 +0000 |
commit | df667f7560f2625d7278935a18bf12b47f76d4d3 (patch) | |
tree | 968b3216de517fa363f5d22166a0de462d90e374 /src/libs/installer/protocol.h | |
parent | d6bca86cad962a0078c2a8111133cff123f1ba0a (diff) |
Fix handling of incomplete messages in client/server communication
Do not assume that the socket always contains enough data. Instead,
prefix every 'packet' with its size, and back off until the full
packet is available.
The actual encoding/decoding is done in Protocol::sendPacket,
Protocol::receivePacket. To be able to use the methods everywhere,
replies are now prefixed by a Protocol::Reply command.
Change-Id: I75a89605b2cc3fe2f2f841d8e3159fc8aea65d77
Reviewed-by: Karsten Heimrich <karsten.heimrich@theqtcompany.com>
Diffstat (limited to 'src/libs/installer/protocol.h')
-rw-r--r-- | src/libs/installer/protocol.h | 9 |
1 files changed, 9 insertions, 0 deletions
diff --git a/src/libs/installer/protocol.h b/src/libs/installer/protocol.h index 376f0c68d..9e7afdcae 100644 --- a/src/libs/installer/protocol.h +++ b/src/libs/installer/protocol.h @@ -35,6 +35,10 @@ #ifndef PROTOCOL_H #define PROTOCOL_H +#include "installer_global.h" + +QT_FORWARD_DECLARE_CLASS(QIODevice) + namespace QInstaller { namespace Protocol { @@ -57,6 +61,7 @@ const char Create[] = "Create"; const char Destroy[] = "Destroy"; const char Shutdown[] = "Shutdown"; const char Authorize[] = "Authorize"; +const char Reply[] = "Reply"; // QProcessWrapper const char QProcess[] = "QProcess"; @@ -165,6 +170,10 @@ const char QAbstractFileEngineRenameOverwrite[] = "QAbstractFileEngine::renameOv const char QAbstractFileEngineFileTime[] = "QAbstractFileEngine::fileTime"; } // namespace Protocol + +void INSTALLER_EXPORT sendPacket(QIODevice *device, const QByteArray &command, const QByteArray &data); +bool INSTALLER_EXPORT receivePacket(QIODevice *device, QByteArray *command, QByteArray *data); + } // namespace QInstaller #endif // PROTOCOL_H |