From mboxrd@z Thu Jan 1 00:00:00 1970 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 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 From: Michael Roth Date: Mon, 19 Oct 2015 18:38:17 -0500 Message-Id: <1445297899-20527-13-git-send-email-mdroth@linux.vnet.ibm.com> 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> Subject: [Qemu-devel] [PULL v4 12/14] qga: handle G_IO_STATUS_AGAIN in ga_channel_write_all() List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org Cc: peter.maydell@linaro.org, Yuri Pudgorodskiy , Michael Roth , "Denis V. Lunev" 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; -- 1.9.1