+ Reply to Thread
Results 1 to 5 of 5
  1. #1
    Junior Member
    Join Date
    Sep 2001
    Posts
    2

    Handle two programs writing to the same file in C++? Help?

    Hi, how to synchronize two cgi programs called
    from browser, and write data to the same file
    at the same time in C++?

    Thank you very much,

    Natxie

  2. #2
    Senior Member Banti's Avatar
    Join Date
    Dec 1999
    Location
    No Longer at Sysopt
    Posts
    903
    WHY??? And how are you at Shared Memory?

    Banti

  3. #3
    Junior Member
    Join Date
    Sep 2001
    Posts
    2
    Hi, here's the more info:

    It's a cgi prgram which read a file, and change some data in it, then write to the same file.
    There's a possibility that two users access the
    same cgi program at the same time, then write to
    the same file at the same time, that caused
    problem.
    Is there's a way to handle it in C++?

    Thanks,

    Natxie
    Last edited by natxie; 09-20-2001 at 06:05 PM.

  4. #4
    Banned qball's Avatar
    Join Date
    Oct 1999
    Location
    Rockaway, NJ 07866
    Posts
    1,730
    concurrency is your problem. you have more than one 'user' trying to write to the same file at the same time, not good.

    Now is your question about CGI or C++?

    Either way, minimize your file IO. Only write to file when absolutely necessary, then open, write, close as fast as possible.

    Why are you using file? Sounds like you need a DB.

  5. #5
    Member
    Join Date
    Apr 2000
    Location
    Alberta, Canada
    Posts
    125
    I'm pretty sure c++ lets you lock your file as well, lock -> write/read -> unlock, but you might have already tried that. Not sure if it would do much or not, but I believe thats what the intention of the lock is! (mebbe, mebbe not!)

    ...you can look into semaphors if you want also!!

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts







New Security Features Planned for Firefox 4
Another Laptop Theft Exposes 21K Patients' Data
Oracle Hits to Road to Pitch Data Center Plans
Microsoft Preps Array of Windows Patches
Microsoft Nears IE9 Beta With Final Preview
Simplified Analytics Improve CRM, BI Tools
Android Passes RIM as Top Mobile OS in 2Q
VMware Updates Hyperic System Management
File Monitoring Key to Enterprise Security
LinkedIn Snaps Up SaaS Player mSpoke