fix svace minmum sleeptime 10000ms 80/167680/2
authorchen89.chen <chen89.chen@samsung.com>
Fri, 19 Jan 2018 08:16:01 +0000 (16:16 +0800)
committerchen89.chen <chen89.chen@samsung.com>
Fri, 19 Jan 2018 08:21:07 +0000 (16:21 +0800)
Change-Id: Ic05e851eee6dcb4a6603cdc0cb1c0aab31a874d5

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

index 780512a..296955f 100755 (executable)
@@ -25,7 +25,7 @@
 #include "stdbool.h"
 #include "media-common-system.h"
 
-#define SCAN_SLEEP_TIME 2000
+#define SCAN_SLEEP_TIME 10000
 
 int msc_set_power_status(bool status);
 int msc_get_power_status(bool *status);
index 8b4a5b9..c02982c 100755 (executable)
@@ -115,6 +115,7 @@ int __msc_folder_bulk_extract(void **handle, const char* storage_id, int storage
        GArray *data_array = NULL;
        ms_item_info_s* db_data = NULL;
        int extract_count = 0;
+       int sleep_count = 0;
 
        ret = ms_get_extract_list(handle, storage_id, storage_type, scan_type, path, burst, uid, (void*)&data_array);
        if (ret != MS_MEDIA_ERR_NONE) {
@@ -151,7 +152,11 @@ int __msc_folder_bulk_extract(void **handle, const char* storage_id, int storage
                        MS_SAFE_FREE(db_data);
                        db_data = NULL;
                }
+               sleep_count++;
+               if (sleep_count % 5 == 0) {
+                       sleep_count = 0;
                usleep(SCAN_SLEEP_TIME);
+               }
        }
 
        if (extract_count > 0)
index 4be87db..06a8ae2 100755 (executable)
@@ -267,6 +267,7 @@ static int __msc_dir_scan_for_folder(void **handle, const char *storage_id, cons
        struct linux_dirent *d;
        int bpos = 0;
        int scan_count = 0;
+       int sleep_count = 0;
 
        const char *trash = "$RECYCLE.BIN";
 
@@ -357,6 +358,7 @@ static int __msc_dir_scan_for_folder(void **handle, const char *storage_id, cons
 
                ms_insert_folder_start(handle);
                ms_set_folder_scan_status(handle, storage_id, current_path, MS_DIR_SCAN_PROCESSING, uid);
+               sleep_count = 0;
 
                fd = open(current_path, O_RDONLY | O_DIRECTORY);
                if (fd == -1) {
@@ -411,6 +413,11 @@ static int __msc_dir_scan_for_folder(void **handle, const char *storage_id, cons
                                break;
 
                        for (bpos = 0; bpos < nread;) {
+                               sleep_count++;
+                               if (sleep_count % 5 == 0) {
+                                       sleep_count = 0;
+                                       usleep(SCAN_SLEEP_TIME);
+                               }
                                /*check poweroff status*/
                                ret = __msc_check_stop_status(scan_type, new_start_path, pid);
                                if (ret != MS_MEDIA_ERR_NONE) {
@@ -444,21 +451,18 @@ static int __msc_dir_scan_for_folder(void **handle, const char *storage_id, cons
 
                                if (d->d_name[0] == '.') {
                                        bpos += d->d_reclen;
-                                       usleep(SCAN_SLEEP_TIME);
                                        continue;
                                }
 
                                if (strcmp(d->d_name, trash) == 0) {
                                        MS_DBG_ERR("trash directory");
                                        bpos += d->d_reclen;
-                                       usleep(SCAN_SLEEP_TIME);
                                        continue;
                                }
 
                                if (ms_strappend(path, sizeof(path), "%s/%s", current_path, d->d_name) != MS_MEDIA_ERR_NONE) {
                                        MS_DBG_ERR("ms_strappend failed");
                                        bpos += d->d_reclen;
-                                       usleep(SCAN_SLEEP_TIME);
                                        continue;
                                }
 
@@ -475,7 +479,6 @@ static int __msc_dir_scan_for_folder(void **handle, const char *storage_id, cons
                                if (d->d_type == DT_REG) {
                                        if (!ms_check_support_media_type(handle, path)) {
                                                bpos += d->d_reclen;
-                                               usleep(SCAN_SLEEP_TIME);
                                                continue;
                                        }
 
@@ -487,7 +490,6 @@ static int __msc_dir_scan_for_folder(void **handle, const char *storage_id, cons
                                                        MS_DBG_ERR("I/O ERROR COUNT[%d]", io_err_folder++);
 
                                                bpos += d->d_reclen;
-                                               usleep(SCAN_SLEEP_TIME);
                                                continue;
                                        } else {
                                                ++scan_count;
@@ -535,14 +537,12 @@ static int __msc_dir_scan_for_folder(void **handle, const char *storage_id, cons
                                                if (ms_insert_folder(handle, storage_id, path, uid) != MS_MEDIA_ERR_NONE) {
                                                        MS_DBG_ERR("insert folder failed");
                                                        bpos += d->d_reclen;
-                                                       usleep(SCAN_SLEEP_TIME);
                                                        continue;
                                                }
                                        }
                                }
 
                                bpos += d->d_reclen;
-                               usleep(SCAN_SLEEP_TIME);
                        }
                        /*update modifiec type for the internal storage*/
                        if (scan_type == MS_MSG_DIRECTORY_SCANNING_NON_RECURSIVE) {
@@ -551,7 +551,6 @@ static int __msc_dir_scan_for_folder(void **handle, const char *storage_id, cons
                                else
                                        ms_update_folder_time(handle, storage_id, current_path, uid);
                        }
-                       usleep(SCAN_SLEEP_TIME);
                }
 
                ms_insert_folder_end(handle, uid);
@@ -608,6 +607,7 @@ static int __msc_dir_scan_for_storage(void **handle, const char *storage_id, con
        struct linux_dirent *d;
        int bpos = 0;
        int scan_count = 0;
+       int sleep_count = 0;
 
        const char *trash = "$RECYCLE.BIN";
 
@@ -696,6 +696,7 @@ static int __msc_dir_scan_for_storage(void **handle, const char *storage_id, con
 
                ms_insert_folder_start(handle);
                ms_set_folder_scan_status(handle, storage_id, current_path, MS_DIR_SCAN_PROCESSING, uid);
+               sleep_count = 0;
 
                fd = open(current_path, O_RDONLY | O_DIRECTORY);
                if (fd == -1) {
@@ -731,6 +732,11 @@ static int __msc_dir_scan_for_storage(void **handle, const char *storage_id, con
                                break;
 
                        for (bpos = 0; bpos < nread;) {
+                               sleep_count++;
+                               if (sleep_count % 5 == 0) {
+                                       sleep_count = 0;
+                                       usleep(SCAN_SLEEP_TIME);
+                               }
                                /*check poweroff status*/
                                ret = __msc_check_stop_status(scan_type, new_start_path, pid);
                                if (ret != MS_MEDIA_ERR_NONE)
@@ -757,14 +763,12 @@ static int __msc_dir_scan_for_storage(void **handle, const char *storage_id, con
                                if (strcmp(d->d_name, trash) == 0) {
                                        MS_DBG_ERR("trash directory");
                                        bpos += d->d_reclen;
-                                       usleep(SCAN_SLEEP_TIME);
                                        continue;
                                }
 
                                if (ms_strappend(path, sizeof(path), "%s/%s", current_path, d->d_name) != MS_MEDIA_ERR_NONE) {
                                        MS_DBG_ERR("ms_strappend failed");
                                        bpos += d->d_reclen;
-                                       usleep(SCAN_SLEEP_TIME);
                                        continue;
                                }
 
@@ -782,7 +786,6 @@ static int __msc_dir_scan_for_storage(void **handle, const char *storage_id, con
                                        /* check media type */
                                        if (!ms_check_support_media_type(handle, path)) {
                                                bpos += d->d_reclen;
-                                               usleep(SCAN_SLEEP_TIME);
                                                continue;
                                        }
 
@@ -794,7 +797,6 @@ static int __msc_dir_scan_for_storage(void **handle, const char *storage_id, con
                                                        MS_DBG_ERR("I/O ERROR COUNT[%d]", io_err_storage++);
 
                                                bpos += d->d_reclen;
-                                               usleep(SCAN_SLEEP_TIME);
                                                continue;
                                        } else {
                                                ++scan_count;
@@ -816,9 +818,7 @@ static int __msc_dir_scan_for_storage(void **handle, const char *storage_id, con
                                }
 
                                bpos += d->d_reclen;
-                               usleep(SCAN_SLEEP_TIME);
                        }
-                       usleep(SCAN_SLEEP_TIME);
                }
 
                ms_insert_folder_end(handle, uid);
@@ -1297,9 +1297,9 @@ gboolean msc_directory_scan_thread(void *data)
                }*/
 
 SCAN_DONE:
+               MS_DBG_WARN("storage_id = [%s], dir Path = [%s], pid = [%d]", storage_id, scan_data->msg, scan_data->pid);
                if (ret != MS_MEDIA_ERR_SCANNER_FORCE_STOP) {
                        if (noti_type == MS_ITEM_DELETE) {
-                               MS_DBG_WARN("storage_id = [%s], dir Path = [%s], folder_uuid = [%s], noti_type = [%d]", storage_id, scan_data->msg, folder_uuid, noti_type);
                                ms_send_dir_update_noti(handle, storage_id, scan_data->msg, folder_uuid, noti_type, scan_data->pid);
                        }
                        msc_insert_exactor_request(scan_data->msg_type, TRUE, scan_data->storage_id, scan_data->msg, scan_data->pid, uid, noti_type);
@@ -1764,6 +1764,7 @@ FREE_RESOURCE:
 
                MS_SAFE_FREE(file_path);
                MS_SAFE_FREE(register_data);
+               usleep(SCAN_SLEEP_TIME);
        }                       /*thread while*/
 
 _POWEROFF: