From patchwork Mon Oct 19 23:38:17 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Michael Roth X-Patchwork-Id: 532738 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 5349D140F8C for ; Tue, 20 Oct 2015 10:40:55 +1100 (AEDT) Received: from localhost ([::1]:42491 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZoK2u-0002R9-7p for incoming@patchwork.ozlabs.org; Mon, 19 Oct 2015 19:40:52 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:49194) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZoK0p-00020M-1c for qemu-devel@nongnu.org; Mon, 19 Oct 2015 19:38:47 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ZoK0i-00021T-Gq for qemu-devel@nongnu.org; Mon, 19 Oct 2015 19:38:39 -0400 Received: from e19.ny.us.ibm.com ([129.33.205.209]:55898) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZoK0i-00021O-BK for qemu-devel@nongnu.org; Mon, 19 Oct 2015 19:38:36 -0400 Received: from localhost by e19.ny.us.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Mon, 19 Oct 2015 19:38:36 -0400 Received: from d01dlp03.pok.ibm.com (9.56.250.168) by e19.ny.us.ibm.com (146.89.104.206) with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted; Mon, 19 Oct 2015 19:38:33 -0400 X-IBM-Helo: d01dlp03.pok.ibm.com X-IBM-MailFrom: mdroth@linux.vnet.ibm.com X-IBM-RcptTo: qemu-devel@nongnu.org Received: from b01cxnp22033.gho.pok.ibm.com (b01cxnp22033.gho.pok.ibm.com [9.57.198.23]) by d01dlp03.pok.ibm.com (Postfix) with ESMTP id C1F0EC9003C for ; Mon, 19 Oct 2015 19:26:43 -0400 (EDT) Received: from d01av05.pok.ibm.com (d01av05.pok.ibm.com [9.56.224.195]) by b01cxnp22033.gho.pok.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id t9JNcWUn45613270 for ; Mon, 19 Oct 2015 23:38:32 GMT Received: from d01av05.pok.ibm.com (localhost [127.0.0.1]) by d01av05.pok.ibm.com (8.14.4/8.14.4/NCO v10.0 AVout) with ESMTP id t9JNbtL4013901 for ; Mon, 19 Oct 2015 19:37:56 -0400 Received: from localhost ([9.80.85.201]) by d01av05.pok.ibm.com (8.14.4/8.14.4/NCO v10.0 AVin) with ESMTP id t9JNbs2F013885; Mon, 19 Oct 2015 19:37:54 -0400 From: Michael Roth To: qemu-devel@nongnu.org Date: Mon, 19 Oct 2015 18:38:17 -0500 Message-Id: <1445297899-20527-13-git-send-email-mdroth@linux.vnet.ibm.com> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1445297899-20527-1-git-send-email-mdroth@linux.vnet.ibm.com> References: <1445297899-20527-1-git-send-email-mdroth@linux.vnet.ibm.com> X-TM-AS-MML: disable X-Content-Scanned: Fidelis XPS MAILER x-cbid: 15101923-0057-0000-0000-00000204405B X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 129.33.205.209 Cc: peter.maydell@linaro.org, Yuri Pudgorodskiy , Michael Roth , "Denis V. Lunev" Subject: [Qemu-devel] [PULL v4 12/14] qga: handle G_IO_STATUS_AGAIN in ga_channel_write_all() X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org From: Yuri Pudgorodskiy glib may return G_IO_STATUS_AGAIN which is actually not an error. Also fixed a bug when on incomplete write buf pointer was not adjusted. Signed-off-by: Yuri Pudgorodskiy Signed-off-by: Denis V. Lunev Reviewed-by: Michael Roth Signed-off-by: Michael Roth --- qga/channel-posix.c | 23 +++++++++++------------ 1 file changed, 11 insertions(+), 12 deletions(-) diff --git a/qga/channel-posix.c b/qga/channel-posix.c index 61aa3cb..50d9dd3 100644 --- a/qga/channel-posix.c +++ b/qga/channel-posix.c @@ -217,25 +217,24 @@ GIOStatus ga_channel_write_all(GAChannel *c, const gchar *buf, gsize size) GIOStatus status = G_IO_STATUS_NORMAL; while (size) { + g_debug("sending data, count: %d", (int)size); status = g_io_channel_write_chars(c->client_channel, buf, size, &written, &err); - g_debug("sending data, count: %d", (int)size); - if (err != NULL) { + if (status == G_IO_STATUS_NORMAL) { + size -= written; + buf += written; + } else if (status != G_IO_STATUS_AGAIN) { g_warning("error writing to channel: %s", err->message); - return G_IO_STATUS_ERROR; - } - if (status != G_IO_STATUS_NORMAL) { - break; + return status; } - size -= written; } - if (status == G_IO_STATUS_NORMAL) { + do { status = g_io_channel_flush(c->client_channel, &err); - if (err != NULL) { - g_warning("error flushing channel: %s", err->message); - return G_IO_STATUS_ERROR; - } + } while (status == G_IO_STATUS_AGAIN); + + if (status != G_IO_STATUS_NORMAL) { + g_warning("error flushing channel: %s", err->message); } return status;