summaryrefslogtreecommitdiffstats
path: root/usr.sbin/bsnmpd
diff options
context:
space:
mode:
authorae <ae@FreeBSD.org>2011-07-11 12:51:35 +0000
committerae <ae@FreeBSD.org>2011-07-11 12:51:35 +0000
commit6425e22b7b2564aacbf2900bc49405df8f170949 (patch)
tree1546f7401cb63ff18c37a0ba635da6dc4342b085 /usr.sbin/bsnmpd
parent7b8dcbd8e6df85a4dfbc98b282ff1dc8e0424ade (diff)
downloadFreeBSD-src-6425e22b7b2564aacbf2900bc49405df8f170949.zip
FreeBSD-src-6425e22b7b2564aacbf2900bc49405df8f170949.tar.gz
Use full buffer size in read(2) call, there is no need to preserve the
last byte of the buffer. Since we call refresh_device_tbl() for any devctl event types - no need to check the first byte of buffer. Remove these checks. Also remove logging for the case of unknown devd message. It incorrectly triggers when all devctl events are not fit into one buffer and part of unread data will be read in the next pass. When length of data readed from devctl is equal to sizeof(buf), then try to read from socket again, to read full data. MFC after: 2 weeks
Diffstat (limited to 'usr.sbin/bsnmpd')
-rw-r--r--usr.sbin/bsnmpd/modules/snmp_hostres/hostres_device_tbl.c16
1 files changed, 5 insertions, 11 deletions
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 cb38145..99d55ee 100644
--- a/usr.sbin/bsnmpd/modules/snmp_hostres/hostres_device_tbl.c
+++ b/usr.sbin/bsnmpd/modules/snmp_hostres/hostres_device_tbl.c
@@ -449,7 +449,8 @@ devd_socket_callback(int fd, void *arg __unused)
HRDBG("called");
- read_len = read(fd, buf, sizeof(buf) - 1);
+again:
+ read_len = read(fd, buf, sizeof(buf));
if (read_len < 0) {
if (errno == EBADF) {
devd_sock = -1;
@@ -476,16 +477,9 @@ devd_socket_callback(int fd, void *arg __unused)
syslog(LOG_ERR, "Closing devd_fd, revert to devinfo polling");
} else {
- switch (buf[0]) {
- case '+':
- case '-':
- case '?':
- case '!':
- refresh_device_tbl(1);
- return;
- default:
- syslog(LOG_ERR, "unknown message from devd socket");
- }
+ if (read_len == sizeof(buf))
+ goto again;
+ refresh_device_tbl(1);
}
}
OpenPOWER on IntegriCloud