[libvirt] [PATCH 4/9] rpc: fix propagation of errors from server

Nikolay Shirokovskiy nshirokovskiy at virtuozzo.com
Thu Feb 7 12:58:42 UTC 2019


Stream server error is not propagated if thread does not have the buck.
In case we have the buck we are ok due to the code added in [1].

Let's check for stream error on all paths. Now we don't need
to raise error in virNetClientCallDispatchStream.

Old code reported error only if the first message in wait
queue awaits reply. It is odd as depends on wait queue
situation. For example if we have only TX
message in queue and in one iteration loop both send the
message and receive error then thread sending TX message did
not receive the error. Next if we have RX message (first)
and TX message (second) in queue and in one iteration
loop both send the TX message and receive error then
thread sending TX message received error. In short
it was inconsistent. Let's report error whenever
we received it and for every type of message as it makes
sense to report errors as early as possible.

[1] 16c6e2b41: Fix propagation of RPC errors from streams

Signed-off-by: Nikolay Shirokovskiy <nshirokovskiy at virtuozzo.com>
---
 src/rpc/virnetclient.c | 11 +++--------
 1 file changed, 3 insertions(+), 8 deletions(-)

diff --git a/src/rpc/virnetclient.c b/src/rpc/virnetclient.c
index c102cdc..fcc2e80 100644
--- a/src/rpc/virnetclient.c
+++ b/src/rpc/virnetclient.c
@@ -1230,9 +1230,6 @@ static int virNetClientCallDispatchStream(virNetClientPtr client)
 
         if (thecall && thecall->expectReply) {
             VIR_DEBUG("Got a synchronous error");
-            /* Raise error now, so that this call will see it immediately */
-            if (!virNetClientStreamRaiseError(st))
-                VIR_DEBUG("unable to raise synchronous error");
             thecall->mode = VIR_NET_CLIENT_MODE_COMPLETE;
         }
         return 0;
@@ -1947,16 +1944,11 @@ static int virNetClientIO(virNetClientPtr client,
      */
     virNetClientIOUpdateCallback(client, false);
 
-    virResetLastError();
     rv = virNetClientIOEventLoop(client, thiscall);
 
     if (client->sock)
         virNetClientIOUpdateCallback(client, true);
 
-    if (rv == 0 &&
-        virGetLastErrorCode())
-        rv = -1;
-
  cleanup:
     VIR_DEBUG("All done with our call head=%p call=%p rv=%d",
               client->waitDispatch, thiscall, rv);
@@ -2213,6 +2205,9 @@ int virNetClientSendStream(virNetClientPtr client,
     if (virNetClientSendInternal(client, msg, expectReply, false) < 0)
         goto cleanup;
 
+    if (virNetClientStreamRaiseError(st))
+        goto cleanup;
+
     ret = 0;
 
  cleanup:
-- 
1.8.3.1




More information about the libvir-list mailing list