From patchwork Wed Jan 18 16:03:13 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Marc-Andr=C3=A9_Lureau?= X-Patchwork-Id: 716738 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [IPv6:2001:4830:134:3::11]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 3v3Xjw1tlzz9t0C for ; Thu, 19 Jan 2017 03:39:16 +1100 (AEDT) Received: from localhost ([::1]:42535 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1cTtGT-0006d8-Ni for incoming@patchwork.ozlabs.org; Wed, 18 Jan 2017 11:39:13 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:37799) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1cTsiX-0002zT-Dn for qemu-devel@nongnu.org; Wed, 18 Jan 2017 11:04:13 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1cTsiT-0007ZX-Gf for qemu-devel@nongnu.org; Wed, 18 Jan 2017 11:04:09 -0500 Received: from mx1.redhat.com ([209.132.183.28]:32854) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1cTsiT-0007ZI-BO for qemu-devel@nongnu.org; Wed, 18 Jan 2017 11:04:05 -0500 Received: from int-mx10.intmail.prod.int.phx2.redhat.com (int-mx10.intmail.prod.int.phx2.redhat.com [10.5.11.23]) (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 8198B3D968 for ; Wed, 18 Jan 2017 16:04:05 +0000 (UTC) Received: from localhost (ovpn-116-95.phx2.redhat.com [10.3.116.95]) by int-mx10.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id v0IG42PD001747; Wed, 18 Jan 2017 11:04:04 -0500 From: =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= To: qemu-devel@nongnu.org Date: Wed, 18 Jan 2017 20:03:13 +0400 Message-Id: <20170118160332.13390-7-marcandre.lureau@redhat.com> In-Reply-To: <20170118160332.13390-1-marcandre.lureau@redhat.com> References: <20170118160332.13390-1-marcandre.lureau@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.68 on 10.5.11.23 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.30]); Wed, 18 Jan 2017 16:04:05 +0000 (UTC) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [PATCH v2 06/25] qmp: add qmp_return_is_cancelled() X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: kraxel@redhat.com, =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= , armbru@redhat.com Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: "Qemu-devel" 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é Lureau --- include/qapi/qmp/dispatch.h | 8 ++++++++ qapi/qmp-dispatch.c | 10 ++++++++++ 2 files changed, 18 insertions(+) diff --git a/include/qapi/qmp/dispatch.h b/include/qapi/qmp/dispatch.h index 32876764f3..bc64d4ed15 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); +/* + * 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 diff --git a/qapi/qmp-dispatch.c b/qapi/qmp-dispatch.c index 31227ce6e9..6ceece5ef0 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); } +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) { assert(!client->return_cb);