Fix block issue of main thread 94/185894/3
authorSeonah Moon <seonah1.moon@samsung.com>
Fri, 3 Aug 2018 08:50:20 +0000 (17:50 +0900)
committerSeonah Moon <seonah1.moon@samsung.com>
Mon, 6 Aug 2018 01:31:08 +0000 (10:31 +0900)
Main thread often faces with bloking when pause and resume occur repeatedly.
It's becuase previous resume event causes data packet.
Although pause() is invoked, data packet can be recieved because of previous resume event.
However, download-provider considers this situaition as 'error' state.
This change makes main thread just wait for changing download state properly.

Change-Id: I1e22661fb909d449b94db26aad8bbe2cfb033d8c

agent/download-agent-http-mgr.c
packaging/download-provider.spec

index 6331017..fd6874f 100755 (executable)
@@ -1248,11 +1248,11 @@ da_ret_t __handle_event_http_packet(http_raw_data_t *raw_data, da_info_t *da_inf
 #ifdef _RAF_SUPPORT
                if (http_info->is_raf_mode_confirmed == DA_FALSE) {
 #endif
-               __check_before_downloading(da_info, http_state);
-               ret = file_write_ongoing(file_info,
+               if (__check_before_downloading(da_info, http_state) == DA_RESULT_OK) {
+                       ret = file_write_ongoing(file_info,
                                raw_data->body, raw_data->body_len);
-               if (ret != DA_RESULT_OK)
-                       goto ERR;
+                       if (ret != DA_RESULT_OK)
+                               goto ERR;
 #ifdef _RAF_SUPPORT
                } else {
                        file_info->bytes_written_to_file =
@@ -1260,7 +1260,10 @@ da_ret_t __handle_event_http_packet(http_raw_data_t *raw_data, da_info_t *da_inf
                        file_info->is_updated = DA_TRUE;
                }
 #endif
-               ret = send_client_update_progress_info(da_info);
+                       ret = send_client_update_progress_info(da_info);
+               } else {
+                       DA_LOGD("Do nothing! Wait for changing state properly");
+               }
                break;
        case HTTP_STATE_REDIRECTED:
                DA_LOGV("http_state[%s]", __get_state_str(http_state));
index 35e58d3..098be4d 100755 (executable)
@@ -1,6 +1,6 @@
 Name:       download-provider
 Summary:    Download the contents in background
-Version:    2.1.99
+Version:    2.1.100
 Release:    0
 Group:      Development/Libraries
 License:    Apache-2.0