Skip to content

Commit b636313

Browse files
Add onlyForTopics and forbiddenTopics config option
1 parent 545f4cb commit b636313

File tree

13 files changed

+264
-30
lines changed

13 files changed

+264
-30
lines changed

docs/manual/config/config_file_reference.rst

Lines changed: 30 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -654,7 +654,7 @@ The default value is: ``default``
654654
//CycloneDDS/Domain/General/Interfaces/PubSubMessageExchange
655655
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
656656

657-
Attributes: :ref:`config<//CycloneDDS/Domain/General/Interfaces/PubSubMessageExchange[@config]>`, :ref:`library<//CycloneDDS/Domain/General/Interfaces/PubSubMessageExchange[@library]>`, :ref:`name<//CycloneDDS/Domain/General/Interfaces/PubSubMessageExchange[@name]>`, :ref:`priority<//CycloneDDS/Domain/General/Interfaces/PubSubMessageExchange[@priority]>`
657+
Attributes: :ref:`config<//CycloneDDS/Domain/General/Interfaces/PubSubMessageExchange[@config]>`, :ref:`forbiddenTopics<//CycloneDDS/Domain/General/Interfaces/PubSubMessageExchange[@forbiddenTopics]>`, :ref:`library<//CycloneDDS/Domain/General/Interfaces/PubSubMessageExchange[@library]>`, :ref:`name<//CycloneDDS/Domain/General/Interfaces/PubSubMessageExchange[@name]>`, :ref:`onlyForTopics<//CycloneDDS/Domain/General/Interfaces/PubSubMessageExchange[@onlyForTopics]>`, :ref:`priority<//CycloneDDS/Domain/General/Interfaces/PubSubMessageExchange[@priority]>`
658658

659659
This element defines a PSMX.
660660

@@ -671,6 +671,18 @@ This attribute specifies any configuration data for the PSMX instance.This has n
671671
The default value is: ``<empty>``
672672

673673

674+
.. _`//CycloneDDS/Domain/General/Interfaces/PubSubMessageExchange[@forbiddenTopics]`:
675+
676+
//CycloneDDS/Domain/General/Interfaces/PubSubMessageExchange[@forbiddenTopics]
677+
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
678+
679+
Text
680+
681+
A comma-separated list of topics that should never use this psmx.Mutually exclusive with onlyForTopics.
682+
683+
The default value is: ``<empty>``
684+
685+
674686
.. _`//CycloneDDS/Domain/General/Interfaces/PubSubMessageExchange[@library]`:
675687

676688
//CycloneDDS/Domain/General/Interfaces/PubSubMessageExchange[@library]
@@ -695,6 +707,18 @@ This attribute specifies the name of the interface.
695707
The default value is: ``<empty>``
696708

697709

710+
.. _`//CycloneDDS/Domain/General/Interfaces/PubSubMessageExchange[@onlyForTopics]`:
711+
712+
//CycloneDDS/Domain/General/Interfaces/PubSubMessageExchange[@onlyForTopics]
713+
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
714+
715+
Text
716+
717+
A comma-separated list of all the topics that should use this PSMX.This option can be used to restrict the PSMX to a selected list of topics.Mutually exclusive with forbiddenTopics.
718+
719+
The default value is: ``<empty>``
720+
721+
698722
.. _`//CycloneDDS/Domain/General/Interfaces/PubSubMessageExchange[@priority]`:
699723

700724
//CycloneDDS/Domain/General/Interfaces/PubSubMessageExchange[@priority]
@@ -2704,14 +2728,14 @@ The categorisation of tracing output is incomplete and hence most of the verbosi
27042728
The default value is: ``none``
27052729

