aboutsummaryrefslogtreecommitdiffstats
path: root/src/libutil/sqlite_utils.c
diff options
context:
space:
mode:
authorVsevolod Stakhov <vsevolod@highsecure.ru>2016-07-28 18:34:19 +0100
committerVsevolod Stakhov <vsevolod@highsecure.ru>2016-07-28 18:34:19 +0100
commit597d9e0af6119b123dce1c7106819fd62609446c (patch)
tree3e46ec332a2d88db8ecf8935e4fd3bda913a47f7 /src/libutil/sqlite_utils.c
parent1bd6eb011a50b0d57781850db9b8fd7150300133 (diff)
downloadrspamd-597d9e0af6119b123dce1c7106819fd62609446c.tar.gz
rspamd-597d9e0af6119b123dce1c7106819fd62609446c.zip
[Minor] Fighting with windmills (sqlite locking)
Diffstat (limited to 'src/libutil/sqlite_utils.c')
-rw-r--r--src/libutil/sqlite_utils.c13
1 files changed, 12 insertions, 1 deletions
diff --git a/src/libutil/sqlite_utils.c b/src/libutil/sqlite_utils.c
index 376a4eca1..04b71ca63 100644
--- a/src/libutil/sqlite_utils.c
+++ b/src/libutil/sqlite_utils.c
@@ -372,7 +372,18 @@ rspamd_sqlite3_open_or_create (rspamd_mempool_t *pool, const gchar *path, const
}
if (create_sql) {
- if (sqlite3_exec (sqlite, create_sql, NULL, NULL, NULL) != SQLITE_OK) {
+ while ((rc = sqlite3_exec (sqlite, create_sql, NULL, NULL, NULL)) != SQLITE_OK) {
+ if (rc == SQLITE_BUSY) {
+ struct timespec sleep_ts = {
+ .tv_sec = 0,
+ .tv_nsec = 1000000
+ };
+
+ nanosleep (&sleep_ts, NULL);
+
+ continue;
+ }
+
g_set_error (err, rspamd_sqlite3_quark (),
-1, "cannot execute create sql `%s`: %s",
create_sql, sqlite3_errmsg (sqlite));