RDK-59167: [POC] T2 Thread And Curl Connection Pool Addition For Efficient Memory Utilization On Low End Devices#178
RDK-59167: [POC] T2 Thread And Curl Connection Pool Addition For Efficient Memory Utilization On Low End Devices#178yogeswaransky wants to merge 13 commits intodevelopfrom
Conversation
…cient Memory Utilization On Low End Devices Signed-off-by: Yogeswaran K <yogeswaransky@comcast.com>
|
Yogeswaran K seems not to be a GitHub user. You need a GitHub account to be able to sign the CLA. If you have already a GitHub account, please add the email address used for this commit to your account. You have signed the CLA already but the status is still pending? Let us recheck it. |
source/xconf-client/xconfclient.c
Outdated
| } | ||
|
|
||
| if(curl) | ||
| { |
There was a problem hiding this comment.
Coverity issue no longer present as of: undefined
Show issue
Coverity Issue - Uninitialized scalar variable
Using uninitialized value "idx" when calling "acquire_pool_handle".
High Impact, CWE-457
UNINIT
| curl_easy_setopt(easy, CURLOPT_URL, url); | ||
| curl_easy_setopt(easy, CURLOPT_HTTPGET, 1L); | ||
| curl_easy_setopt(easy, CURLOPT_WRITEFUNCTION, httpGetCallBack); | ||
| curl_easy_setopt(easy, CURLOPT_WRITEDATA, (void *) &response); |
There was a problem hiding this comment.
Coverity issue no longer present as of: undefined
Show issue
Coverity Issue - Incorrect sizeof expression
Taking the size of "&response", which is the address of an object, is suspicious.
Medium Impact, CWE-467
BAD_SIZEOF
How to fix
Did you intend the size of "response" itself?
| easy = pool.easy_handles[idx]; | ||
|
|
||
| // Configure for POST request | ||
| curl_easy_setopt(easy, CURLOPT_URL, url); |
There was a problem hiding this comment.
Coverity issue no longer present as of: undefined
Show issue
Coverity Issue - Unchecked return value from library
Calling "curl_easy_setopt(easy, _curl_opt, url)" without checking return value. This library function may fail and return an error code.
Medium Impact, CWE-252
CHECKED_RETURN
|
|
||
| // Configure for POST request | ||
| curl_easy_setopt(easy, CURLOPT_URL, url); | ||
| curl_easy_setopt(easy, CURLOPT_CUSTOMREQUEST, "POST"); |
There was a problem hiding this comment.
Coverity issue no longer present as of: undefined
Show issue
Coverity Issue - Unchecked return value from library
Calling "curl_easy_setopt(easy, _curl_opt, "POST")" without checking return value. This library function may fail and return an error code.
Medium Impact, CWE-252
CHECKED_RETURN
| curl_easy_setopt(pool.easy_handles[i], CURLOPT_HTTP_VERSION, CURL_HTTP_VERSION_1_1); // Use HTTP/1.1 | ||
| #endif | ||
| // Enable connection pooling with limited cache size | ||
| curl_easy_setopt(pool.easy_handles[i], CURLOPT_MAXCONNECTS, 3L); // Only 1 connection per handle |
There was a problem hiding this comment.
Coverity issue no longer present as of: undefined
Show issue
Coverity Issue - Unchecked return value from library
Calling "curl_easy_setopt(pool.easy_handles[i], _curl_opt, 3L)" without checking return value. This library function may fail and return an error code.
Medium Impact, CWE-252
CHECKED_RETURN
| curl_easy_setopt(pool.easy_handles[i], CURLOPT_SSLENGINE_DEFAULT, 1L); | ||
| #endif | ||
|
|
||
| curl_easy_setopt(pool.easy_handles[i], CURLOPT_VERBOSE, 1L); |
There was a problem hiding this comment.
Coverity issue no longer present as of: undefined
Show issue
Coverity Issue - Unchecked return value from library
Calling "curl_easy_setopt(pool.easy_handles[i], _curl_opt, 1L)" without checking return value. This library function may fail and return an error code.
Medium Impact, CWE-252
CHECKED_RETURN
| #endif | ||
|
|
||
| curl_easy_setopt(pool.easy_handles[i], CURLOPT_VERBOSE, 1L); | ||
| curl_easy_setopt(pool.easy_handles[i], CURLOPT_DEBUGFUNCTION, curl_debug_callback_func); |
There was a problem hiding this comment.
Coverity issue no longer present as of: undefined
Show issue
Coverity Issue - Unchecked return value from library
Calling "curl_easy_setopt(pool.easy_handles[i], _curl_opt, curl_debug_callback_func)" without checking return value. This library function may fail and return an error code.
Medium Impact, CWE-252
CHECKED_RETURN
|
|
||
| curl_easy_setopt(pool.easy_handles[i], CURLOPT_VERBOSE, 1L); | ||
| curl_easy_setopt(pool.easy_handles[i], CURLOPT_DEBUGFUNCTION, curl_debug_callback_func); | ||
| curl_easy_setopt(pool.easy_handles[i], CURLOPT_DEBUGDATA, NULL); |
There was a problem hiding this comment.
Coverity issue no longer present as of: undefined
Show issue
Coverity Issue - Unchecked return value from library
Calling "curl_easy_setopt(pool.easy_handles[i], _curl_opt, NULL)" without checking return value. This library function may fail and return an error code.
Medium Impact, CWE-252
CHECKED_RETURN
source/xconf-client/xconfclient.c
Outdated
| { | ||
|
|
||
| code = curl_easy_setopt(curl, CURLOPT_URL, httpsUrl); | ||
| if(code != CURLE_OK) |
There was a problem hiding this comment.
Coverity issue no longer present as of: undefined
Show issue
Coverity Issue - Resource leak
Variable "httpResponse" going out of scope leaks the storage it points to.
High Impact, CWE-404
RESOURCE_LEAK
…cient Memory Utilization On Low End Devices Signed-off-by: Yogeswaran K <yogeswaransky@comcast.com>
source/xconf-client/xconfclient.c
Outdated
| } | ||
|
|
||
| if(curl) | ||
| { |
There was a problem hiding this comment.
Coverity issue no longer present as of: undefined
Show issue
Coverity Issue - Uninitialized scalar variable
Using uninitialized value "idx" when calling "acquire_pool_handle".
High Impact, CWE-457
UNINIT
source/xconf-client/xconfclient.c
Outdated
| { | ||
|
|
||
| code = curl_easy_setopt(curl, CURLOPT_URL, httpsUrl); | ||
| if(code != CURLE_OK) |
There was a problem hiding this comment.
Coverity issue no longer present as of: undefined
Show issue
Coverity Issue - Resource leak
Variable "httpResponse" going out of scope leaks the storage it points to.
High Impact, CWE-404
RESOURCE_LEAK
…cient Memory Utilization On Low End Devices Signed-off-by: Yogeswaran K <yogeswaransky@comcast.com>
source/protocol/http/curlinterface.c
Outdated
| T2ERROR ret = acquire_pool_handle(&curl, &idx); | ||
| if (ret != T2ERROR_SUCCESS) | ||
| { | ||
| return ret; |
There was a problem hiding this comment.
Coverity issue no longer present as of: undefined
Show issue
Coverity Issue - Resource leak
Variable "pCertFile" going out of scope leaks the storage it points to.
High Impact, CWE-404
RESOURCE_LEAK
source/protocol/http/curlinterface.c
Outdated
| { | ||
| curl = curl_easy_init(); | ||
| int idx; | ||
| T2ERROR ret = acquire_pool_handle(&curl, &idx); |
There was a problem hiding this comment.
Coverity Issue - Uninitialized scalar variable
Using uninitialized value "idx" when calling "acquire_pool_handle".
High Impact, CWE-457
UNINIT
source/xconf-client/xconfclient.c
Outdated
| } | ||
|
|
||
| if(curl) | ||
| { |
There was a problem hiding this comment.
Coverity Issue - Uninitialized scalar variable
Using uninitialized value "idx" when calling "acquire_pool_handle".
High Impact, CWE-457
UNINIT
source/xconf-client/xconfclient.c
Outdated
| { | ||
|
|
||
| code = curl_easy_setopt(curl, CURLOPT_URL, httpsUrl); | ||
| if(code != CURLE_OK) |
There was a problem hiding this comment.
Coverity Issue - Resource leak
Variable "httpResponse" going out of scope leaks the storage it points to.
High Impact, CWE-404
RESOURCE_LEAK
…cient Memory Utilization On Low End Devices Signed-off-by: Yogeswaran K <yogeswaransky@comcast.com>
source/protocol/http/curlinterface.c
Outdated
| { | ||
| curl = curl_easy_init(); | ||
| int idx; | ||
| T2ERROR ret = acquire_pool_handle(&curl, &idx); |
There was a problem hiding this comment.
Coverity Issue - Uninitialized scalar variable
Using uninitialized value "idx" when calling "acquire_pool_handle".
High Impact, CWE-457
UNINIT
…cient Memory Utilization On Low End Devices Signed-off-by: Yogeswaran K <yogeswaransky@comcast.com>
source/protocol/http/curlinterface.c
Outdated
| if((childPid = fork()) < 0) | ||
|
|
||
| // Acquire curl handle from pool | ||
| ret = acquire_pool_handle(&curl, &idx); |
There was a problem hiding this comment.
Coverity Issue - Uninitialized scalar variable
Using uninitialized value "idx" when calling "acquire_pool_handle".
High Impact, CWE-457
UNINIT
…cient Memory Utilization On Low End Devices Signed-off-by: Yogeswaran K <yogeswaransky@comcast.com>
source/protocol/http/curlinterface.c
Outdated
| if((childPid = fork()) < 0) | ||
|
|
||
| // Acquire curl handle from pool | ||
| ret = acquire_pool_handle(&curl, &idx); |
There was a problem hiding this comment.
Coverity Issue - Uninitialized scalar variable
Using uninitialized value "idx" when calling "acquire_pool_handle".
High Impact, CWE-457
UNINIT
…cient Memory Utilization On Low End Devices Signed-off-by: Yogeswaran K <yogeswaransky@comcast.com>
source/protocol/http/curlinterface.c
Outdated
| if((childPid = fork()) < 0) | ||
|
|
||
| // Acquire curl handle from pool | ||
| ret = acquire_pool_handle(&curl, &idx); |
There was a problem hiding this comment.
Coverity Issue - Uninitialized scalar variable
Using uninitialized value "idx" when calling "acquire_pool_handle".
High Impact, CWE-457
UNINIT
…cient Memory Utilization On Low End Devices Signed-off-by: Yogeswaran K <yogeswaransky@comcast.com>
|
|
||
| #if 1 | ||
| // More aggressive keepalive settings for your environment | ||
| curl_easy_setopt(pool.easy_handles[i], CURLOPT_TCP_KEEPALIVE, 1L); |
There was a problem hiding this comment.
Coverity Issue - Unchecked return value from library
Calling "curl_easy_setopt(pool.easy_handles[i], _curl_opt, 1L)" without checking return value. This library function may fail and return an error code.
Medium Impact, CWE-252
CHECKED_RETURN
| #if 1 | ||
| // More aggressive keepalive settings for your environment | ||
| curl_easy_setopt(pool.easy_handles[i], CURLOPT_TCP_KEEPALIVE, 1L); | ||
| curl_easy_setopt(pool.easy_handles[i], CURLOPT_TCP_KEEPIDLE, 50L); // 1 minute instead of 2 |
There was a problem hiding this comment.
Coverity Issue - Unchecked return value from library
Calling "curl_easy_setopt(pool.easy_handles[i], _curl_opt, 50L)" without checking return value. This library function may fail and return an error code.
Medium Impact, CWE-252
CHECKED_RETURN
| // More aggressive keepalive settings for your environment | ||
| curl_easy_setopt(pool.easy_handles[i], CURLOPT_TCP_KEEPALIVE, 1L); | ||
| curl_easy_setopt(pool.easy_handles[i], CURLOPT_TCP_KEEPIDLE, 50L); // 1 minute instead of 2 | ||
| curl_easy_setopt(pool.easy_handles[i], CURLOPT_TCP_KEEPINTVL, 30L); // 30 seconds instead of 60 |
There was a problem hiding this comment.
Coverity Issue - Unchecked return value from library
Calling "curl_easy_setopt(pool.easy_handles[i], _curl_opt, 30L)" without checking return value. This library function may fail and return an error code.
Medium Impact, CWE-252
CHECKED_RETURN
| #endif | ||
|
|
||
| // Add connection reuse validation | ||
| curl_easy_setopt(pool.easy_handles[i], CURLOPT_FORBID_REUSE, 0L); |
There was a problem hiding this comment.
Coverity Issue - Unchecked return value from library
Calling "curl_easy_setopt(pool.easy_handles[i], _curl_opt, 0L)" without checking return value. This library function may fail and return an error code.
Medium Impact, CWE-252
CHECKED_RETURN
|
|
||
| // Add connection reuse validation | ||
| curl_easy_setopt(pool.easy_handles[i], CURLOPT_FORBID_REUSE, 0L); | ||
| curl_easy_setopt(pool.easy_handles[i], CURLOPT_FRESH_CONNECT, 0L); |
There was a problem hiding this comment.
Coverity Issue - Unchecked return value from library
Calling "curl_easy_setopt(pool.easy_handles[i], _curl_opt, 0L)" without checking return value. This library function may fail and return an error code.
Medium Impact, CWE-252
CHECKED_RETURN
| curl_easy_setopt(pool.easy_handles[i], CURLOPT_HTTPHEADER, NULL); // Reset any existing headers first | ||
|
|
||
| // Add low-level socket options for better connection health detection | ||
| curl_easy_setopt(pool.easy_handles[i], CURLOPT_NOSIGNAL, 1L); |
There was a problem hiding this comment.
Coverity Issue - Unchecked return value from library
Calling "curl_easy_setopt(pool.easy_handles[i], _curl_opt, 1L)" without checking return value. This library function may fail and return an error code.
Medium Impact, CWE-252
CHECKED_RETURN
| curl_easy_setopt(pool.easy_handles[i], CURLOPT_NOSIGNAL, 1L); | ||
|
|
||
| // Connection management options that work with older libcurl | ||
| curl_easy_setopt(pool.easy_handles[i], CURLOPT_PIPEWAIT, 0L); // Don't wait for pipelining |
There was a problem hiding this comment.
Coverity Issue - Unchecked return value from library
Calling "curl_easy_setopt(pool.easy_handles[i], _curl_opt, 0L)" without checking return value. This library function may fail and return an error code.
Medium Impact, CWE-252
CHECKED_RETURN
|
|
||
| // Connection management options that work with older libcurl | ||
| curl_easy_setopt(pool.easy_handles[i], CURLOPT_PIPEWAIT, 0L); // Don't wait for pipelining | ||
| curl_easy_setopt(pool.easy_handles[i], CURLOPT_HTTP_VERSION, CURL_HTTP_VERSION_1_1); // Use HTTP/1.1 |
There was a problem hiding this comment.
Coverity Issue - Unchecked return value from library
Calling "curl_easy_setopt(pool.easy_handles[i], _curl_opt, CURL_HTTP_VERSION_1_1)" without checking return value. This library function may fail and return an error code.
Medium Impact, CWE-252
CHECKED_RETURN
| } | ||
|
|
||
| // Certificate selector and SSL/TLS specific options from original code | ||
| curl_easy_setopt(pool.easy_handles[i], CURLOPT_SSL_VERIFYPEER, 1L); |
There was a problem hiding this comment.
Coverity Issue - Unchecked return value from library
Calling "curl_easy_setopt(pool.easy_handles[i], _curl_opt, 1L)" without checking return value. This library function may fail and return an error code.
Medium Impact, CWE-252
CHECKED_RETURN
|
|
||
| // Certificate selector and SSL/TLS specific options from original code | ||
| curl_easy_setopt(pool.easy_handles[i], CURLOPT_SSL_VERIFYPEER, 1L); | ||
| curl_easy_setopt(pool.easy_handles[i], CURLOPT_SSLENGINE_DEFAULT, 1L); |
There was a problem hiding this comment.
Coverity Issue - Unchecked return value from library
Calling "curl_easy_setopt(pool.easy_handles[i], _curl_opt, 1L)" without checking return value. This library function may fail and return an error code.
Medium Impact, CWE-252
CHECKED_RETURN
…cient Memory Utilization On Low End Devices Signed-off-by: Yogeswaran K <yogeswaransky@comcast.com>
…cient Memory Utilization On Low End Devices Signed-off-by: Yogeswaran K <yogeswaransky@comcast.com>
…cient Memory Utilization On Low End Devices Signed-off-by: Yogeswaran K <yogeswaransky@comcast.com>
| { | ||
| T2Error("%s : Curl set opts failed with error %s \n", __FUNCTION__, curl_easy_strerror(code)); | ||
| } | ||
| code = curl_easy_setopt(easy, CURLOPT_WRITEDATA, (void *) &response); |
There was a problem hiding this comment.
Coverity Issue - Incorrect sizeof expression
Taking the size of "&response", which is the address of an object, is suspicious.
Medium Impact, CWE-467
BAD_SIZEOF
How to fix
Did you intend the size of "response" itself?
…cient Memory Utilization On Low End Devices