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:
Eelco Dolstra 2013-10-16 14:51:20 +02:00
parent 4bd5282573
commit ff02f5336c

View file

@ -421,7 +421,7 @@ void LocalStore::openDB(bool create)
stmtInvalidatePath.create(db,
"delete from ValidPaths where path = ?;");
stmtRegisterFailedPath.create(db,
"insert into FailedPaths (path, time) values (?, ?);");
"insert or ignore into FailedPaths (path, time) values (?, ?);");
stmtHasPathFailed.create(db,
"select time from FailedPaths where path = ?;");
stmtQueryFailedPaths.create(db,
@ -692,7 +692,6 @@ void LocalStore::addReference(unsigned long long referrer, unsigned long long re
void LocalStore::registerFailedPath(const Path & path)
{
if (hasPathFailed(path)) return;
SQLiteStmtUse use(stmtRegisterFailedPath);
stmtRegisterFailedPath.bind(path);
stmtRegisterFailedPath.bind(time(0));