From 208d5836c8c4f4256622788ec5c26aeca1bfa51a Mon Sep 17 00:00:00 2001 From: "Daniel P. Berrange" Date: Wed, 21 Sep 2011 14:51:33 +0100 Subject: [PATCH] Fix synchronous reading of stream data commit 984840a2c292402926ad100aeea33f8859ff31a9 removed the notification of waiting calls when VIR_NET_CONTINUE messages arrive. This was to fix the case of a virStreamAbort() call being prematurely notified of completion. The problem is that sometimes there are dummy calls from a virStreamRecv() call waiting that *do* need to be notified. These dummy calls should have a status VIR_NET_CONTINUE. So re-add the notification upon VIR_NET_CONTINUE, but only if the waiter also has a status of VIR_NET_CONTINUE. * src/rpc/virnetclient.c: Notify waiting call if stream data arrives * src/rpc/virnetclientstream.c: Mark dummy stream read packet with status VIR_NET_CONTINUE (cherry picked from commit cb61009236a96f16fa7eabc92f5d6ed5f6313163) --- src/rpc/virnetclient.c | 10 ++++++++++ src/rpc/virnetclientstream.c | 1 + 2 files changed, 11 insertions(+) diff --git a/src/rpc/virnetclient.c b/src/rpc/virnetclient.c index 055361d0da..b2c528a10f 100644 --- a/src/rpc/virnetclient.c +++ b/src/rpc/virnetclient.c @@ -627,6 +627,15 @@ static int virNetClientCallDispatchStream(virNetClientPtr client) case VIR_NET_CONTINUE: { if (virNetClientStreamQueuePacket(st, &client->msg) < 0) return -1; + + if (thecall && thecall->expectReply) { + if (thecall->msg->header.status == VIR_NET_CONTINUE) { + VIR_DEBUG("Got a synchronous confirm"); + thecall->mode = VIR_NET_CLIENT_MODE_COMPLETE; + } else { + VIR_DEBUG("Not completing call with status %d", thecall->msg->header.status); + } + } return 0; } @@ -1189,6 +1198,7 @@ int virNetClientSend(virNetClientPtr client, int ret = -1; if (expectReply && + (msg->bufferLength != 0) && (msg->header.status == VIR_NET_CONTINUE)) { virNetError(VIR_ERR_INTERNAL_ERROR, "%s", _("Attempt to send an asynchronous message with a synchronous reply")); diff --git a/src/rpc/virnetclientstream.c b/src/rpc/virnetclientstream.c index 2cc84d40dc..4cd02952bf 100644 --- a/src/rpc/virnetclientstream.c +++ b/src/rpc/virnetclientstream.c @@ -400,6 +400,7 @@ int virNetClientStreamRecvPacket(virNetClientStreamPtr st, msg->header.type = VIR_NET_STREAM; msg->header.serial = st->serial; msg->header.proc = st->proc; + msg->header.status = VIR_NET_CONTINUE; VIR_DEBUG("Dummy packet to wait for stream data"); virMutexUnlock(&st->lock); -- GitLab