Rename function and apply it to scanner-v2 60/239260/9
authorhj kim <backto.kim@samsung.com>
Thu, 23 Jul 2020 07:36:17 +0000 (16:36 +0900)
committerhj kim <backto.kim@samsung.com>
Tue, 28 Jul 2020 03:30:07 +0000 (03:30 +0000)
Change __msc_is_stop_needed() to __msc_is_power_off() because this function check only power status.
And msc_get_power_status() has been removed. _msc_is_power_off() can cover it.

Change-Id: Ib51109da141a4596ac67485d3bcdbaf5998dd619

src/scanner-v2/include/media-scanner-common-v2.h
src/scanner-v2/media-scanner-common-v2.c
src/scanner-v2/media-scanner-extract-v2.c
src/scanner-v2/media-scanner-scan-v2.c
src/scanner/media-scanner-scan.c

index 3471259a657bd4dab8c9ed15f533342c942d77bc..1acac7a701e9d6ff6c5fae1deb83df2079e24355 100755 (executable)
 #define _MEDIA_SCANNER_COMMON_V2_H_
 
 #include "stdbool.h"
-#include "media-common-system.h"
 
 #define SCAN_SLEEP_TIME 10000
 
+bool _msc_is_power_off(void);
 void _msc_set_power_status(bool status);
-void msc_get_power_status(bool *status);
 
 #endif /*_MEDIA_SCANNER_COMMON_V2_H_*/
index ca266f2b68f19eb4376a4eb8a152138a0f24c585..03f1ca1563df53e5d6094b62b12a6bdbf6b48870 100755 (executable)
 #include "media-scanner-common-v2.h"
 #include "media-common-dbg.h"
 
-bool power_off2;
+static bool power_off2;
 
-void _msc_set_power_status(bool status)
+bool _msc_is_power_off(void)
 {
-       power_off2 = status;
+       if (power_off2) {
+               MS_DBG_ERR("Power off");
+               return true;
+       }
 
-       MS_DBG_WARN("media_scanner_v2 set power_off2 to %s", (status) ? "true" : "false");
+       return false;
 }
 
-void msc_get_power_status(bool *status)
+void _msc_set_power_status(bool status)
 {
-       *status = power_off2;
+       power_off2 = status;
+
+       MS_DBG_WARN("media_scanner_v2 set power_off2 to %s", (status) ? "true" : "false");
 }
index d507c0df9565bb545531d4e85b0f61a5d3e1c4e0..057e2ec9d5ddd844930856e8c3e9801659af6036 100644 (file)
@@ -41,7 +41,6 @@
 #include "media-scanner-socket-v2.h"
 #include "media-scanner-extract-v2.h"
 
-extern bool power_off2;
 GAsyncQueue *storage_extract_queue;
 GAsyncQueue *folder_extract_queue;
 static GMutex extract_req_mutex;
@@ -254,10 +253,8 @@ gpointer msc_folder_extract_thread(gpointer data)
 
 NEXT:
                g_directory_extract_processing = false;
-               if (power_off2) {
-                       MS_DBG_ERR("power off");
+               if (_msc_is_power_off())
                        goto _POWEROFF;
-               }
 
                /*Active flush */
                malloc_trim(0);
@@ -421,10 +418,8 @@ NEXT:
                g_free(update_path);
                update_path = NULL;
 
-               if (power_off2) {
-                       MS_DBG_ERR("power off");
+               if (_msc_is_power_off())
                        goto _POWEROFF;
-               }
 
                /*disconnect form media db*/
                ms_disconnect_db(handle);
