Received: from eggs.gnu.org ([2001:4830:134:3::10]:43331) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1W8CRY-0005fs-Mh for qemu-devel@nongnu.org; Tue, 28 Jan 2014 12:27:29 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1W8CRT-0004dF-Uh for qemu-devel@nongnu.org; Tue, 28 Jan 2014 12:27:24 -0500 Received: from mx1.redhat.com ([209.132.183.28]:33409) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1W8CRT-0004cz-Ng for qemu-devel@nongnu.org; Tue, 28 Jan 2014 12:27:19 -0500 From: Luiz Capitulino Date: Tue, 28 Jan 2014 12:27:09 -0500 Message-Id: <1390930029-14697-6-git-send-email-lcapitulino@redhat.com> In-Reply-To: <1390930029-14697-1-git-send-email-lcapitulino@redhat.com> References: <1390930029-14697-1-git-send-email-lcapitulino@redhat.com> Subject: [Qemu-devel] [PULL 5/5] monitor: Cleanup mon->outbuf on write error List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: anthony@codemonkey.ws Cc: qemu-devel@nongnu.org From: Stratos Psomadakis In case monitor_flush() fails to write the contents of mon->outbuf to the output device, mon->outbuf is not cleaned up properly. Check the return code of the qemu_chr_fe_write() function and cleanup the outbuf if it fails. References: http://lists.nongnu.org/archive/html/qemu-devel/2014-01/msg02890.html Signed-off-by: Stratos Psomadakis Signed-off-by: Dimitris Aragiorgis Signed-off-by: Luiz Capitulino --- monitor.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/monitor.c b/monitor.c index 80456fb..cba56bc 100644 --- a/monitor.c +++ b/monitor.c @@ -288,8 +288,8 @@ void monitor_flush(Monitor *mon) if (len && !mon->mux_out) { rc = qemu_chr_fe_write(mon->chr, (const uint8_t *) buf, len); - if (rc == len) { - /* all flushed */ + if ((rc < 0 && errno != EAGAIN) || (rc == len)) { + /* all flushed or error */ QDECREF(mon->outbuf); mon->outbuf = qstring_new(); return; -- 1.8.1.4