aboutsummaryrefslogtreecommitdiff
path: root/sbuf.c
diff options
context:
space:
mode:
authorJan Kiszka <jan.kiszka@siemens.com>2012-03-30 19:29:08 +0200
committerJan Kiszka <jan.kiszka@siemens.com>2012-03-30 19:43:00 +0200
commit35e2bb8ff467da6eefef9650fc5b80e224807ebb (patch)
tree9388babe4d98bae85e0ac9cc2bf1cd54d99a27a3 /sbuf.c
parent8d259f48aeb258c500362056ab52c856eb2fd4f1 (diff)
downloadslirp-35e2bb8ff467da6eefef9650fc5b80e224807ebb.zip
slirp-35e2bb8ff467da6eefef9650fc5b80e224807ebb.tar.gz
slirp-35e2bb8ff467da6eefef9650fc5b80e224807ebb.tar.bz2
slirp: Signal free input buffer space to io-thread
This massively accelerates slirp reception speed: If data arrives faster than the guest can read it from the input buffer, the file descriptor for the corresponding socket was taken out of the fdset for select. However, the event of the guest reading enough data from the buffer was not signaled. Thus, the io-thread only noticed this change on the next time-driven poll. Fix this by kicking the io-thread as required. Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
Diffstat (limited to 'sbuf.c')
-rw-r--r--sbuf.c7
1 files changed, 7 insertions, 0 deletions
diff --git a/sbuf.c b/sbuf.c
index 632595a..521da08 100644
--- a/sbuf.c
+++ b/sbuf.c
@@ -6,6 +6,7 @@
*/
#include <slirp.h>
+#include <main-loop.h>
static void sbappendsb(struct sbuf *sb, struct mbuf *m);
@@ -16,6 +17,8 @@ void sbfree(struct sbuf *sb)
void sbdrop(struct sbuf *sb, int num)
{
+ int limit = sb->sb_datalen / 2;
+
/*
* We can only drop how much we have
* This should never succeed
@@ -26,6 +29,10 @@ void sbdrop(struct sbuf *sb, int num)
sb->sb_rptr += num;
if (sb->sb_rptr >= sb->sb_data + sb->sb_datalen)
sb->sb_rptr -= sb->sb_datalen;
+
+ if (sb->sb_cc < limit && sb->sb_cc + num >= limit) {
+ qemu_notify_event();
+ }
}
void sbreserve(struct sbuf *sb, int size)