Skip to content

RDK-59167: [POC] T2 Thread And Curl Connection Pool Addition For Efficient Memory Utilization On Low End Devices#178

Closed
yogeswaransky wants to merge 13 commits intodevelopfrom
RDK-59167
Closed

RDK-59167: [POC] T2 Thread And Curl Connection Pool Addition For Efficient Memory Utilization On Low End Devices#178
yogeswaransky wants to merge 13 commits intodevelopfrom
RDK-59167

Conversation

@yogeswaransky
Copy link
Contributor

…cient Memory Utilization On Low End Devices

…cient Memory Utilization On Low End Devices

Signed-off-by: Yogeswaran K <yogeswaransky@comcast.com>
@CLAassistant
Copy link

CLAassistant commented Sep 23, 2025

CLA assistant check
Thank you for your submission! We really appreciate it. Like many open source projects, we ask that you all sign our Contributor License Agreement before we can accept your contribution.
1 out of 2 committers have signed the CLA.

✅ yogeswaransky
❌ Yogeswaran K


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.

}

if(curl)
{
Copy link
Contributor

@rdkcmf-jenkins rdkcmf-jenkins Sep 23, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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);
Copy link
Contributor

@rdkcmf-jenkins rdkcmf-jenkins Sep 23, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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);
Copy link
Contributor

@rdkcmf-jenkins rdkcmf-jenkins Sep 23, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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");
Copy link
Contributor

@rdkcmf-jenkins rdkcmf-jenkins Sep 23, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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
Copy link
Contributor

@rdkcmf-jenkins rdkcmf-jenkins Sep 23, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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);
Copy link
Contributor

@rdkcmf-jenkins rdkcmf-jenkins Sep 23, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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);
Copy link
Contributor

@rdkcmf-jenkins rdkcmf-jenkins Sep 23, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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);
Copy link
Contributor

@rdkcmf-jenkins rdkcmf-jenkins Sep 23, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

{

code = curl_easy_setopt(curl, CURLOPT_URL, httpsUrl);
if(code != CURLE_OK)
Copy link
Contributor

@rdkcmf-jenkins rdkcmf-jenkins Sep 23, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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>
@yogeswaransky yogeswaransky changed the title RDK-59167: [POC] T2 Thread And Curl Connection Pool Addition For Effi… RDK-59167: [POC] T2 Thread And Curl Connection Pool Addition For Efficient Memory Utilization On Low End Devices Sep 23, 2025
}

if(curl)
{
Copy link
Contributor

@rdkcmf-jenkins rdkcmf-jenkins Sep 23, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

{

code = curl_easy_setopt(curl, CURLOPT_URL, httpsUrl);
if(code != CURLE_OK)
Copy link
Contributor

@rdkcmf-jenkins rdkcmf-jenkins Sep 23, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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>
T2ERROR ret = acquire_pool_handle(&curl, &idx);
if (ret != T2ERROR_SUCCESS)
{
return ret;
Copy link
Contributor

@rdkcmf-jenkins rdkcmf-jenkins Sep 23, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

{
curl = curl_easy_init();
int idx;
T2ERROR ret = acquire_pool_handle(&curl, &idx);
Copy link
Contributor

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

}

if(curl)
{
Copy link
Contributor

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

{

code = curl_easy_setopt(curl, CURLOPT_URL, httpsUrl);
if(code != CURLE_OK)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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>
{
curl = curl_easy_init();
int idx;
T2ERROR ret = acquire_pool_handle(&curl, &idx);
Copy link
Contributor

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

…cient Memory Utilization On Low End Devices

Signed-off-by: Yogeswaran K <yogeswaransky@comcast.com>
if((childPid = fork()) < 0)

// Acquire curl handle from pool
ret = acquire_pool_handle(&curl, &idx);
Copy link
Contributor

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

…cient Memory Utilization On Low End Devices

Signed-off-by: Yogeswaran K <yogeswaransky@comcast.com>
if((childPid = fork()) < 0)

// Acquire curl handle from pool
ret = acquire_pool_handle(&curl, &idx);
Copy link
Contributor

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

…cient Memory Utilization On Low End Devices

Signed-off-by: Yogeswaran K <yogeswaransky@comcast.com>
if((childPid = fork()) < 0)

// Acquire curl handle from pool
ret = acquire_pool_handle(&curl, &idx);
Copy link
Contributor

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

…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);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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>
Yogeswaran K and others added 2 commits September 25, 2025 12:25
…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);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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?

@shibu-kv shibu-kv closed this Oct 22, 2025
@github-actions github-actions bot locked and limited conversation to collaborators Oct 22, 2025
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants