From 7e7315b5428a63d1bc4be4b5295da5a493c02c98 Mon Sep 17 00:00:00 2001 From: "Pedro F. Giffuni" Date: Sat, 28 Oct 2017 21:26:49 +0000 Subject: [PATCH] bsnmpd: Only refresh devtree if devd event is a new or removed device. It makes sense to refresh the tree only when a device is inserted or removed, otherwise bsnmpd wastes lot of CPU. PR: 209368 MFC after: 1 week --- usr.sbin/bsnmpd/modules/snmp_hostres/hostres_device_tbl.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/usr.sbin/bsnmpd/modules/snmp_hostres/hostres_device_tbl.c b/usr.sbin/bsnmpd/modules/snmp_hostres/hostres_device_tbl.c index 8216acce27dc..a360898e6785 100644 --- a/usr.sbin/bsnmpd/modules/snmp_hostres/hostres_device_tbl.c +++ b/usr.sbin/bsnmpd/modules/snmp_hostres/hostres_device_tbl.c @@ -479,7 +479,9 @@ devd_socket_callback(int fd, void *arg __unused) } else { if (read_len == sizeof(buf)) goto again; - refresh_device_tbl(1); + /* Only refresh device table on a device add or remove event. */ + if (buf[0] == '+' || buf[0] == '-') + refresh_device_tbl(1); } }