summaryrefslogtreecommitdiff
path: root/src/agent
diff options
context:
space:
mode:
Diffstat (limited to 'src/agent')
-rw-r--r--src/agent/download-agent-basic.c15
-rw-r--r--src/agent/download-agent-client-mgr.c3
-rw-r--r--src/agent/download-agent-dl-info-util.c3
-rw-r--r--src/agent/download-agent-dl-mgr.c9
-rw-r--r--src/agent/download-agent-file.c3
-rw-r--r--src/agent/download-agent-http-mgr.c4
6 files changed, 18 insertions, 19 deletions
diff --git a/src/agent/download-agent-basic.c b/src/agent/download-agent-basic.c
index db40f45..d069e7e 100644
--- a/src/agent/download-agent-basic.c
+++ b/src/agent/download-agent-basic.c
@@ -64,6 +64,7 @@ da_result_t start_download_with_extension(
client_input_t *client_input = DA_NULL;
client_input_basic_t *client_input_basic = DA_NULL;
download_thread_input *thread_info = DA_NULL;
+ pthread_attr_t thread_attr;
DA_LOG_FUNC_START(Default);
@@ -132,7 +133,7 @@ da_result_t start_download_with_extension(
}
thread_info = (download_thread_input *)calloc(1, sizeof(download_thread_input));
- if(!thread_info) {
+ if (!thread_info) {
DA_LOG_ERR(Default, "DA_ERR_FAIL_TO_MEMALLOC");
ret = DA_ERR_FAIL_TO_MEMALLOC;
goto ERR;
@@ -140,8 +141,18 @@ da_result_t start_download_with_extension(
thread_info->download_id = download_id;
thread_info->client_input = client_input;
}
+ if (pthread_attr_init(&thread_attr) != 0) {
+ ret = DA_ERR_FAIL_TO_CREATE_THREAD;
+ goto ERR;
+ }
+
+ if (pthread_attr_setdetachstate(&thread_attr, PTHREAD_CREATE_DETACHED) != 0) {
+ ret = DA_ERR_FAIL_TO_CREATE_THREAD;
+ goto ERR;
+ }
- if(pthread_create(&GET_DL_THREAD_ID(download_id), DA_NULL, __thread_start_download, thread_info) < 0) {
+ if (pthread_create(&GET_DL_THREAD_ID(download_id), &thread_attr,
+ __thread_start_download, thread_info) < 0) {
DA_LOG_ERR(Thread, "making thread failed..");
ret = DA_ERR_FAIL_TO_CREATE_THREAD;
} else {
diff --git a/src/agent/download-agent-client-mgr.c b/src/agent/download-agent-client-mgr.c
index c9c04b3..4575fd7 100644
--- a/src/agent/download-agent-client-mgr.c
+++ b/src/agent/download-agent-client-mgr.c
@@ -304,11 +304,12 @@ da_result_t send_client_update_dl_info (
if (http_response_header) {
update_dl_info->http_response_header = strdup(http_response_header);
}
- if (http_chunked_data)
+ if (http_chunked_data) {
update_dl_info->http_chunked_data = calloc (1, file_size);
if (update_dl_info->http_chunked_data)
memcpy(update_dl_info->http_chunked_data, http_chunked_data,
file_size);
+ }
DA_LOG(ClientNoti, "pushing file_size=%lu, download_id=%d, dl_req_id=%d",
file_size, download_id, dl_req_id);
diff --git a/src/agent/download-agent-dl-info-util.c b/src/agent/download-agent-dl-info-util.c
index bf78d9d..98e8ff1 100644
--- a/src/agent/download-agent-dl-info-util.c
+++ b/src/agent/download-agent-dl-info-util.c
@@ -102,9 +102,12 @@ da_result_t deinit_download_mgr(void) {
if (dl_info && dl_info->is_using) {
request_to_abort_http_download(GET_DL_CURRENT_STAGE(i));
DA_LOG_CRITICAL(Thread, "===download id[%d] thread id[%lu] join===",i, GET_DL_THREAD_ID(i));
+/* Because the download daemon can call the deinit function, the resources of pthread are not freed
+ FIXME later : It is needed to change the termination flow again.
if (pthread_join(GET_DL_THREAD_ID(i), &t_return) < 0) {
DA_LOG_ERR(Thread, "join client thread is failed!!!");
}
+*/
DA_LOG_CRITICAL(Thread, "===download id[%d] thread join return[%d]===",i, (char*)t_return);
}
}
diff --git a/src/agent/download-agent-dl-mgr.c b/src/agent/download-agent-dl-mgr.c
index fc654d4..c00d8a5 100644
--- a/src/agent/download-agent-dl-mgr.c
+++ b/src/agent/download-agent-dl-mgr.c
@@ -160,9 +160,6 @@ static da_result_t __cancel_download_with_download_id(int download_id)
}
_da_thread_mutex_unlock (&mutex_download_state[download_id]);
- if (ret != DA_RESULT_OK)
- goto ERR;
-
stage = GET_DL_CURRENT_STAGE(download_id);
if (!stage)
return DA_RESULT_OK;
@@ -278,9 +275,6 @@ static da_result_t __suspend_download_with_download_id(int download_id)
DA_LOG(Default, "download_state = %d", GET_DL_STATE_ON_ID(download_id));
_da_thread_mutex_unlock (&mutex_download_state[download_id]);
- if (ret != DA_RESULT_OK)
- goto ERR;
-
stage = GET_DL_CURRENT_STAGE(download_id);
if (!stage)
return DA_ERR_CANNOT_SUSPEND;
@@ -390,9 +384,6 @@ static da_result_t __resume_download_with_download_id(int download_id)
DA_LOG(Default, "download_state = %d", GET_DL_STATE_ON_ID(download_id));
_da_thread_mutex_unlock (&mutex_download_state[download_id]);
- if (ret != DA_RESULT_OK)
- goto ERR;
-
stage = GET_DL_CURRENT_STAGE(download_id);
ret = request_to_resume_http_download(stage);
diff --git a/src/agent/download-agent-file.c b/src/agent/download-agent-file.c
index 1f29205..cd5d4ad 100644
--- a/src/agent/download-agent-file.c
+++ b/src/agent/download-agent-file.c
@@ -490,9 +490,6 @@ da_result_t __get_candidate_file_name(stage_info *stage, char **out_pure_file_na
return DA_RESULT_OK;
ERR:
- if (pure_file_name)
- free(pure_file_name);
-
if (extension)
free(extension);
diff --git a/src/agent/download-agent-http-mgr.c b/src/agent/download-agent-http-mgr.c
index 02813d9..7f3b36f 100644
--- a/src/agent/download-agent-http-mgr.c
+++ b/src/agent/download-agent-http-mgr.c
@@ -1686,10 +1686,6 @@ ERR:
free(field);
field = NULL;
}
- if (value) {
- free(value);
- value = NULL;
- }
return;
}