summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorNeels Hofmeyr <nhofmeyr@sysmocom.de>2016-02-29 16:44:13 +0100
committerNeels Hofmeyr <nhofmeyr@sysmocom.de>2016-02-29 16:44:13 +0100
commit45ee133d1d7392efcb446f5f79cf47cf792ee21a (patch)
treea65e2d4cec1f55f91f5cc661f60ac6536a1f3ec1
parent5b38312b92607247afee1532d78ccc88f001c933 (diff)
check return value of sqlite3_close(), retry up to three times.
-rw-r--r--openbsc/src/utils/meas_db.c12
1 files changed, 11 insertions, 1 deletions
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);