aboutsummaryrefslogtreecommitdiffstats
path: root/src/libutil/sqlite_utils.c
diff options
context:
space:
mode:
authorVsevolod Stakhov <vsevolod@highsecure.ru>2016-07-22 11:17:45 +0100
committerVsevolod Stakhov <vsevolod@highsecure.ru>2016-07-22 11:17:45 +0100
commit62c5109fb1dd650531b09440add5481a27cad8cb (patch)
treebdfac713554e10050186c3a2a1ec0fb6fcb5ed65 /src/libutil/sqlite_utils.c
parent6c04ef798d74cb0b61640dd273470db7758f1d5c (diff)
downloadrspamd-62c5109fb1dd650531b09440add5481a27cad8cb.tar.gz
rspamd-62c5109fb1dd650531b09440add5481a27cad8cb.zip
[Feature] Wait for sqlite if locked when switching to WAL mode
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 e7768142c..5c437b654 100644
--- a/src/libutil/sqlite_utils.c
+++ b/src/libutil/sqlite_utils.c
@@ -476,9 +476,21 @@ rspamd_sqlite3_open_or_create (rspamd_mempool_t *pool, const gchar *path, const
}
}
- 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, fsync_sql, NULL, NULL, NULL) != SQLITE_OK) {