From ff02f5336cd0cff0e97fbcf3c54b5b23827702d6 Mon Sep 17 00:00:00 2001 From: Eelco Dolstra Date: Wed, 16 Oct 2013 14:51:20 +0200 Subject: [PATCH] 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. --- src/libstore/local-store.cc | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/libstore/local-store.cc b/src/libstore/local-store.cc index 15200e842..9f324608c 100644 --- a/src/libstore/local-store.cc +++ b/src/libstore/local-store.cc @@ -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));