From owner-freebsd-net Fri Sep 8 15:34:18 2000 Delivered-To: freebsd-net@freebsd.org Received: from khavrinen.lcs.mit.edu (khavrinen.lcs.mit.edu [18.24.4.193]) by hub.freebsd.org (Postfix) with ESMTP id 1654237B423; Fri, 8 Sep 2000 15:34:16 -0700 (PDT) Received: (from wollman@localhost) by khavrinen.lcs.mit.edu (8.9.3/8.9.3) id SAA56346; Fri, 8 Sep 2000 18:34:08 -0400 (EDT) (envelope-from wollman) Date: Fri, 8 Sep 2000 18:34:08 -0400 (EDT) From: Garrett Wollman Message-Id: <200009082234.SAA56346@khavrinen.lcs.mit.edu> To: Alfred Perlstein Cc: wollman@freebsd.org, net@freebsd.org Subject: Your comment re so_gencnt In-Reply-To: <20000908142322.I12231@fw.wintelcom.net> References: <20000908142322.I12231@fw.wintelcom.net> Sender: owner-freebsd-net@FreeBSD.ORG Precedence: bulk X-Loop: FreeBSD.org < said: > /* XXX race condition for reentrant kernel */ > bzero(so, sizeof *so); > so->so_gencnt = ++so_gencnt; > Is the race condition on the ++so_gencnt? No, the race condition is between the bzero (which might set so->so_gencnt to a currently-valid value) and the assignment to so->so_gencnt. Statistically speaking, it's a fairly unlikely race, but the correct thing to do would be to zero everything *but* the generation count, and do the assignment before zeroing anything. I didn't want to worry about that case. (I probably should have written ``preemptible'' rather than ``reentrant'' there.) -GAWollman To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-net" in the body of the message