Received: (from majordomo@localhost) by oss.sgi.com (8.11.2/8.11.3) id f92Nwqh30736 for fam-outgoing; Tue, 2 Oct 2001 16:58:52 -0700 Received: from vergenet.net (root@fritz.vergenet.net [61.8.3.7]) by oss.sgi.com (8.11.2/8.11.3) with SMTP id f92NwjD30733 for ; Tue, 2 Oct 2001 16:58:46 -0700 Received: (from raster@localhost) by vergenet.net (8.11.6/8.11.6) id f92NwiF02833; Wed, 3 Oct 2001 09:58:44 +1000 From: raster@rasterman.com To: alexl@redhat.com, fam@oss.sgi.com Date: Wed, 3 Oct 2001 09:21:10 +1000 From: Carsten Haitzler (The Rasterman) To: Alex Larsson Cc: fam@oss.sgi.com Subject: Re: [fam] Fam race condition Message-Id: <20011003092110.7ac0f5ff.raster@rasterman.com> In-Reply-To: References: Organization: You expect me to be organized? X-Mailer: Sylpheed version 0.5.3 (GTK+ 1.2.8; i686-pc-linux-gnu) Mime-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit Sender: owner-fam@oss.sgi.com Precedence: bulk On Tue, 2 Oct 2001 16:30:51 -0400 (EDT) Alex Larsson babbled profusely: > I found a pretty bad race condition in fam. > If several changes are made to one file in the same second, fam will only > report the first one. It does not detect the following ones, because the > resolution of ctime (used to see if the file changed) is only one second. > > This patch partly fixes the problem: > > --- fam-oss-2.6.4-alex/fam/Interest.c++.race Tue Oct 2 16:05:45 2001 > +++ fam-oss-2.6.4-alex/fam/Interest.c++ Tue Oct 2 16:14:12 2001 > @@ -181,7 +181,13 @@ > > bool exists = status.st_mode != 0; > bool did_exist = old_stat.st_mode != 0; > - bool stat_changed = old_stat.st_ctime != status.st_ctime; > + bool stat_changed = > + (old_stat.st_ctime != status.st_ctime) || > + (old_stat.st_mode != status.st_mode) || > + (old_stat.st_uid != status.st_uid) || > + (old_stat.st_gid != status.st_gid) || > + (old_stat.st_size != status.st_size) || > + (old_stat.st_ino != status.st_ino); > old_stat = status; > > if (exists && !did_exist) > > But it is still broken if parts of the file contents are rewritten during > the second. I see no way to fix this except delaying change notifications > until the end of the second. That sort of breaks the reason for fam > though, so i didn't do that. > > How did sgi never notice this? They've shipped fam forever. Don't they > ever test their software? likely they havent heavily tested the "polling" mode - and rely on the kernel layer (imon) to do the work. i think they assume you knwo that polling mode isnt 100% reliable (could miss a file appear and dissapear if it does it between polls and more) so it wan't an issue to look into. at least that's what i assume was the case :) -- --------------- Codito, ergo sum - "I code, therefore I am" -------------------- The Rasterman (Carsten Haitzler) raster@rasterman.com Unemployed Bum raster@deephackmode.org Mobile Phone: +61 (0)408 363 984 Home Phone: 02 9386 9362 -- Source code, list archive, and docs: http://oss.sgi.com/projects/fam/ To unsubscribe: echo unsubscribe fam | mail majordomo@oss.sgi.com