Skip to content

Commit

Permalink
psmx_dummy: fix Windows linkage issue, make Cyclone reject configurat…
Browse files Browse the repository at this point in the history
…ion with multiple psmx interfaces

Signed-off-by: Michel van den Hoek <[email protected]>
  • Loading branch information
mvandenhoek committed Jul 8, 2024
1 parent 22f2a7e commit 5f904c1
Show file tree
Hide file tree
Showing 4 changed files with 27 additions and 36 deletions.
44 changes: 18 additions & 26 deletions src/core/ddsc/src/dds_psmx.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down
10 changes: 3 additions & 7 deletions src/core/ddsc/tests/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down Expand Up @@ -199,6 +194,7 @@ add_cunit_executable(cunit_ddsc ${ddsc_test_sources})
target_include_directories(
cunit_ddsc PRIVATE
"$<BUILD_INTERFACE:${CMAKE_BINARY_DIR}/src/include/>"
"$<BUILD_INTERFACE:${CMAKE_CURRENT_BINARY_DIR}/include>"
"$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/../../ddsc/src>"
"$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/../../ddsi/include>"
"$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/../../ddsi/src>"
Expand Down
8 changes: 5 additions & 3 deletions src/core/ddsc/tests/psmx_dummy_public.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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)
}
Expand Down
1 change: 1 addition & 0 deletions src/core/ddsc/tests/psmxif.c
Original file line number Diff line number Diff line change
Expand Up @@ -149,6 +149,7 @@ CU_Test(ddsc_psmxif, config_multiple_psmx)
configstr_in = ddsrt_expand_envvars(configstr, domainId);
}
const dds_entity_t domain = dds_create_domain (domainId, configstr_in);
ddsrt_free(configstr_in);
CU_ASSERT_FATAL(domain <= 0);
}

Expand Down

0 comments on commit 5f904c1

Please sign in to comment.