From 98494d188b6e4b9e0c50a31bd82ad9d089fb2e2c Mon Sep 17 00:00:00 2001 From: DL6ER Date: Wed, 8 Jan 2025 19:36:00 +0100 Subject: [PATCH] Tolerate if the database is (shorty) locked when trying to create an in-memory Teleporter database Signed-off-by: DL6ER --- src/zip/teleporter.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/zip/teleporter.c b/src/zip/teleporter.c index 0185edb8b..07b5b04ad 100644 --- a/src/zip/teleporter.c +++ b/src/zip/teleporter.c @@ -85,6 +85,11 @@ static bool create_teleporter_database(const char *filename, const char **tables snprintf(attach_stmt, sizeof(attach_stmt), "ATTACH DATABASE '%s' AS \"disk\";", filename); + // Set busy timeout to 1 second to access the database in a + // multi-threaded environment + if(sqlite3_busy_timeout(db, 1000) != SQLITE_OK) + log_warn("Failed to set busy timeout during creation of in-memory Teleporter database: %s", sqlite3_errmsg(db)); + if(sqlite3_exec(db, attach_stmt, NULL, NULL, &err) != SQLITE_OK) { log_warn("Failed to attach database \"%s\" to in-memory database: %s", filename, err);