From: Vsevolod Stakhov Date: Wed, 25 Nov 2015 17:45:24 +0000 (+0000) Subject: Fix race condition when opening sqlite db X-Git-Tag: 1.1.0~476 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=7649d8f199222b8771024bd8ffb56226d8c052c1;p=thirdparty%2Frspamd.git Fix race condition when opening sqlite db --- diff --git a/src/libutil/sqlite_utils.c b/src/libutil/sqlite_utils.c index dff90fb6fc..fd7287c7fd 100644 --- a/src/libutil/sqlite_utils.c +++ b/src/libutil/sqlite_utils.c @@ -219,6 +219,12 @@ rspamd_sqlite3_wait (rspamd_mempool_t *pool, const gchar *lock) fd = open (lock, O_RDONLY); if (fd == -1) { + + if (errno == ENOENT) { + /* Lock is already released, so we can continue */ + return TRUE; + } + msg_err_pool ("cannot open lock file %s: %s", lock, strerror (errno)); return FALSE; @@ -398,12 +404,12 @@ rspamd_sqlite3_open_or_create (rspamd_mempool_t *pool, const gchar *path, const sqlite3_errmsg (sqlite)); } - if (sizeof (gpointer) >= 8 && - (rc = sqlite3_exec (sqlite, enable_mmap, NULL, NULL, NULL)) != - SQLITE_OK) { +#if defined(__LP64__) || defined(_LP64) + if ((rc = sqlite3_exec (sqlite, enable_mmap, NULL, NULL, NULL)) != SQLITE_OK) { msg_warn_pool ("cannot enable mmap: %s", sqlite3_errmsg (sqlite)); } +#endif if ((rc = sqlite3_exec (sqlite, other_pragmas, NULL, NULL, NULL)) != SQLITE_OK) {