From: Muhammad Rizki <kiizuha@gnuweeb.org>
To: Ammar Faizi <ammarfaizi2@gnuweeb.org>
Cc: Muhammad Rizki <kiizuha@gnuweeb.org>,
Alviro Iskandar Setiawan <alviro.iskandar@gnuweeb.org>,
GNU/Weeb Mailing List <gwml@vger.gnuweeb.org>
Subject: [PATCH v1 2/4] core:lib: fix memory leak and reduce threads
Date: Tue, 16 Dec 2025 01:23:04 +0700 [thread overview]
Message-ID: <20251215182308.48766-3-kiizuha@gnuweeb.org> (raw)
In-Reply-To: <20251215182308.48766-1-kiizuha@gnuweeb.org>
This commit fixes a memory leak in the lib/curl.c file where the
`current_thread_curl_handle` keeps creating a new thread cURL handles
overtime.
This commit also reduces the number of threads and max pending works in
core/ring.c.
Signed-off-by: Muhammad Rizki <kiizuha@gnuweeb.org>
Tested-by: Muhammad Rizki <kiizuha@gnuweeb.org>
Reported-by: Muhammad Rizki <kiizuha@gnuweeb.org>
---
core/ring.c | 4 ++--
lib/curl.c | 4 +++-
2 files changed, 5 insertions(+), 3 deletions(-)
diff --git a/core/ring.c b/core/ring.c
index 9497cfd..fedec52 100644
--- a/core/ring.c
+++ b/core/ring.c
@@ -25,8 +25,8 @@ int gw_ring_init(struct gw_ring *ring, uint32_t size)
.name = "gw-ring-wq",
.flags = WQ_F_LAZY_THREAD_CREATION,
.max_threads = 1024u,
- .min_threads = 32u,
- .max_pending_works = 4096u,
+ .min_threads = 1u,
+ .max_pending_works = 128u,
};
uint32_t max = 2u;
int ret;
diff --git a/lib/curl.c b/lib/curl.c
index 09745d0..78606b9 100644
--- a/lib/curl.c
+++ b/lib/curl.c
@@ -29,7 +29,7 @@ int gw_curl_global_init(long flags)
if (curl_global_init(flags) != CURLE_OK)
return -ENOMEM;
-
+
cd = malloc(sizeof(*g_gw_curl_data));
if (!cd) {
ret = -ENOMEM;
@@ -108,6 +108,8 @@ void *gw_curl_thread_init(void)
return NULL;
}
}
+
+ current_thread_curl_handle = ret;
cd->handles[cd->nr_handles++] = ret;
mutex_unlock(&cd->mutex);
return ret;
--
Muhammad Rizki
next prev parent reply other threads:[~2025-12-15 18:23 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-12-15 18:23 [PATCH v1 0/4] GNUWeebBot2 Fixes and New Updates Muhammad Rizki
2025-12-15 18:23 ` [PATCH v1 1/4] .vscode: add some C/C++ extension settings Muhammad Rizki
2025-12-15 18:23 ` Muhammad Rizki [this message]
2025-12-15 18:23 ` [PATCH v1 3/4] lib/tgapi: add new properties for type User Muhammad Rizki
2025-12-15 18:23 ` [PATCH v1 4/4] modules: create a `user` module Muhammad Rizki
2025-12-18 22:16 ` [PATCH v1 0/4] GNUWeebBot2 Fixes and New Updates Ammar Faizi
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20251215182308.48766-3-kiizuha@gnuweeb.org \
--to=kiizuha@gnuweeb.org \
--cc=alviro.iskandar@gnuweeb.org \
--cc=ammarfaizi2@gnuweeb.org \
--cc=gwml@vger.gnuweeb.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox