From 3510a5d021943b6de11e5066e2113dbdd7301eb0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Damir=20Ned=C5=BEibovi=C4=87?= Date: Thu, 4 Mar 2021 13:25:39 +0100 Subject: [PATCH] Make poller per thread functionality configurable. --- daemon/main.c | 12 +++++++++--- daemon/media_socket.c | 5 +++-- include/main.h | 1 + 3 files changed, 13 insertions(+), 5 deletions(-) diff --git a/daemon/main.c b/daemon/main.c index d8018ffe7..61f1d7685 100644 --- a/daemon/main.c +++ b/daemon/main.c @@ -479,6 +479,7 @@ static void options(int *argc, char ***argv) { { "https-key", 0,0, G_OPTION_ARG_STRING, &rtpe_config.https_key, "Private key for HTTPS and WSS","FILE"}, { "http-threads", 0,0, G_OPTION_ARG_INT, &rtpe_config.http_threads,"Number of worker threads for HTTP and WS","INT"}, { "software-id", 0,0, G_OPTION_ARG_STRING, &rtpe_config.software_id,"Identification string of this software presented to external systems","STRING"}, + { "poller-per-thread", 0,0, G_OPTION_ARG_NONE, &rtpe_config.poller_per_thread, "Use poller per thread", NULL }, #ifdef WITH_TRANSCODING { "dtx-delay", 0,0, G_OPTION_ARG_INT, &rtpe_config.dtx_delay, "Delay in milliseconds to trigger DTX handling","INT"}, { "max-dtx", 0,0, G_OPTION_ARG_INT, &rtpe_config.max_dtx, "Maximum duration of DTX handling", "INT"}, @@ -1080,10 +1081,15 @@ int main(int argc, char **argv) { service_notify("READY=1\n"); - for (idx = 0; idx < rtpe_config.num_threads; ++idx) - thread_create_detach_prio(poller_loop, rtpe_poller_map, rtpe_config.scheduling, rtpe_config.priority, "poller"); + for (idx = 0; idx < rtpe_config.num_threads; ++idx) { + if (!rtpe_config.poller_per_thread) + thread_create_detach_prio(poller_loop2, rtpe_poller, rtpe_config.scheduling, rtpe_config.priority, "poller"); + else + thread_create_detach_prio(poller_loop, rtpe_poller_map, rtpe_config.scheduling, rtpe_config.priority, "poller"); + } - thread_create_detach_prio(poller_loop2, rtpe_poller, rtpe_config.scheduling, rtpe_config.priority, "poller"); + if (!rtpe_config.poller_per_thread) + thread_create_detach_prio(poller_loop2, rtpe_poller, rtpe_config.scheduling, rtpe_config.priority, "poller"); if (rtpe_config.media_num_threads < 0) rtpe_config.media_num_threads = rtpe_config.num_threads; diff --git a/daemon/media_socket.c b/daemon/media_socket.c index a9520b56d..495e18581 100644 --- a/daemon/media_socket.c +++ b/daemon/media_socket.c @@ -2223,7 +2223,7 @@ static void stream_fd_free(void *p) { struct stream_fd *stream_fd_new(socket_t *fd, struct call *call, const struct local_intf *lif) { struct stream_fd *sfd; struct poller_item pi; - struct poller *p; + struct poller *p = rtpe_poller; sfd = obj_alloc0("stream_fd", sizeof(*sfd), stream_fd_free); sfd->unique_id = g_queue_get_length(&call->stream_fds); @@ -2241,7 +2241,8 @@ struct stream_fd *stream_fd_new(socket_t *fd, struct call *call, const struct lo pi.readable = stream_fd_readable; pi.closed = stream_fd_closed; - p = poller_map_get(rtpe_poller_map); + if (rtpe_config.poller_per_thread) + p = poller_map_get(rtpe_poller_map); if (p) { if (poller_add_item(p, &pi)) ilog(LOG_ERR, "Failed to add stream_fd to poller"); diff --git a/include/main.h b/include/main.h index 8bebd5351..f861e453e 100644 --- a/include/main.h +++ b/include/main.h @@ -116,6 +116,7 @@ struct rtpengine_config { str cn_payload; int reorder_codecs; char *software_id; + int poller_per_thread; };