From b5d8c695e43e9ba0f42596e09857bdf96508e2bf Mon Sep 17 00:00:00 2001 From: Richard Fuchs Date: Wed, 7 May 2025 08:45:03 -0400 Subject: [PATCH] MT#55283 add global bufferpool These are normally held per thread, but in cases of threads not having dedicated init/cleanup functions (GLib thread pool), we can use a global one as fallback. Fixes #1936 Change-Id: Ia2ff3523e6079baa73e0721862100ec2f8b66c88 (cherry picked from commit 5d613020e62f182e0659944a30e92711b08c6857) (cherry picked from commit 871162b13b51bb6d82f727d1838a6c8f0ab90e53) (cherry picked from commit 97dfc13c9f6ae975036d73cda3a4dc3252646d6d) --- daemon/main.c | 3 +++ daemon/websocket.c | 2 ++ include/main.h | 1 + t/test-stats.c | 1 + t/test-transcode.c | 1 + 5 files changed, 8 insertions(+) diff --git a/daemon/main.c b/daemon/main.c index b0ae60832..c1f6793d6 100644 --- a/daemon/main.c +++ b/daemon/main.c @@ -79,6 +79,7 @@ static GQueue rtpe_cli = G_QUEUE_INIT; GQueue rtpe_control_ng = G_QUEUE_INIT; GQueue rtpe_control_ng_tcp = G_QUEUE_INIT; struct bufferpool *shm_bufferpool; +struct bufferpool *rtpe_bufferpool; struct rtpengine_config rtpe_config = { // non-zero defaults @@ -1233,6 +1234,7 @@ static void options_free(void) { static void early_init(void) { socket_init(); // needed for socktype_udp + rtpe_bufferpool = bufferpool_new(g_malloc, g_free, 64 * 65536); } #ifdef WITH_TRANSCODING @@ -1644,6 +1646,7 @@ int main(int argc, char **argv) { kernel_shutdown_table(); options_free(); bufferpool_cleanup(); + bufferpool_destroy(rtpe_bufferpool); return 0; } diff --git a/daemon/websocket.c b/daemon/websocket.c index 363054506..9cde4071a 100644 --- a/daemon/websocket.c +++ b/daemon/websocket.c @@ -230,6 +230,8 @@ static void websocket_message_push(struct websocket_conn *wc, websocket_message_ static void websocket_process(void *p, void *up) { + media_bufferpool = rtpe_bufferpool; + struct websocket_conn *wc = p; mutex_lock(&wc->lock); diff --git a/include/main.h b/include/main.h index 1ca6ee989..ec21ebdaf 100644 --- a/include/main.h +++ b/include/main.h @@ -229,6 +229,7 @@ extern GQueue rtpe_control_ng; extern GQueue rtpe_control_ng_tcp; extern struct bufferpool *shm_bufferpool; +extern struct bufferpool *rtpe_bufferpool; #endif diff --git a/t/test-stats.c b/t/test-stats.c index 25418c1e5..64a8cc38d 100644 --- a/t/test-stats.c +++ b/t/test-stats.c @@ -24,6 +24,7 @@ unsigned int rtpe_poller_rr_iter; GString *dtmf_logs; GQueue rtpe_control_ng = G_QUEUE_INIT; struct bufferpool *shm_bufferpool; +struct bufferpool *rtpe_bufferpool; static void __assert_g_string_eq(GString *a, const char *b, unsigned int line) { if (strcmp(a->str, b) == 0) { diff --git a/t/test-transcode.c b/t/test-transcode.c index a963abcb0..1080c09cc 100644 --- a/t/test-transcode.c +++ b/t/test-transcode.c @@ -20,6 +20,7 @@ unsigned int rtpe_poller_rr_iter; GString *dtmf_logs; GQueue rtpe_control_ng = G_QUEUE_INIT; struct bufferpool *shm_bufferpool; +struct bufferpool *rtpe_bufferpool; static str *sdup(char *s) { str r = STR_INIT(s);