aboutsummaryrefslogtreecommitdiffstats
path: root/src/libutil/sqlite_utils.c
diff options
context:
space:
mode:
authorVsevolod Stakhov <vsevolod@highsecure.ru>2016-07-28 15:19:41 +0100
committerVsevolod Stakhov <vsevolod@highsecure.ru>2016-07-28 15:19:41 +0100
commit7832d599185cf68128ef9106d08ec51401ffb018 (patch)
tree881ad4f854449dee8189d4767423f8d1adf15247 /src/libutil/sqlite_utils.c
parent2bd116b62f762bd2b5473b2640cbdb4f4ff95f97 (diff)
downloadrspamd-7832d599185cf68128ef9106d08ec51401ffb018.tar.gz
rspamd-7832d599185cf68128ef9106d08ec51401ffb018.zip
[Fix] Another effort to unbreak sqlite locking
Diffstat (limited to 'src/libutil/sqlite_utils.c')
-rw-r--r--src/libutil/sqlite_utils.c14
1 files changed, 13 insertions, 1 deletions
diff --git a/src/libutil/sqlite_utils.c b/src/libutil/sqlite_utils.c
index 5c437b654..376a4eca1 100644
--- a/src/libutil/sqlite_utils.c
+++ b/src/libutil/sqlite_utils.c
@@ -349,9 +349,21 @@ rspamd_sqlite3_open_or_create (rspamd_mempool_t *pool, const gchar *path, const
}
if (create && has_lock) {
- if (sqlite3_exec (sqlite, sqlite_wal, NULL, NULL, NULL) != SQLITE_OK) {
+ while ((rc = sqlite3_exec (sqlite, sqlite_wal, NULL, NULL, NULL)) != SQLITE_OK) {
+ if (rc == SQLITE_BUSY) {
+ struct timespec sleep_ts = {
+ .tv_sec = 0,
+ .tv_nsec = 1000000
+ };
+
+ nanosleep (&sleep_ts, NULL);
+
+ continue;
+ }
+
msg_warn_pool_check ("WAL mode is not supported (%s), locking issues might occur",
sqlite3_errmsg (sqlite));
+ break;
}
if (sqlite3_exec (sqlite, exclusive_lock_sql, NULL, NULL, NULL) != SQLITE_OK) {