From owner-freebsd-hackers@FreeBSD.ORG Mon May 16 12:51:26 2005 Return-Path: Delivered-To: freebsd-hackers@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id F133116A4CE for ; Mon, 16 May 2005 12:51:26 +0000 (GMT) Received: from fafoe.narf.at (chello213047085026.6.14.vie.surfer.at [213.47.85.26]) by mx1.FreeBSD.org (Postfix) with ESMTP id 5346843D45 for ; Mon, 16 May 2005 12:51:26 +0000 (GMT) (envelope-from stefan@fafoe.narf.at) Received: from wombat.fafoe.narf.at (wombat.fafoe.narf.at [192.168.1.42]) by fafoe.narf.at (Postfix) with ESMTP id B075E3FA6; Mon, 16 May 2005 14:51:14 +0200 (CEST) Received: by wombat.fafoe.narf.at (Postfix, from userid 1001) id 1571CDF; Mon, 16 May 2005 14:51:12 +0200 (CEST) Date: Mon, 16 May 2005 14:51:12 +0200 From: Stefan Farfeleder To: Juho Vuori Message-ID: <20050516125109.GF33622@wombat.fafoe.narf.at> Mail-Followup-To: Juho Vuori , freebsd-hackers@freebsd.org References: <42887FEE.3000705@kepa.fi> Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="sdtB3X0nJg68CQEu" Content-Disposition: inline In-Reply-To: <42887FEE.3000705@kepa.fi> User-Agent: Mutt/1.5.9i cc: freebsd-hackers@freebsd.org Subject: Re: Bug in devinfo or something wrong with me? X-BeenThere: freebsd-hackers@freebsd.org X-Mailman-Version: 2.1.1 Precedence: list List-Id: Technical Discussions relating to FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 16 May 2005 12:51:27 -0000 --sdtB3X0nJg68CQEu Content-Type: text/plain; charset=us-ascii Content-Disposition: inline On Mon, May 16, 2005 at 02:11:42PM +0300, Juho Vuori wrote: > The below included simple program reliably printfs "error 4\n" on > 5.4-RELEASE. Am I understanding something wrong or is this a bug in > libdevinfo? There is indeed a bug in libdevinfo. > To continue on this however, if you put say sleep(5) between > devinfo_free() and the second devinfo_init() and manage to change the > device configuration during the sleep (tested with pluggin in/out a USB > memory), the program terminates with no errors. I've run into other > oddities with devinfo as well, but in much more complex situations so > they might just as well be variations of this simple example. > if (devinfo_init()) { devinfo_init() initialises the devinfo_dev tailq, devinfo_generation and sets devinfo_initted to 1. > devinfo_free(); devinfo_free() clears devinfo_dev and sets devinfo_initted to 0 but devinfo_generation keeps its value. > if (devinfo_init()) { Now devinfo_dev doesn't get filled because ubus.ub_generation == devinfo_generation. Here is a patch that resets devinfo_generation to 0 in devinfo_free(). The whole file can probably be simplified a bit due to this bug. Stefan --sdtB3X0nJg68CQEu Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename="devinfo.c.diff" Index: devinfo.c =================================================================== RCS file: /home/ncvs/src/lib/libdevinfo/devinfo.c,v retrieving revision 1.6 diff -I.svn -u -r1.6 devinfo.c --- devinfo.c 1 Mar 2005 20:32:05 -0000 1.6 +++ devinfo.c 16 May 2005 12:40:24 -0000 @@ -367,6 +370,7 @@ free(dr); } devinfo_initted = 0; + devinfo_generation = 0; } /* --sdtB3X0nJg68CQEu--