/* 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);
}
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);
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;
}
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);
break;
}
sqlite3_finalize(stmt);
+error_db:
sqlite3_close(battery_stats_db);
return totaltime;
}
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;
}
}