-
file locking online
I have a simple form on a site that allows users to save info to a text file. I've opened the form on my desktop and then went online and submittedto the form. I didn't get any errors or corrupted information. So my question is, if multiple ppl are attempting to submit to the form simultaneously, will the file be locked? I tried to do the same thing with a csv file and it did lock and was unable to write to it until I closed the file. I'm trying to avoid using a RDBMS, should i be worried that multiple users won't simultaneously submit to the file? and why do i get a traceback when i attempt to do it to a csv file and not a plain text file? Thank you for your replies
-
hmm... doesnt it depend on whether or not the script that processes the form implements file locking, e.g. via semaphores?
-
don't know, thats what i'm asking?
-
That depends on how the site handles the data.
If multiple people are trying to write to it, it may have corrupted data, or the data may not be written at all.
The best way to set this up would be to have a deamon who actually writes the data and the script at the site communicates with it using UNIX sockets, although this would be very resource-hungry.
Semaphores would also be a good idea, although it may be some time untill the script returns a success to the user and s/he may try reloading, which would add to the problem.
-
this is done over the internet? the chances are very, very, very slim. but, I'd say write to a temp file first and have another part of the script write to the file. This way other users are writing to seperate temp files, then they wait in line to go to the master file.... (if that's what semaphores are then excuse my ignorance and repeitivitivitiveness)
-
so basically the only way to get around this is to you use RDMS. dAMN it!! oh well i've been meaning to check out sqllite
-
If you're going to use an SQL server to store the data, then you'll probably not have problems, as it'll be handled by the server and the script will (most likely) return inmediatly.