From owner-svn-src-all@FreeBSD.ORG Mon Jul 11 12:51:36 2011 Return-Path: Delivered-To: svn-src-all@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 1C583106566C; Mon, 11 Jul 2011 12:51:36 +0000 (UTC) (envelope-from ae@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 0CBB18FC15; Mon, 11 Jul 2011 12:51:36 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.4/8.14.4) with ESMTP id p6BCpZ4T094277; Mon, 11 Jul 2011 12:51:35 GMT (envelope-from ae@svn.freebsd.org) Received: (from ae@localhost) by svn.freebsd.org (8.14.4/8.14.4/Submit) id p6BCpZ1c094275; Mon, 11 Jul 2011 12:51:35 GMT (envelope-from ae@svn.freebsd.org) Message-Id: <201107111251.p6BCpZ1c094275@svn.freebsd.org> From: "Andrey V. Elsukov" Date: Mon, 11 Jul 2011 12:51:35 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r223933 - head/usr.sbin/bsnmpd/modules/snmp_hostres X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 11 Jul 2011 12:51:36 -0000 Author: ae Date: Mon Jul 11 12:51:35 2011 New Revision: 223933 URL: http://svn.freebsd.org/changeset/base/223933 Log: 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 Modified: head/usr.sbin/bsnmpd/modules/snmp_hostres/hostres_device_tbl.c Modified: head/usr.sbin/bsnmpd/modules/snmp_hostres/hostres_device_tbl.c ============================================================================== --- head/usr.sbin/bsnmpd/modules/snmp_hostres/hostres_device_tbl.c Mon Jul 11 10:42:36 2011 (r223932) +++ head/usr.sbin/bsnmpd/modules/snmp_hostres/hostres_device_tbl.c Mon Jul 11 12:51:35 2011 (r223933) @@ -449,7 +449,8 @@ devd_socket_callback(int fd, void *arg _ 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 _ 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); } }