From 20d8ef6f0dabcaed5fa10eec1fba265d53496c1e Mon Sep 17 00:00:00 2001 From: Erik Boasson Date: Tue, 17 Jul 2018 21:46:18 +0200 Subject: [PATCH] do not start sendq thread if async mode is disabled Signed-off-by: Erik Boasson --- src/core/ddsi/src/q_init.c | 14 ++++++++++---- src/core/ddsi/src/q_xmsg.c | 4 ++++ 2 files changed, 14 insertions(+), 4 deletions(-) diff --git a/src/core/ddsi/src/q_init.c b/src/core/ddsi/src/q_init.c index 926a120..4c453d9 100644 --- a/src/core/ddsi/src/q_init.c +++ b/src/core/ddsi/src/q_init.c @@ -1125,8 +1125,11 @@ int rtps_init (void) } } - nn_xpack_sendq_init(); - nn_xpack_sendq_start(); + if (config.xpack_send_async) + { + nn_xpack_sendq_init(); + nn_xpack_sendq_start(); + } #ifdef DDSI_INCLUDE_NETWORK_CHANNELS /* Create a delivery queue and start tev for each channel */ @@ -1413,8 +1416,11 @@ void rtps_term (void) xeventq_free (gv.xevents); - nn_xpack_sendq_stop(); - nn_xpack_sendq_fini(); + if (config.xpack_send_async) + { + nn_xpack_sendq_stop(); + nn_xpack_sendq_fini(); + } #ifdef DDSI_INCLUDE_NETWORK_CHANNELS chptr = config.channels; diff --git a/src/core/ddsi/src/q_xmsg.c b/src/core/ddsi/src/q_xmsg.c index 0141b67..1643cb8 100644 --- a/src/core/ddsi/src/q_xmsg.c +++ b/src/core/ddsi/src/q_xmsg.c @@ -1236,6 +1236,10 @@ struct nn_xpack * nn_xpack_new (ddsi_tran_conn_t conn, uint32_t bw_limit, bool a const nn_vendorid_t myvendorid = MY_VENDOR_ID; struct nn_xpack *xp; + /* Disallow setting async_mode if not configured to enable async mode: this way we + can avoid starting the async send thread altogether */ + assert (!async_mode || config.xpack_send_async); + xp = os_malloc (sizeof (*xp)); memset (xp, 0, sizeof (*xp)); xp->async_mode = async_mode;