From 6fda596def0e25901e30478b05f490d8231774ad Mon Sep 17 00:00:00 2001 From: Seonah Moon Date: Fri, 3 Aug 2018 17:50:20 +0900 Subject: [PATCH] Fix block issue of main thread 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 | 13 ++++++++----- packaging/download-provider.spec | 2 +- 2 files changed, 9 insertions(+), 6 deletions(-) diff --git a/agent/download-agent-http-mgr.c b/agent/download-agent-http-mgr.c index 6331017..fd6874f 100755 --- a/agent/download-agent-http-mgr.c +++ b/agent/download-agent-http-mgr.c @@ -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)); diff --git a/packaging/download-provider.spec b/packaging/download-provider.spec index 35e58d3..098be4d 100755 --- a/packaging/download-provider.spec +++ b/packaging/download-provider.spec @@ -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 -- 2.7.4