27062730
..
2707-
generated from ddsi_config.h[83ad19f1a665710b0c82b3ac6b861e6c8e83913f]
2731+
generated from ddsi_config.h[99b38dad99d609bd1f2e2aa7b43cf2a3aa10948d]
27082732
generated from ddsi__cfgunits.h[bd22f0c0ed210501d0ecd3b07c992eca549ef5aa]
2709-
generated from ddsi__cfgelems.h[194217161977869610495a7889bbc1e6bc976ce1]
2710-
generated from ddsi_config.c[a439a20e32fe327db26f2f10028d0056e46c1a0b]
2711-
generated from _confgen.h[e32eabfc35e9f3a7dcb63b19ed148c0d17c6e5fc]
2733+
generated from ddsi__cfgelems.h[fdfcbecb910d6a859d5e5ab25d81065aaca18ae8]
2734+
generated from ddsi_config.c[3f9cdfe5934118aeb3e6f7e8d9b71f815e8021c2]
2735+
generated from _confgen.h[b3b98385ecc752860a55e126b3893423730f53ab]
27122736
generated from _confgen.c[237308acd53897a34e8c643e16e05a61d73ffd65]
27132737
generated from generate_rnc.c[b50e4b7ab1d04b2bc1d361a0811247c337b74934]
27142738
generated from generate_md.c[789b92e422631684352909cfb8bf43f6ceb16a01]
27152739
generated from generate_rst.c[3c4b523fbb57c8e4a7e247379d06a8021ccc21c4]
27162740
generated from generate_xsd.c[6b6818d7f17a35d56c376c04ec1410427f34c0f0]
2717-
generated from generate_defconfig.c[63ca9d8ae2f1ce2e761c9d4c0510a45eb062d830]
2741+
generated from generate_defconfig.c[0ef1411470804c3db386c20c8752b161eb8418ae]

docs/manual/options.md

Lines changed: 22 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -437,7 +437,7 @@ The default value is: `default`
437437

438438

