Limit maxinum retries of BUSY/BLOCK/LOCKED operations to MAX_RETRIES (default 10)

This commit is contained in:
Love Hornquist Astrand
2009-07-19 18:01:51 -07:00
parent 4895349431
commit bd073cfd72

View File

@@ -34,6 +34,8 @@
#include "hdb_locl.h"
#include "sqlite3.h"
#define MAX_RETRIES 10
typedef struct hdb_sqlite_db {
double version;
sqlite3 *db;
@@ -126,10 +128,11 @@ hdb_sqlite_prepare_stmt(krb5_context context,
sqlite3_stmt **statement,
const char *str)
{
int ret;
int ret, tries = 0;
ret = sqlite3_prepare_v2(db, str, -1, statement, NULL);
while(((ret == SQLITE_BUSY) ||
while((tries++ < MAX_RETRIES) &&
((ret == SQLITE_BUSY) ||
(ret == SQLITE_IOERR_BLOCKED) ||
(ret == SQLITE_LOCKED))) {
krb5_warnx(context, "hdb-sqlite: prepare busy");