net: determine if packets can be sent before net queue deliver packets
authorZhi Yong Wu <wuzhy@linux.vnet.ibm.com>
Tue, 24 Jul 2012 15:35:18 +0000 (16:35 +0100)
committerStefan Hajnoczi <stefanha@linux.vnet.ibm.com>
Wed, 1 Aug 2012 12:32:11 +0000 (13:32 +0100)
Reviewed-by: Paolo Bonzini <pbonzini@redhat.com>
Signed-off-by: Zhi Yong Wu <wuzhy@linux.vnet.ibm.com>
Signed-off-by: Stefan Hajnoczi <stefanha@linux.vnet.ibm.com>
Reviewed-by: Laszlo Ersek <lersek@redhat.com>
net/queue.c
net/slirp.c
slirp/if.c
slirp/libslirp.h

index 0afd7830a4d5113cb1a9a3cebbfd22207e2c4524..e8030aafe4355cd04cb7ad8fea3f26d052931e19 100644 (file)
@@ -176,8 +176,8 @@ ssize_t qemu_net_queue_send(NetQueue *queue,
 {
     ssize_t ret;
 
-    if (queue->delivering) {
-        return qemu_net_queue_append(queue, sender, flags, data, size, NULL);
+    if (queue->delivering || !qemu_can_send_packet(sender)) {
+        return qemu_net_queue_append(queue, sender, flags, data, size, sent_cb);
     }
 
     ret = qemu_net_queue_deliver(queue, sender, flags, data, size);
@@ -200,8 +200,9 @@ ssize_t qemu_net_queue_send_iov(NetQueue *queue,
 {
     ssize_t ret;
 
-    if (queue->delivering) {
-        return qemu_net_queue_append_iov(queue, sender, flags, iov, iovcnt, NULL);
+    if (queue->delivering || !qemu_can_send_packet(sender)) {
+        return qemu_net_queue_append_iov(queue, sender, flags,
+                                         iov, iovcnt, sent_cb);
     }
 
     ret = qemu_net_queue_deliver_iov(queue, sender, flags, iov, iovcnt);
index 9d5ca79ff764ec395bb686756f7af8e3632fdc78..08adb97da59b7ff37697993cebfd7b7a81d2b8b9 100644 (file)
@@ -97,13 +97,6 @@ static void slirp_smb_cleanup(SlirpState *s);
 static inline void slirp_smb_cleanup(SlirpState *s) { }
 #endif
 
-int slirp_can_output(void *opaque)
-{
-    SlirpState *s = opaque;
-
-    return qemu_can_send_packet(&s->nc);
-}
-
 void slirp_output(void *opaque, const uint8_t *pkt, int pkt_len)
 {
     SlirpState *s = opaque;
index 096cf6fd07b645b35afa002019634cdc363898ef..533295dd075c1bd9f07b8dedcb9768dc5420c190 100644 (file)
@@ -177,11 +177,6 @@ void if_start(Slirp *slirp)
     }
 
     while (ifm_next) {
-        /* check if we can really output */
-        if (!slirp_can_output(slirp->opaque)) {
-            break;
-        }
-
         ifm = ifm_next;
         from_batchq = next_from_batchq;
 
index 77527ad922989c867625830c7f3dd22783fce568..9b471b50538f69532012b5c926e3de779c715255 100644 (file)
@@ -25,7 +25,6 @@ void slirp_select_poll(fd_set *readfds, fd_set *writefds, fd_set *xfds,
 void slirp_input(Slirp *slirp, const uint8_t *pkt, int pkt_len);
 
 /* you must provide the following functions: */
-int slirp_can_output(void *opaque);
 void slirp_output(void *opaque, const uint8_t *pkt, int pkt_len);
 
 int slirp_add_hostfwd(Slirp *slirp, int is_udp,