Do not free http_info in client request thread 90/244290/1
authorSeonah Moon <seonah1.moon@samsung.com>
Thu, 17 Sep 2020 01:47:58 +0000 (10:47 +0900)
committerSeonah Moon <seonah1.moon@samsung.com>
Thu, 17 Sep 2020 02:05:38 +0000 (11:05 +0900)
http_info is used in download thread and it is freed if download is
finished.

However, in pause state, client request thread releases http_info if
client requests 'cancel'.
This makes a crash occasionally during download thread is terminating.

So, download thread should have ownership of http_info and this thread
should free it only.

Change-Id: Ia3ec64d1ce64e2aee49e260b901686a4ae6d4d76

agent/download-agent-dl-info.c
agent/download-agent-http-mgr.c
agent/include/download-agent-dl-info.h
packaging/download-provider.spec

index b65003a..edaddd7 100644 (file)
@@ -439,36 +439,6 @@ void reset_http_info_for_resume(http_info_t *http_info)
        }
 }
 
-void reset_http_info(http_info_t *http_info)
-{
-       if (http_info) {
-               DA_LOGI("[TEST] location_url[%p]", http_info->location_url);
-               free(http_info->location_url);
-               http_info->location_url = DA_NULL;
-               free(http_info->content_type_from_header);
-               http_info->content_type_from_header = DA_NULL;
-               if (http_info->proxy_info) {
-                       __destroy_proxy_info(http_info->proxy_info);
-                       http_info->proxy_info = DA_NULL;
-               }
-               if (http_info->http_msg_request) {
-                       __destroy_http_msg_request(http_info->http_msg_request);
-                       http_info->http_msg_request = DA_NULL;
-               }
-               if (http_info->http_msg_response) {
-                       __destroy_http_msg_response(http_info->http_msg_response);
-                       http_info->http_msg_response = DA_NULL;
-               }
-               if (http_info->http_msg) {
-                       __destroy_http_msg(http_info->http_msg);
-                       http_info->http_msg = DA_NULL;
-               }
-               http_info->http_method = HTTP_METHOD_GET;
-               http_info->content_len_from_header = 0;
-               http_info->total_size = 0;
-       }
-}
-
 da_bool_t is_valid_download_id(int download_id)
 {
        da_ret_t ret = DA_RESULT_OK;
index 7c4d34e..f048687 100755 (executable)
@@ -669,7 +669,6 @@ da_ret_t request_to_cancel_http_download(da_info_t *da_info)
                DA_MUTEX_UNLOCK(&(http_info->mutex_http));
                break;
        case HTTP_STATE_PAUSED:
-               reset_http_info(http_info);
                DA_MUTEX_LOCK(&(http_info->mutex_state));
                http_info->state = HTTP_STATE_CANCELED;
                DA_MUTEX_UNLOCK(&(http_info->mutex_state));
index 445a025..fc35efb 100644 (file)
@@ -201,7 +201,6 @@ void destroy_da_info_list(void);
 da_ret_t get_da_info_with_da_id(int id, da_info_t **out_info);
 da_ret_t init_http_msg_t(http_msg_t **http_msg);
 void destroy_http_msg_t(http_msg_t *http_msg);
-void reset_http_info(http_info_t *http_info);
 void reset_http_info_for_resume(http_info_t *http_info);
 void destroy_http_info(http_info_t *http_info);
 void destroy_file_info(file_info_t *file_info);
index d4daee4..5bbf7c3 100755 (executable)
@@ -1,6 +1,6 @@
 Name:       download-provider
 Summary:    Download the contents in background
-Version:    2.2.2
+Version:    2.2.3
 Release:    0
 Group:      Development/Libraries
 License:    Apache-2.0