Fix a race in registerFailedPath()
Registering the path as failed can fail if another process does the same thing after the call to hasPathFailed(). This is extremely unlikely though.
This commit is contained in:
parent
4bd5282573
commit
ff02f5336c
1 changed files with 1 additions and 2 deletions
|
@ -421,7 +421,7 @@ void LocalStore::openDB(bool create)
|
||||||
stmtInvalidatePath.create(db,
|
stmtInvalidatePath.create(db,
|
||||||
"delete from ValidPaths where path = ?;");
|
"delete from ValidPaths where path = ?;");
|
||||||
stmtRegisterFailedPath.create(db,
|
stmtRegisterFailedPath.create(db,
|
||||||
"insert into FailedPaths (path, time) values (?, ?);");
|
"insert or ignore into FailedPaths (path, time) values (?, ?);");
|
||||||
stmtHasPathFailed.create(db,
|
stmtHasPathFailed.create(db,
|
||||||
"select time from FailedPaths where path = ?;");
|
"select time from FailedPaths where path = ?;");
|
||||||
stmtQueryFailedPaths.create(db,
|
stmtQueryFailedPaths.create(db,
|
||||||
|
@ -692,7 +692,6 @@ void LocalStore::addReference(unsigned long long referrer, unsigned long long re
|
||||||
|
|
||||||
void LocalStore::registerFailedPath(const Path & path)
|
void LocalStore::registerFailedPath(const Path & path)
|
||||||
{
|
{
|
||||||
if (hasPathFailed(path)) return;
|
|
||||||
SQLiteStmtUse use(stmtRegisterFailedPath);
|
SQLiteStmtUse use(stmtRegisterFailedPath);
|
||||||
stmtRegisterFailedPath.bind(path);
|
stmtRegisterFailedPath.bind(path);
|
||||||
stmtRegisterFailedPath.bind(time(0));
|
stmtRegisterFailedPath.bind(time(0));
|
||||||
|
|
Loading…
Reference in a new issue