Dale Worley wrote:
> The current code for writing the XML files that hold the persistent
> version of the IMDB data has a problem, in that if several processes (on
> one host) can change an IMDB table, and thus will write the XML file
> from time to time, there is a risk that two of them will write to the
> XML file at the same time.
> 
> Currently, an XML file is written using this strategy:  Write the XML
> data to a file whose name has an added suffix ".new", and then rename
> the ".new" file to the proper name.  Since the file with the proper name
> is replaced atomically (by the rename operation), this protects the file
> from being in a partially-written state if the process or host crashes.
> 
> But if two processes attempt to write the same XML file at the same
> time, they might write into the same .new file at the same time.
> 
> To fix this, I've written a patch that generates the temporary file name
> using mktemp().  This ensures that two process that try to write the XML
> file at the same time will use different temporary file names.  Of
> course, one of those files (the one that is renamed last) will become
> the new XML file, but that is OK.
> 
> I'd like people to review this design and patch.
> 

Can't we use flock and a semaphore file to control access to the ".new" file? 
Or would that not work?

Arjun
_______________________________________________
sipx-dev mailing list
[email protected]
List Archive: http://list.sipfoundry.org/archive/sipx-dev
Unsubscribe: http://list.sipfoundry.org/mailman/listinfo/sipx-dev

Reply via email to