Don't attempt to read from a stream if it is closed

The I/O event callback processes incoming packets first, and then
does outgoing packets. If the incoming packet caused the stream to
close, then the attempt to process outgoing data resulted in an
error. This caused libvirt to then send an error back to the client,
but the stream had already been stopped. This confused the client
since it sees 2 error events.

* daemon/stream.c: Don't attempt read if stream is closed
This commit is contained in:
Daniel P. Berrange 2011-08-16 16:20:58 -07:00
parent 108ca33357
commit dbf04dac3e
1 changed files with 9 additions and 1 deletions

View File

@ -678,7 +678,15 @@ daemonStreamHandleRead(virNetServerClientPtr client,
size_t bufferLen = VIR_NET_MESSAGE_PAYLOAD_MAX;
int ret;
VIR_DEBUG("client=%p, stream=%p", client, stream);
VIR_DEBUG("client=%p, stream=%p tx=%d closed=%d",
client, stream, stream->tx, stream->closed);
/* We might have had an event pending before we shut
* down the stream, so if we're marked as closed,
* then do nothing
*/
if (stream->closed)
return 0;
/* Shouldn't ever be called unless we're marked able to
* transmit, but doesn't hurt to check */