[racket] `port-try-file-lock?' change (was: flock() stops racket-5.1.1 build on Solaris x86)

From: Matthew Flatt (mflatt at cs.utah.edu)
Date: Thu Aug 11 15:37:13 EDT 2011

At Mon, 23 May 2011 20:28:20 -0600, Matthew Flatt wrote:
> [... problems with `port-try-file-lock?' under Solaris]
> 
> I don't see an easy way around the problem. Your patch to make file
> locks unsupported looks like the right one for now.

We have a use for `port-try-file-lock?' that needs to work on all
platforms, including Solaris, so I took another look this problem. I
found a solution that involves forking a process under Solaris for each
file lock, so there's no issue of other file descriptors being closed
for the same file within the same process.

There's another problem, though, which is that fcntl(...,F_SETLK,...)
allows exclusive locks only on writable file descriptors, and it allows
shared locks only on readable file descriptors. So,
`port-try-file-lock?' now requires an output port for an 'exclusive
lock, and it requires an input port for a 'shared lock.



Posted on the users mailing list.