From 2a679481cdae25a22638a77195f469f206e6c57a Mon Sep 17 00:00:00 2001 From: jongmyeongko Date: Thu, 18 May 2017 19:56:16 +0900 Subject: [PATCH 1/1] Change the timing of adding sqlite busy handler Earlier execution of sqlite_exec can be failed becase of db lock when two different type packages are installed at the same time. Change-Id: I8c53f68f7b1ee984b70573bdd441e66edcecc9d6 Signed-off-by: jongmyeongko --- parser/src/pkgmgr_parser_db.c | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/parser/src/pkgmgr_parser_db.c b/parser/src/pkgmgr_parser_db.c index 95f2472..74a8f47 100644 --- a/parser/src/pkgmgr_parser_db.c +++ b/parser/src/pkgmgr_parser_db.c @@ -474,6 +474,14 @@ static int __open_db(uid_t uid, const char *path, sqlite3 **db, int flags) if (ret != SQLITE_OK) return ret; + ret = sqlite3_busy_handler(*db, __db_busy_handler, NULL); + if (ret != SQLITE_OK) { + _LOGE("failed to register busy handler: %s", + sqlite3_errmsg(*db)); + sqlite3_close_v2(*db); + return ret; + } + if (flags & SQLITE_OPEN_CREATE) { ret = __initialize_db(*db, path, uid); if (ret) { @@ -491,14 +499,6 @@ static int __open_db(uid_t uid, const char *path, sqlite3 **db, int flags) return ret; } - ret = sqlite3_busy_handler(*db, __db_busy_handler, NULL); - if (ret != SQLITE_OK) { - _LOGE("failed to register busy handler: %s", - sqlite3_errmsg(*db)); - sqlite3_close_v2(*db); - return ret; - } - return ret; } -- 2.7.4