Re: Flock and file deletion
- From: Erwin Moller <Since_humans_read_this_I_am_spammed_too_much@xxxxxxxxxxxxxxxx>
- Date: Tue, 30 Sep 2008 17:15:35 +0200
Jerry Stuckle schreef:
Bill H wrote:I am wondering if this is possible. I have a file that is accessed by
multiple users and keeps track of activity (the file is polled by
flash every 2 seconds). As users leave, the flash program tells the
php program to remove them from the activity file, and as users access
this activity file, users who have timed out (haven't been heard from
in 60 seconds) are removed. Using a combination of flock, microsecond
sleeps, loops and the flash file repolling if it doesn't get a
completed result back, I have been able to keep anyone from stepping
on each other.
The question I have is, when the last user exits, I want to delete the
file, but am afraid that the file deletion may step on a user just
coming in and remove their activity. I had the thought of, and this
may be totally stupid, to open the file for read, flock it and delete
it while open. The theory behind this is that the flock would stay
active till the php script ended and the file handle was closed. At
which point the other waiting user would be able to access the file
for writing. Does this make sense?
Bill H
Make it easy on yourself. Use a database. That's what they're good at.
Excactly, avoid that flock() mess by using a database.
I did a lot of online gaming programming with Perl serverside using files and filelocking to avoid concurrencyproblems.
Especially when you need access to multiple files this can cause a headache.
Man, was I glad when I learned how to use a database. :-)
Regards,
Erwin Moller
--
============================
Erwin Moller
Now dropping all postings from googlegroups.
Why? http://improve-usenet.org/
============================
.
- References:
- Flock and file deletion
- From: Bill H
- Re: Flock and file deletion
- From: Jerry Stuckle
- Flock and file deletion
- Prev by Date: Re: Encryption & Decryption script
- Next by Date: Array file I/O
- Previous by thread: Re: Flock and file deletion
- Next by thread: Re: Flock and file deletion
- Index(es):
Relevant Pages
|