rconn: Wake up immediately if we drain the send queue.
authorBen Pfaff <blp@nicira.com>
Wed, 13 Aug 2008 18:30:31 +0000 (11:30 -0700)
committerBen Pfaff <blp@nicira.com>
Wed, 13 Aug 2008 18:30:31 +0000 (11:30 -0700)
It is possible that some task is waiting for space to open up in the
send queue, so we need to give it a chance to run.

lib/rconn.c

index da3ffb6..671a584 100644 (file)
@@ -310,12 +310,18 @@ run_CONNECTING(struct rconn *rc)
 static void
 do_tx_work(struct rconn *rc)
 {
+    if (!rc->txq.n) {
+        return;
+    }
     while (rc->txq.n > 0) {
         int error = try_send(rc);
         if (error) {
             break;
         }
     }
+    if (!rc->txq.n) {
+        poll_immediate_wake();
+    }
 }
 
 static unsigned int
@@ -618,6 +624,9 @@ disconnect(struct rconn *rc, int error)
 static void
 flush_queue(struct rconn *rc)
 {
+    if (!rc->txq.n) {
+        return;
+    }
     while (rc->txq.n > 0) {
         struct buffer *b = queue_pop_head(&rc->txq);
         int *n_queued = b->private;
@@ -626,6 +635,7 @@ flush_queue(struct rconn *rc)
         }
         buffer_delete(b);
     }
+    poll_immediate_wake();
 }
 
 static unsigned int