set db handle to NULL after disconnect to avoid double close 17/311617/3 accepted/tizen_8.0_unified tizen_8.0 accepted/tizen/8.0/unified/20240524.142357
authorsamsung2013 <yuzhi.he@samsung.com>
Thu, 23 May 2024 17:56:38 +0000 (01:56 +0800)
committersamsung2013 <yuzhi.he@samsung.com>
Thu, 23 May 2024 18:17:36 +0000 (02:17 +0800)
Change-Id: I2482bdf4b8396ce534773618efaaf9fb0a768801

lib/media-util-db.c
packaging/media-server.spec
src/mediadb-update.c
src/scanner-v2/media-scanner-extract-v2.c
src/scanner-v2/media-scanner-scan-v2.c

index 93a995308879f9717c20b3ffd0a86150c1c97da9..75208363de3737f489c804308fc8a0c864a368ee 100755 (executable)
@@ -360,10 +360,8 @@ void media_db_disconnect(sqlite3 *handle)
 {
        MSAPI_DBG_FUNC();
 
-       if (handle) {
+       if (handle)
                sqlite3_close_v2(handle);
-               handle = NULL;
-       }
 }
 
 int media_db_request_update_db(const char *query_str, uid_t uid)
index 942ea684af1bccb19e62483224a0f65ef8682222..eec7e60d810682d85840d8f2b7d586d9ac7673e9 100755 (executable)
@@ -1,6 +1,6 @@
 Name:       media-server
 Summary:    A server for media content management
-Version:    0.4.30
+Version:    0.4.31
 Release:    0
 Group:      Multimedia/Service
 License:    Apache-2.0
index 8396c3357223a1f0e86d64a92651e157abe10a51..8586e71024f30c09857c8d642b898d9d459f087e 100755 (executable)
@@ -134,16 +134,14 @@ static int __get_storage_id(const char *path, char *storage_id, uid_t uid)
        }
 
        ret = svc_get_storage_id(db_handle, path, storage_id, tzplatform_getuid(TZ_USER_NAME));
+       media_db_disconnect(db_handle);
+       dlclose(funcHandle);
        if (ret < 0) {
                printf("Error svc_get_storage_id\n");
-               dlclose(funcHandle);
                return -1;
        }
-       media_db_disconnect(db_handle);
-       printf("Start Scanning for [%s][%s]\n", path, storage_id);
-
-       dlclose(funcHandle);
 
+       printf("Start Scanning for [%s][%s]\n", path, storage_id);
        return 0;
 }
 
index de1c6e72ce0e3019915a0bfad7c6f1605ef3ee90..2480014277688dd362d6d50b2157951aab1d63b5 100644 (file)
@@ -267,6 +267,7 @@ NEXT:
                }
 
                ms_disconnect_db(handle);
+               handle = NULL;
                usleep(SCAN_SLEEP_TIME);
        }
 
@@ -394,6 +395,7 @@ NEXT:
 
                /*disconnect form media db*/
                ms_disconnect_db(handle);
+               handle = NULL;
 
                /*Active flush */
                malloc_trim(0);
index 60931a5743dfff3e2ff349095ca2ed32e2a81986..e3f6b72d5abad543a4c38589fd7935cf565eddfd 100644 (file)
@@ -986,6 +986,7 @@ NEXT:
                MS_DBG_WARN("DIRECTORY SCAN END [%d]", ret);
 
                ms_disconnect_db(handle);
+               handle = NULL;
                usleep(SCAN_SLEEP_TIME);
        }
 
@@ -1099,6 +1100,7 @@ NEXT:
                        goto _POWEROFF;
 
                ms_disconnect_db(handle);
+               handle = NULL;
 
                malloc_trim(0);