From owner-p4-projects@FreeBSD.ORG Sat Jul 23 18:44:17 2005 Return-Path: X-Original-To: p4-projects@freebsd.org Delivered-To: p4-projects@freebsd.org Received: by hub.freebsd.org (Postfix, from userid 32767) id 6725F16A421; Sat, 23 Jul 2005 18:44:17 +0000 (GMT) X-Original-To: perforce@freebsd.org Delivered-To: perforce@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id 298F616A41F for ; Sat, 23 Jul 2005 18:44:17 +0000 (GMT) (envelope-from soc-victor@freebsd.org) Received: from repoman.freebsd.org (repoman.freebsd.org [216.136.204.115]) by mx1.FreeBSD.org (Postfix) with ESMTP id E3EE543D45 for ; Sat, 23 Jul 2005 18:44:16 +0000 (GMT) (envelope-from soc-victor@freebsd.org) Received: from repoman.freebsd.org (localhost [127.0.0.1]) by repoman.freebsd.org (8.13.1/8.13.1) with ESMTP id j6NIiGhX035008 for ; Sat, 23 Jul 2005 18:44:16 GMT (envelope-from soc-victor@freebsd.org) Received: (from perforce@localhost) by repoman.freebsd.org (8.13.1/8.13.1/Submit) id j6NIiGaC035005 for perforce@freebsd.org; Sat, 23 Jul 2005 18:44:16 GMT (envelope-from soc-victor@freebsd.org) Date: Sat, 23 Jul 2005 18:44:16 GMT Message-Id: <200507231844.j6NIiGaC035005@repoman.freebsd.org> X-Authentication-Warning: repoman.freebsd.org: perforce set sender to soc-victor@freebsd.org using -f From: Victor Cruceru To: Perforce Change Reviews Cc: Subject: PERFORCE change 80875 for review X-BeenThere: p4-projects@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: p4 projects tree changes List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 23 Jul 2005 18:44:18 -0000 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 # +# 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__)); }