[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]

[libvirt] [PATCH] Fix race condition in abort of stream



From: "Daniel P. Berrange" <berrange redhat com>

If a stream gets a server initiated abort, the client may still
send an abort request before it receives the server side abort.
This causes the server to send back another abort for the
stream. Since the protocol defines that abort is the last thing
to be sent, the client gets confused by this second abort from
the server. If the stream is already shutdown, just drop any
client requested abort, rather than sending back another message.
This fixes the regression from previous versions.

Tested as follows

In one virsh session

  virsh # start foo
  virsh # console foo

In other virsh session

  virsh # destroy foo

The first virsh session should be able to continue issues
commands without error. Prior to this patch it saw

  virsh # list
  error: Failed to list active domains
  error: An error occurred, but the cause is unknown

  virsh # list
  error: Failed to list active domains
  error: no call waiting for reply with prog 536903814 vers 1 serial 9

* src/rpc/virnetserverprogram.c: Drop abort requests
  for streams which no longer exist
---
 src/rpc/virnetserverprogram.c |   25 ++++++++-----------------
 1 files changed, 8 insertions(+), 17 deletions(-)

diff --git a/src/rpc/virnetserverprogram.c b/src/rpc/virnetserverprogram.c
index 63a6b6d..ca80ae0 100644
--- a/src/rpc/virnetserverprogram.c
+++ b/src/rpc/virnetserverprogram.c
@@ -257,23 +257,14 @@ int virNetServerProgramDispatch(virNetServerProgramPtr prog,
          * stream packets after we closed down a stream. Just drop & ignore
          * these.
          */
-        if (msg->header.status == VIR_NET_CONTINUE) {
-            VIR_INFO("Ignoring unexpected stream data serial=%d proc=%d status=%d",
-                     msg->header.serial, msg->header.proc, msg->header.status);
-            /* Send a dummy reply to free up 'msg' & unblock client rx */
-            memset(msg, 0, sizeof(*msg));
-            msg->header.type = VIR_NET_REPLY;
-            if (virNetServerClientSendMessage(client, msg) < 0) {
-                ret = -1;
-                goto cleanup;
-            }
-        } else {
-            VIR_INFO("Unexpected stream control message serial=%d proc=%d status=%d",
-                     msg->header.serial, msg->header.proc, msg->header.status);
-            virNetError(VIR_ERR_RPC,
-                        _("Unexpected stream control message serial=%d proc=%d status=%d"),
-                          msg->header.serial, msg->header.proc, msg->header.status);
-            goto error;
+        VIR_INFO("Ignoring unexpected stream data serial=%d proc=%d status=%d",
+                 msg->header.serial, msg->header.proc, msg->header.status);
+        /* Send a dummy reply to free up 'msg' & unblock client rx */
+        memset(msg, 0, sizeof(*msg));
+        msg->header.type = VIR_NET_REPLY;
+        if (virNetServerClientSendMessage(client, msg) < 0) {
+            ret = -1;
+            goto cleanup;
         }
         ret = 0;
         break;
-- 
1.7.6


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]