439439
##### //CycloneDDS/Domain/General/Interfaces/PubSubMessageExchange
440-
Attributes: [config](#cycloneddsdomaingeneralinterfacespubsubmessageexchangeconfig), [library](#cycloneddsdomaingeneralinterfacespubsubmessageexchangelibrary), [name](#cycloneddsdomaingeneralinterfacespubsubmessageexchangename), [priority](#cycloneddsdomaingeneralinterfacespubsubmessageexchangepriority)
440+
Attributes: [config](#cycloneddsdomaingeneralinterfacespubsubmessageexchangeconfig), [forbiddenTopics](#cycloneddsdomaingeneralinterfacespubsubmessageexchangeforbiddentopics), [library](#cycloneddsdomaingeneralinterfacespubsubmessageexchangelibrary), [name](#cycloneddsdomaingeneralinterfacespubsubmessageexchangename), [onlyForTopics](#cycloneddsdomaingeneralinterfacespubsubmessageexchangeonlyfortopics), [priority](#cycloneddsdomaingeneralinterfacespubsubmessageexchangepriority)
441441

442442
This element defines a PSMX.
443443

@@ -450,6 +450,14 @@ This attribute specifies any configuration data for the PSMX instance.This has n
450450
The default value is: `<empty>`
451451

452452

453+
##### //CycloneDDS/Domain/General/Interfaces/PubSubMessageExchange[@forbiddenTopics]
454+
Text
455+
456+
A comma-separated list of topics that should never use this psmx.Mutually exclusive with onlyForTopics.
457+
458+
The default value is: `<empty>`
459+
460+
453461
##### //CycloneDDS/Domain/General/Interfaces/PubSubMessageExchange[@library]
454462
Text
455463

@@ -466,6 +474,14 @@ This attribute specifies the name of the interface.
466474
The default value is: `<empty>`
467475

468476

477+
##### //CycloneDDS/Domain/General/Interfaces/PubSubMessageExchange[@onlyForTopics]
478+
Text
479+
480+
A comma-separated list of all the topics that should use this PSMX.This option can be used to restrict the PSMX to a selected list of topics.Mutually exclusive with forbiddenTopics.
481+
482+
The default value is: `<empty>`
483+
484+
469485
##### //CycloneDDS/Domain/General/Interfaces/PubSubMessageExchange[@priority]
470486
Text
471487

@@ -1898,14 +1914,14 @@ While none prevents any message from being written to a DDSI2 log file.
18981914
The categorisation of tracing output is incomplete and hence most of the verbosity levels and categories are not of much use in the current release. This is an ongoing process and here we describe the target situation rather than the current situation. Currently, the most useful verbosity levels are config, fine and finest.
18991915

19001916
The default value is: `none`
1901-
<!--- generated from ddsi_config.h[83ad19f1a665710b0c82b3ac6b861e6c8e83913f] -->
1917+
<!--- generated from ddsi_config.h[99b38dad99d609bd1f2e2aa7b43cf2a3aa10948d] -->
19021918
<!--- generated from ddsi__cfgunits.h[bd22f0c0ed210501d0ecd3b07c992eca549ef5aa] -->
1903-
<!--- generated from ddsi__cfgelems.h[194217161977869610495a7889bbc1e6bc976ce1] -->
1904-
<!--- generated from ddsi_config.c[a439a20e32fe327db26f2f10028d0056e46c1a0b] -->
1905-
<!--- generated from _confgen.h[e32eabfc35e9f3a7dcb63b19ed148c0d17c6e5fc] -->
1919+
<!--- generated from ddsi__cfgelems.h[fdfcbecb910d6a859d5e5ab25d81065aaca18ae8] -->
1920+
<!--- generated from ddsi_config.c[3f9cdfe5934118aeb3e6f7e8d9b71f815e8021c2] -->
1921+
<!--- generated from _confgen.h[b3b98385ecc752860a55e126b3893423730f53ab] -->
19061922
<!--- generated from _confgen.c[237308acd53897a34e8c643e16e05a61d73ffd65] -->
19071923
<!--- generated from generate_rnc.c[b50e4b7ab1d04b2bc1d361a0811247c337b74934] -->
19081924
<!--- generated from generate_md.c[789b92e422631684352909cfb8bf43f6ceb16a01] -->
19091925
<!--- generated from generate_rst.c[3c4b523fbb57c8e4a7e247379d06a8021ccc21c4] -->
19101926
<!--- generated from generate_xsd.c[6b6818d7f17a35d56c376c04ec1410427f34c0f0] -->
1911-
<!--- generated from generate_defconfig.c[63ca9d8ae2f1ce2e761c9d4c0510a45eb062d830] -->
1927+
<!--- generated from generate_defconfig.c[0ef1411470804c3db386c20c8752b161eb8418ae] -->

etc/cyclonedds.rnc

Lines changed: 17 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -317,6 +317,12 @@ CycloneDDS configuration""" ] ]
317317
text
318318
}?
319319
& [ a:documentation [ xml:lang="en" """
320+
<p>A comma-separated list of topics that should never use this psmx.Mutually exclusive with onlyForTopics.</p>
321+
<p>The default value is: <code>&lt;empty&gt;</code></p>""" ] ]
322+
attribute forbiddenTopics {
323+
text
324+
}?
325+
& [ a:documentation [ xml:lang="en" """
320326
<p>This attribute specifies the filename of the interface library. </p>
321327
<p>The default value is: <code>&lt;empty&gt;</code></p>""" ] ]
322328
attribute library {
@@ -329,6 +335,12 @@ CycloneDDS configuration""" ] ]
329335
text
330336
}?
331337
& [ a:documentation [ xml:lang="en" """
338+
<p>A comma-separated list of all the topics that should use this PSMX.This option can be used to restrict the PSMX to a selected list of topics.Mutually exclusive with forbiddenTopics.</p>
339+
<p>The default value is: <code>&lt;empty&gt;</code></p>""" ] ]
340+
attribute onlyForTopics {
341+
text
342+
}?
343+
& [ a:documentation [ xml:lang="en" """
332344
<p>This attribute specifies the interface priority (decimal integer or <i>default</i>). The default value for a PSMX is 0.</p>
333345
<p>The default value is: <code>default</code></p>""" ] ]
334346
attribute priority {
@@ -1313,14 +1325,14 @@ MIIEpAIBAAKCAQEA3HIh...AOBaaqSV37XBUJg==<br>
13131325
duration_inf = xsd:token { pattern = "inf|0|(\d+(\.\d*)?([Ee][\-+]?\d+)?|\.\d+([Ee][\-+]?\d+)?) *([num]?s|min|hr|day)" }
13141326
memsize = xsd:token { pattern = "0|(\d+(\.\d*)?([Ee][\-+]?\d+)?|\.\d+([Ee][\-+]?\d+)?) *([kMG]i?)?B" }
13151327
}
1316-
# generated from ddsi_config.h[83ad19f1a665710b0c82b3ac6b861e6c8e83913f]
1328+
# generated from ddsi_config.h[99b38dad99d609bd1f2e2aa7b43cf2a3aa10948d]
13171329
# generated from ddsi__cfgunits.h[bd22f0c0ed210501d0ecd3b07c992eca549ef5aa]
1318-
# generated from ddsi__cfgelems.h[194217161977869610495a7889bbc1e6bc976ce1]
1319-
# generated from ddsi_config.c[a439a20e32fe327db26f2f10028d0056e46c1a0b]
1320-
# generated from _confgen.h[e32eabfc35e9f3a7dcb63b19ed148c0d17c6e5fc]
1330+
# generated from ddsi__cfgelems.h[fdfcbecb910d6a859d5e5ab25d81065aaca18ae8]
1331+
# generated from ddsi_config.c[3f9cdfe5934118aeb3e6f7e8d9b71f815e8021c2]
1332+
# generated from _confgen.h[b3b98385ecc752860a55e126b3893423730f53ab]
13211333
# generated from _confgen.c[237308acd53897a34e8c643e16e05a61d73ffd65]
13221334
# generated from generate_rnc.c[b50e4b7ab1d04b2bc1d361a0811247c337b74934]
13231335
# generated from generate_md.c[789b92e422631684352909cfb8bf43f6ceb16a01]
13241336
# generated from generate_rst.c[3c4b523fbb57c8e4a7e247379d06a8021ccc21c4]
13251337
# generated from generate_xsd.c[6b6818d7f17a35d56c376c04ec1410427f34c0f0]
1326-
# generated from generate_defconfig.c[63ca9d8ae2f1ce2e761c9d4c0510a45eb062d830]
1338+
# generated from generate_defconfig.c[0ef1411470804c3db386c20c8752b161eb8418ae]

