[gst-devel] Registry writing troubles
msmith at fluendo.com
Fri Mar 3 08:08:01 CET 2006
For some time, people have been seeing problems with registry writing.
These occur in two major classes:
1) Running out of disk while writing the new registry file. There was
nothing checking writes, so the truncated temp file was happily renamed
to the final filename. We had someone in #gstreamer a couple of days ago
with this problem.
2) Multiple gstreamer processes writing the registry simultaneously.
This certainly causes problems for flumotion, and could easily cause
problems for other applications. What happens is this: 1. process A sees
outdated registry, creates temporary file, starts writing to it. 2.
process B sees outdated registry, creates temp file, starts writing to
it. 3. Process A finishes writing the registry, renames temp file (which
is now process B's temp file, incomplete) to final registry file. 4.
Process C reads incomplete registry. Chaos ensues!
So, the correct way to deal with 1) is obvious: check write return
values. Dealing with 2) is also obvious: don't use a fixed filename for
temporary registry files. However, this means that if we crash while
writing the registry (which isn't entirely impossible - it touches many
data structures, etc., some of which might be invalid in some ways), we
leave temporary files around. So we want to reduce the chances of that
as far as possible.
Solution, as in attached patch: we build the registry xml file in
memory, then write it to the temp file, then rename the temp file. The
only point where we might leave a temp file around is while actually
writing the file (NOT when building the XML) - this is fairly simple
code, and relatively fast, so it's unlikely to crash/be killed here.
Comments? I'd like to commit this before the next core release.
-------------- next part --------------
A non-text attachment was scrubbed...
Size: 7672 bytes
Desc: not available
More information about the gstreamer-devel