in reply to Re: File Locking plus delete Lockfile question
in thread File Locking plus delete Lockfile question
While I question the sanity of wanting to delete the lockfile (you do realize that other processes may already have opened the file and are all waiting to grab the lock?)Indeed, this could be a problem which I didn't see before. The problem is that I really would like to go away the lockfile. The reason is that in my application, we have not just one lock file of this type, but we create maybe a hundred or so per day, each guarding its own "checkin/checkout" system. At one point in time, this system will cease to exist, but because of the distributed nature of the application, no single instance has the knowledge whether or not a single "checkin/checkout" system is still alive or not. We only know that *if* the number of customers is still greater than 0, it is alive. Otherwise, it may be dead.
Initially, there is no lockfile at all (that's why I also pass the CREATE flag to sysopen. If the customer count drops back to zero one time, and I find a safe way to delete the lockfile, there is no harm done. If a new customer arrives later (i.e. it turns out that the system is not dead yet), the lockfile is simply recreated.
If I don't delete the lockfile, I would either need an external instance which manages whether a specific checkin/checkout system is alive or dead (and erase the lockfiles of the dead ones), or I would end up with a large number of unused lockfiles.
Thinking about your argument, I fear that the only safe way would be to do some kind of centralization. Probably I will end up having a single lockfile common to all "checkin/checkout" systems on each host and handle the customer count separately.
Thank you for pointing out the flaw in my algorithm.
|
---|
Replies are listed 'Best First'. | |
---|---|
Re^3: File Locking plus delete Lockfile question
by wol (Hermit) on Feb 12, 2009 at 13:20 UTC | |
by rovf (Priest) on Feb 12, 2009 at 15:21 UTC | |
Re^3: File Locking plus delete Lockfile question
by drench (Beadle) on Feb 12, 2009 at 21:18 UTC | |
Re^3: File Locking plus delete Lockfile question
by gone2015 (Deacon) on Feb 12, 2009 at 16:02 UTC | |
by rovf (Priest) on Feb 13, 2009 at 10:09 UTC | |
Re^3: File Locking plus delete Lockfile question
by JavaFan (Canon) on Feb 12, 2009 at 13:51 UTC | |
by rovf (Priest) on Feb 12, 2009 at 15:32 UTC | |
by JavaFan (Canon) on Feb 12, 2009 at 16:09 UTC |