From: Seonah Moon Date: Thu, 24 Nov 2016 09:31:19 +0000 (+0900) Subject: [Bug fix] Modified transaction list X-Git-Tag: submit/tizen_3.0/20161222.022008^0 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=b7b4ee71b9b0596e4c8766c85e8629ae60ed5c57;p=platform%2Fcore%2Fapi%2Fhttp.git [Bug fix] Modified transaction list Change-Id: Id7e7df39482e3a47870080f83b50887eb22dd4d0 Signed-off-by: Seonah Moon --- diff --git a/include/http_private.h b/include/http_private.h index 74572d9..faf6d64 100644 --- a/include/http_private.h +++ b/include/http_private.h @@ -216,6 +216,7 @@ int _generate_session_id(void); void _add_transaction_to_list(http_transaction_h http_transaction); void _remove_transaction_from_list(http_transaction_h http_transaction); void _remove_transaction_list(void); +void _destroy_transactions(int session_id); curl_http_auth_scheme_e _get_http_curl_auth_scheme(http_auth_scheme_e auth_scheme); http_auth_scheme_e _get_http_auth_scheme(bool proxy_auth, curl_http_auth_scheme_e curl_auth_scheme); int _set_authentication_info(http_transaction_h http_transaction); diff --git a/packaging/capi-network-http.spec b/packaging/capi-network-http.spec index c2df533..91f66e8 100644 --- a/packaging/capi-network-http.spec +++ b/packaging/capi-network-http.spec @@ -1,6 +1,6 @@ Name: capi-network-http Summary: Http Framework -Version: 0.0.18 +Version: 0.0.19 Release: 0 Group: System/Network License: Apache-2.0 diff --git a/src/http_session.c b/src/http_session.c index 01c7d8d..39b55e5 100644 --- a/src/http_session.c +++ b/src/http_session.c @@ -189,6 +189,9 @@ API int http_session_destroy(http_session_h http_session) session->multi_handle = NULL; } + if (session->active_transaction_count) + _destroy_transactions(session->session_id); + session->active_transaction_count = 0; session->still_running = 0; session->auto_redirect = FALSE; @@ -263,3 +266,18 @@ API int http_session_get_max_transaction_count(http_session_h http_session, int return HTTP_ERROR_NONE; } + +API int http_session_destroy_all_transactions(http_session_h http_session) +{ + _retvm_if(_http_is_init() == false, HTTP_ERROR_INVALID_OPERATION, + "http isn't initialized"); + _retvm_if(http_session == NULL, HTTP_ERROR_INVALID_PARAMETER, + "parameter(http_session) is NULL\n"); + + __http_session_h *session = (__http_session_h *)http_session; + + _destroy_transactions(session->session_id); + + return HTTP_ERROR_NONE; +} + diff --git a/src/http_transaction.c b/src/http_transaction.c index f2b4fcf..a1feb42 100644 --- a/src/http_transaction.c +++ b/src/http_transaction.c @@ -17,24 +17,48 @@ #include "http.h" #include "http_private.h" -static __thread GSList *transaction_list = NULL; +static __thread GList *transaction_list = NULL; //LCOV_EXCL_START void _add_transaction_to_list(http_transaction_h http_transaction) { - transaction_list = g_slist_append(transaction_list, http_transaction); + transaction_list = g_list_append(transaction_list, http_transaction); } void _remove_transaction_from_list(http_transaction_h http_transaction) { - transaction_list = g_slist_remove(transaction_list, http_transaction); + transaction_list = g_list_remove(transaction_list, http_transaction); } void _remove_transaction_list(void) { - g_slist_free_full(transaction_list, g_free); + g_list_free_full(transaction_list, g_free); transaction_list = NULL; } + +void _destroy_transactions(int session_id) +{ + int ret = 0; + GList *list = transaction_list; + + while (list) { + __http_transaction_h *transaction = (__http_transaction_h *)list->data; + if (session_id == transaction->session->session_id) { + DBG("PREV[%p] NEXT[%p]", list->prev, list->next); + if (list->prev) + list = list->prev; + else + list = list->next; + + ret = http_transaction_destroy((http_transaction_h) transaction); + if (ret != HTTP_ERROR_NONE) + ERR("Fail to destroy transaction!!"); + + continue; + } + list = list->next; + } +} //LCOV_EXCL_STOP curl_socket_t __handle_opensocket_cb(void *client_fd, curlsocktype purpose, struct curl_sockaddr *address) @@ -992,31 +1016,6 @@ API int http_transaction_set_server_certificate_verification(http_transaction_h return HTTP_ERROR_NONE; } -API int http_session_destroy_all_transactions(http_session_h http_session) -{ - _retvm_if(_http_is_init() == false, HTTP_ERROR_INVALID_OPERATION, - "http isn't initialized"); - _retvm_if(http_session == NULL, HTTP_ERROR_INVALID_PARAMETER, - "parameter(http_session) is NULL\n"); - - int ret = 0; - GSList *list = NULL; - __http_session_h *session = (__http_session_h *)http_session; - - for (list = transaction_list; list; list = list->next) { - __http_transaction_h *transaction = (__http_transaction_h *)list->data; - if (session->session_id == transaction->session->session_id) { - _remove_transaction_from_list(list->data); - ret = http_transaction_destroy((http_transaction_h) transaction); - if (ret != HTTP_ERROR_NONE) { - ERR("Fail to destroy transaction!!"); - return HTTP_ERROR_OPERATION_FAILED; - } - } - } - - return HTTP_ERROR_NONE; -} //LCOV_EXCL_START API int http_transaction_set_http_auth_scheme(http_transaction_h http_transaction, http_auth_scheme_e auth_scheme) {