commit f90b03d: [Minor] Another try to fix transactions mess

Vsevolod Stakhov vsevolod at highsecure.ru
Tue Jun 11 11:21:05 UTC 2019


Author: Vsevolod Stakhov
Date: 2019-06-11 12:17:38 +0100
URL: https://github.com/rspamd/rspamd/commit/f90b03d52fe3510275681cdda61106b5759414c2 (HEAD -> master)

[Minor] Another try to fix transactions mess

---
 src/libstat/backends/sqlite3_backend.c | 25 +++----------------------
 1 file changed, 3 insertions(+), 22 deletions(-)

diff --git a/src/libstat/backends/sqlite3_backend.c b/src/libstat/backends/sqlite3_backend.c
index f4254c779..2a512db8b 100644
--- a/src/libstat/backends/sqlite3_backend.c
+++ b/src/libstat/backends/sqlite3_backend.c
@@ -485,29 +485,10 @@ rspamd_sqlite3_opendb (rspamd_mempool_t *pool,
 	}
 
 	/* Check tokenizer configuration */
-
-	while ((ret = rspamd_sqlite3_run_prstmt (pool, bk->sqlite, bk->prstmt,
-			RSPAMD_STAT_BACKEND_TRANSACTION_START_IM)) == SQLITE_BUSY &&
-			++ntries <= max_tries) {
-		nanosleep (&sleep_ts, NULL);
-	}
-
-	if (ret != SQLITE_OK) {
-		msg_err_pool ("failed to start transaction: %d, %s", ret,
-				sqlite3_errmsg (bk->sqlite));
-		sqlite3_close (bk->sqlite);
-		g_free (bk);
-
-		return NULL;
-	}
-
 	if (rspamd_sqlite3_run_prstmt (pool, bk->sqlite, bk->prstmt,
 			RSPAMD_STAT_BACKEND_LOAD_TOKENIZER, &sz64, &tk_conf) != SQLITE_OK ||
 			sz64 == 0) {
 
-		rspamd_sqlite3_run_prstmt (pool, bk->sqlite, bk->prstmt,
-				RSPAMD_STAT_BACKEND_TRANSACTION_COMMIT);
-
 		while ((ret = rspamd_sqlite3_run_prstmt (pool, bk->sqlite, bk->prstmt,
 				RSPAMD_STAT_BACKEND_TRANSACTION_START_EXCL)) == SQLITE_BUSY &&
 			   ++ntries <= max_tries) {
@@ -534,15 +515,15 @@ rspamd_sqlite3_opendb (rspamd_mempool_t *pool,
 
 			return NULL;
 		}
+
+		rspamd_sqlite3_run_prstmt (pool, bk->sqlite, bk->prstmt,
+				RSPAMD_STAT_BACKEND_TRANSACTION_COMMIT);
 		g_free (tok_conf_encoded);
 	}
 	else {
 		g_free (tk_conf);
 	}
 
-	rspamd_sqlite3_run_prstmt (pool, bk->sqlite, bk->prstmt,
-				RSPAMD_STAT_BACKEND_TRANSACTION_COMMIT);
-
 	return bk;
 }
 


More information about the Commits mailing list