Patchwork Only flush queue or call sent callback on successful delivery

login
register
mail settings
Submitter Mark Wu
Date Oct. 27, 2011, 8:50 a.m.
Message ID <1319705416-24285-1-git-send-email-wudxw@linux.vnet.ibm.com>
Download mbox | patch
Permalink /patch/122091/
State New
Headers show

Comments

Mark Wu - Oct. 27, 2011, 8:50 a.m.
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(-)

Patch

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);
         }