qemu-devel
[Top][All Lists]
Advanced

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

[Qemu-devel] [RFC v2 15/22] monitor: send event when request queue full


From: Peter Xu
Subject: [Qemu-devel] [RFC v2 15/22] monitor: send event when request queue full
Date: Fri, 29 Sep 2017 11:38:37 +0800

Set maximum QMP request queue length to 8.  If queue full, instead of
queue the command, we directly return a "request-dropped" event, telling
client that specific command is dropped.

Signed-off-by: Peter Xu <address@hidden>
---
 monitor.c | 15 +++++++++++++++
 1 file changed, 15 insertions(+)

diff --git a/monitor.c b/monitor.c
index 1e9a6cb6a5..d9bed31248 100644
--- a/monitor.c
+++ b/monitor.c
@@ -3971,6 +3971,8 @@ static void monitor_qmp_bh_dispatcher(void *data)
     }
 }
 
+#define  QMP_ASYNC_QUEUE_LEN_MAX  (8)
+
 static void handle_qmp_command(JSONMessageParser *parser, GQueue *tokens,
                                void *opaque)
 {
@@ -4002,6 +4004,19 @@ static void handle_qmp_command(JSONMessageParser 
*parser, GQueue *tokens,
     req_obj->id = id;
     req_obj->req = req;
 
+    /* Drop the request if queue is full. */
+    if (mon->qmp_requests->length >= QMP_ASYNC_QUEUE_LEN_MAX) {
+        const char *id_str = qobject_get_try_str(id);
+
+        qapi_event_send_request_dropped(id_str ? id_str : "",
+                                        REQUEST_DROP_REASON_QUEUE_FULL,
+                                        NULL);
+        qobject_decref(id);
+        qobject_decref(req);
+        g_free(req_obj);
+        return;
+    }
+
     /*
      * Put the request to the end of queue so that requests will be
      * handled in time order.  Ownership for req_obj, req, id,
-- 
2.13.5




reply via email to

[Prev in Thread] Current Thread [Next in Thread]