Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/sbin/route Handle the routing socket overflowing gracefully.
details: https://anonhg.NetBSD.org/src/rev/5921afbf0dbd
branches: trunk
changeset: 360688:5921afbf0dbd
user: roy <roy%NetBSD.org@localhost>
date: Fri Mar 23 11:57:33 2018 +0000
description:
Handle the routing socket overflowing gracefully.
diffstat:
sbin/route/route.c | 19 ++++++++++++++-----
1 files changed, 14 insertions(+), 5 deletions(-)
diffs (54 lines):
diff -r 0918fbf2a2ee -r 5921afbf0dbd sbin/route/route.c
--- a/sbin/route/route.c Fri Mar 23 10:05:45 2018 +0000
+++ b/sbin/route/route.c Fri Mar 23 11:57:33 2018 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: route.c,v 1.158 2017/12/13 17:42:44 christos Exp $ */
+/* $NetBSD: route.c,v 1.159 2018/03/23 11:57:33 roy Exp $ */
/*
* Copyright (c) 1983, 1989, 1991, 1993
@@ -39,7 +39,7 @@
#if 0
static char sccsid[] = "@(#)route.c 8.6 (Berkeley) 4/28/95";
#else
-__RCSID("$NetBSD: route.c,v 1.158 2017/12/13 17:42:44 christos Exp $");
+__RCSID("$NetBSD: route.c,v 1.159 2018/03/23 11:57:33 roy Exp $");
#endif
#endif /* not lint */
@@ -341,8 +341,10 @@
continue;
rtm->rtm_type = RTM_DELETE;
rtm->rtm_seq = seqno;
- if ((rlen = prog_write(sock, next,
- rtm->rtm_msglen)) < 0) {
+ do {
+ rlen = prog_write(sock, next, rtm->rtm_msglen);
+ } while (rlen == -1 && errno == ENOBUFS);
+ if (rlen == -1) {
warnx("writing to routing socket: %s",
route_strerror(errno));
return 1;
@@ -1139,6 +1141,10 @@
for(i = 0; count == 0 || i < count; i++) {
time_t now;
n = prog_read(sock, &u, sizeof(u));
+ if (n == -1) {
+ warn("read");
+ continue;
+ }
now = time(NULL);
(void)printf("got message of size %d on %s", n, ctime(&now));
print_rtmsg(&u.hdr, n);
@@ -1214,7 +1220,10 @@
}
if (debugonly)
return 0;
- if ((rlen = prog_write(sock, (char *)&m_rtmsg, l)) < 0) {
+ do {
+ rlen = prog_write(sock, (char *)&m_rtmsg, l);
+ } while (rlen == -1 && errno == ENOBUFS);
+ if (rlen == -1) {
warnx("writing to routing socket: %s", route_strerror(errno));
return -1;
}
Home |
Main Index |
Thread Index |
Old Index