From 947c910449c599c502a1e9ef860e6651ce97b814 Mon Sep 17 00:00:00 2001 From: Michel van den Hoek Date: Mon, 8 Jul 2024 16:54:02 +0200 Subject: [PATCH] psmx_dummy: fix Windows linkage issue, make Cyclone reject configuration with multiple psmx interfaces Signed-off-by: Michel van den Hoek --- src/core/ddsc/src/dds_psmx.c | 44 ++++++++++--------------- src/core/ddsc/tests/CMakeLists.txt | 10 ++---- src/core/ddsc/tests/psmx_dummy_public.h | 8 +++-- 3 files changed, 26 insertions(+), 36 deletions(-) diff --git a/src/core/ddsc/src/dds_psmx.c b/src/core/ddsc/src/dds_psmx.c index 7f613984d9..20f52beed7 100644 --- a/src/core/ddsc/src/dds_psmx.c +++ b/src/core/ddsc/src/dds_psmx.c @@ -327,40 +327,32 @@ static dds_return_t psmx_instance_load (const struct ddsi_domaingv *gv, const st return ret; } -static int compare_psmx_prio (const void *va, const void *vb) -{ - const struct dds_psmx *psmx1 = va; - const struct dds_psmx *psmx2 = vb; - return (psmx1->priority == psmx2->priority) ? 0 : ((psmx1->priority < psmx2->priority) ? 1 : -1); -} - dds_return_t dds_pubsub_message_exchange_init (const struct ddsi_domaingv *gv, struct dds_domain *domain) { dds_return_t ret = DDS_RETCODE_OK; if (gv->config.psmx_instances != NULL) { struct ddsi_config_psmx_listelem *iface = gv->config.psmx_instances; - while (iface && domain->psmx_instances.length < DDS_MAX_PSMX_INSTANCES) - { - GVLOG(DDS_LC_INFO, "Loading PSMX instances %s\n", iface->cfg.name); - struct dds_psmx *psmx = NULL; - ddsrt_dynlib_t lib_handle; - if (psmx_instance_load (gv, &iface->cfg, &psmx, &lib_handle) == DDS_RETCODE_OK) - { - domain->psmx_instances.instances[domain->psmx_instances.length] = psmx; - domain->psmx_instances.lib_handles[domain->psmx_instances.length] = lib_handle; - domain->psmx_instances.length++; - } - else - { - GVERROR ("error loading PSMX instance \"%s\"\n", iface->cfg.name); - ret = DDS_RETCODE_ERROR; - break; + if ( iface != NULL ) { + if ( iface->next != NULL ) { + ret = DDS_RETCODE_UNSUPPORTED; // Only one psmx interface is supported. + }else{ + GVLOG(DDS_LC_INFO, "Loading PSMX instances %s\n", iface->cfg.name); + struct dds_psmx *psmx = NULL; + ddsrt_dynlib_t lib_handle; + if (psmx_instance_load (gv, &iface->cfg, &psmx, &lib_handle) == DDS_RETCODE_OK) + { + domain->psmx_instances.instances[domain->psmx_instances.length] = psmx; + domain->psmx_instances.lib_handles[domain->psmx_instances.length] = lib_handle; + domain->psmx_instances.length++; + } + else + { + GVERROR ("error loading PSMX instance \"%s\"\n", iface->cfg.name); + ret = DDS_RETCODE_ERROR; + } } - iface = iface->next; } - - qsort (domain->psmx_instances.instances, domain->psmx_instances.length, sizeof (*domain->psmx_instances.instances), compare_psmx_prio); } return ret; } diff --git a/src/core/ddsc/tests/CMakeLists.txt b/src/core/ddsc/tests/CMakeLists.txt index c10d9e9a30..b54e40ad0f 100644 --- a/src/core/ddsc/tests/CMakeLists.txt +++ b/src/core/ddsc/tests/CMakeLists.txt @@ -159,15 +159,10 @@ if(ENABLE_QOS_PROVIDER) endif() # PSMX dummy implementation for interface testing -set( - psmx_dummy_sources - "psmx_dummy_impl.c" - "psmx_dummy_impl.h" -) if(BUILD_SHARED_LIBS) - add_library(psmx_dummy SHARED ${psmx_dummy_sources}) + add_library(psmx_dummy SHARED "psmx_dummy_impl.c") else() - add_library(psmx_dummy OBJECT ${psmx_dummy_sources}) + add_library(psmx_dummy OBJECT "psmx_dummy_impl.c") set_property(GLOBAL APPEND PROPERTY cdds_plugin_list psmx_dummy) set_property(GLOBAL PROPERTY psmx_dummy_symbols dummy_create_psmx) endif() @@ -199,6 +194,7 @@ add_cunit_executable(cunit_ddsc ${ddsc_test_sources}) target_include_directories( cunit_ddsc PRIVATE "$" + "$" "$" "$" "$" diff --git a/src/core/ddsc/tests/psmx_dummy_public.h b/src/core/ddsc/tests/psmx_dummy_public.h index 3037900726..176ec63f4a 100644 --- a/src/core/ddsc/tests/psmx_dummy_public.h +++ b/src/core/ddsc/tests/psmx_dummy_public.h @@ -12,6 +12,8 @@ #ifndef PSMX_DUMMY_PUBLIC_H #define PSMX_DUMMY_PUBLIC_H +#include "dds/psmx_dummy/export.h" + #if defined (__cplusplus) extern "C" { #endif @@ -58,9 +60,9 @@ typedef struct dummy_mockstats_s{ dds_loaned_sample_t* write_rcv_loan; }dummy_mockstats_t; -DDS_EXPORT dummy_mockstats_t* dummy_mockstats_get_ptr(void); -DDS_EXPORT void dummy_topics_alloc(dummy_mockstats_t* mockstats, size_t topics_capacity); -DDS_EXPORT void dummy_endpoints_alloc(dummy_mockstats_t* mockstats, size_t endpoints_capacity); +PSMX_DUMMY_EXPORT dummy_mockstats_t* dummy_mockstats_get_ptr(void); +PSMX_DUMMY_EXPORT void dummy_topics_alloc(dummy_mockstats_t* mockstats, size_t topics_capacity); +PSMX_DUMMY_EXPORT void dummy_endpoints_alloc(dummy_mockstats_t* mockstats, size_t endpoints_capacity); #if defined (__cplusplus) }