Browse Source

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
pull/1938/head
Richard Fuchs 7 months ago
parent
commit
5d613020e6
5 changed files with 8 additions and 0 deletions
  1. +3
    -0
      daemon/main.c
  2. +2
    -0
      daemon/websocket.c
  3. +1
    -0
      include/main.h
  4. +1
    -0
      t/test-stats.c
  5. +1
    -0
      t/test-transcode.c

+ 3
- 0
daemon/main.c View File

@ -80,6 +80,7 @@ static GQueue rtpe_cli = G_QUEUE_INIT;
GQueue rtpe_control_ng = G_QUEUE_INIT; GQueue rtpe_control_ng = G_QUEUE_INIT;
GQueue rtpe_control_ng_tcp = G_QUEUE_INIT; GQueue rtpe_control_ng_tcp = G_QUEUE_INIT;
struct bufferpool *shm_bufferpool; struct bufferpool *shm_bufferpool;
struct bufferpool *rtpe_bufferpool;
memory_arena_t rtpe_arena; memory_arena_t rtpe_arena;
struct rtpengine_config rtpe_config = { struct rtpengine_config rtpe_config = {
@ -1501,6 +1502,7 @@ RTPE_CONFIG_CHARPP_PARAMS
static void early_init(void) { static void early_init(void) {
socket_init(); // needed for socktype_udp socket_init(); // needed for socktype_udp
rtpe_bufferpool = bufferpool_new(bufferpool_aligned_alloc, bufferpool_aligned_free);
memory_arena_init(&rtpe_arena); memory_arena_init(&rtpe_arena);
memory_arena = &rtpe_arena; memory_arena = &rtpe_arena;
} }
@ -1982,6 +1984,7 @@ int main(int argc, char **argv) {
options_free(); options_free();
bufferpool_cleanup(); bufferpool_cleanup();
memory_arena_free(&rtpe_arena); memory_arena_free(&rtpe_arena);
bufferpool_destroy(rtpe_bufferpool);
return 0; return 0;
} }

+ 2
- 0
daemon/websocket.c View File

@ -230,6 +230,8 @@ static void websocket_message_push(struct websocket_conn *wc, websocket_message_
static void websocket_process(void *p, void *up) { static void websocket_process(void *p, void *up) {
media_bufferpool = rtpe_bufferpool;
struct websocket_conn *wc = p; struct websocket_conn *wc = p;
mutex_lock(&wc->lock); mutex_lock(&wc->lock);


+ 1
- 0
include/main.h View File

@ -323,6 +323,7 @@ extern GQueue rtpe_control_ng;
extern GQueue rtpe_control_ng_tcp; extern GQueue rtpe_control_ng_tcp;
extern struct bufferpool *shm_bufferpool; extern struct bufferpool *shm_bufferpool;
extern struct bufferpool *rtpe_bufferpool;
extern memory_arena_t rtpe_arena; extern memory_arena_t rtpe_arena;


+ 1
- 0
t/test-stats.c View File

@ -25,6 +25,7 @@ unsigned int rtpe_poller_rr_iter;
GString *dtmf_logs; GString *dtmf_logs;
GQueue rtpe_control_ng = G_QUEUE_INIT; GQueue rtpe_control_ng = G_QUEUE_INIT;
struct bufferpool *shm_bufferpool; struct bufferpool *shm_bufferpool;
struct bufferpool *rtpe_bufferpool;
memory_arena_t rtpe_arena; memory_arena_t rtpe_arena;
static void __assert_g_string_eq(GString *a, const char *b, unsigned int line) { static void __assert_g_string_eq(GString *a, const char *b, unsigned int line) {


+ 1
- 0
t/test-transcode.c View File

@ -20,6 +20,7 @@ unsigned int rtpe_poller_rr_iter;
GString *dtmf_logs; GString *dtmf_logs;
GQueue rtpe_control_ng = G_QUEUE_INIT; GQueue rtpe_control_ng = G_QUEUE_INIT;
struct bufferpool *shm_bufferpool; struct bufferpool *shm_bufferpool;
struct bufferpool *rtpe_bufferpool;
memory_arena_t rtpe_arena; memory_arena_t rtpe_arena;
static str *sdup(char *s) { static str *sdup(char *s) {


Loading…
Cancel
Save