aboutsummaryrefslogtreecommitdiffstats
path: root/src/libserver/fuzzy_backend.c
diff options
context:
space:
mode:
authorVsevolod Stakhov <vsevolod@highsecure.ru>2015-11-07 00:21:16 +0000
committerVsevolod Stakhov <vsevolod@highsecure.ru>2015-11-07 00:21:16 +0000
commita496040058553462cfe9e7edda664ea2f091ddee (patch)
treee3fa464561129eea051a785620f1c36a239228c0 /src/libserver/fuzzy_backend.c
parent9154d4f68d648fe643070f3c7a8a1880d039d335 (diff)
downloadrspamd-a496040058553462cfe9e7edda664ea2f091ddee.tar.gz
rspamd-a496040058553462cfe9e7edda664ea2f091ddee.zip
Add retries for simple sql commands in fuzzy backend
Diffstat (limited to 'src/libserver/fuzzy_backend.c')
-rw-r--r--src/libserver/fuzzy_backend.c12
1 files changed, 11 insertions, 1 deletions
diff --git a/src/libserver/fuzzy_backend.c b/src/libserver/fuzzy_backend.c
index d34617521..1d9cc754c 100644
--- a/src/libserver/fuzzy_backend.c
+++ b/src/libserver/fuzzy_backend.c
@@ -348,7 +348,17 @@ static gboolean
rspamd_fuzzy_backend_run_sql (const gchar *sql, struct rspamd_fuzzy_backend *bk,
GError **err)
{
- if (sqlite3_exec (bk->db, sql, NULL, NULL, NULL) != SQLITE_OK) {
+ guint retries = 0;
+ struct timespec ts;
+ gint ret;
+
+ do {
+ ret = sqlite3_exec (bk->db, sql, NULL, NULL, NULL);
+ double_to_ts (sql_sleep_time, &ts);
+ } while (ret == SQLITE_BUSY && retries++ < max_retries &&
+ nanosleep (&ts, NULL) == 0);
+
+ if (ret != SQLITE_OK) {
g_set_error (err, rspamd_fuzzy_backend_quark (),
-1, "Cannot execute raw sql `%s`: %s",
sql, sqlite3_errmsg (bk->db));