* Fix a race condition in addTextToStore().
This commit is contained in:
parent
c4e7d324b8
commit
92eea8fc4e
1 changed files with 12 additions and 7 deletions
|
@ -302,7 +302,11 @@ void addTextToStore(const Path & dstPath, const string & s)
|
|||
{
|
||||
if (!isValidPath(dstPath)) {
|
||||
|
||||
/* !!! locking? -> parallel writes are probably idempotent */
|
||||
PathSet lockPaths;
|
||||
lockPaths.insert(dstPath);
|
||||
PathLocks outputLock(lockPaths);
|
||||
|
||||
if (!isValidPath(dstPath)) {
|
||||
|
||||
AutoCloseFD fd = open(dstPath.c_str(), O_CREAT | O_EXCL | O_WRONLY, 0666);
|
||||
if (fd == -1) throw SysError(format("creating store file `%1%'") % dstPath);
|
||||
|
@ -314,6 +318,7 @@ void addTextToStore(const Path & dstPath, const string & s)
|
|||
txn.commit();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void deleteFromStore(const Path & _path)
|
||||
|
|
Loading…
Reference in a new issue