From owner-freebsd-arch@FreeBSD.ORG Wed Aug 17 01:01:54 2005 Return-Path: X-Original-To: freebsd-arch@freebsd.org Delivered-To: freebsd-arch@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id 1F35816A423; Wed, 17 Aug 2005 01:01:54 +0000 (GMT) (envelope-from bde@zeta.org.au) Received: from mailout1.pacific.net.au (mailout1.pacific.net.au [61.8.0.84]) by mx1.FreeBSD.org (Postfix) with ESMTP id 671ED43D48; Wed, 17 Aug 2005 01:01:53 +0000 (GMT) (envelope-from bde@zeta.org.au) Received: from mailproxy1.pacific.net.au (mailproxy1.pacific.net.au [61.8.0.86]) by mailout1.pacific.net.au (8.13.4/8.13.4/Debian-3) with ESMTP id j7H11pkk016746; Wed, 17 Aug 2005 11:01:51 +1000 Received: from epsplex.bde.org (katana.zip.com.au [61.8.7.246]) by mailproxy1.pacific.net.au (8.13.4/8.13.4/Debian-3) with ESMTP id j7H11nXp011889; Wed, 17 Aug 2005 11:01:50 +1000 Date: Wed, 17 Aug 2005 11:01:49 +1000 (EST) From: Bruce Evans X-X-Sender: bde@epsplex.bde.org To: Pawel Jakub Dawidek In-Reply-To: <20050816133307.GD3944@garage.freebsd.pl> Message-ID: <20050817104144.L1361@epsplex.bde.org> References: <20050816221033.C47830@delplex.bde.org> <20050816133307.GD3944@garage.freebsd.pl> MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII; format=flowed Cc: m.ehinger@ltur.de, freebsd-arch@freebsd.org Subject: Re: sysctl_proc calls handler twice X-BeenThere: freebsd-arch@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Discussion related to FreeBSD architecture List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 17 Aug 2005 01:01:54 -0000 On Tue, 16 Aug 2005, Pawel Jakub Dawidek wrote: > On Tue, Aug 16, 2005 at 11:17:21PM +1000, Bruce Evans wrote: > +> No, just don't call it twice like sysctl(8) if you know the size in advance > +> or from a previous call (and know that it won't change or handle the error > +> from it changing...). > > Thread's author, as I understand/guess it, represents kernel side. > He doesn't want his handler to be called twice and tools like sysctl(8) > are not able to know size of every sysctl, so he just has to be ready > that his handler will be called twice. [It turned out to be a race problem] Well, any handler may be called any number of times in any order, including possibly concurrently. All sysctls are still Giant-locked so concurent calls can't actually happen, but making a separate call to determine the size gives races anyway if the size can change. Applications should loop if the size that they got turns out to be insufficent. sysctl(8) doesn't do this -- it doubles the size but doesn't retry. Writing requires even more care. Bruce