[libvirt] [PATCH v2 1/2] rpc: Report proper close reason for keepalive disconnections

Martin Kletzander mkletzan at redhat.com
Mon Dec 1 11:00:52 UTC 2014


Whenever client socket was disconnected due to keepalive timeout, the
I/O event loop did not exit and continued until the point where the
hangup was found.  Ending with an error right away when the
keepalive times out takes care of this problem.

Signed-off-by: Martin Kletzander <mkletzan at redhat.com>
---
 src/rpc/virkeepalive.c | 11 ++++++-----
 src/rpc/virnetclient.c |  1 +
 2 files changed, 7 insertions(+), 5 deletions(-)

diff --git a/src/rpc/virkeepalive.c b/src/rpc/virkeepalive.c
index c882313..f382f93 100644
--- a/src/rpc/virkeepalive.c
+++ b/src/rpc/virkeepalive.c
@@ -136,11 +136,12 @@ virKeepAliveTimerInternal(virKeepAlivePtr ka,
           ka, ka->client, ka->countToDeath, timeval);

     if (ka->countToDeath == 0) {
-        VIR_WARN("No response from client %p after %d keepalive messages in"
-                 " %d seconds",
-                 ka->client,
-                 ka->count,
-                 timeval);
+        virReportError(VIR_ERR_INTERNAL_ERROR,
+                       _("No response from client %p after %d keepalive messages in"
+                         " %d seconds"),
+                       ka->client,
+                       ka->count,
+                       timeval);
         return true;
     } else {
         ka->countToDeath--;
diff --git a/src/rpc/virnetclient.c b/src/rpc/virnetclient.c
index 8657b0e..ac4850c 100644
--- a/src/rpc/virnetclient.c
+++ b/src/rpc/virnetclient.c
@@ -1525,6 +1525,7 @@ static int virNetClientIOEventLoop(virNetClientPtr client,

         if (virKeepAliveTrigger(client->keepalive, &msg)) {
             virNetClientMarkClose(client, VIR_CONNECT_CLOSE_REASON_KEEPALIVE);
+            goto error;
         } else if (msg && virNetClientQueueNonBlocking(client, msg) < 0) {
             VIR_WARN("Could not queue keepalive request");
             virNetMessageFree(msg);
-- 
2.1.3




More information about the libvir-list mailing list