Received: from eggs.gnu.org ([2001:4830:134:3::10]:56297) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1btWnz-0002AT-GQ for qemu-devel@nongnu.org; Mon, 10 Oct 2016 05:23:32 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1btWnv-00036u-Ck for qemu-devel@nongnu.org; Mon, 10 Oct 2016 05:23:31 -0400 Received: from mx1.redhat.com ([209.132.183.28]:39466) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1btWnv-00036n-6L for qemu-devel@nongnu.org; Mon, 10 Oct 2016 05:23:27 -0400 Received: from int-mx13.intmail.prod.int.phx2.redhat.com (int-mx13.intmail.prod.int.phx2.redhat.com [10.5.11.26]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id BF5373F1F5 for ; Mon, 10 Oct 2016 09:23:26 +0000 (UTC) From: =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= Date: Mon, 10 Oct 2016 13:22:43 +0400 Message-Id: <20161010092301.14974-7-marcandre.lureau@redhat.com> In-Reply-To: <20161010092301.14974-1-marcandre.lureau@redhat.com> References: <20161010092301.14974-1-marcandre.lureau@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable Subject: [Qemu-devel] [PATCH 06/24] qmp: add qmp_return_is_cancelled() List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org Cc: eblake@redhat.com, berrange@redhat.com, armbru@redhat.com, =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= If the client is gone, no need to return. The async handler can use this information to avoid unnecessary work and exit earlier. Signed-off-by: Marc-Andr=C3=A9 Lureau --- qapi/qmp-dispatch.c | 10 ++++++++++ include/qapi/qmp/dispatch.h | 8 ++++++++ 2 files changed, 18 insertions(+) diff --git a/qapi/qmp-dispatch.c b/qapi/qmp-dispatch.c index c8821b7..0c4022f 100644 --- a/qapi/qmp-dispatch.c +++ b/qapi/qmp-dispatch.c @@ -155,6 +155,16 @@ void qmp_return_error(QmpReturn *qret, Error *err) do_qmp_return(qret); } =20 +bool qmp_return_is_cancelled(QmpReturn *qret) +{ + if (!qret->client) { + qmp_return_free(qret); + return true; + } + + return false; +} + void qmp_client_init(QmpClient *client, QmpDispatchReturn *return_cb) { client->return_cb =3D return_cb; diff --git a/include/qapi/qmp/dispatch.h b/include/qapi/qmp/dispatch.h index 3287676..bc64d4e 100644 --- a/include/qapi/qmp/dispatch.h +++ b/include/qapi/qmp/dispatch.h @@ -78,4 +78,12 @@ void qmp_for_each_command(qmp_cmd_callback_fn fn, void= *opaque); void qmp_return(QmpReturn *qret, QObject *cmd_rsp); void qmp_return_error(QmpReturn *qret, Error *err); =20 +/* + * 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); + #endif --=20 2.10.0