-
Notifications
You must be signed in to change notification settings - Fork 22
RDK-59167: [POC] T2 Thread And Curl Connection Pool Addition For Efficient Memory Utilization On Low End Devices #178
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 4 commits
6879103
978d7cd
50386a3
04e6c39
069528d
9af8283
63958d7
ec3beea
05c4e93
e8e7208
54eb074
6110d3a
00f6dd2
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -32,6 +32,7 @@ | |
| #include <curl/curl.h> | ||
| #include <signal.h> | ||
|
|
||
| #include "../xconf-client/multicurlinterface.h" | ||
| #include "curlinterface.h" | ||
| #include "reportprofiles.h" | ||
| #include "t2MtlsUtils.h" | ||
|
|
@@ -332,7 +333,7 @@ T2ERROR sendReportOverHTTP(char *httpUrl, char *payload, pid_t* outForkedPid) | |
| pid_t childPid; | ||
| int sharedPipeFds[2]; | ||
|
|
||
| T2Debug("%s ++in\n", __FUNCTION__); | ||
| T2Info("%s ++in\n", __FUNCTION__); | ||
| if(httpUrl == NULL || payload == NULL) | ||
| { | ||
| return ret; | ||
|
|
@@ -441,18 +442,24 @@ T2ERROR sendReportOverHTTP(char *httpUrl, char *payload, pid_t* outForkedPid) | |
| */ | ||
| if(childPid == 0) | ||
| { | ||
| curl = curl_easy_init(); | ||
| int idx; | ||
| T2ERROR ret = acquire_pool_handle(&curl, &idx); | ||
|
||
| if (ret != T2ERROR_SUCCESS) | ||
| { | ||
| return ret; | ||
|
||
| } | ||
|
|
||
| if(curl) | ||
| { | ||
| childCurlResponse.curlStatus = true; | ||
| if(setHeader(curl, httpUrl, &headerList, &childCurlResponse) != T2ERROR_SUCCESS) | ||
| { | ||
| curl_easy_cleanup(curl); | ||
| //curl_easy_cleanup(curl); | ||
| goto child_cleanReturn; | ||
| } | ||
| if (setPayload(curl, payload, &childCurlResponse) != T2ERROR_SUCCESS) | ||
| { | ||
| curl_easy_cleanup(curl); // CID 189985: Resource leak | ||
| //curl_easy_cleanup(curl); // CID 189985: Resource leak | ||
| goto child_cleanReturn; | ||
| } | ||
| #ifdef LIBRDKCERTSEL_BUILD | ||
|
|
@@ -467,7 +474,7 @@ T2ERROR sendReportOverHTTP(char *httpUrl, char *payload, pid_t* outForkedPid) | |
| } | ||
| if(code != CURLE_OK) | ||
| { | ||
| curl_easy_cleanup(curl); | ||
| //curl_easy_cleanup(curl); | ||
| goto child_cleanReturn; | ||
| } | ||
| do | ||
|
|
@@ -480,7 +487,7 @@ T2ERROR sendReportOverHTTP(char *httpUrl, char *payload, pid_t* outForkedPid) | |
| { | ||
| T2Error("%s, T2:Failed to retrieve the certificate.\n", __func__); | ||
| curlCertSelectorFree(); | ||
| curl_easy_cleanup(curl); | ||
| //curl_easy_cleanup(curl); | ||
| goto child_cleanReturn; | ||
| } | ||
| else | ||
|
|
@@ -494,7 +501,7 @@ T2ERROR sendReportOverHTTP(char *httpUrl, char *payload, pid_t* outForkedPid) | |
| #endif | ||
| if((mtls_enable == true) && (setMtlsHeaders(curl, pCertFile, pCertPC, &childCurlResponse) != T2ERROR_SUCCESS)) | ||
| { | ||
| curl_easy_cleanup(curl); // CID 189985: Resource leak | ||
| //curl_easy_cleanup(curl); // CID 189985: Resource leak | ||
| goto child_cleanReturn; | ||
| } | ||
| pthread_once(&curlFileMutexOnce, sendOverHTTPInit); | ||
|
|
@@ -537,12 +544,13 @@ T2ERROR sendReportOverHTTP(char *httpUrl, char *payload, pid_t* outForkedPid) | |
| while(rdkcertselector_setCurlStatus(thisCertSel, curl_code, (const char*)httpUrl) == TRY_ANOTHER); | ||
| #endif | ||
| curl_slist_free_all(headerList); | ||
| curl_easy_cleanup(curl); | ||
| //curl_easy_cleanup(curl); | ||
| } | ||
| else | ||
| { | ||
| childCurlResponse.curlStatus = false; | ||
| } | ||
| release_pool_handle(idx); | ||
|
|
||
| child_cleanReturn : | ||
| #ifndef LIBRDKCERTSEL_BUILD | ||
|
|
@@ -571,6 +579,7 @@ child_cleanReturn : | |
| T2Error("unable to write \n"); | ||
| } | ||
| close(sharedPipeFds[1]); | ||
| release_pool_handle(idx); | ||
| exit(0); | ||
|
|
||
| } | ||
|
|
@@ -624,7 +633,7 @@ child_cleanReturn : | |
| ret = T2ERROR_SUCCESS; | ||
| T2Info("Report Sent Successfully over HTTP : %ld\n", childCurlResponse.http_code); | ||
| } | ||
| T2Debug("%s --out\n", __FUNCTION__); | ||
| T2Info("%s --out\n", __FUNCTION__); | ||
| return ret; | ||
| } | ||
|
|
||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Coverity Issue - Uninitialized scalar variable
Using uninitialized value "idx" when calling "acquire_pool_handle".
High Impact, CWE-457
UNINIT