diff options
author | Christian Mollekopf <chrigi_1@fastmail.fm> | 2018-05-20 11:58:21 +0200 |
---|---|---|
committer | Christian Mollekopf <chrigi_1@fastmail.fm> | 2018-05-20 13:28:37 +0200 |
commit | aefb0ad3288fb021d821d69a8425aff0c7531328 (patch) | |
tree | 8d7ee22242ce4ba2b6de94a8488b57f7fde3c568 | |
parent | eba994ef522089abb4cb0af324cf098588a20765 (diff) | |
download | sink-aefb0ad3288fb021d821d69a8425aff0c7531328.tar.gz sink-aefb0ad3288fb021d821d69a8425aff0c7531328.zip |
Read all remaining data before closing down the socket.
We run into this on windows with the resourceconfigtest.
-rw-r--r-- | common/resourceaccess.cpp | 13 |
1 files 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() | |||
534 | void ResourceAccess::disconnected() | 534 | void ResourceAccess::disconnected() |
535 | { | 535 | { |
536 | SinkLog() << QString("Disconnected from %1").arg(d->socket->fullServerName()); | 536 | SinkLog() << QString("Disconnected from %1").arg(d->socket->fullServerName()); |
537 | //Ensure we read all remaining data before closing the socket. | ||
538 | //This is required on windows at least. | ||
539 | readResourceMessage(); | ||
537 | d->socket->close(); | 540 | d->socket->close(); |
538 | emit ready(false); | 541 | emit ready(false); |
539 | } | 542 | } |
@@ -566,15 +569,17 @@ void ResourceAccess::connectionError(QLocalSocket::LocalSocketError error) | |||
566 | 569 | ||
567 | void ResourceAccess::readResourceMessage() | 570 | void ResourceAccess::readResourceMessage() |
568 | { | 571 | { |
569 | if (!d->socket || !d->socket->isValid()) { | 572 | if (!d->socket) { |
570 | SinkWarning() << "No socket available"; | 573 | SinkWarning() << "No socket available"; |
571 | return; | 574 | return; |
572 | } | 575 | } |
573 | 576 | ||
574 | d->partialMessageBuffer += d->socket->readAll(); | 577 | if (d->socket->bytesAvailable()) { |
578 | d->partialMessageBuffer += d->socket->readAll(); | ||
575 | 579 | ||
576 | // should be scheduled rather than processed all at once | 580 | // should be scheduled rather than processed all at once |
577 | while (processMessageBuffer()) { | 581 | while (processMessageBuffer()) { |
582 | } | ||
578 | } | 583 | } |
579 | } | 584 | } |
580 | 585 | ||