mirror of
https://gitlab.nic.cz/labs/bird.git
synced 2024-11-08 12:18:42 +00:00
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).
This commit is contained in:
parent
2757985709
commit
4323099da9
@ -30,6 +30,12 @@
|
|||||||
#include "lib/unix.h"
|
#include "lib/unix.h"
|
||||||
#include "lib/sysio.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
|
* Tracked Files
|
||||||
*/
|
*/
|
||||||
@ -1341,22 +1347,27 @@ io_loop(void)
|
|||||||
{
|
{
|
||||||
sock *s = current_sock;
|
sock *s = current_sock;
|
||||||
int e;
|
int e;
|
||||||
|
int steps = MAX_STEPS;
|
||||||
if (FD_ISSET(s->fd, &rd) && s->rx_hook)
|
if (FD_ISSET(s->fd, &rd) && s->rx_hook)
|
||||||
do
|
do
|
||||||
{
|
{
|
||||||
|
steps--;
|
||||||
e = sk_read(s);
|
e = sk_read(s);
|
||||||
if (s != current_sock)
|
if (s != current_sock)
|
||||||
goto next;
|
goto next;
|
||||||
}
|
}
|
||||||
while (e && s->rx_hook);
|
while (e && s->rx_hook && steps);
|
||||||
|
|
||||||
|
steps = MAX_STEPS;
|
||||||
if (FD_ISSET(s->fd, &wr))
|
if (FD_ISSET(s->fd, &wr))
|
||||||
do
|
do
|
||||||
{
|
{
|
||||||
|
steps--;
|
||||||
e = sk_write(s);
|
e = sk_write(s);
|
||||||
if (s != current_sock)
|
if (s != current_sock)
|
||||||
goto next;
|
goto next;
|
||||||
}
|
}
|
||||||
while (e);
|
while (e && steps);
|
||||||
current_sock = sk_next(s);
|
current_sock = sk_next(s);
|
||||||
next: ;
|
next: ;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user