| Barry Pearce 2005-04-08, 5:45 pm |
| Hi,
> what's a .lck file? locking by definition *must* be an OS capability or
> else it _is_ subject to race conditions.
errr. no. here is the code snippet:
persist = os.open(self.m_file, os.O_CREAT | os.O_EXCL | os.O_WRONLY, 0660)
O_CREAT | O_EXCL ensures that any race is coped with by the operating
system kernel - works equally well on mac/win32/unix/linux if two
threads try it at precisely the same time one will win one will fail -
the failed one simply re-evaluates the random and tries again. As yet
though I have yet to see a collision on my code...I could only test by
manufacturing the situation.
> Current locking uses the APR's global locking mechanism which decides
> based on OS and the httpd config/compile options what the most efficient
> locking mechanism is. There is no reason to reinvent the wheel here -
> it's a complex problem that I trust the APR folks are most qualified to
> solve.
Fair do. But its not complex - given that part of the day job is linux
kernel development - locking is not that bad!!! 
Regards,
Barry
|