[libvirt] [PATCH] Fix synchronous reading of stream data
Dave Allan
dallan at redhat.com
Wed Sep 21 14:42:12 UTC 2011
On Wed, Sep 21, 2011 at 02:54:38PM +0100, Daniel P. Berrange wrote:
> From: "Daniel P. Berrange" <berrange at redhat.com>
>
> 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.
No regressions with my console script with that patch applied, so ACK
in that regard. I have not reviewed it otherwise.
Dave
> * 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
> ---
> src/rpc/virnetclient.c | 10 ++++++++++
> src/rpc/virnetclientstream.c | 1 +
> 2 files changed, 11 insertions(+), 0 deletions(-)
>
> diff --git a/src/rpc/virnetclient.c b/src/rpc/virnetclient.c
> index 055361d..b2c528a 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 2cc84d4..4cd0295 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);
> --
> 1.7.6.2
>
More information about the libvir-list
mailing list