@@ -648,8 +643,7 @@ static int __msc_check_extract_stop_status(int scan_type, const char *start_path
        int ret = MS_MEDIA_ERR_NONE;
 
        /*check poweroff status*/
-       if (power_off2) {
-               MS_DBG_ERR("Power off");
+       if (_msc_is_power_off()) {
                ret = MS_MEDIA_ERR_SCANNER_FORCE_STOP;
                goto END;
        }
index 877a7525861fcb509bcca4d79261a24d54d229b2..0df869aef46819d95e13dd91ca8145a1c4f7dc3c 100644 (file)
@@ -50,7 +50,6 @@
 #define DIR_SCAN_RECURSIVE             1
 #define DIR_SCAN_NON_RECURSIVE 2
 
-extern bool power_off2;
 GAsyncQueue *storage_queue2;
 GAsyncQueue *scan_queue2;
 GAsyncQueue *reg_queue2;
@@ -177,8 +176,7 @@ static int __msc_check_stop_status(int scan_type, const char *start_path, int pi
        int ret = MS_MEDIA_ERR_NONE;
 
        /*check poweroff status*/
-       if (power_off2) {
-               MS_DBG_ERR("Power off");
+       if (_msc_is_power_off()) {
                ret = MS_MEDIA_ERR_SCANNER_FORCE_STOP;
                goto END;
        }
@@ -1181,10 +1179,9 @@ SCAN_DONE:
                        }
                        msc_insert_exactor_request(scan_data->msg_type, true, scan_data->storage_id, scan_data->msg, scan_data->pid, uid, noti_type);
                }
-               if (power_off2) {
-                       MS_DBG_ERR("power off");
+
+               if (_msc_is_power_off())
                        goto _POWEROFF;
-               }
 
 NEXT:
                /*Active flush */
@@ -1228,7 +1225,7 @@ static void __msc_check_pvr_svc(void)
 #ifdef _USE_TVPD_MODE
        if (ms_is_support_pvr()) {
                MS_DBG_ERR("Waiting PVR service");
-               while (!power_off2) {
+               while (!_msc_is_power_off()) {
                        FILE* file = fopen("/run/pvr_ready", "rb");
 
                        if (file != NULL) {
@@ -1348,10 +1345,8 @@ NEXT:
                g_free(update_path);
                update_path = NULL;
 
-               if (power_off2) {
-                       MS_DBG_ERR("power off");
+               if (_msc_is_power_off())
                        goto _POWEROFF;
-               }
 
                /*disconnect from media db*/
                ms_disconnect_db(handle);
@@ -1461,7 +1456,6 @@ static int __msc_batch_insert(int pid, GArray *path_array, uid_t uid)
        sqlite3 *handle = NULL;
        char *insert_path = NULL;
        char storage_id[MS_UUID_SIZE] = {0,};
-       bool power_off_status = false;
 
        /* connect to media db, if conneting is failed, db updating is stopped */
        err = ms_connect_db(&handle, uid);
@@ -1489,9 +1483,7 @@ static int __msc_batch_insert(int pid, GArray *path_array, uid_t uid)
                /* insert to db */
                err = ms_insert_item_batch(handle, storage_id, insert_path, uid);
 
-               msc_get_power_status(&power_off_status);
-               if (power_off_status) {
-                       MS_DBG_ERR("power off");
+               if (_msc_is_power_off()) {
                        /*call for bundle commit*/
                        break;
                }
index 6fcd99ecbf6ea65036d2f2ca7ca1ee46b6f30a5d..71450a8450280b15f4fe2dc9b0a257a35d84e5eb 100644 (file)
 #include "media-scanner-socket.h"
 #include "media-scanner-scan.h"
 
-bool power_off;
+static bool power_off;
 static GAsyncQueue * storage_queue;
 GAsyncQueue *scan_queue;
 static GAsyncQueue *reg_queue;
 GMutex scan_req_mutex;
 
-static bool __msc_is_stop_needed(void)
+static bool __msc_is_power_off(void)
 {
        if (power_off) {
-               MS_DBG_WARN("Power off");
+               MS_DBG_ERR("Power off");
                return true;
        }
 
@@ -66,7 +66,7 @@ static int __msc_dir_scan(sqlite3 *handle, const char *storage_id, char *start_p
                current_path = g_ptr_array_index(dir_array, 0);
                g_ptr_array_remove_index(dir_array, 0);
 
-               if (__msc_is_stop_needed()) {
+               if (__msc_is_power_off()) {
                        ret = MS_MEDIA_ERR_SCANNER_FORCE_STOP;
                        MS_SAFE_FREE(current_path);
                        continue;
@@ -91,7 +91,7 @@ static int __msc_dir_scan(sqlite3 *handle, const char *storage_id, char *start_p
                        MS_DBG_ERR("insert folder failed");
 
                while ((name = g_dir_read_name(dir))) {
-                       if (__msc_is_stop_needed()) {
+                       if (__msc_is_power_off()) {
                                ret = MS_MEDIA_ERR_SCANNER_FORCE_STOP;
                                break;
                        }
@@ -301,7 +301,7 @@ gpointer msc_directory_scan_thread(gpointer data)
 
                ms_disconnect_db(handle);
 
-               if (__msc_is_stop_needed())
+               if (__msc_is_power_off())
                        goto _POWEROFF;
 NEXT:
                /*Active flush */
@@ -415,7 +415,7 @@ gpointer msc_storage_scan_thread(gpointer data)
                else
                        ms_set_db_status(MS_DB_UPDATED, storage_type);
 NEXT:
-               if (__msc_is_stop_needed())
+               if (__msc_is_power_off())
                        goto _POWEROFF;
 
                /*Active flush */
@@ -493,7 +493,7 @@ static int __msc_batch_insert(int pid, GPtrArray *path_array, uid_t uid)
 
                ret = ms_insert_item_batch(handle, storage_id, insert_path, uid);
 
-               if (__msc_is_stop_needed()) {
+               if (__msc_is_power_off()) {
                        ret = MS_MEDIA_ERR_SCANNER_FORCE_STOP;
                        break;
                }