GAsyncQueue *folder_extract_queue;
static GMutex extract_req_mutex;
static GMutex extract_blocked_mutex;
-static char *g_extract_cancel_path;
static char *g_extract_blocked_path;
bool g_directory_extract_processing;
static int stg_extract_status;
char *path;
} ms_item_info_s;
-static int __msc_folder_bulk_extract(sqlite3 *handle, const char* storage_id, int storage_type, const char *path, int scan_type, int pid, uid_t uid, unsigned int *io_err_count, bool is_end);
-
void msc_init_extract_thread(void)
{
if (!storage_extract_queue) storage_extract_queue = g_async_queue_new();
g_cond_clear(&extract_data_cond);
}
-int __msc_folder_bulk_extract(sqlite3 *handle, const char* storage_id, int storage_type, const char *path, int scan_type, int pid, uid_t uid, unsigned int *io_err_count, bool is_end)
+static int __msc_folder_bulk_extract(sqlite3 *handle, const char *storage_id, int storage_type, const char *path, int scan_type, int pid, uid_t uid, bool is_end)
{
MS_DBG_WARN("begin of __msc_folder_bulk_extract");
int ret = MS_MEDIA_ERR_NONE;
int extract_count = 0;
int sleep_count = 0;
- ret = ms_get_extract_list(handle, storage_id, storage_type, scan_type, path, is_end, uid, (void*)&data_array);
- if (ret != MS_MEDIA_ERR_NONE) {
- MS_DBG_ERR("ms_get_extract_list failed!!!");
- return MS_MEDIA_ERR_NONE;
- }
-
- if (data_array == NULL) {
- MS_DBG_ERR("data_array is NULL!!!");
- return MS_MEDIA_ERR_NONE;
- }
+ ret = ms_get_extract_list(handle, storage_id, storage_type, scan_type, path, is_end, uid, (void *)&data_array);
+ MS_DBG_RETVM_IF(ret != MS_MEDIA_ERR_NONE, MS_MEDIA_ERR_NONE, "ms_get_extract_list failed!!!");
+ MS_DBG_RETVM_IF(!data_array, MS_MEDIA_ERR_NONE, "data_array is NULL!!!");
while (data_array->len != 0) {
tmp_ret = MS_MEDIA_ERR_NONE;
g_mutex_unlock(&decode_mutex);
if (tmp_ret == MS_MEDIA_ERR_NONE)
extract_count++;
- else if (tmp_ret == MS_MEDIA_ERR_INTERNAL)
- (*io_err_count)++;
if (db_data) {
MS_SAFE_FREE(db_data->path);
MS_SAFE_FREE(db_data);
db_data = NULL;
}
- sleep_count++;
- if (sleep_count % 5 == 0) {
+
+ if (++sleep_count == 5) {
sleep_count = 0;
- usleep(SCAN_SLEEP_TIME);
+ usleep(SCAN_SLEEP_TIME);
}
}
while (data_array->len != 0) {
db_data = NULL;
- db_data = g_array_index(data_array, ms_item_info_s*, 0);
+ db_data = g_array_index(data_array, ms_item_info_s *, 0);
g_array_remove_index(data_array, 0);
if (db_data) {
ms_user_storage_type_e storage_type;
char *storage_id = NULL;
char *update_path = NULL;
- unsigned int io_err_count = 0;
uid_t uid = MEDIA_DEFAULT_UID;
int end_flag = NORMAL_EVENT;
ms_noti_type_e noti_type = MS_ITEM_INSERT;
MS_DBG_WARN("DIRECTORY EXTRACT START [%.*s %d]", MAX_MSG_SIZE, extract_data->msg, extract_data->msg_type);
- io_err_count = 0;
-
__msc_set_cur_extract_item(extract_data->msg, extract_data->pid);
g_directory_extract_processing = true;
uid = extract_data->uid;
goto NEXT;
}
- ret = __msc_folder_bulk_extract(handle, extract_data->storage_id, storage_type, update_path, scan_type, extract_data->pid, uid, &io_err_count, end_flag);
+ ret = __msc_folder_bulk_extract(handle, extract_data->storage_id, storage_type, update_path, scan_type, extract_data->pid, uid, end_flag);
NEXT:
g_directory_extract_processing = false;
ms_user_storage_type_e storage_type = MS_USER_STORAGE_INTERNAL;
int scan_type;
char *update_path = NULL;
- unsigned int io_err_count = 0;
uid_t uid = MEDIA_DEFAULT_UID;
int end_flag = NORMAL_EVENT;
int tem_ret = MS_MEDIA_ERR_NONE;
__msc_set_storage_extract_status(MS_STORAGE_SCAN_META_PROCESSING);
- io_err_count = 0;
-
MS_DBG_WARN("STORAGE extract START extract len is %d ", g_async_queue_length(storage_extract_queue));
scan_type = extract_data->msg_type;
}
/*extract meta*/
- ret = __msc_folder_bulk_extract(handle, extract_data->storage_id, storage_type, update_path, scan_type, extract_data->pid, uid, &io_err_count, end_flag);
+ ret = __msc_folder_bulk_extract(handle, extract_data->storage_id, storage_type, update_path, scan_type, extract_data->pid, uid, end_flag);
MS_DBG_WARN("extract PAUSE");
__msc_pause_extract();
MS_DBG_WARN("extract RESUME");
return res;
}
-int msc_get_remain_extract_request(ms_extract_type_e scan_type, int *remain_request)
-{
- int ret = MS_MEDIA_ERR_NONE;
-
- switch (scan_type) {
- case MS_EXTRACT_STORAGE:
- *remain_request = g_async_queue_length(storage_extract_queue);
- break;
- case MS_EXTRACT_DIRECTORY:
- *remain_request = g_async_queue_length(folder_extract_queue);
- break;
- default:
- MS_DBG_ERR("invalid parameter");
- ret = MS_MEDIA_ERR_INVALID_PARAMETER;
- break;
- }
-
- return ret;
-}
-
-void msc_stop_extract_thread(void)
-{
- ms_comm_msg_s *data = NULL;
-
- if (storage_extract_queue) {
- /*notify to storage extract thread*/
- data = g_new0(ms_comm_msg_s, 1);
-
- data->pid = POWEROFF;
- g_async_queue_push(storage_extract_queue, data);
- }
-
- if (folder_extract_queue) {
- /*notify to folder extract thread*/
- data = g_new0(ms_comm_msg_s, 1);
-
- data->pid = POWEROFF;
- g_async_queue_push(folder_extract_queue, data);
- }
-}
-
-int msc_set_extract_cancel_path(const char *cancel_path)
-{
- if (g_extract_cancel_path != NULL) {
- MS_DBG_WARN("g_extract_cancel_path is not NULL");
- g_free(g_extract_cancel_path);
- }
-
- g_extract_cancel_path = g_strdup(cancel_path);
-
- return MS_MEDIA_ERR_NONE;
-}
-