aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMichal Privoznik <mprivozn@redhat.com>2012-01-10 16:57:30 +0100
committerMichal Privoznik <mprivozn@redhat.com>2012-01-12 12:02:40 +0100
commit833b901cb711a9db148b4fe39e658411f82f3467 (patch)
tree98366a9829653435b7410011ee11a692ad2eff89 /src/rpc/virnetclientstream.c
parentvirsh: New command print summary of all virtual interfaces (diff)
downloadlibvirt-833b901cb711a9db148b4fe39e658411f82f3467.tar.gz
libvirt-833b901cb711a9db148b4fe39e658411f82f3467.tar.bz2
libvirt-833b901cb711a9db148b4fe39e658411f82f3467.zip
stream: Check for stream EOF
If client stream does not have any data to sink and neither received EOF, a dummy packet is sent to the daemon signalising client is ready to sink some data. However, after we added event loop to client a race may occur: Thread 1 calls virNetClientStreamRecvPacket and since no data are cached nor stream has EOF, it decides to send dummy packet to server which will sent some data in turn. However, during this decision and actual message exchange with server - Thread 2 receives last stream data from server. Therefore an EOF is set on stream and if there is a call waiting (which is not yet) it is woken up. However, Thread 1 haven't sent anything so far, so there is no call to be woken up. So this thread sent dummy packet to daemon, which ignores that as no stream is associated with such packet and therefore no reply will ever come. This race causes client to hang indefinitely.
Diffstat (limited to 'src/rpc/virnetclientstream.c')
-rw-r--r--src/rpc/virnetclientstream.c7
1 files changed, 6 insertions, 1 deletions
diff --git a/src/rpc/virnetclientstream.c b/src/rpc/virnetclientstream.c
index a4292e77a..be06c66b4 100644
--- a/src/rpc/virnetclientstream.c
+++ b/src/rpc/virnetclientstream.c
@@ -408,7 +408,7 @@ int virNetClientStreamRecvPacket(virNetClientStreamPtr st,
VIR_DEBUG("Dummy packet to wait for stream data");
virMutexUnlock(&st->lock);
- ret = virNetClientSendWithReply(client, msg);
+ ret = virNetClientSendWithReplyStream(client, msg, st);
virMutexLock(&st->lock);
virNetMessageFree(msg);
@@ -530,3 +530,8 @@ cleanup:
virMutexUnlock(&st->lock);
return ret;
}
+
+bool virNetClientStreamEOF(virNetClientStreamPtr st)
+{
+ return st->incomingEOF;
+}