All of lore.kernel.org
 help / color / mirror / Atom feed
From: Stratos Psomadakis <psomas@grnet.gr>
To: qemu-devel@nongnu.org
Cc: synnefo-devel@googlegroups.com,
	Stratos Psomdakis <psomas@grnet.gr>,
	ganeti-devel@googlegroups.com, dimara@grnet.gr
Subject: [Qemu-devel] [PATCH] monitor: Cleanup mon->outbuf on write error
Date: Mon, 27 Jan 2014 12:30:15 +0200	[thread overview]
Message-ID: <1390818615-4926-1-git-send-email-psomas@grnet.gr> (raw)
In-Reply-To: <20140124184822.4a49e3ea@redhat.com>

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 <psomas@grnet.gr>
Signed-off-by: Dimitris Aragiorgis <dimara@grnet.gr>
---
 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.7.10.4

  reply	other threads:[~2014-01-27 10:30 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-01-22 15:53 [Qemu-devel] Possible bug in monitor code Stratos Psomadakis
2014-01-23  3:07 ` Fam Zheng
2014-01-23 10:17   ` Stratos Psomadakis
2014-01-24 23:48 ` Luiz Capitulino
2014-01-27 10:30   ` Stratos Psomadakis [this message]
2014-01-29 10:46     ` [Qemu-devel] [PATCH] monitor: Cleanup mon->outbuf on write error Stratos Psomadakis
2014-01-29 14:12       ` Luiz Capitulino

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1390818615-4926-1-git-send-email-psomas@grnet.gr \
    --to=psomas@grnet.gr \
    --cc=dimara@grnet.gr \
    --cc=ganeti-devel@googlegroups.com \
    --cc=qemu-devel@nongnu.org \
    --cc=synnefo-devel@googlegroups.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.