etc/cyclonedds.xsd

Lines changed: 19 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -502,6 +502,13 @@ CycloneDDS configuration</xs:documentation>
502502
<xs:annotation>
503503
<xs:documentation>
504504
&lt;p&gt;This attribute specifies any configuration data for the PSMX instance.This has no meaning in CycloneDDS itself, and its parsing is deferred to thePSMX implementation.&lt;/p&gt;
505+
&lt;p&gt;The default value is: &lt;code&gt;&amp;lt;empty&amp;gt;&lt;/code&gt;&lt;/p&gt;</xs:documentation>
506+
</xs:annotation>
507+
</xs:attribute>
508+
<xs:attribute name="forbiddenTopics">
509+
<xs:annotation>
510+
<xs:documentation>
511+
&lt;p&gt;A comma-separated list of topics that should never use this psmx.Mutually exclusive with onlyForTopics.&lt;/p&gt;
505512
&lt;p&gt;The default value is: &lt;code&gt;&amp;lt;empty&amp;gt;&lt;/code&gt;&lt;/p&gt;</xs:documentation>
506513
</xs:annotation>
507514
</xs:attribute>
@@ -516,6 +523,13 @@ CycloneDDS configuration</xs:documentation>
516523
<xs:annotation>
517524
<xs:documentation>
518525
&lt;p&gt;This attribute specifies the name of the interface. &lt;/p&gt;
526+
&lt;p&gt;The default value is: &lt;code&gt;&amp;lt;empty&amp;gt;&lt;/code&gt;&lt;/p&gt;</xs:documentation>
527+
</xs:annotation>
528+
</xs:attribute>
529+
<xs:attribute name="onlyForTopics">
530+
<xs:annotation>
531+
<xs:documentation>
532+
&lt;p&gt;A comma-separated list of all the topics that should use this PSMX.This option can be used to restrict the PSMX to a selected list of topics.Mutually exclusive with forbiddenTopics.&lt;/p&gt;
519533
&lt;p&gt;The default value is: &lt;code&gt;&amp;lt;empty&amp;gt;&lt;/code&gt;&lt;/p&gt;</xs:documentation>
520534
</xs:annotation>
521535
</xs:attribute>
@@ -1971,14 +1985,14 @@ MIIEpAIBAAKCAQEA3HIh...AOBaaqSV37XBUJg==&lt;br&gt;
19711985
</xs:restriction>
19721986
</xs:simpleType>
19731987
</xs:schema>
1974-
<!--- generated from ddsi_config.h[83ad19f1a665710b0c82b3ac6b861e6c8e83913f] -->
1988+
<!--- generated from ddsi_config.h[99b38dad99d609bd1f2e2aa7b43cf2a3aa10948d] -->
19751989
<!--- generated from ddsi__cfgunits.h[bd22f0c0ed210501d0ecd3b07c992eca549ef5aa] -->
1976-
<!--- generated from ddsi__cfgelems.h[194217161977869610495a7889bbc1e6bc976ce1] -->
1977-
<!--- generated from ddsi_config.c[a439a20e32fe327db26f2f10028d0056e46c1a0b] -->
1978-
<!--- generated from _confgen.h[e32eabfc35e9f3a7dcb63b19ed148c0d17c6e5fc] -->
1990+
<!--- generated from ddsi__cfgelems.h[fdfcbecb910d6a859d5e5ab25d81065aaca18ae8] -->
1991+
<!--- generated from ddsi_config.c[3f9cdfe5934118aeb3e6f7e8d9b71f815e8021c2] -->
1992+
<!--- generated from _confgen.h[b3b98385ecc752860a55e126b3893423730f53ab] -->
19791993
<!--- generated from _confgen.c[237308acd53897a34e8c643e16e05a61d73ffd65] -->
19801994
<!--- generated from generate_rnc.c[b50e4b7ab1d04b2bc1d361a0811247c337b74934] -->
19811995
<!--- generated from generate_md.c[789b92e422631684352909cfb8bf43f6ceb16a01] -->
19821996
<!--- generated from generate_rst.c[3c4b523fbb57c8e4a7e247379d06a8021ccc21c4] -->
19831997
<!--- generated from generate_xsd.c[6b6818d7f17a35d56c376c04ec1410427f34c0f0] -->
1984-
<!--- generated from generate_defconfig.c[63ca9d8ae2f1ce2e761c9d4c0510a45eb062d830] -->
1998+
<!--- generated from generate_defconfig.c[0ef1411470804c3db386c20c8752b161eb8418ae] -->

