aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorVsevolod Stakhov <vsevolod@highsecure.ru>2015-11-25 17:45:24 +0000
committerVsevolod Stakhov <vsevolod@highsecure.ru>2015-11-25 17:45:24 +0000
commit7649d8f199222b8771024bd8ffb56226d8c052c1 (patch)
treef3157a8e9108570440cfff6e28c0b7c56502930d
parent0fc01045cf60e0728e7a33c6df2141de0aa858af (diff)
downloadrspamd-7649d8f199222b8771024bd8ffb56226d8c052c1.tar.gz
rspamd-7649d8f199222b8771024bd8ffb56226d8c052c1.zip
Fix race condition when opening sqlite db
-rw-r--r--src/libutil/sqlite_utils.c12
1 files changed, 9 insertions, 3 deletions
diff --git a/src/libutil/sqlite_utils.c b/src/libutil/sqlite_utils.c
index dff90fb6f..fd7287c7f 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) {