From aefb0ad3288fb021d821d69a8425aff0c7531328 Mon Sep 17 00:00:00 2001 From: Christian Mollekopf Date: Sun, 20 May 2018 11:58:21 +0200 Subject: Read all remaining data before closing down the socket. We run into this on windows with the resourceconfigtest. --- common/resourceaccess.cpp | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/common/resourceaccess.cpp b/common/resourceaccess.cpp index c641421..2fa753d 100644 --- a/common/resourceaccess.cpp +++ b/common/resourceaccess.cpp @@ -534,6 +534,9 @@ void ResourceAccess::connected() void ResourceAccess::disconnected() { SinkLog() << QString("Disconnected from %1").arg(d->socket->fullServerName()); + //Ensure we read all remaining data before closing the socket. + //This is required on windows at least. + readResourceMessage(); d->socket->close(); emit ready(false); } @@ -566,15 +569,17 @@ void ResourceAccess::connectionError(QLocalSocket::LocalSocketError error) void ResourceAccess::readResourceMessage() { - if (!d->socket || !d->socket->isValid()) { + if (!d->socket) { SinkWarning() << "No socket available"; return; } - d->partialMessageBuffer += d->socket->readAll(); + if (d->socket->bytesAvailable()) { + d->partialMessageBuffer += d->socket->readAll(); - // should be scheduled rather than processed all at once - while (processMessageBuffer()) { + // should be scheduled rather than processed all at once + while (processMessageBuffer()) { + } } } -- cgit v1.2.3