From: Daniel P. Berrangé <[email protected]>

Since e23fd0b7fd36c41e6db49df4f4962762d3ef6ab0 the stream read
code will repeatedly try to read a message from the background
thread until it has filled its buffer. When hitting EOF, there
will be no message left on the queue, and if the read buffer
was non-zero length an error will be raised. This should only
be done if there was no data previously read off the stream.

Fixes: e23fd0b7fd36c41e6db49df4f4962762d3ef6ab0
Reported-by: Roman Bogorodskiy <[email protected]>
Signed-off-by: Daniel P. Berrangé <[email protected]>
---
 src/util/virfdstream.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/src/util/virfdstream.c b/src/util/virfdstream.c
index 4c974ba5d7..efda768ef3 100644
--- a/src/util/virfdstream.c
+++ b/src/util/virfdstream.c
@@ -911,7 +911,7 @@ static int virFDStreamRead(virStreamPtr st, char *bytes, 
size_t nbytes)
     more:
         while (!(msg = fdst->msg)) {
             if (fdst->threadQuit || fdst->threadErr) {
-                if (nbytes) {
+                if (nbytes && !got) {
                     /* virStreamRecv will virResetLastError possibly set
                      * by virFDStreamEvent */
                     if (fdst->threadErr && !virGetLastError())
-- 
2.53.0

Reply via email to