From: Daniel P. Berrange Date: Tue, 9 Apr 2013 12:24:02 +0000 (+0100) Subject: Tweak EOF handling of streams X-Git-Tag: v0.10.2.6~6 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=69838772ccc2c281825daadcb428cb5951bfa81d;p=thirdparty%2Flibvirt.git Tweak EOF handling of streams Typically when you get EOF on a stream, poll will return POLLIN|POLLHUP at the same time. Thus when we deal with stream reads, if we see EOF during the read, we can then clear the VIR_STREAM_EVENT_HANGUP & VIR_STREAM_EVENT_ERROR event bits. Signed-off-by: Daniel P. Berrange (cherry picked from commit e7b0382945c9bf043f06ee4dd760c2051d63d0f0) --- diff --git a/daemon/stream.c b/daemon/stream.c index 58c53a9c53..43489eb38e 100644 --- a/daemon/stream.c +++ b/daemon/stream.c @@ -148,6 +148,14 @@ daemonStreamEvent(virStreamPtr st, int events, void *opaque) virNetServerClientClose(client); goto cleanup; } + /* If we detected EOF during read processing, + * then clear hangup/error conditions, since + * we want the client to see the EOF message + * we just sent them + */ + if (stream->recvEOF) + events = events & ~(VIR_STREAM_EVENT_HANGUP | + VIR_STREAM_EVENT_ERROR); } /* If we have a completion/abort message, always process it */