Skip to content

Commit

Permalink
Call ddsrt_dlclose on shutdown for PSMX plugins
Browse files Browse the repository at this point in the history
Signed-off-by: Erik Boasson <[email protected]>
  • Loading branch information
eboasson committed Sep 26, 2023
1 parent 81f1dac commit 9c6c5df
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 3 deletions.
2 changes: 2 additions & 0 deletions src/core/ddsc/src/dds__types.h
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@

#include "dds/dds.h"
#include "dds/ddsrt/sync.h"
#include "dds/ddsrt/dynlib.h"
#include "dds/ddsi/ddsi_protocol.h"
#include "dds/ddsi/ddsi_domaingv.h"
#ifdef DDS_HAS_TOPIC_DISCOVERY
Expand Down Expand Up @@ -273,6 +274,7 @@ typedef struct dds_cyclonedds_entity {
struct dds_psmx_set {
uint32_t length;
struct dds_psmx *instances[DDS_MAX_PSMX_INSTANCES];
ddsrt_dynlib_t lib_handles[DDS_MAX_PSMX_INSTANCES];
};

typedef struct dds_domain {
Expand Down
15 changes: 12 additions & 3 deletions src/core/ddsc/src/dds_psmx.c
Original file line number Diff line number Diff line change
Expand Up @@ -210,7 +210,7 @@ static dds_psmx_instance_id_t get_psmx_instance_id (const struct ddsi_domaingv *
return ddsrt_mh3 (config_name, strlen (config_name), hashed_id);
}

static dds_return_t psmx_instance_load (const struct ddsi_domaingv *gv, struct ddsi_config_psmx *config, struct dds_psmx **out)
static dds_return_t psmx_instance_load (const struct ddsi_domaingv *gv, struct ddsi_config_psmx *config, struct dds_psmx **out, ddsrt_dynlib_t *lib_handle)
{
dds_psmx_create_fn creator = NULL;
const char *lib_name;
Expand Down Expand Up @@ -247,6 +247,7 @@ static dds_return_t psmx_instance_load (const struct ddsi_domaingv *gv, struct d
}
psmx_instance->priority = config->priority.value;
*out = psmx_instance;
*lib_handle = handle;
return DDS_RETCODE_OK;

err_init:
Expand All @@ -273,8 +274,13 @@ dds_return_t dds_pubsub_message_exchange_init (const struct ddsi_domaingv *gv, s
{
GVLOG(DDS_LC_INFO, "Loading PSMX instances %s\n", iface->cfg.name);
struct dds_psmx *psmx = NULL;
if (psmx_instance_load (gv, &iface->cfg, &psmx) == DDS_RETCODE_OK)
domain->psmx_instances.instances[domain->psmx_instances.length++] = psmx;
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);
Expand All @@ -296,7 +302,10 @@ dds_return_t dds_pubsub_message_exchange_fini (struct dds_domain *domain)
{
struct dds_psmx *psmx = domain->psmx_instances.instances[i];
if ((ret = psmx->ops.deinit (psmx)) == DDS_RETCODE_OK)
{
(void) ddsrt_dlclose (domain->psmx_instances.lib_handles[i]);
domain->psmx_instances.instances[i] = NULL;
}
}
return ret;
}
Expand Down

0 comments on commit 9c6c5df

Please sign in to comment.