I implemented a trivial "database", stored in ordinary files, and had to ensure mutual exclusion of database access between simultaneously running CGI scripts. Since each CGI run is short, I simply locked the entire database for the entire run. Claiming a lock on a file is easy in C (well, it takes 18 lines...), but there's nothing in the standard Haskell libraries that can do it. So I borrowed a little C code from the net, and called it via the FFI.
Locking support is available in the unix package distributed with GHC. See: http://www.haskell.org/ghc/docs/latest/html/unix/System.Posix.IO.html#7 Cheers, Simon
On Fri, 5 Sep 2003, Simon Marlow wrote:
... Claiming a lock on a file is
easy in C (well, it takes 18 lines...), but there's nothing in the standard Haskell libraries that can do it. So I borrowed a little C code from the net, and called it via the FFI.
Locking support is available in the unix package distributed with GHC. See:
http://www.haskell.org/ghc/docs/latest/html/unix/System.Posix.IO.html#7
Cheers, Simon
That'll teach me not just to look in the standard Haskell 98 libraries! Thanks. john
participants (2)
-
John Hughes -
Simon Marlow