Add missing return value checking routine for begin_transaction 12/165712/1
authorJi-hoon Lee <dalton.lee@samsung.com>
Wed, 20 Dec 2017 06:16:47 +0000 (15:16 +0900)
committerJi-hoon Lee <dalton.lee@samsung.com>
Wed, 3 Jan 2018 10:35:25 +0000 (19:35 +0900)
Change-Id: I4102304e01b588997bcef27275dc1393962268d6

ism/src/isf_pkg.cpp
ism/src/isf_query_utility.cpp

index bf9c691..7b2f7e7 100644 (file)
@@ -272,13 +272,14 @@ void isf_pkg_reload_ime_info_db(void)
     if (ret == PMINFO_R_OK) {
         ret = pkgmgrinfo_appinfo_filter_add_string (handle, PMINFO_APPINFO_PROP_APP_CATEGORY, "http://tizen.org/category/ime");
         if (ret == PMINFO_R_OK) {
-            isf_db_begin_transaction();
-            ret = pkgmgrinfo_appinfo_filter_foreach_appinfo (handle, isf_pkg_ime_app_list_cb, NULL);
-            if (ret != PMINFO_R_OK) {
-                LOGW ("pkgmgrinfo_appinfo_filter_foreach_appinfo failed(%d)", ret);
-                isf_db_rollback_transaction();
-            } else {
-                isf_db_commit_transaction();
+            if (isf_db_begin_transaction ()) {
+                ret = pkgmgrinfo_appinfo_filter_foreach_appinfo (handle, isf_pkg_ime_app_list_cb, NULL);
+                if (ret != PMINFO_R_OK) {
+                    LOGW ("pkgmgrinfo_appinfo_filter_foreach_appinfo failed(%d)", ret);
+                    isf_db_rollback_transaction ();
+                } else {
+                    isf_db_commit_transaction ();
+                }
             }
         }
         else {
index 9a04532..7dcf859 100644 (file)
@@ -210,15 +210,18 @@ static inline int _db_create_ime_info(void)
 
 static inline int _db_create_table(void)
 {
-    _begin_transaction();
-
-    int ret = _db_create_ime_info();
-    if (ret < 0) {
-        _rollback_transaction();
-        return ret;
+    int ret = _begin_transaction();
+    if (ret == EXIT_SUCCESS) {
+        ret = _db_create_ime_info();
+        if (ret < 0) {
+            LOGW("Failed");
+            _rollback_transaction();
+            return ret;
+        }
+        ret = _commit_transaction();
+    } else {
+        LOGW("Failed");
     }
-
-    _commit_transaction();
     return ret;
 }
 
@@ -289,6 +292,7 @@ static inline int _db_connect(void)
         int ret = _db_init();
         if (databaseInfo.need_reset) {
             _db_disconnect();
+            LOGD("need_reset, removing db");
             databaseInfo.need_reset = false;
             remove(databaseInfo.pPath);
             ret = _db_init();
@@ -1745,9 +1749,12 @@ EXAPI int isf_db_begin_transaction(void)
     if (_db_is_connected() == 0) {
         if (_db_connect() == 0) {
             ret = _begin_transaction();
+        } else {
+            LOGW("Connect failed!");
         }
-    } else
-        LOGW("failed");
+    } else {
+        LOGW("Already connected!");
+    }
 
     return (ret == EXIT_SUCCESS);
 }