From: jongmyeongko Date: Thu, 18 May 2017 10:56:16 +0000 (+0900) Subject: Change the timing of adding sqlite busy handler X-Git-Tag: accepted/tizen/unified/20170607.063236~1 X-Git-Url: http://review.tizen.org/git/?p=platform%2Fcore%2Fappfw%2Fpkgmgr-info.git;a=commitdiff_plain;h=2a679481cdae25a22638a77195f469f206e6c57a 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 --- 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; }