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

[Xen-devel] [PATCH v3 25/31] libxl_qmp_ev: Disconnect QMP when no more events



This will check if there is more libxl_ev_qmp in flight, and if not,
just disconnect from the QMP socket.

Signed-off-by: Anthony PERARD <anthony.perard@xxxxxxxxxx>
---
 tools/libxl/libxl_qmp.c | 13 +++++++++++++
 1 file changed, 13 insertions(+)

diff --git a/tools/libxl/libxl_qmp.c b/tools/libxl/libxl_qmp.c
index adf466e4c4..302178c5f5 100644
--- a/tools/libxl/libxl_qmp.c
+++ b/tools/libxl/libxl_qmp.c
@@ -1800,6 +1800,7 @@ static void ev_qmp_callback_error(libxl__egc *egc, 
libxl__ev_qmp_state *qmp)
     libxl__ev_qmp_stop(gc, qmp);
 }
 
+static void libxl__ev_qmp_checkstate(libxl__gc *gc, libxl__ev_qmp_state *qmp);
 static void ev_qmp_fd_callback(libxl__egc *egc, libxl__ev_fd *ev_fd,
                                int fd, short events, short revents)
 {
@@ -1836,6 +1837,8 @@ static void ev_qmp_fd_callback(libxl__egc *egc, 
libxl__ev_fd *ev_fd,
             libxl__ev_fd_modify(gc, &qmp->efd, events & ~POLLOUT);
         }
     }
+    /* Check if there is still something to do or just disconnect. */
+    libxl__ev_qmp_checkstate(gc, qmp);
 }
 
 static void libxl__ev_qmp_state_init(libxl__ev_qmp_state *qmp)
@@ -1922,6 +1925,16 @@ out:
     return qmp;
 }
 
+/* Check if it should stay around or just close the socket to let other use use
+ * it. */
+static void libxl__ev_qmp_checkstate(libxl__gc *gc, libxl__ev_qmp_state *qmp)
+{
+    if (LIBXL_TAILQ_EMPTY(&qmp->qmp_events)) {
+        LOGD(DEBUG, qmp->domid, "Nothing left to do, stop QMP ev handler");
+        libxl__ev_qmp_stop(gc, qmp);
+    }
+}
+
 void libxl__ev_qmp_stop(libxl__gc *gc, libxl__ev_qmp_state *qmp)
 {
     libxl__qmp_rx_buf *buf, *tbuf;
-- 
Anthony PERARD


_______________________________________________
Xen-devel mailing list
Xen-devel@xxxxxxxxxxxxxxxxxxxx
https://lists.xenproject.org/mailman/listinfo/xen-devel

 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.