src/core/ddsc/include/dds/ddsc/dds_psmx.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -260,6 +260,8 @@ typedef struct dds_psmx {
260260
dds_psmx_ops_t ops; //!< associated functions
261261
const char *instance_name; //!< name of this PSMX instance
262262
int32_t priority; //!< priority of choosing this interface
263+
char ** only_for_topics; //!< See ddsi_config_psmx. Format is nullptr-terminated array of separately allocated char*
264+
char ** forbidden_topics; //!< See ddsi_config_psmx. Format is nullptr-terminated array of separately allocated char*
263265
const struct ddsi_locator *locator; //!< the locator for this PSMX instance
264266
dds_psmx_instance_id_t instance_id; //!< the identifier of this PSMX instance
265267
struct dds_psmx_topic_list_elem *psmx_topics; //!< associated topics

src/core/ddsc/src/dds_psmx.c

Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
#include <string.h>
1212

1313
#include "dds/ddsrt/heap.h"
14+
#include "dds/ddsrt/string.h"
1415
#include "dds/ddsrt/dynlib.h"
1516
#include "dds/ddsrt/mh3.h"
1617
#include "dds/ddsrt/io.h"
@@ -27,6 +28,8 @@
2728
static struct dds_psmx_endpoint * psmx_create_endpoint (struct dds_psmx_topic *psmx_topic, const struct dds_qos *qos, dds_psmx_endpoint_type_t endpoint_type);
2829
static dds_return_t psmx_delete_endpoint (struct dds_psmx_endpoint *psmx_endpoint);
2930

31+
void deep_cleanup_topic_array(char **topic_array);
32+
3033
dds_return_t dds_add_psmx_topic_to_list (struct dds_psmx_topic *psmx_topic, struct dds_psmx_topic_list_elem **list)
3134
{
3235
if (!psmx_topic)
@@ -84,6 +87,14 @@ dds_return_t dds_remove_psmx_topic_from_list (struct dds_psmx_topic *psmx_topic,
8487
return ret;
8588
}
8689

90+
// Free all members of a nullptr-terminated array of separately allocated char pointers
91+
void deep_cleanup_topic_array(char **topic_array) {
92+
for (char * topic = *topic_array; topic; topic++) {
93+
ddsrt_free((void*)topic);
94+
}
95+
ddsrt_free((void*)topic_array);
96+
}
97+
8798
dds_return_t dds_add_psmx_endpoint_to_list (struct dds_psmx_endpoint *psmx_endpoint, struct dds_psmx_endpoint_list_elem **list)
8899
{
89100
if (!psmx_endpoint)
@@ -164,6 +175,12 @@ dds_return_t dds_psmx_cleanup_generic (struct dds_psmx *psmx)
164175
dds_free ((void *) psmx->instance_name);
165176
dds_free ((void *) psmx->locator);
166177

178+
deep_cleanup_topic_array(psmx->only_for_topics);
179+
psmx->only_for_topics = NULL;
180+
181+
deep_cleanup_topic_array(psmx->forbidden_topics);
182+
psmx->forbidden_topics = NULL;
183+
167184
while (ret == DDS_RETCODE_OK && psmx->psmx_topics)
168185
ret = dds_remove_psmx_topic_from_list (psmx->psmx_topics->topic, &psmx->psmx_topics);
169186

@@ -313,11 +330,55 @@ static dds_return_t psmx_instance_load (const struct ddsi_domaingv *gv, const st
313330
goto err_init;
314331
}
315332
psmx_instance->priority = config->priority.value;
333+
334+
if (config->only_for_topics.size > 0 && config->forbidden_topics.size > 0) {
335+
ret = DDS_RETCODE_UNSUPPORTED;
336+
GVERROR ("Failed to initialize PSMX instance '%s': conflicting options only_for_topics and forbidden_topics were both present",
337+
config->name);
338+
goto err_init;
339+
}
340+
341+
// Copy over the only_for_topics and forbidden_topics array, switching to nullptr-terminated array of separately-allocated strings
342+
psmx_instance->only_for_topics = psmx_instance->forbidden_topics = NULL;
343+
344+
// Allocate +1 for the final nullptr terminator
345+
psmx_instance->only_for_topics = ddsrt_calloc_s(config->only_for_topics.size + 1, sizeof(char*));
346+
psmx_instance->forbidden_topics = ddsrt_calloc_s(config->forbidden_topics.size + 1, sizeof(char*));
347+
if (!psmx_instance->only_for_topics || !psmx_instance->forbidden_topics) {
348+
GVERROR ("Failed to initialize PSMX instance '%s': out of memory",
349+
config->name);
350+
goto err_topic_arrays_oom;
351+
}
352+
353+
for (size_t i = 0 ; i < config->only_for_topics.size; i++) {
354+
psmx_instance->only_for_topics[i] = ddsrt_strdup(config->only_for_topics.topics[i]);
355+
if (psmx_instance->only_for_topics[i] == NULL) {
356+
GVERROR ("Failed to initialize PSMX instance '%s': out of memory",
357+
config->name);
358+
goto err_topic_arrays_oom;
359+
}
360+
}
361+
for (size_t i = 0 ; i < config->forbidden_topics.size; i++) {
362+
psmx_instance->forbidden_topics[i] = ddsrt_strdup(config->forbidden_topics.topics[i]);
363+
if (psmx_instance->forbidden_topics[i] == NULL) {
364+
GVERROR ("Failed to initialize PSMX instance '%s': out of memory",
365+
config->name);
366+
goto err_topic_arrays_oom;
367+
}
368+
}
369+
316370
*out = psmx_instance;
317371
*lib_handle = handle;
318372
ddsrt_free (configstr);
319373
return DDS_RETCODE_OK;
320374

375+
err_topic_arrays_oom:
376+
if (psmx_instance->only_for_topics) {
377+
deep_cleanup_topic_array(psmx_instance->only_for_topics);
378+
}
379+
if (psmx_instance->forbidden_topics) {
380+
deep_cleanup_topic_array(psmx_instance->forbidden_topics);
381+
}
321382
err_init:
322383
err_dlsym:
323384
ddsrt_dlclose (handle);

src/core/ddsc/src/dds_topic.c

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -583,6 +583,30 @@ dds_entity_t dds_create_topic_impl (
583583
struct dds_psmx *psmx = dom->psmx_instances.instances[i];
584584
if (!psmx->ops.type_qos_supported (psmx, DDS_PSMX_ENDPOINT_TYPE_UNSET, sertype_registered->data_type_props, new_qos))
585585
continue;
586+
587+
// Check if the topic is in the forbiddenTopics or NOT in the onlyForTopics list, depending
588+
// on which one is used.
589+
// First off, topics not mentioned are allowed iff only_for_topics is unused
590+
bool allowed_by_config = !psmx->only_for_topics[0];
591+
// Then any topic in only_for_topics is allowed
592+
for (char **topic = psmx->only_for_topics; *topic; topic++) {
593+
if (strcmp(ktp->name, *topic) == 0) {
594+
allowed_by_config = true;
595+
break;
596+
}
597+
}
598+
// And any topic in forbidden_topics is forbidden
599+
for (char **topic = psmx->forbidden_topics; *topic; topic++) {
600+
if (strcmp(ktp->name, *topic) == 0) {
601+
allowed_by_config = false;
602+
break;
603+
}
604+
}
605+
606+
if (!allowed_by_config) {
607+
continue;
608+
}
609+
586610
struct dds_psmx_topic *psmx_topic = psmx->ops.create_topic (psmx, ktp->name, sertype_registered->type_name, sertype_registered->data_type_props);
587611
if (psmx_topic == NULL)
588612
{

0 commit comments

Comments
 (0)