> 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.
Interesting. Does it mean that the second process to perform the rename may overwrite (lose) the changes made by the first? _______________________________________________ sipx-dev mailing list [email protected] List Archive: http://list.sipfoundry.org/archive/sipx-dev Unsubscribe: http://list.sipfoundry.org/mailman/listinfo/sipx-dev
