]> xenbits.xensource.com Git - people/liuw/libxenctrl-split/libvirt.git/commitdiff
Tweak EOF handling of streams
authorDaniel P. Berrange <berrange@redhat.com>
Tue, 9 Apr 2013 12:24:02 +0000 (13:24 +0100)
committerDaniel P. Berrange <berrange@redhat.com>
Fri, 12 Apr 2013 10:27:57 +0000 (11:27 +0100)
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 <berrange@redhat.com>
daemon/stream.c

index 4df1145ce3dc283dcc69a8f13c3a2a1c0b7f28bc..0fb5c8523130e93ce03470f499968e16367619fd 100644 (file)
@@ -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 */