]> source.dussan.org Git - rspamd.git/commitdiff
[Fix] Another effort to unbreak sqlite locking
authorVsevolod Stakhov <vsevolod@highsecure.ru>
Thu, 28 Jul 2016 14:19:41 +0000 (15:19 +0100)
committerVsevolod Stakhov <vsevolod@highsecure.ru>
Thu, 28 Jul 2016 14:19:41 +0000 (15:19 +0100)
src/libutil/sqlite_utils.c

index 5c437b65488a7bc8b6bde608132558933416bc3d..376a4eca18b6c39143617bf93bcd19dddb3f6dec 100644 (file)
@@ -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) {