Skip to content

Commit

Permalink
[backend] serialize source diff creation if the same diff is requeste…
Browse files Browse the repository at this point in the history
…d multiple times
  • Loading branch information
mlschroe authored and adrianschroeter committed Apr 4, 2012
1 parent 9cfc397 commit d13b995
Showing 1 changed file with 13 additions and 0 deletions.
13 changes: 13 additions & 0 deletions src/backend/bs_srcserver
Expand Up @@ -3964,6 +3964,17 @@ sub sourcediff {
BSServer::reply_file(\*F, $view eq 'xml' ? 'Content-Type: text/xml' : 'Content-Type: text/plain');
return undef;
}
local *LF;
mkdir_p("$diffcache/".substr($cacheid, 0, 2));
BSUtil::lockopen(\*LF, '>>', "$cn.run");
# retry open, maybe somebody else has created the diff meanwhile
if (open(F, '<', $cn)) {
unlink("$cn.run");
close LF;
utime(time, time, $cn);
BSServer::reply_file(\*F, $view eq 'xml' ? 'Content-Type: text/xml' : 'Content-Type: text/plain');
return undef;
}
my $tmpdir = "$uploaddir/srcdiff$$";
my $d;
if ($view eq 'xml') {
Expand All @@ -3983,6 +3994,8 @@ sub sourcediff {
}
mkdir_p("$diffcache/".substr($cacheid, 0, 2));
writestr("$diffcache/.new$$", $cn, $d);
unlink("$cn.run");
close LF;
return ($d, $view eq 'xml' ? 'Content-Type: text/xml' : 'Content-Type: text/plain');
}

Expand Down

0 comments on commit d13b995

Please sign in to comment.