Fix bugs reported on SVACE 21/271421/7
authorUnsung Lee <unsung.lee@samsung.com>
Mon, 21 Feb 2022 04:35:47 +0000 (13:35 +0900)
committerUnsung Lee <unsung.lee@samsung.com>
Tue, 22 Feb 2022 05:45:52 +0000 (14:45 +0900)
Change-Id: Ibec54113306431ffe8d059d6fb4e22838c4c86b9
Signed-off-by: Unsung Lee <unsung.lee@samsung.com>
.gitignore
src/resource-limiter/memory/vmpressure-lowmem-handler.c
src/resource-monitor/battery/heart-battery.c
src/resource-monitor/logging.c

index 9306ae6..eb7bd76 100644 (file)
@@ -1,3 +1,6 @@
 cscope.files
 cscope.out
 tags
+*log
+*.swp
+*.swo
index f3f6d99..7b32f5f 100644 (file)
@@ -1137,7 +1137,10 @@ static void *lowmem_reclaim_worker(void *arg)
                /* Wait on any wake-up call */
                ctl = g_async_queue_pop(lmw->queue);
 
-               if (!LOWMEM_WORKER_IS_ACTIVE(lmw) || (ctl->flags & OOM_DROP))
+               if (ctl->flags & OOM_DROP)
+                       LOWMEM_DESTROY_REQUEST(ctl);
+
+               if (!LOWMEM_WORKER_IS_ACTIVE(lmw) || !ctl)
                        break;
 
                LOWMEM_WORKER_RUN(lmw);
index 0794d83..4c5b9b6 100644 (file)
@@ -3396,7 +3396,7 @@ int heart_battery_stats_execute_insert_db(char buf[])
        }
        ret = heart_battery_stats_db_open_transaction(battery_stats_db);
        if (ret != RESOURCED_ERROR_NONE)
-               return ret;
+               goto error_close;
 
        if (sqlite3_exec(battery_stats_db, buf, NULL, NULL, &err_msg) != SQLITE_OK) {
                _E("sqlite3_exec(\"%s\") failed! -> %s", buf, err_msg);
@@ -3417,6 +3417,7 @@ error_db:
        if (sqlite3_exec(battery_stats_db, "ROLLBACK", NULL, NULL, NULL) != SQLITE_OK)
                _E("sqlite3_exec(\"ROLLBACK\") failed!");
        _I("QUERY: %s FAILED", buf);
+error_close:
        sqlite3_close(battery_stats_db);
        return RESOURCED_ERROR_DB_FAILED;
 }
@@ -3437,7 +3438,7 @@ long heart_battery_stats_execute_select_total_db(char buf[])
        ret = sqlite3_prepare_v2(battery_stats_db, buf, -1, &stmt, NULL);
        if (ret != SQLITE_OK) {
                _E("Failed to prepare query %s", sqlite3_errmsg(battery_stats_db));
-               return 0;
+               goto error_db;
        }
 
        ret = sqlite3_step(stmt);
@@ -3458,6 +3459,7 @@ long heart_battery_stats_execute_select_total_db(char buf[])
                break;
        }
        sqlite3_finalize(stmt);
+error_db:
        sqlite3_close(battery_stats_db);
        return totaltime;
 }
index b559c83..e4e9c6f 100644 (file)
@@ -254,11 +254,13 @@ static int logging_create_default_db(char *name, sqlite3 **db)
        if (strstr(name, "storage")) {
                if (sqlite3_exec(*db, "PRAGMA journal_mode = WAL", 0, 0, 0) != SQLITE_OK) {
                        _E("Can't set journal mode %s", sqlite3_errmsg(*db));
+                       sqlite3_close(*db);
                        return RESOURCED_ERROR_DB_FAILED;
                }
        } else {
                if (sqlite3_exec(*db, "PRAGMA locking_mode = NORMAL", 0, 0, 0) != SQLITE_OK) {
                        _E("Can't set locking mode %s", sqlite3_errmsg(*db));
+                       sqlite3_close(*db);
                        return RESOURCED_ERROR_DB_FAILED;
                }
        }