Thread: file locking online

  1. #1
    Registered User caroundw5h's Avatar
    Join Date
    Oct 2003
    Posts
    751

    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
    Warning: Opinions subject to change without notice

    The C Library Reference Guide
    Understand the fundamentals
    Then have some more fun

  2. #2
    C++ Witch laserlight's Avatar
    Join Date
    Oct 2003
    Location
    Singapore
    Posts
    28,413
    hmm... doesnt it depend on whether or not the script that processes the form implements file locking, e.g. via semaphores?
    Quote Originally Posted by Bjarne Stroustrup (2000-10-14)
    I get maybe two dozen requests for help with some sort of programming or design problem every day. Most have more sense than to send me hundreds of lines of code. If they do, I ask them to find the smallest example that exhibits the problem and send me that. Mostly, they then find the error themselves. "Finding the smallest program that demonstrates the error" is a powerful debugging tool.
    Look up a C++ Reference and learn How To Ask Questions The Smart Way

  3. #3
    Registered User caroundw5h's Avatar
    Join Date
    Oct 2003
    Posts
    751
    don't know, thats what i'm asking?
    Warning: Opinions subject to change without notice

    The C Library Reference Guide
    Understand the fundamentals
    Then have some more fun

  4. #4
    Me -=SoKrA=-'s Avatar
    Join Date
    Oct 2002
    Location
    Europe
    Posts
    448
    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.
    SoKrA-BTS "Judge not the program I made, but the one I've yet to code"
    I say what I say, I mean what I mean.
    IDE: emacs + make + gcc and proud of it.

  5. #5
    PC Fixer-Upper Waldo2k2's Avatar
    Join Date
    May 2002
    Posts
    2,001
    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)
    PHP and XML
    Let's talk about SAX

  6. #6
    Registered User caroundw5h's Avatar
    Join Date
    Oct 2003
    Posts
    751
    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
    Warning: Opinions subject to change without notice

    The C Library Reference Guide
    Understand the fundamentals
    Then have some more fun

  7. #7
    Me -=SoKrA=-'s Avatar
    Join Date
    Oct 2002
    Location
    Europe
    Posts
    448
    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.
    SoKrA-BTS "Judge not the program I made, but the one I've yet to code"
    I say what I say, I mean what I mean.
    IDE: emacs + make + gcc and proud of it.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. File being filled with NULLs
    By Tigers! in forum Windows Programming
    Replies: 2
    Last Post: 06-30-2009, 05:28 PM
  2. Replies: 3
    Last Post: 03-04-2005, 02:46 PM
  3. System
    By drdroid in forum C++ Programming
    Replies: 3
    Last Post: 06-28-2002, 10:12 PM
  4. Need a suggestion on a school project..
    By Screwz Luse in forum C Programming
    Replies: 5
    Last Post: 11-27-2001, 02:58 AM