* Fix a race condition in addTextToStore().
This commit is contained in:
parent
c4e7d324b8
commit
92eea8fc4e
|
@ -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);
|
||||
|
@ -313,6 +317,7 @@ void addTextToStore(const Path & dstPath, const string & s)
|
|||
registerValidPath(txn, dstPath);
|
||||
txn.commit();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
|
Loading…
Reference in a new issue