@@ -91,6 +91,14 @@ void qmp_return_free(QmpReturn *qret);
void qmp_return(QmpReturn *qret, QObject *rsp);
void qmp_return_error(QmpReturn *qret, Error *err);
+/*
+ * @qmp_return_is_cancelled:
+ *
+ * Return true if the QmpReturn is cancelled, and free the QmpReturn
+ * in this case.
+ */
+bool qmp_return_is_cancelled(QmpReturn *qret);
+
void qmp_register_command(QmpCommandList *cmds, const char *name,
QmpCommandFunc *fn, QmpCommandOptions options);
void qmp_register_async_command(QmpCommandList *cmds, const char *name,
@@ -63,6 +63,16 @@ void qmp_return_free(QmpReturn *qret)
}
}
+bool qmp_return_is_cancelled(QmpReturn *qret)
+{
+ if (!qret->session) {
+ qmp_return_free(qret);
+ return true;
+ }
+
+ return false;
+}
+
static void qmp_return_orderly(QmpReturn *qret)
{
QmpSession *session = qret->session;
If the client is gone, and the session finished, no need to return. The async handler can use this information to avoid unnecessary work and exit earlier. Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com> --- include/qapi/qmp/dispatch.h | 8 ++++++++ qapi/qmp-dispatch.c | 10 ++++++++++ 2 files changed, 18 insertions(+)