From dfe523b695e70e7839b68c25078b659d266c3196 Mon Sep 17 00:00:00 2001 From: Minje Ahn Date: Tue, 26 Sep 2017 17:21:33 +0900 Subject: [PATCH] Modify to use glist length instead of counter Modify length checker Add exception handler for multiples of 200 Signed-off-by: Minje Ahn Change-Id: Ib42a226bd53a6c8250dc2a56583d3f89e881b004 --- packaging/libmedia-service.spec | 2 +- src/common/media-svc-media.c | 16 +++++++--------- 2 files changed, 8 insertions(+), 10 deletions(-) diff --git a/packaging/libmedia-service.spec b/packaging/libmedia-service.spec index 3039c0a..112629a 100644 --- a/packaging/libmedia-service.spec +++ b/packaging/libmedia-service.spec @@ -1,6 +1,6 @@ Name: libmedia-service Summary: Media information service library for multimedia applications -Version: 0.3.18 +Version: 0.3.19 Release: 0 Group: Multimedia/Libraries License: Apache-2.0 and PD diff --git a/src/common/media-svc-media.c b/src/common/media-svc-media.c index b250741..53f51de 100755 --- a/src/common/media-svc-media.c +++ b/src/common/media-svc-media.c @@ -37,7 +37,6 @@ static __thread GList *g_media_svc_insert_item_query_list = NULL; __thread GList *g_media_svc_move_item_query_list = NULL; static __thread GList *g_media_svc_update_item_query_list = NULL; static __thread GList *g_media_svc_update_list = NULL; -static __thread int g_media_svc_update_list_count = 0; static int __media_svc_get_invalid_records_with_thumbnail(sqlite3 *handle, media_svc_storage_type_e storage_type, GArray **thumb_path) { @@ -650,6 +649,12 @@ int _media_svc_list_query_do(media_svc_query_type_e query_type, uid_t uid) { int ret = MS_MEDIA_ERR_NONE; + /* For multiples of 200, empty requests are possible */ + if (query_type == MEDIA_SVC_QUERY_UPDATE_COMMON) { + if (g_media_svc_update_list == NULL || g_list_length(g_media_svc_update_list) == 0) + return MS_MEDIA_ERR_NONE; + } + ret = _media_svc_sql_begin_trans(uid); media_svc_retv_if(ret != MS_MEDIA_ERR_NONE, ret); @@ -668,9 +673,6 @@ int _media_svc_list_query_do(media_svc_query_type_e query_type, uid_t uid) else ret = MS_MEDIA_ERR_INVALID_PARAMETER; - if (query_type == MEDIA_SVC_QUERY_UPDATE_COMMON) - g_media_svc_update_list_count = 0; - media_svc_retvm_if(ret != MS_MEDIA_ERR_NONE, ret, "Failed to request queries"); ret = _media_svc_sql_end_trans(uid); @@ -685,12 +687,8 @@ int _media_svc_append_query_list(const char *query, uid_t uid) g_media_svc_update_list = g_list_append(g_media_svc_update_list, (gpointer)query); - g_media_svc_update_list_count++; - - if (g_media_svc_update_list_count >= MEDIA_SVC_MAX_COMMIT_SIZE) { + if (g_list_length(g_media_svc_update_list) >= MEDIA_SVC_MAX_COMMIT_SIZE) ret = _media_svc_list_query_do(MEDIA_SVC_QUERY_UPDATE_COMMON, uid); - g_media_svc_update_list_count = 0; - } return ret; } -- 2.7.4