From 45ee133d1d7392efcb446f5f79cf47cf792ee21a Mon Sep 17 00:00:00 2001 From: Neels Hofmeyr Date: Mon, 29 Feb 2016 16:44:13 +0100 Subject: check return value of sqlite3_close(), retry up to three times. --- openbsc/src/utils/meas_db.c | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) (limited to 'openbsc/src/utils') diff --git a/openbsc/src/utils/meas_db.c b/openbsc/src/utils/meas_db.c index 2e70b313b..cf4ce6e2e 100644 --- a/openbsc/src/utils/meas_db.c +++ b/openbsc/src/utils/meas_db.c @@ -314,10 +314,20 @@ err_io: void meas_db_close(struct meas_db_state *st) { + int retries; sqlite3_finalize(st->stmt_ins_mr); sqlite3_finalize(st->stmt_ins_ud); sqlite3_finalize(st->stmt_upd_mr); - sqlite3_close(st->db); + retries = 0; + while (1) { + if (sqlite3_close(st->db) == SQLITE_OK) + break; + if ((++retries) >= 3) { + fprintf(stderr, "Unable to close DB\n"); + break; + } + sleep(1); + } talloc_free(st); -- cgit v1.2.3