]> git.sesse.net Git - nageru/commitdiff
Fix a crash in Futatabi when two threads wanted to write to the database at the same...
authorSteinar H. Gunderson <sgunderson@bigfoot.com>
Sat, 9 Mar 2019 18:08:18 +0000 (19:08 +0100)
committerSteinar H. Gunderson <sgunderson@bigfoot.com>
Sat, 9 Mar 2019 18:08:18 +0000 (19:08 +0100)
futatabi/db.cpp

index 4da0a0a89becb427a0c4991e632c47e76cf30c3e..af2bfab0fd0c0d0dc9e36e118a7ddb9b3e43a3d0 100644 (file)
@@ -15,6 +15,14 @@ DB::DB(const string &filename)
                exit(1);
        }
 
+       // Set an effectively infinite timeout for waiting for write locks;
+       // if we get SQLITE_LOCKED, we just exit out, so this is much better.
+       ret = sqlite3_busy_timeout(db, 3600000);
+       if (ret != SQLITE_OK) {
+               fprintf(stderr, "sqlite3_busy_timeout: %s\n", sqlite3_errmsg(db));
+               exit(1);
+       }
+
        sqlite3_exec(db, R"(
                CREATE TABLE IF NOT EXISTS state (state BLOB);
        )",