From owner-freebsd-threads@FreeBSD.ORG Mon Dec 28 16:37:07 2009 Return-Path: Delivered-To: freebsd-threads@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 94B971065672; Mon, 28 Dec 2009 16:37:07 +0000 (UTC) (envelope-from jhb@freebsd.org) Received: from cyrus.watson.org (cyrus.watson.org [65.122.17.42]) by mx1.freebsd.org (Postfix) with ESMTP id 673F18FC1B; Mon, 28 Dec 2009 16:37:07 +0000 (UTC) Received: from bigwig.baldwin.cx (66.111.2.69.static.nyinternet.net [66.111.2.69]) by cyrus.watson.org (Postfix) with ESMTPSA id 2637E46B0C; Mon, 28 Dec 2009 11:37:07 -0500 (EST) Received: from jhbbsd.localnet (unknown [209.249.190.9]) by bigwig.baldwin.cx (Postfix) with ESMTPA id 54BD18A01D; Mon, 28 Dec 2009 11:37:06 -0500 (EST) From: John Baldwin To: David Xu Date: Mon, 28 Dec 2009 11:19:18 -0500 User-Agent: KMail/1.12.1 (FreeBSD/7.2-CBSD-20091103; KDE/4.3.1; amd64; ; ) References: <4B317741.8080004@freebsd.org> <200912240755.11841.jhb@freebsd.org> <4B341241.9090208@freebsd.org> In-Reply-To: <4B341241.9090208@freebsd.org> MIME-Version: 1.0 Content-Type: Text/Plain; charset="iso-8859-1" Content-Transfer-Encoding: 7bit Message-Id: <200912281119.18173.jhb@freebsd.org> X-Greylist: Sender succeeded SMTP AUTH, not delayed by milter-greylist-4.0.1 (bigwig.baldwin.cx); Mon, 28 Dec 2009 11:37:06 -0500 (EST) X-Virus-Scanned: clamav-milter 0.95.1 at bigwig.baldwin.cx X-Virus-Status: Clean X-Spam-Status: No, score=-2.5 required=4.2 tests=AWL,BAYES_00,RDNS_NONE autolearn=no version=3.2.5 X-Spam-Checker-Version: SpamAssassin 3.2.5 (2008-06-10) on bigwig.baldwin.cx Cc: freebsd-threads@freebsd.org Subject: Re: first patch for process-shared semaphore X-BeenThere: freebsd-threads@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Threading on FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 28 Dec 2009 16:37:07 -0000 On Thursday 24 December 2009 8:15:45 pm David Xu wrote: > John Baldwin wrote: > > > Yes, Solaris uses files in /tmp and Darwin uses special file descriptors > > similar to what we do. However, you will have to restrict the namespace if > > you go the /tmp route to be safe I think similar to what Solaris does (no path > > separators, just simple names like 'foo'). > > I will only allow names like /XXX, make sure to be compatible with > current implementation. Actually, the current implementation in 8+ allow for arbitrary pathnames. However, that is a relatively recent change and it is probably ok to restrict it again. > > You might also want to use the > > same naming convention as Solaris if you go the /tmp route (I think they use a > > path other than .semaphore under /tmp IIRC). > > What is their name convention? The patch just create all semaphore files > in directory /tmp/.semaphore and semaphore name is not changed. They actually create two files in /tmp for each semaphore, a lock file and a data file. _Solaris Internals_ doesn't really indicate why the lock file exists. The files are named /tmp/SEML and /tmp/SEMD where does not include the leading '/', a sem_open() of '/foo' opens /tmp/SEMDfoo. It is perhaps safer to not assume that a /tmp/.semaphore directory exists and to create files in /tmp directly? > > Not sure if we want to do > > anything special to ensure that those particular set of files in /tmp always > > get purged on reboot to avoid weird bugs with semaphores unexpectedly > > persisting across reboots. > > > > Yes, this is an issue, I would like to purge it on reboot. Perhaps /etc/rc.d/cleartmp should always clean semaphores, or at least have a separate rc.conf variable (similar to the one for X files) that is enabled by default? -- John Baldwin