From owner-freebsd-arch@FreeBSD.ORG Tue Aug 23 16:56:37 2005 Return-Path: X-Original-To: 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 D18E516A41F for ; Tue, 23 Aug 2005 16:56:37 +0000 (GMT) (envelope-from babkin@verizon.net) Received: from vms048pub.verizon.net (vms048pub.verizon.net [206.46.252.48]) by mx1.FreeBSD.org (Postfix) with ESMTP id 8CE4E43D48 for ; Tue, 23 Aug 2005 16:56:37 +0000 (GMT) (envelope-from babkin@verizon.net) Received: from vms070.mailsrvcs.net ([192.168.1.3]) by vms048.mailsrvcs.net (Sun Java System Messaging Server 6.2 HotFix 0.04 (built Dec 24 2004)) with ESMTPA id <0ILO000Q7PQDEBA0@vms048.mailsrvcs.net> for arch@freebsd.org; Tue, 23 Aug 2005 11:56:37 -0500 (CDT) Date: Tue, 23 Aug 2005 11:56:37 -0500 (CDT) From: Sergey Babkin To: Dan Nelson , Peter Jeremy Message-id: <1347627.1124816197248.JavaMail.root@vms070.mailsrvcs.net> MIME-version: 1.0 Content-type: text/plain; charset=us-ascii Content-transfer-encoding: 7bit Cc: arch@freebsd.org, Matthew Reimer Subject: Re: Re: [CFR] reflect resolv.conf update to running application X-BeenThere: freebsd-arch@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list Reply-To: babkin@users.sf.net List-Id: Discussion related to FreeBSD architecture List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 23 Aug 2005 16:56:37 -0000 >In the last episode (Aug 23), Peter Jeremy said: >> On Mon, 2005-Aug-22 13:18:46 -0700, Matthew Reimer wrote: >> >How about just stat'ing resolv.conf if more than X seconds has >> >passed since the last stat, rather than for every lookup? >> >> That reduces the number of stat() calls but doesn't resolve the >> possibility of reading a half-written resolv.conf. > >Easy enough to only reread the file if stat tells you it's more than 2 >seconds old. Won't reliably help: the file might change after you've done stat. The real solution would be to : * do stat, see that the file has changed * read the file into an intermediate buffer * wait 1 or 2 seconds * do stat again, if the time has not changed since the first stat then the contents of your buffer is valid and yu can use it -SB