qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Mark Wu <wudxw@linux.vnet.ibm.com>
To: Anthony Liguori <aliguori@us.ibm.com>,
	Mark McLoughlin <markmc@redhat.com>
Cc: qemu-devel@nongnu.org
Subject: [Qemu-devel] [PATCH] net: Only flush queue or call sent callback on successful delivery
Date: Thu, 27 Oct 2011 17:02:25 +0800	[thread overview]
Message-ID: <1319706145-26599-1-git-send-email-wudxw@linux.vnet.ibm.com> (raw)

Now queue flushing and sent callback could be invoked even on delivery
failure. We add a checking of receiver's return value to avoid this
case.

Signed-off-by: Mark Wu <wudxw@linux.vnet.ibm.com>
---
 net/queue.c |   12 +++++++-----
 1 files changed, 7 insertions(+), 5 deletions(-)

diff --git a/net/queue.c b/net/queue.c
index 1ab5247..c9a027c 100644
--- a/net/queue.c
+++ b/net/queue.c
@@ -190,8 +190,9 @@ ssize_t qemu_net_queue_send(NetQueue *queue,
         qemu_net_queue_append(queue, sender, flags, data, size, sent_cb);
         return 0;
     }
-
-    qemu_net_queue_flush(queue);
+    if (ret > 0) {
+        qemu_net_queue_flush(queue);
+    }
 
     return ret;
 }
@@ -214,8 +215,9 @@ ssize_t qemu_net_queue_send_iov(NetQueue *queue,
         qemu_net_queue_append_iov(queue, sender, flags, iov, iovcnt, sent_cb);
         return 0;
     }
-
-    qemu_net_queue_flush(queue);
+    if (ret > 0) {
+        qemu_net_queue_flush(queue);
+    }
 
     return ret;
 }
@@ -251,7 +253,7 @@ void qemu_net_queue_flush(NetQueue *queue)
             break;
         }
 
-        if (packet->sent_cb) {
+        if (ret > 0 && packet->sent_cb) {
             packet->sent_cb(packet->sender, ret);
         }
 
-- 
1.7.1

             reply	other threads:[~2011-10-27  9:04 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-10-27  9:02 Mark Wu [this message]
2011-10-28  9:13 ` [Qemu-devel] [PATCH] net: Only flush queue or call sent callback on successful delivery Stefan Hajnoczi
2011-10-28 10:02   ` Mark Wu
2011-10-28 10:10     ` Stefan Hajnoczi

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=1319706145-26599-1-git-send-email-wudxw@linux.vnet.ibm.com \
    --to=wudxw@linux.vnet.ibm.com \
    --cc=aliguori@us.ibm.com \
    --cc=markmc@redhat.com \
    --cc=qemu-devel@nongnu.org \
    /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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).