Modify media_content_disconnect() 55/211355/2 accepted/tizen/unified/20190806.072159 submit/tizen/20190805.053702
authorMinje Ahn <minje.ahn@samsung.com>
Fri, 2 Aug 2019 00:33:53 +0000 (09:33 +0900)
committerMinje Ahn <minje.ahn@samsung.com>
Sun, 4 Aug 2019 23:21:43 +0000 (08:21 +0900)
Modify the code according to the change in the return value of media_db_disconnect()

Change-Id: I9ec4ecc431c67ed271f64fdf05d58f11ff941ceb
Signed-off-by: Minje Ahn <minje.ahn@samsung.com>
src/media_content.c

index d430dde..f66ffef 100755 (executable)
@@ -229,50 +229,25 @@ int media_content_connect_with_uid(uid_t uid)
 
 int media_content_disconnect(void)
 {
-       int ret = MEDIA_CONTENT_ERROR_NONE;
-
        g_mutex_lock(&db_mutex);
        media_content_debug("ref count : %d", ref_count);
-       if (ref_count > 0) {
-               if (db_handle != NULL) {
-                       ref_count--;
-               } else {
-                       media_content_error("Wrong DB Handle status");
-                       ret = MEDIA_CONTENT_ERROR_DB_FAILED;
+
+       if (db_handle && ref_count > 0) {
+               if (--ref_count == 0) {
+                       media_db_disconnect(db_handle);
+                       db_handle = NULL;
                }
        } else {
-               media_content_error("DB_FAILED(0x%08x) database is not connected", MEDIA_CONTENT_ERROR_DB_FAILED);
+               media_content_error("Database is not connected");
                g_mutex_unlock(&db_mutex);
                return MEDIA_CONTENT_ERROR_DB_FAILED;
        }
 
-       if (ref_count == 0) {
-               if (db_handle != NULL) {
-                       ret = media_db_disconnect(db_handle);
-                       ret = _content_error_capi(ret);
-                       if (ret == MEDIA_CONTENT_ERROR_NONE) {
-                               db_handle = NULL;
-                       } else {
-                               media_content_error("database disconnect fail");
-                               ref_count++;
-                       }
-               } else {
-                       media_content_error("Wrong DB Handle status");
-                       ret = MEDIA_CONTENT_ERROR_DB_FAILED;
-               }
-
-               g_mutex_unlock(&db_mutex);
-
-               media_content_info("ref count changed to: %d", ref_count);
-
-               return ret;
-       }
-
        g_mutex_unlock(&db_mutex);
 
        media_content_info("ref count changed to: %d", ref_count);
 
-       return ret;
+       return MEDIA_CONTENT_ERROR_NONE;
 }
 
 int media_content_scan_file(const char *path)