mirror of
https://git.rtems.org/rtems-libbsd/
synced 2025-10-15 11:55:36 +08:00
ROUTE(8): Disable routing socket timeout support
FIXME: This reverts the following change in FreeBSD. commit 76a39ff8dc5e1f7bc8a065115ec3837761ed0600 Author: ae <ae@FreeBSD.org> Date: Wed Jul 27 08:26:34 2016 +0000 Due to dropped mbuf in netisr queue route(8) can fall into infinity loop of reading the rtsock's feed. When it used by some scripts, this leads to growing number of not finished route(8) instances and thus growing number of rtsock consumers. Add SIGALRM handler to prevent this.
This commit is contained in:
@@ -164,6 +164,7 @@ static int fiboptlist_range(const char *, struct fibl_head_t *);
|
||||
|
||||
static void usage(const char *) __dead2;
|
||||
|
||||
#ifndef __rtems__
|
||||
#define READ_TIMEOUT 10
|
||||
static volatile sig_atomic_t stop_read;
|
||||
|
||||
@@ -173,6 +174,9 @@ stopit(int sig __unused)
|
||||
|
||||
stop_read = 1;
|
||||
}
|
||||
#else /* __rtems__ */
|
||||
#define stop_read 0
|
||||
#endif /* __rtems__ */
|
||||
|
||||
static void
|
||||
usage(const char *cp)
|
||||
@@ -838,7 +842,9 @@ set_metric(char *value, int key)
|
||||
static void
|
||||
newroute(int argc, char **argv)
|
||||
{
|
||||
#ifndef __rtems__
|
||||
struct sigaction sa;
|
||||
#endif /* __rtems__ */
|
||||
struct hostent *hp;
|
||||
struct fibl *fl;
|
||||
char *cmd;
|
||||
@@ -854,11 +860,13 @@ newroute(int argc, char **argv)
|
||||
hp = NULL;
|
||||
TAILQ_INIT(&fibl_head);
|
||||
|
||||
#ifndef __rtems__
|
||||
sigemptyset(&sa.sa_mask);
|
||||
sa.sa_flags = 0;
|
||||
sa.sa_handler = stopit;
|
||||
if (sigaction(SIGALRM, &sa, 0) == -1)
|
||||
warn("sigaction SIGALRM");
|
||||
#endif /* __rtems__ */
|
||||
|
||||
cmd = argv[0];
|
||||
if (*cmd != 'g' && *cmd != 's')
|
||||
@@ -1610,17 +1618,21 @@ rtmsg(int cmd, int flags, int fib)
|
||||
return (-1);
|
||||
}
|
||||
if (cmd == RTM_GET) {
|
||||
#ifndef __rtems__
|
||||
stop_read = 0;
|
||||
alarm(READ_TIMEOUT);
|
||||
#endif /* __rtems__ */
|
||||
do {
|
||||
l = read(s, (char *)&m_rtmsg, sizeof(m_rtmsg));
|
||||
} while (l > 0 && stop_read == 0 &&
|
||||
(rtm.rtm_seq != rtm_seq || rtm.rtm_pid != pid));
|
||||
#ifndef __rtems__
|
||||
if (stop_read != 0) {
|
||||
warnx("read from routing socket timed out");
|
||||
return (-1);
|
||||
} else
|
||||
alarm(0);
|
||||
#endif /* __rtems__ */
|
||||
if (l < 0)
|
||||
warn("read from routing socket");
|
||||
else
|
||||
|
Reference in New Issue
Block a user