From 9bff3b7f01b2fde6d2083d9fb71beddb46323c8c Mon Sep 17 00:00:00 2001 From: Ben Pfaff Date: Wed, 13 Aug 2008 11:30:31 -0700 Subject: [PATCH] rconn: Wake up immediately if we drain the send queue. 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 | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/lib/rconn.c b/lib/rconn.c index da3ffb67..671a584d 100644 --- a/lib/rconn.c +++ b/lib/rconn.c @@ -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 -- 2.30.2