Date: Sat, 23 Jul 2005 18:44:16 GMT From: Victor Cruceru <soc-victor@FreeBSD.org> To: Perforce Change Reviews <perforce@freebsd.org> Subject: PERFORCE change 80875 for review Message-ID: <200507231844.j6NIiGaC035005@repoman.freebsd.org>
next in thread | raw e-mail | index | archive | help
http://perforce.freebsd.org/chv.cgi?CH=80875 Change 80875 by soc-victor@soc-victor_82.76.158.176 on 2005/07/23 18:44:05 Made the hrDeviceTable's refresh to work. Note: need to upgrade libdevinfo with the latest version in order to have the chance to re-query the system for changes. Affected files ... .. //depot/projects/soc2005/bsnmp/usr.sbin/bsnmpd/modules/snmp_hostres/Makefile#11 edit .. //depot/projects/soc2005/bsnmp/usr.sbin/bsnmpd/modules/snmp_hostres/hostres_device_tbl.c#2 edit Differences ... ==== //depot/projects/soc2005/bsnmp/usr.sbin/bsnmpd/modules/snmp_hostres/Makefile#11 (text+ko) ==== @@ -3,6 +3,28 @@ # All rights reserved. # Author: Victor Cruceru <soc-victor@freebsd.org> # +# Redistribution of this software and documentation and use in source and +# binary forms, with or without modification, are permitted provided that +# the following conditions are met: +# +# 1. Redistributions of source code or documentation must retain the above +# copyright notice, this list of conditions and the following disclaimer. +# 2. Redistributions in binary form must reproduce the above copyright +# notice, this list of conditions and the following disclaimer in the +# documentation and/or other materials provided with the distribution. +# +# THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND +# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +# ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE +# FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL +# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS +# OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) +# HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT +# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY +# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF +# SUCH DAMAGE. +# CONTRIB=${.CURDIR}/../../../../contrib/bsnmp ==== //depot/projects/soc2005/bsnmp/usr.sbin/bsnmpd/modules/snmp_hostres/hostres_device_tbl.c#2 (text+ko) ==== @@ -249,21 +249,6 @@ } void init_hrDevice_tbl_v(void) { - if ( hrState_g.dev_root != NULL ) { - syslog(LOG_ERR,"hrDeviceTable: attempt to re-initialization of devinfo."); - return; - } - if (devinfo_init() != 0) { - syslog(LOG_ERR,"hrDeviceTable: devinfo_init failed: %m"); - return; - - } - hrState_g.dev_root = devinfo_handle_to_device(DEVINFO_ROOT_DEVICE); - - if (hrState_g.dev_root == NULL) { - syslog(LOG_ERR,"hrDeviceTable: can't get the root device: %m"); - return; - } refresh_hrDevice_tbl_v(); } @@ -303,6 +288,23 @@ HR_DPRINTF((stderr, "%s: no refresh needed\n ",__func__)); return; } + if ( hrState_g.dev_root != NULL ) { + syslog(LOG_ERR,"hrDeviceTable: attempt to re-initialization of devinfo."); + return; + } + if (devinfo_init() != 0) { + syslog(LOG_ERR,"hrDeviceTable: devinfo_init failed: %m"); + return; + + } + hrState_g.dev_root = devinfo_handle_to_device(DEVINFO_ROOT_DEVICE); + + if (hrState_g.dev_root == NULL) { + syslog(LOG_ERR,"hrDeviceTable: can't get the root device: %m. Most likely you need to upgrade libdevinfo!"); + return; + } + + /*mark each entry as missing*/ TAILQ_FOREACH(entry, &hrState_g.hr_device_tbl, link) entry->flags &= ~HR_DEVICE_FOUND; @@ -324,6 +326,11 @@ hrState_g.hrDevice_tbl_age = time(NULL); + + devinfo_free(); + hrState_g.dev_root = NULL; + + HR_DPRINTF((stderr, "%s: refresh DONE\n ",__func__)); }
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200507231844.j6NIiGaC035005>