file locking online

This is a discussion on file locking online within the Tech Board forums, part of the Community Boards category; I have a simple form on a site that allows users to save info to a text file. I've opened ...

  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

  2. #2
    C++ Witch laserlight's Avatar
    Join Date
    Oct 2003
    Location
    Singapore
    Posts
    21,717
    hmm... doesnt it depend on whether or not the script that processes the form implements file locking, e.g. via semaphores?
    C + C++ Compiler: MinGW port of GCC
    Version Control System: Bazaar

    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?

  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

  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, 01: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, 01:58 AM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21