summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorOndrej Zajicek <santiago@crfreenet.org>2009-06-20 00:59:32 +0200
committerOndrej Zajicek <santiago@crfreenet.org>2009-06-20 00:59:32 +0200
commit4323099da9e6e8d53072595009731da9b39e9f19 (patch)
treead75ccad19c8df8105b1f2b07fe3dae794c9775e
parent2757985709f0a132427d4f440ec913b6a0064f80 (diff)
downloadbird-4323099da9e6e8d53072595009731da9b39e9f19.tar
bird-4323099da9e6e8d53072595009731da9b39e9f19.zip
Fixes bug in scheduling of callback by main loop.
If other side of a socket is sending data faster than BIRD is processing, BIRD does not schedule any other callbacks (events, timers, rx/tx callbacks).
-rw-r--r--sysdep/unix/io.c15
1 files changed, 13 insertions, 2 deletions
diff --git a/sysdep/unix/io.c b/sysdep/unix/io.c
index 58aed4e..91ca4c6 100644
--- a/sysdep/unix/io.c
+++ b/sysdep/unix/io.c
@@ -30,6 +30,12 @@
#include "lib/unix.h"
#include "lib/sysio.h"
+/* Maximum number of calls of rx/tx handler for one socket in one
+ * select iteration. Should be small enough to not monopolize CPU by
+ * one protocol instance.
+ */
+#define MAX_STEPS 4
+
/*
* Tracked Files
*/
@@ -1341,22 +1347,27 @@ io_loop(void)
{
sock *s = current_sock;
int e;
+ int steps = MAX_STEPS;
if (FD_ISSET(s->fd, &rd) && s->rx_hook)
do
{
+ steps--;
e = sk_read(s);
if (s != current_sock)
goto next;
}
- while (e && s->rx_hook);
+ while (e && s->rx_hook && steps);
+
+ steps = MAX_STEPS;
if (FD_ISSET(s->fd, &wr))
do
{
+ steps--;
e = sk_write(s);
if (s != current_sock)
goto next;
}
- while (e);
+ while (e && steps);
current_sock = sk_next(s);
next: ;
}