Date: Mon, 28 Dec 2009 11:19:18 -0500 From: John Baldwin <jhb@freebsd.org> To: David Xu <davidxu@freebsd.org> Cc: freebsd-threads@freebsd.org Subject: Re: first patch for process-shared semaphore Message-ID: <200912281119.18173.jhb@freebsd.org> In-Reply-To: <4B341241.9090208@freebsd.org> References: <4B317741.8080004@freebsd.org> <200912240755.11841.jhb@freebsd.org> <4B341241.9090208@freebsd.org>
next in thread | previous in thread | raw e-mail | index | archive | help
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<name> and /tmp/SEMD<name> where <name> 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
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200912281119.18173.jhb>