X-Git-Url: http://review.tizen.org/git/?a=blobdiff_plain;f=src%2Fdatabase_main.c;h=9756a3d56c91252f56ea56ace6bb1782362ed98e;hb=110c65cb3df37993d8a11e18b44c71605f10ba53;hp=707358da0a04f9de93d0a9a1112557c1074706f1;hpb=1cb49b4c965fef704499cd720e7e65312681ab07;p=platform%2Fcore%2Ftelephony%2Ftel-plugin-database.git diff --git a/src/database_main.c b/src/database_main.c index 707358d..9756a3d 100644 --- a/src/database_main.c +++ b/src/database_main.c @@ -25,7 +25,8 @@ #include #include -#include +#include +#include #include #include @@ -92,14 +93,37 @@ static gboolean __update_query_database(Storage *strg, void *handle, const char return TRUE; } +static int _busy_handler(void *pData, int count) +{ + if (5 - count > 0) { + dbg("Busy Handler Called! : CNT(%d)\n", count + 1); + usleep((count + 1) * 100000); + return 1; + } else { + dbg("Busy Handler will be returned SQLITE_BUSY error\n"); + return 0; + } +} + static void *create_handle(Storage *strg, const char *path) { int rv = 0; sqlite3 *handle = NULL; - rv = db_util_open(path, &handle, 0); + if (path == NULL) { + err("Invalid input param error"); + return NULL; + } + + rv = sqlite3_open(path, &handle); + if (rv != SQLITE_OK) { + err("fail to connect database err(%d), errmsg(%s)", rv, sqlite3_errmsg(handle)); + return NULL; + } + + rv = sqlite3_busy_handler(handle, _busy_handler, NULL); if (rv != SQLITE_OK) { - err("fail to connect database err(%d)", rv); + err("fail to register busy handler err(%d), errmsg(%s)", rv, sqlite3_errmsg(handle)); return NULL; } @@ -114,7 +138,7 @@ static gboolean remove_handle(Storage *strg, void *handle) if (!handle) return FALSE; - rv = db_util_close(handle); + rv = sqlite3_close(handle); if (rv != SQLITE_OK) { err("fail to close database err(%d)", rv); handle = NULL;