From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:35331) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Zml2M-0000JL-Oe for qemu-devel@nongnu.org; Thu, 15 Oct 2015 12:05:55 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Zml2G-0000wy-Tb for qemu-devel@nongnu.org; Thu, 15 Oct 2015 12:05:50 -0400 Received: from e39.co.us.ibm.com ([32.97.110.160]:35050) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Zml2G-0000wS-LA for qemu-devel@nongnu.org; Thu, 15 Oct 2015 12:05:44 -0400 Received: from localhost by e39.co.us.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Thu, 15 Oct 2015 10:05:44 -0600 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 06135C9005C for ; Thu, 15 Oct 2015 11:53:53 -0400 (EDT) Received: from d01av02.pok.ibm.com (d01av02.pok.ibm.com [9.56.224.216]) by b01cxnp22033.gho.pok.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id t9FG5ftI40239248 for ; Thu, 15 Oct 2015 16:05:41 GMT Received: from d01av02.pok.ibm.com (localhost [127.0.0.1]) by d01av02.pok.ibm.com (8.14.4/8.14.4/NCO v10.0 AVout) with ESMTP id t9FG5d6b029251 for ; Thu, 15 Oct 2015 12:05:40 -0400 From: Michael Roth Date: Thu, 15 Oct 2015 11:05:17 -0500 Message-Id: <1444925118-10629-12-git-send-email-mdroth@linux.vnet.ibm.com> In-Reply-To: <1444925118-10629-1-git-send-email-mdroth@linux.vnet.ibm.com> References: <1444925118-10629-1-git-send-email-mdroth@linux.vnet.ibm.com> Subject: [Qemu-devel] [PATCH 11/12] 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