From: Steinar H. Gunderson Date: Sat, 9 Mar 2019 18:08:18 +0000 (+0100) Subject: Fix a crash in Futatabi when two threads wanted to write to the database at the same... X-Git-Tag: 1.8.3~10 X-Git-Url: https://git.sesse.net/?a=commitdiff_plain;ds=sidebyside;h=ff1d436d47eb49dae5890454c584b3aacfaf1e39;p=nageru Fix a crash in Futatabi when two threads wanted to write to the database at the same time. --- diff --git a/futatabi/db.cpp b/futatabi/db.cpp index 4da0a0a..af2bfab 100644 --- a/futatabi/db.cpp +++ b/futatabi/db.cpp @@ -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); )",