[darcs-devel] Race in darcs.cgi

Andrew Pimlott andrew at pimlott.net
Tue Sep 28 13:29:24 PDT 2004


On Mon, Sep 27, 2004 at 12:14:48PM +0200, Davide Dente wrote:
> I'm testing Darcs and I think I've found a race condition in darcs.cgi,
> the new CGI script for querying via web a Darcs repository.
> 
> darcs.cgi call the command "darcs", to create an XML output, and then
> "xsltproc" to create an HTML page out of it. For the intermediate output
> file  the library function File::Temp::tempfile is used.
> 
> The problem is that I have xsltproc trying to read the tempfile *after*
> it has been created but *before* anything has been written to it. This
> is because perl invoked by CGI does not autoflush the files, and my
> server is probably to slow (SUN Ultra 60, Solaris 2.6, Perl 5.6.1).

This analysis is not quite right, although I'm sure your patch fixes the
problem.  xsltproc fails to see the (whole) xml document not because of
a race condition (all output to the temporary file is done synchronously
before xsltproc is called), but because some of the output is still
buffered by perl.  So a more clear and efficient solution is to add a
flush to finish_xml.  

Andrew




More information about the darcs-devel mailing list