From 259a921d8a66d132810f3c9c8252b1ccf15cfda1 Mon Sep 17 00:00:00 2001 From: Minje Ahn Date: Thu, 7 Apr 2016 14:38:14 +0900 Subject: [PATCH] Change journal mode (persist to wal) Change-Id: I9c1eee2ddf1cacdc33a51311021b1469c60af69b Signed-off-by: Minje Ahn --- include/media_controller_db.h | 2 +- packaging/media-controller_create_db.sh | 9 --------- src/media_controller_client.c | 2 +- src/media_controller_db.c | 7 ++----- src/media_controller_server.c | 2 +- svc/media_controller_db_util.c | 7 ++----- svc/media_controller_db_util.h | 2 +- svc/media_controller_svc.c | 2 +- 8 files changed, 9 insertions(+), 24 deletions(-) diff --git a/include/media_controller_db.h b/include/media_controller_db.h index 87aeab3..6218fb3 100755 --- a/include/media_controller_db.h +++ b/include/media_controller_db.h @@ -59,7 +59,7 @@ #define SQLITE3_SAFE_FREE(sql_string) {if (sql_string) { sqlite3_free(sql_string); sql_string = NULL; } } #define SQLITE3_FINALIZE(x) {if (x != NULL) sqlite3_finalize(x); } -int mc_db_connect(void **db_handle, bool need_write); +int mc_db_connect(void **db_handle); int mc_db_disconnect(void *db_handle); int mc_db_create_server_table(void *handle, const char *server_name); int mc_db_delete_server_table(void *handle, const char *server_name); diff --git a/packaging/media-controller_create_db.sh b/packaging/media-controller_create_db.sh index 0c4a116..ac71ac8 100755 --- a/packaging/media-controller_create_db.sh +++ b/packaging/media-controller_create_db.sh @@ -8,12 +8,3 @@ mkdir -p $TZ_USER_DB sqlite3 ${TZ_USER_DB}/.media_controller.db 'PRAGMA journal_mode = PERSIST; CREATE TABLE IF NOT EXISTS latest_server (server_name TEXT PRIMARY KEY); ' - -#Change permission -chmod 644 ${TZ_USER_DB}/.media_controller.db -chmod 644 ${TZ_USER_DB}/.media_controller.db-journal - -#Change group (6017: db_filemanager 5000: app) -chgrp $TZ_SYS_USER_GROUP ${TZ_USER_DB} -#chgrp 6017 ${TZ_USER_DB}/.media_controller.db -#chgrp 6017 ${TZ_USER_DB}/.media_controller.db-journal diff --git a/src/media_controller_client.c b/src/media_controller_client.c index 7292dc6..2df2ba8 100755 --- a/src/media_controller_client.c +++ b/src/media_controller_client.c @@ -180,7 +180,7 @@ static int __mc_client_create(media_controller_client_s **mc_client) goto Error; } - ret = mc_db_connect(&_client->db_handle, false); + ret = mc_db_connect(&_client->db_handle); if (ret != MEDIA_CONTROLLER_ERROR_NONE) { mc_error("error in connecting to DB %d", ret); goto Error; diff --git a/src/media_controller_db.c b/src/media_controller_db.c index 8f9209d..9d56b80 100755 --- a/src/media_controller_db.c +++ b/src/media_controller_db.c @@ -145,7 +145,7 @@ static int __mc_db_get_ulong_value_of_key(void *handle, const char *server_name, return MEDIA_CONTROLLER_ERROR_NONE; } -int mc_db_connect(void **handle, bool need_write) +int mc_db_connect(void **handle) { int ret = MEDIA_CONTROLLER_ERROR_NONE; sqlite3 *db_handle = NULL; @@ -155,10 +155,7 @@ int mc_db_connect(void **handle, bool need_write) mc_retvm_if(handle == NULL, MEDIA_CONTROLLER_ERROR_INVALID_PARAMETER, "Handle is NULL"); /*Connect DB*/ - if (need_write) - ret = db_util_open_with_options(tzplatform_mkpath(TZ_USER_DB, MC_DB_NAME), &db_handle, SQLITE_OPEN_READWRITE, NULL); - else - ret = db_util_open_with_options(tzplatform_mkpath(TZ_USER_DB, MC_DB_NAME), &db_handle, SQLITE_OPEN_READONLY, NULL); + ret = db_util_open_with_options(tzplatform_mkpath(TZ_USER_DB, MC_DB_NAME), &db_handle, SQLITE_OPEN_READWRITE, NULL); if (SQLITE_OK != ret) { mc_error("error when db open"); diff --git a/src/media_controller_server.c b/src/media_controller_server.c index 6a32d58..ae244d6 100755 --- a/src/media_controller_server.c +++ b/src/media_controller_server.c @@ -46,7 +46,7 @@ static int __mc_server_create(media_controller_server_s **mc_server) goto ERROR; } - ret = mc_db_connect(&(_server->db_handle), false); + ret = mc_db_connect(&(_server->db_handle)); if (ret != MEDIA_CONTROLLER_ERROR_NONE) { mc_error("fail mc_db_connect [%d]", ret); goto ERROR; diff --git a/svc/media_controller_db_util.c b/svc/media_controller_db_util.c index e401cbe..e8eb5a6 100755 --- a/svc/media_controller_db_util.c +++ b/svc/media_controller_db_util.c @@ -166,7 +166,7 @@ static char* __mc_get_db_name(uid_t uid) return result_psswd_rtn; } -int mc_db_util_connect(void **handle, uid_t uid, bool need_write) +int mc_db_util_connect(void **handle, uid_t uid) { int ret = MEDIA_CONTROLLER_ERROR_NONE; sqlite3 *db_handle = NULL; @@ -183,10 +183,7 @@ int mc_db_util_connect(void **handle, uid_t uid, bool need_write) } /*Connect DB*/ - if (need_write) - ret = db_util_open_with_options(db_name, &db_handle, SQLITE_OPEN_READWRITE, NULL); - else - ret = db_util_open_with_options(db_name, &db_handle, SQLITE_OPEN_READONLY, NULL); + ret = db_util_open_with_options(db_name, &db_handle, SQLITE_OPEN_READWRITE, NULL); MC_SAFE_FREE(db_name); diff --git a/svc/media_controller_db_util.h b/svc/media_controller_db_util.h index a427212..78386ff 100755 --- a/svc/media_controller_db_util.h +++ b/svc/media_controller_db_util.h @@ -31,7 +31,7 @@ #define SQLITE3_SAFE_FREE(sql_string) {if (sql_string) {sqlite3_free(sql_string); sql_string = NULL; } } #define SQLITE3_FINALIZE(x) {if (x != NULL) sqlite3_finalize(x); } -int mc_db_util_connect(void **handle, uid_t uid, bool need_write); +int mc_db_util_connect(void **handle, uid_t uid); int mc_db_util_disconnect(void *handle); int mc_db_util_create_tables(void *handle); int mc_db_util_update_db(void *handle, const char *sql_str); diff --git a/svc/media_controller_svc.c b/svc/media_controller_svc.c index 46ad57b..9e15586 100644 --- a/svc/media_controller_svc.c +++ b/svc/media_controller_svc.c @@ -329,7 +329,7 @@ gboolean mc_svc_thread(void *data) } /* Connect media controller DB*/ - if (mc_db_util_connect(&(mc_svc_data->db_handle), uid, true) != MEDIA_CONTROLLER_ERROR_NONE) { + if (mc_db_util_connect(&(mc_svc_data->db_handle), uid) != MEDIA_CONTROLLER_ERROR_NONE) { mc_error("Failed to connect DB"); MC_SAFE_FREE(mc_svc_data); return FALSE; -- 2.7.4