Table-driven parameter list handling
The old parameter list parsing was a mess of custom code with tons of duplicated checks, even though parameter list parsing really is a fairly straightforward affair. This commit changes it to a mostly table-driven implementation, where the vast majority of the settings are handled by a generic deserializer and the irregular ones (like reliability, locators) are handled by custom functions. The crazy ones (IPv4 address and port rely on additional state and are completely special-cased). Given these tables, the serialization, finalisation, validation, merging, unalias'ing can all be handled by a very small amount of custom code and an appropriately defined generic function for the common cases. This also makes it possible to have all QoS validation in place, and so removes the need for the specialized implementations for the various entity kinds in the upper layer. QoS inapplicable to an entity were previously ignored, allowing one to have invalid values set in a QoS object when creating an entity, provided that the invalid values are irrelevant to that entity. Whether this is a good thing or not is debatable, but certainly it is a good thing to avoid copying in inapplicable QoS settings. That in turn means the behaviour of the API can remain the same. It does turn out that the code used to return "inconsistent QoS" also for invalid values. That has now been rectified, and it returns "inconsistent QoS" or "bad parameter" as appropriate. Tests have been updated accordingly. Signed-off-by: Erik Boasson <eb@ilities.com>
This commit is contained in:
parent
8ae81db490
commit
3322fc086d
36 changed files with 2367 additions and 2735 deletions
|
@ -374,7 +374,8 @@ dds_qset_durability_service (
|
|||
* @param[in,out] qos - Pointer to a dds_qos_t structure that will store the policy
|
||||
* @param[in] ignore - True if readers and writers owned by the same participant should be ignored
|
||||
*/
|
||||
DDS_EXPORT void dds_qset_ignorelocal (
|
||||
DDS_EXPORT void
|
||||
dds_qset_ignorelocal (
|
||||
dds_qos_t * __restrict qos,
|
||||
dds_ignorelocal_kind_t ignore);
|
||||
|
||||
|
|
|
@ -14,21 +14,11 @@
|
|||
|
||||
#include "dds__entity.h"
|
||||
#include "dds/ddsi/q_xqos.h"
|
||||
#include "dds/ddsi/q_time.h"
|
||||
#include "dds/ddsi/q_plist.h"
|
||||
|
||||
#if defined (__cplusplus)
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
bool validate_deadline_and_timebased_filter (const dds_duration_t deadline, const dds_duration_t minimum_separation);
|
||||
bool validate_entityfactory_qospolicy (const dds_entity_factory_qospolicy_t * entityfactory);
|
||||
bool validate_octetseq (const ddsi_octetseq_t* seq);
|
||||
bool validate_partition_qospolicy (const dds_partition_qospolicy_t * partition);
|
||||
bool validate_reliability_qospolicy (const dds_reliability_qospolicy_t * reliability);
|
||||
bool validate_stringseq (const ddsi_stringseq_t* seq);
|
||||
|
||||
bool dds_qos_validate_common (const dds_qos_t *qos);
|
||||
dds_return_t dds_qos_validate_mutable_common (const dds_qos_t *qos);
|
||||
|
||||
#if defined (__cplusplus)
|
||||
|
|
|
@ -11,9 +11,11 @@
|
|||
*/
|
||||
#include <assert.h>
|
||||
#include <string.h>
|
||||
#include "dds/ddsrt/string.h"
|
||||
#include "dds/ddsi/q_entity.h"
|
||||
#include "dds/ddsi/q_thread.h"
|
||||
#include "dds/ddsi/q_config.h"
|
||||
#include "dds/ddsi/q_plist.h" /* for nn_keyhash */
|
||||
#include "dds__init.h"
|
||||
#include "dds__qos.h"
|
||||
#include "dds__domain.h"
|
||||
|
@ -103,6 +105,7 @@ dds_entity_t dds__get_builtin_topic (dds_entity_t e, dds_entity_t topic)
|
|||
|
||||
static bool qos_has_resource_limits (const dds_qos_t *qos)
|
||||
{
|
||||
assert (qos->present & QP_RESOURCE_LIMITS);
|
||||
return (qos->resource_limits.max_samples != DDS_LENGTH_UNLIMITED ||
|
||||
qos->resource_limits.max_instances != DDS_LENGTH_UNLIMITED ||
|
||||
qos->resource_limits.max_samples_per_instance != DDS_LENGTH_UNLIMITED);
|
||||
|
@ -115,8 +118,9 @@ bool dds__validate_builtin_reader_qos (dds_entity_t topic, const dds_qos_t *qos)
|
|||
return true;
|
||||
else
|
||||
{
|
||||
/* failing writes on built-in topics are unwelcome complications, so we simply forbid the creation of
|
||||
a reader matching a built-in topics writer that has resource limits */
|
||||
/* failing writes on built-in topics are unwelcome complications, so we simply
|
||||
forbid the creation of a reader matching a built-in topics writer that has
|
||||
resource limits */
|
||||
struct local_orphan_writer *bwr;
|
||||
if (topic == DDS_BUILTIN_TOPIC_DCPSPARTICIPANT) {
|
||||
bwr = builtintopic_writer_participant;
|
||||
|
@ -128,7 +132,15 @@ bool dds__validate_builtin_reader_qos (dds_entity_t topic, const dds_qos_t *qos)
|
|||
assert (0);
|
||||
return false;
|
||||
}
|
||||
return !qos_match_p (qos, bwr->wr.xqos, NULL) && !qos_has_resource_limits (qos);
|
||||
|
||||
/* FIXME: DDSI-level readers, writers have topic, type name in their QoS, but
|
||||
DDSC-level ones don't and that gives an automatic mismatch when comparing
|
||||
the full QoS object ... Here the two have the same topic by construction
|
||||
so ignoring them in the comparison makes things work. The discrepancy
|
||||
should be addressed one day. */
|
||||
const uint64_t qmask = ~(QP_TOPIC_NAME | QP_TYPE_NAME);
|
||||
dds_qos_policy_id_t dummy;
|
||||
return qos_match_mask_p (qos, bwr->wr.xqos, qmask, &dummy) && !qos_has_resource_limits (qos);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -20,6 +20,7 @@
|
|||
#include "dds__reader.h"
|
||||
#include "dds__listener.h"
|
||||
#include "dds/version.h"
|
||||
#include "dds/ddsi/q_xqos.h"
|
||||
|
||||
extern inline dds_entity *dds_entity_from_handle_link (struct dds_handle_link *hdllink);
|
||||
extern inline bool dds_entity_is_enabled (const dds_entity *e);
|
||||
|
@ -354,7 +355,8 @@ dds_return_t dds_get_qos (dds_entity_t entity, dds_qos_t *qos)
|
|||
else
|
||||
{
|
||||
dds_reset_qos (qos);
|
||||
ret = dds_copy_qos (qos, e->m_qos);
|
||||
nn_xqos_mergein_missing (qos, e->m_qos, ~(QP_TOPIC_NAME | QP_TYPE_NAME));
|
||||
ret = DDS_RETCODE_OK;
|
||||
}
|
||||
dds_entity_unlock(e);
|
||||
return ret;
|
||||
|
|
|
@ -15,6 +15,7 @@
|
|||
#include "dds/ddsi/q_entity.h"
|
||||
#include "dds/ddsi/q_thread.h"
|
||||
#include "dds/ddsi/q_config.h"
|
||||
#include "dds/ddsi/q_plist.h"
|
||||
#include "dds__init.h"
|
||||
#include "dds__qos.h"
|
||||
#include "dds__domain.h"
|
||||
|
@ -73,13 +74,10 @@ static dds_return_t dds_participant_qos_validate (const dds_qos_t *qos, bool ena
|
|||
|
||||
static dds_return_t dds_participant_qos_validate (const dds_qos_t *qos, bool enabled)
|
||||
{
|
||||
dds_return_t ret;
|
||||
(void)enabled;
|
||||
|
||||
if ((qos->present & QP_USER_DATA) && !validate_octetseq (&qos->user_data))
|
||||
return DDS_RETCODE_INCONSISTENT_POLICY;
|
||||
if ((qos->present & QP_PRISMTECH_ENTITY_FACTORY) && !validate_entityfactory_qospolicy (&qos->entity_factory))
|
||||
return DDS_RETCODE_INCONSISTENT_POLICY;
|
||||
|
||||
if ((ret = nn_xqos_valid (qos)) < 0)
|
||||
return ret;
|
||||
return DDS_RETCODE_OK;
|
||||
}
|
||||
|
||||
|
@ -112,13 +110,14 @@ dds_entity_t dds_create_participant (const dds_domainid_t domain, const dds_qos_
|
|||
if ((ret = dds__check_domain (domain)) != DDS_RETCODE_OK)
|
||||
goto err_domain_check;
|
||||
|
||||
/* Validate qos or use default if NULL */
|
||||
if (qos && (ret = dds_participant_qos_validate (qos, false)) != DDS_RETCODE_OK)
|
||||
goto err_qos_validation;
|
||||
|
||||
#define DDS_QOSMASK_PARTICIPANT (QP_USER_DATA | QP_PRISMTECH_ENTITY_FACTORY | QP_CYCLONE_IGNORELOCAL)
|
||||
new_qos = dds_create_qos ();
|
||||
if (qos != NULL)
|
||||
(void) dds_copy_qos (new_qos, qos);
|
||||
nn_xqos_mergein_missing (new_qos, qos, DDS_QOSMASK_PARTICIPANT);
|
||||
/* Validate qos or use default if NULL */
|
||||
if ((ret = dds_participant_qos_validate (new_qos, false)) != DDS_RETCODE_OK)
|
||||
goto err_qos_validation;
|
||||
|
||||
/* Translate qos */
|
||||
nn_plist_init_empty (&plist);
|
||||
|
@ -157,8 +156,8 @@ dds_entity_t dds_create_participant (const dds_domainid_t domain, const dds_qos_
|
|||
err_entity_init:
|
||||
dds_free (pp);
|
||||
err_new_participant:
|
||||
dds_delete_qos (new_qos);
|
||||
err_qos_validation:
|
||||
dds_delete_qos (new_qos);
|
||||
err_domain_check:
|
||||
dds_fini ();
|
||||
err_dds_init:
|
||||
|
|
|
@ -17,6 +17,7 @@
|
|||
#include "dds__publisher.h"
|
||||
#include "dds__qos.h"
|
||||
#include "dds/ddsi/q_entity.h"
|
||||
#include "dds/ddsi/q_globals.h"
|
||||
#include "dds/version.h"
|
||||
|
||||
DECL_ENTITY_LOCK_UNLOCK (extern inline, dds_publisher)
|
||||
|
@ -37,14 +38,9 @@ static dds_return_t dds_publisher_qos_validate (const dds_qos_t *qos, bool enabl
|
|||
|
||||
static dds_return_t dds_publisher_qos_validate (const dds_qos_t *qos, bool enabled)
|
||||
{
|
||||
if ((qos->present & QP_GROUP_DATA) && !validate_octetseq (&qos->group_data))
|
||||
return DDS_RETCODE_INCONSISTENT_POLICY;
|
||||
if ((qos->present & QP_PRESENTATION) && validate_presentation_qospolicy (&qos->presentation) < 0)
|
||||
return DDS_RETCODE_INCONSISTENT_POLICY;
|
||||
if ((qos->present & QP_PARTITION) && !validate_stringseq (&qos->partition))
|
||||
return DDS_RETCODE_INCONSISTENT_POLICY;
|
||||
if ((qos->present & QP_PRISMTECH_ENTITY_FACTORY) && !validate_entityfactory_qospolicy (&qos->entity_factory))
|
||||
return DDS_RETCODE_INCONSISTENT_POLICY;
|
||||
dds_return_t ret;
|
||||
if ((ret = nn_xqos_valid (qos)) < 0)
|
||||
return ret;
|
||||
/* FIXME: Improve/check immutable check. */
|
||||
if (enabled && (qos->present & QP_PRESENTATION))
|
||||
return DDS_RETCODE_IMMUTABLE_POLICY;
|
||||
|
@ -74,21 +70,25 @@ dds_entity_t dds_create_publisher (dds_entity_t participant, const dds_qos_t *qo
|
|||
dds_participant *par;
|
||||
dds_publisher *pub;
|
||||
dds_entity_t hdl;
|
||||
dds_qos_t *new_qos = NULL;
|
||||
dds_qos_t *new_qos;
|
||||
dds_return_t ret;
|
||||
|
||||
if (qos && (ret = dds_publisher_qos_validate (qos, false)) != DDS_RETCODE_OK)
|
||||
return ret;
|
||||
|
||||
if ((ret = dds_participant_lock (participant, &par)) != DDS_RETCODE_OK)
|
||||
return ret;
|
||||
|
||||
#define DDS_QOSMASK_PUBLISHER (QP_PARTITION | QP_PRESENTATION | QP_GROUP_DATA | QP_PRISMTECH_ENTITY_FACTORY | QP_CYCLONE_IGNORELOCAL)
|
||||
new_qos = dds_create_qos ();
|
||||
if (qos)
|
||||
nn_xqos_mergein_missing (new_qos, qos, DDS_QOSMASK_PUBLISHER);
|
||||
nn_xqos_mergein_missing (new_qos, &gv.default_xqos_pub, ~(uint64_t)0);
|
||||
if ((ret = dds_publisher_qos_validate (new_qos, false)) != DDS_RETCODE_OK)
|
||||
{
|
||||
new_qos = dds_create_qos ();
|
||||
(void) dds_copy_qos (new_qos, qos);
|
||||
dds_delete_qos (new_qos);
|
||||
return ret;
|
||||
}
|
||||
|
||||
if ((ret = dds_participant_lock (participant, &par)) != DDS_RETCODE_OK)
|
||||
{
|
||||
dds_delete_qos (new_qos);
|
||||
return ret;
|
||||
}
|
||||
pub = dds_alloc (sizeof (*pub));
|
||||
hdl = dds_entity_init (&pub->m_entity, &par->m_entity, DDS_KIND_PUBLISHER, new_qos, listener, DDS_PUBLISHER_STATUS_MASK);
|
||||
pub->m_entity.m_deriver.set_qos = dds_publisher_qos_set;
|
||||
|
|
|
@ -12,21 +12,16 @@
|
|||
#include <assert.h>
|
||||
#include <string.h>
|
||||
#include "dds__qos.h"
|
||||
#include "dds/ddsrt/heap.h"
|
||||
#include "dds/ddsrt/string.h"
|
||||
#include "dds/ddsi/q_config.h"
|
||||
|
||||
static void dds_qos_data_copy_in (ddsi_octetseq_t *data, const void * __restrict value, size_t sz)
|
||||
static void dds_qos_data_copy_in (ddsi_octetseq_t *data, const void * __restrict value, size_t sz, bool overwrite)
|
||||
{
|
||||
if (data->value)
|
||||
{
|
||||
dds_free (data->value);
|
||||
data->value = NULL;
|
||||
}
|
||||
if (overwrite && data->value)
|
||||
ddsrt_free (data->value);
|
||||
data->length = (uint32_t) sz;
|
||||
if (sz && value)
|
||||
{
|
||||
data->value = dds_alloc (sz);
|
||||
memcpy (data->value, value, sz);
|
||||
}
|
||||
data->value = ddsrt_memdup (value, sz);
|
||||
}
|
||||
|
||||
static bool dds_qos_data_copy_out (const ddsi_octetseq_t *data, void **value, size_t *sz)
|
||||
|
@ -52,57 +47,6 @@ static bool dds_qos_data_copy_out (const ddsi_octetseq_t *data, void **value, si
|
|||
return true;
|
||||
}
|
||||
|
||||
bool validate_octetseq (const ddsi_octetseq_t *seq)
|
||||
{
|
||||
/* default value is NULL with length 0 */
|
||||
return ((seq->length == 0 && seq->value == NULL) || (seq->length > 0 && seq->length < UINT32_MAX));
|
||||
}
|
||||
|
||||
bool validate_stringseq (const ddsi_stringseq_t *seq)
|
||||
{
|
||||
if (seq->n == 0)
|
||||
return (seq->strs == NULL);
|
||||
else
|
||||
{
|
||||
for (uint32_t i = 0; i < seq->n; i++)
|
||||
if (seq->strs[i] == NULL)
|
||||
return false;
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
bool validate_entityfactory_qospolicy (const dds_entity_factory_qospolicy_t *entityfactory)
|
||||
{
|
||||
/* Bools must be 0 or 1, i.e., only the lsb may be set */
|
||||
return !(entityfactory->autoenable_created_entities & ~1);
|
||||
}
|
||||
|
||||
bool validate_reliability_qospolicy (const dds_reliability_qospolicy_t *reliability)
|
||||
{
|
||||
return ((reliability->kind == DDS_RELIABILITY_BEST_EFFORT || reliability->kind == DDS_RELIABILITY_RELIABLE) &&
|
||||
(validate_duration (reliability->max_blocking_time) == 0));
|
||||
}
|
||||
|
||||
bool validate_deadline_and_timebased_filter (const dds_duration_t deadline, const dds_duration_t minimum_separation)
|
||||
{
|
||||
return (validate_duration (deadline) == DDS_RETCODE_OK &&
|
||||
validate_duration (minimum_separation) == DDS_RETCODE_OK &&
|
||||
minimum_separation <= deadline);
|
||||
}
|
||||
|
||||
bool dds_qos_validate_common (const dds_qos_t *qos)
|
||||
{
|
||||
return !(((qos->present & QP_DURABILITY) && validate_durability_qospolicy (&qos->durability) != DDS_RETCODE_OK) ||
|
||||
((qos->present & QP_DEADLINE) && validate_duration (qos->deadline.deadline) != DDS_RETCODE_OK) ||
|
||||
((qos->present & QP_LATENCY_BUDGET) && validate_duration (qos->latency_budget.duration) != DDS_RETCODE_OK) ||
|
||||
((qos->present & QP_OWNERSHIP) && validate_ownership_qospolicy (&qos->ownership) != DDS_RETCODE_OK) ||
|
||||
((qos->present & QP_LIVELINESS) && validate_liveliness_qospolicy (&qos->liveliness) != DDS_RETCODE_OK) ||
|
||||
((qos->present & QP_RELIABILITY) && ! validate_reliability_qospolicy (&qos->reliability)) ||
|
||||
((qos->present & QP_DESTINATION_ORDER) && validate_destination_order_qospolicy (&qos->destination_order) != DDS_RETCODE_OK) ||
|
||||
((qos->present & QP_HISTORY) && validate_history_qospolicy (&qos->history) != DDS_RETCODE_OK) ||
|
||||
((qos->present & QP_RESOURCE_LIMITS) && validate_resource_limits_qospolicy (&qos->resource_limits) != DDS_RETCODE_OK));
|
||||
}
|
||||
|
||||
dds_return_t dds_qos_validate_mutable_common (const dds_qos_t *qos)
|
||||
{
|
||||
/* FIXME: Check whether immutable QoS are changed should actually incorporate change to current QoS */
|
||||
|
@ -123,44 +67,10 @@ dds_return_t dds_qos_validate_mutable_common (const dds_qos_t *qos)
|
|||
return DDS_RETCODE_OK;
|
||||
}
|
||||
|
||||
static void dds_qos_init_defaults (dds_qos_t * __restrict qos) ddsrt_nonnull_all;
|
||||
|
||||
static void dds_qos_init_defaults (dds_qos_t * __restrict qos)
|
||||
{
|
||||
assert (qos);
|
||||
memset (qos, 0, sizeof (*qos));
|
||||
qos->durability.kind = DDS_DURABILITY_VOLATILE;
|
||||
qos->deadline.deadline = DDS_INFINITY;
|
||||
qos->durability_service.service_cleanup_delay = 0;
|
||||
qos->durability_service.history.kind = DDS_HISTORY_KEEP_LAST;
|
||||
qos->durability_service.history.depth = 1;
|
||||
qos->durability_service.resource_limits.max_samples = DDS_LENGTH_UNLIMITED;
|
||||
qos->durability_service.resource_limits.max_instances = DDS_LENGTH_UNLIMITED;
|
||||
qos->durability_service.resource_limits.max_samples_per_instance = DDS_LENGTH_UNLIMITED;
|
||||
qos->presentation.access_scope = DDS_PRESENTATION_INSTANCE;
|
||||
qos->latency_budget.duration = 0;
|
||||
qos->ownership.kind = DDS_OWNERSHIP_SHARED;
|
||||
qos->liveliness.kind = DDS_LIVELINESS_AUTOMATIC;
|
||||
qos->liveliness.lease_duration = DDS_INFINITY;
|
||||
qos->time_based_filter.minimum_separation = 0;
|
||||
qos->reliability.kind = DDS_RELIABILITY_BEST_EFFORT;
|
||||
qos->reliability.max_blocking_time = DDS_MSECS (100);
|
||||
qos->lifespan.duration = DDS_INFINITY;
|
||||
qos->destination_order.kind = DDS_DESTINATIONORDER_BY_RECEPTION_TIMESTAMP;
|
||||
qos->history.kind = DDS_HISTORY_KEEP_LAST;
|
||||
qos->history.depth = 1;
|
||||
qos->resource_limits.max_samples = DDS_LENGTH_UNLIMITED;
|
||||
qos->resource_limits.max_instances = DDS_LENGTH_UNLIMITED;
|
||||
qos->resource_limits.max_samples_per_instance = DDS_LENGTH_UNLIMITED;
|
||||
qos->writer_data_lifecycle.autodispose_unregistered_instances = true;
|
||||
qos->reader_data_lifecycle.autopurge_nowriter_samples_delay = DDS_INFINITY;
|
||||
qos->reader_data_lifecycle.autopurge_disposed_samples_delay = DDS_INFINITY;
|
||||
}
|
||||
|
||||
dds_qos_t *dds_create_qos (void)
|
||||
{
|
||||
dds_qos_t *qos = dds_alloc (sizeof (dds_qos_t));
|
||||
dds_qos_init_defaults (qos);
|
||||
dds_qos_t *qos = ddsrt_malloc (sizeof (dds_qos_t));
|
||||
nn_xqos_init_empty (qos);
|
||||
return qos;
|
||||
}
|
||||
|
||||
|
@ -174,7 +84,7 @@ void dds_reset_qos (dds_qos_t * __restrict qos)
|
|||
if (qos)
|
||||
{
|
||||
nn_xqos_fini (qos);
|
||||
dds_qos_init_defaults (qos);
|
||||
nn_xqos_init_empty (qos);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -187,8 +97,8 @@ void dds_delete_qos (dds_qos_t * __restrict qos)
|
|||
{
|
||||
if (qos)
|
||||
{
|
||||
dds_reset_qos(qos);
|
||||
dds_free(qos);
|
||||
nn_xqos_fini (qos);
|
||||
ddsrt_free (qos);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -214,7 +124,7 @@ void dds_merge_qos (dds_qos_t * __restrict dst, const dds_qos_t * __restrict src
|
|||
{
|
||||
/* Copy qos from source to destination unless already set */
|
||||
if (src != NULL && dst != NULL)
|
||||
nn_xqos_mergein_missing (dst, src);
|
||||
nn_xqos_mergein_missing (dst, src, ~(uint64_t)0);
|
||||
}
|
||||
|
||||
void dds_qos_merge (dds_qos_t * __restrict dst, const dds_qos_t * __restrict src)
|
||||
|
@ -235,155 +145,140 @@ bool dds_qos_equal (const dds_qos_t * __restrict a, const dds_qos_t * __restrict
|
|||
|
||||
void dds_qset_userdata (dds_qos_t * __restrict qos, const void * __restrict value, size_t sz)
|
||||
{
|
||||
if (qos != NULL)
|
||||
{
|
||||
dds_qos_data_copy_in (&qos->user_data, value, sz);
|
||||
qos->present |= QP_USER_DATA;
|
||||
}
|
||||
if (qos == NULL || (sz > 0 && value == NULL))
|
||||
return;
|
||||
dds_qos_data_copy_in (&qos->user_data, value, sz, qos->present & QP_USER_DATA);
|
||||
qos->present |= QP_USER_DATA;
|
||||
}
|
||||
|
||||
void dds_qset_topicdata (dds_qos_t * __restrict qos, const void * __restrict value, size_t sz)
|
||||
{
|
||||
if (qos != NULL)
|
||||
{
|
||||
dds_qos_data_copy_in (&qos->topic_data, value, sz);
|
||||
qos->present |= QP_TOPIC_DATA;
|
||||
}
|
||||
if (qos == NULL || (sz > 0 && value == NULL))
|
||||
return;
|
||||
dds_qos_data_copy_in (&qos->topic_data, value, sz, qos->present & QP_TOPIC_DATA);
|
||||
qos->present |= QP_TOPIC_DATA;
|
||||
}
|
||||
|
||||
void dds_qset_groupdata (dds_qos_t * __restrict qos, const void * __restrict value, size_t sz)
|
||||
{
|
||||
if (qos != NULL)
|
||||
{
|
||||
dds_qos_data_copy_in (&qos->group_data, value, sz);
|
||||
qos->present |= QP_GROUP_DATA;
|
||||
}
|
||||
if (qos == NULL || (sz > 0 && value == NULL))
|
||||
return;
|
||||
dds_qos_data_copy_in (&qos->group_data, value, sz, qos->present & QP_GROUP_DATA);
|
||||
qos->present |= QP_GROUP_DATA;
|
||||
}
|
||||
|
||||
void dds_qset_durability (dds_qos_t * __restrict qos, dds_durability_kind_t kind)
|
||||
{
|
||||
if (qos != NULL)
|
||||
{
|
||||
qos->durability.kind = kind;
|
||||
qos->present |= QP_DURABILITY;
|
||||
}
|
||||
if (qos == NULL)
|
||||
return;
|
||||
qos->durability.kind = kind;
|
||||
qos->present |= QP_DURABILITY;
|
||||
}
|
||||
|
||||
void dds_qset_history (dds_qos_t * __restrict qos, dds_history_kind_t kind, int32_t depth)
|
||||
{
|
||||
if (qos != NULL)
|
||||
{
|
||||
qos->history.kind = kind;
|
||||
qos->history.depth = depth;
|
||||
qos->present |= QP_HISTORY;
|
||||
}
|
||||
if (qos == NULL)
|
||||
return;
|
||||
qos->history.kind = kind;
|
||||
qos->history.depth = depth;
|
||||
qos->present |= QP_HISTORY;
|
||||
}
|
||||
|
||||
void dds_qset_resource_limits (dds_qos_t * __restrict qos, int32_t max_samples, int32_t max_instances, int32_t max_samples_per_instance)
|
||||
{
|
||||
if (qos != NULL)
|
||||
{
|
||||
qos->resource_limits.max_samples = max_samples;
|
||||
qos->resource_limits.max_instances = max_instances;
|
||||
qos->resource_limits.max_samples_per_instance = max_samples_per_instance;
|
||||
qos->present |= QP_RESOURCE_LIMITS;
|
||||
}
|
||||
if (qos == NULL)
|
||||
return;
|
||||
qos->resource_limits.max_samples = max_samples;
|
||||
qos->resource_limits.max_instances = max_instances;
|
||||
qos->resource_limits.max_samples_per_instance = max_samples_per_instance;
|
||||
qos->present |= QP_RESOURCE_LIMITS;
|
||||
}
|
||||
|
||||
void dds_qset_presentation (dds_qos_t * __restrict qos, dds_presentation_access_scope_kind_t access_scope, bool coherent_access, bool ordered_access)
|
||||
{
|
||||
if (qos != NULL)
|
||||
{
|
||||
qos->presentation.access_scope = access_scope;
|
||||
qos->presentation.coherent_access = coherent_access;
|
||||
qos->presentation.ordered_access = ordered_access;
|
||||
qos->present |= QP_PRESENTATION;
|
||||
}
|
||||
if (qos == NULL)
|
||||
return;
|
||||
qos->presentation.access_scope = access_scope;
|
||||
qos->presentation.coherent_access = coherent_access;
|
||||
qos->presentation.ordered_access = ordered_access;
|
||||
qos->present |= QP_PRESENTATION;
|
||||
}
|
||||
|
||||
void dds_qset_lifespan (dds_qos_t * __restrict qos, dds_duration_t lifespan)
|
||||
{
|
||||
if (qos != NULL)
|
||||
{
|
||||
qos->lifespan.duration = lifespan;
|
||||
qos->present |= QP_LIFESPAN;
|
||||
}
|
||||
if (qos == NULL)
|
||||
return;
|
||||
qos->lifespan.duration = lifespan;
|
||||
qos->present |= QP_LIFESPAN;
|
||||
}
|
||||
|
||||
void dds_qset_deadline (dds_qos_t * __restrict qos, dds_duration_t deadline)
|
||||
{
|
||||
if (qos != NULL)
|
||||
{
|
||||
qos->deadline.deadline = deadline;
|
||||
qos->present |= QP_DEADLINE;
|
||||
}
|
||||
if (qos == NULL)
|
||||
return;
|
||||
qos->deadline.deadline = deadline;
|
||||
qos->present |= QP_DEADLINE;
|
||||
}
|
||||
|
||||
void dds_qset_latency_budget (dds_qos_t * __restrict qos, dds_duration_t duration)
|
||||
{
|
||||
if (qos != NULL)
|
||||
{
|
||||
qos->latency_budget.duration = duration;
|
||||
qos->present |= QP_LATENCY_BUDGET;
|
||||
}
|
||||
if (qos == NULL)
|
||||
return;
|
||||
qos->latency_budget.duration = duration;
|
||||
qos->present |= QP_LATENCY_BUDGET;
|
||||
}
|
||||
|
||||
void dds_qset_ownership (dds_qos_t * __restrict qos, dds_ownership_kind_t kind)
|
||||
{
|
||||
if (qos != NULL)
|
||||
{
|
||||
qos->ownership.kind = kind;
|
||||
qos->present |= QP_OWNERSHIP;
|
||||
}
|
||||
if (qos == NULL)
|
||||
return;
|
||||
qos->ownership.kind = kind;
|
||||
qos->present |= QP_OWNERSHIP;
|
||||
}
|
||||
|
||||
void dds_qset_ownership_strength (dds_qos_t * __restrict qos, int32_t value)
|
||||
{
|
||||
if (qos != NULL)
|
||||
{
|
||||
qos->ownership_strength.value = value;
|
||||
qos->present |= QP_OWNERSHIP_STRENGTH;
|
||||
}
|
||||
if (qos == NULL)
|
||||
return;
|
||||
qos->ownership_strength.value = value;
|
||||
qos->present |= QP_OWNERSHIP_STRENGTH;
|
||||
}
|
||||
|
||||
void dds_qset_liveliness (dds_qos_t * __restrict qos, dds_liveliness_kind_t kind, dds_duration_t lease_duration)
|
||||
{
|
||||
if (qos != NULL)
|
||||
{
|
||||
qos->liveliness.kind = kind;
|
||||
qos->liveliness.lease_duration = lease_duration;
|
||||
qos->present |= QP_LIVELINESS;
|
||||
}
|
||||
if (qos == NULL)
|
||||
return;
|
||||
qos->liveliness.kind = kind;
|
||||
qos->liveliness.lease_duration = lease_duration;
|
||||
qos->present |= QP_LIVELINESS;
|
||||
}
|
||||
|
||||
void dds_qset_time_based_filter (dds_qos_t * __restrict qos, dds_duration_t minimum_separation)
|
||||
{
|
||||
if (qos != NULL)
|
||||
{
|
||||
qos->time_based_filter.minimum_separation = minimum_separation;
|
||||
qos->present |= QP_TIME_BASED_FILTER;
|
||||
}
|
||||
if (qos == NULL)
|
||||
return;
|
||||
qos->time_based_filter.minimum_separation = minimum_separation;
|
||||
qos->present |= QP_TIME_BASED_FILTER;
|
||||
}
|
||||
|
||||
void dds_qset_partition (dds_qos_t * __restrict qos, uint32_t n, const char ** __restrict ps)
|
||||
{
|
||||
if (qos == NULL || (n && ps == NULL))
|
||||
if (qos == NULL || (n > 0 && ps == NULL))
|
||||
return;
|
||||
|
||||
if (qos->partition.strs != NULL)
|
||||
if (qos->present & QP_PARTITION)
|
||||
{
|
||||
for (uint32_t i = 0; i < qos->partition.n; i++)
|
||||
dds_free (qos->partition.strs[i]);
|
||||
dds_free (qos->partition.strs);
|
||||
qos->partition.strs = NULL;
|
||||
ddsrt_free (qos->partition.strs[i]);
|
||||
ddsrt_free (qos->partition.strs);
|
||||
}
|
||||
|
||||
qos->partition.n = n;
|
||||
if (n > 0)
|
||||
if (qos->partition.n == 0)
|
||||
qos->partition.strs = NULL;
|
||||
else
|
||||
{
|
||||
qos->partition.strs = dds_alloc (sizeof (char*) * n);
|
||||
qos->partition.strs = ddsrt_malloc (n * sizeof (*qos->partition.strs));
|
||||
for (uint32_t i = 0; i < n; i++)
|
||||
qos->partition.strs[i] = dds_string_dup (ps[i]);
|
||||
qos->partition.strs[i] = ddsrt_strdup (ps[i]);
|
||||
}
|
||||
qos->present |= QP_PARTITION;
|
||||
}
|
||||
|
@ -398,72 +293,65 @@ void dds_qset_partition1 (dds_qos_t * __restrict qos, const char * __restrict na
|
|||
|
||||
void dds_qset_reliability (dds_qos_t * __restrict qos, dds_reliability_kind_t kind, dds_duration_t max_blocking_time)
|
||||
{
|
||||
if (qos != NULL)
|
||||
{
|
||||
qos->reliability.kind = kind;
|
||||
qos->reliability.max_blocking_time = max_blocking_time;
|
||||
qos->present |= QP_RELIABILITY;
|
||||
}
|
||||
if (qos == NULL)
|
||||
return;
|
||||
qos->reliability.kind = kind;
|
||||
qos->reliability.max_blocking_time = max_blocking_time;
|
||||
qos->present |= QP_RELIABILITY;
|
||||
}
|
||||
|
||||
void dds_qset_transport_priority (dds_qos_t * __restrict qos, int32_t value)
|
||||
{
|
||||
if (qos != NULL)
|
||||
{
|
||||
qos->transport_priority.value = value;
|
||||
qos->present |= QP_TRANSPORT_PRIORITY;
|
||||
}
|
||||
if (qos == NULL)
|
||||
return;
|
||||
qos->transport_priority.value = value;
|
||||
qos->present |= QP_TRANSPORT_PRIORITY;
|
||||
}
|
||||
|
||||
void dds_qset_destination_order (dds_qos_t * __restrict qos, dds_destination_order_kind_t kind)
|
||||
{
|
||||
if (qos != NULL)
|
||||
{
|
||||
qos->destination_order.kind = kind;
|
||||
qos->present |= QP_DESTINATION_ORDER;
|
||||
}
|
||||
if (qos == NULL)
|
||||
return;
|
||||
qos->destination_order.kind = kind;
|
||||
qos->present |= QP_DESTINATION_ORDER;
|
||||
}
|
||||
|
||||
void dds_qset_writer_data_lifecycle (dds_qos_t * __restrict qos, bool autodispose)
|
||||
{
|
||||
if (qos != NULL)
|
||||
{
|
||||
qos->writer_data_lifecycle.autodispose_unregistered_instances = autodispose;
|
||||
qos->present |= QP_PRISMTECH_WRITER_DATA_LIFECYCLE;
|
||||
}
|
||||
if (qos == NULL)
|
||||
return;
|
||||
qos->writer_data_lifecycle.autodispose_unregistered_instances = autodispose;
|
||||
qos->present |= QP_PRISMTECH_WRITER_DATA_LIFECYCLE;
|
||||
}
|
||||
|
||||
void dds_qset_reader_data_lifecycle (dds_qos_t * __restrict qos, dds_duration_t autopurge_nowriter_samples_delay, dds_duration_t autopurge_disposed_samples_delay)
|
||||
{
|
||||
if (qos != NULL)
|
||||
{
|
||||
qos->reader_data_lifecycle.autopurge_nowriter_samples_delay = autopurge_nowriter_samples_delay;
|
||||
qos->reader_data_lifecycle.autopurge_disposed_samples_delay = autopurge_disposed_samples_delay;
|
||||
qos->present |= QP_PRISMTECH_READER_DATA_LIFECYCLE;
|
||||
}
|
||||
if (qos == NULL)
|
||||
return;
|
||||
qos->reader_data_lifecycle.autopurge_nowriter_samples_delay = autopurge_nowriter_samples_delay;
|
||||
qos->reader_data_lifecycle.autopurge_disposed_samples_delay = autopurge_disposed_samples_delay;
|
||||
qos->present |= QP_PRISMTECH_READER_DATA_LIFECYCLE;
|
||||
}
|
||||
|
||||
void dds_qset_durability_service (dds_qos_t * __restrict qos, dds_duration_t service_cleanup_delay, dds_history_kind_t history_kind, int32_t history_depth, int32_t max_samples, int32_t max_instances, int32_t max_samples_per_instance)
|
||||
{
|
||||
if (qos != NULL)
|
||||
{
|
||||
qos->durability_service.service_cleanup_delay = service_cleanup_delay;
|
||||
qos->durability_service.history.kind = history_kind;
|
||||
qos->durability_service.history.depth = history_depth;
|
||||
qos->durability_service.resource_limits.max_samples = max_samples;
|
||||
qos->durability_service.resource_limits.max_instances = max_instances;
|
||||
qos->durability_service.resource_limits.max_samples_per_instance = max_samples_per_instance;
|
||||
qos->present |= QP_DURABILITY_SERVICE;
|
||||
}
|
||||
if (qos == NULL)
|
||||
return;
|
||||
qos->durability_service.service_cleanup_delay = service_cleanup_delay;
|
||||
qos->durability_service.history.kind = history_kind;
|
||||
qos->durability_service.history.depth = history_depth;
|
||||
qos->durability_service.resource_limits.max_samples = max_samples;
|
||||
qos->durability_service.resource_limits.max_instances = max_instances;
|
||||
qos->durability_service.resource_limits.max_samples_per_instance = max_samples_per_instance;
|
||||
qos->present |= QP_DURABILITY_SERVICE;
|
||||
}
|
||||
|
||||
void dds_qset_ignorelocal (dds_qos_t * __restrict qos, dds_ignorelocal_kind_t ignore)
|
||||
{
|
||||
if (qos != NULL)
|
||||
{
|
||||
qos->ignorelocal.value = ignore;
|
||||
qos->present |= QP_CYCLONE_IGNORELOCAL;
|
||||
}
|
||||
if (qos == NULL)
|
||||
return;
|
||||
qos->ignorelocal.value = ignore;
|
||||
qos->present |= QP_CYCLONE_IGNORELOCAL;
|
||||
}
|
||||
|
||||
bool dds_qget_userdata (const dds_qos_t * __restrict qos, void **value, size_t *sz)
|
||||
|
|
|
@ -81,18 +81,9 @@ static dds_return_t dds_reader_qos_validate (const dds_qos_t *qos, bool enabled)
|
|||
|
||||
static dds_return_t dds_reader_qos_validate (const dds_qos_t *qos, bool enabled)
|
||||
{
|
||||
if (!dds_qos_validate_common (qos))
|
||||
return DDS_RETCODE_ERROR;
|
||||
if ((qos->present & QP_USER_DATA) && !validate_octetseq (&qos->user_data))
|
||||
return DDS_RETCODE_INCONSISTENT_POLICY;
|
||||
if ((qos->present & QP_PRISMTECH_READER_DATA_LIFECYCLE) && validate_reader_data_lifecycle (&qos->reader_data_lifecycle) < 0)
|
||||
return DDS_RETCODE_INCONSISTENT_POLICY;
|
||||
if ((qos->present & QP_TIME_BASED_FILTER) && validate_duration (qos->time_based_filter.minimum_separation) < 0)
|
||||
return DDS_RETCODE_INCONSISTENT_POLICY;
|
||||
if ((qos->present & QP_HISTORY) && (qos->present & QP_RESOURCE_LIMITS) && validate_history_and_resource_limits (&qos->history, &qos->resource_limits) < 0)
|
||||
return DDS_RETCODE_INCONSISTENT_POLICY;
|
||||
if ((qos->present & QP_TIME_BASED_FILTER) && (qos->present & QP_DEADLINE) && !validate_deadline_and_timebased_filter (qos->deadline.deadline, qos->time_based_filter.minimum_separation))
|
||||
return DDS_RETCODE_INCONSISTENT_POLICY;
|
||||
dds_return_t ret;
|
||||
if ((ret = nn_xqos_valid (qos)) < 0)
|
||||
return ret;
|
||||
return (enabled ? dds_qos_validate_mutable_common (qos) : DDS_RETCODE_OK);
|
||||
}
|
||||
|
||||
|
@ -372,20 +363,15 @@ dds_entity_t dds_create_reader (dds_entity_t participant_or_subscriber, dds_enti
|
|||
|
||||
/* Merge qos from topic and subscriber, dds_copy_qos only fails when it is passed a null
|
||||
argument, but that isn't the case here */
|
||||
#define DDS_QOSMASK_READER (QP_USER_DATA | QP_DURABILITY | QP_DEADLINE | QP_LATENCY_BUDGET | QP_OWNERSHIP | QP_LIVELINESS | QP_TIME_BASED_FILTER | QP_RELIABILITY | QP_DESTINATION_ORDER | QP_HISTORY | QP_RESOURCE_LIMITS | QP_PRISMTECH_READER_DATA_LIFECYCLE | QP_CYCLONE_IGNORELOCAL)
|
||||
rqos = dds_create_qos ();
|
||||
if (qos)
|
||||
(void) dds_copy_qos (rqos, qos);
|
||||
|
||||
nn_xqos_mergein_missing (rqos, qos, DDS_QOSMASK_READER);
|
||||
if (sub->m_entity.m_qos)
|
||||
dds_merge_qos (rqos, sub->m_entity.m_qos);
|
||||
|
||||
nn_xqos_mergein_missing (rqos, sub->m_entity.m_qos, ~(uint64_t)0);
|
||||
if (tp->m_entity.m_qos)
|
||||
{
|
||||
dds_merge_qos (rqos, tp->m_entity.m_qos);
|
||||
/* reset the following qos policies if set during topic qos merge as they aren't applicable for reader */
|
||||
rqos->present &= ~(QP_DURABILITY_SERVICE | QP_TRANSPORT_PRIORITY | QP_LIFESPAN);
|
||||
}
|
||||
nn_xqos_mergein_missing (rqos, &gv.default_xqos_rd);
|
||||
nn_xqos_mergein_missing (rqos, tp->m_entity.m_qos, ~(uint64_t)0);
|
||||
nn_xqos_mergein_missing (rqos, &gv.default_xqos_rd, ~(uint64_t)0);
|
||||
|
||||
if ((ret = dds_reader_qos_validate (rqos, false)) != DDS_RETCODE_OK)
|
||||
{
|
||||
|
@ -397,7 +383,7 @@ dds_entity_t dds_create_reader (dds_entity_t participant_or_subscriber, dds_enti
|
|||
/* Additional checks required for built-in topics: we don't want to
|
||||
run into a resource limit on a built-in topic, it is a needless
|
||||
complication */
|
||||
if (internal_topic && !dds__validate_builtin_reader_qos (topic, qos))
|
||||
if (internal_topic && !dds__validate_builtin_reader_qos (topic, rqos))
|
||||
{
|
||||
dds_delete_qos (rqos);
|
||||
reader = DDS_RETCODE_INCONSISTENT_POLICY;
|
||||
|
|
|
@ -19,6 +19,7 @@
|
|||
#include "dds/ddsi/q_bswap.h"
|
||||
#include "dds/ddsi/q_config.h"
|
||||
#include "dds/ddsi/q_freelist.h"
|
||||
#include "dds/ddsi/q_plist.h"
|
||||
#include "dds__stream.h"
|
||||
#include "dds__serdata_builtintopic.h"
|
||||
#include "dds/ddsi/ddsi_tkmap.h"
|
||||
|
@ -193,7 +194,7 @@ static dds_qos_t *dds_qos_from_xqos_reuse (dds_qos_t *old, const dds_qos_t *src)
|
|||
old = ddsrt_malloc (sizeof (*old));
|
||||
nn_xqos_init_empty (old);
|
||||
old->present |= QP_TOPIC_NAME | QP_TYPE_NAME;
|
||||
nn_xqos_mergein_missing (old, src);
|
||||
nn_xqos_mergein_missing (old, src, ~(uint64_t)0);
|
||||
old->present &= ~(QP_TOPIC_NAME | QP_TYPE_NAME);
|
||||
}
|
||||
else
|
||||
|
@ -201,7 +202,7 @@ static dds_qos_t *dds_qos_from_xqos_reuse (dds_qos_t *old, const dds_qos_t *src)
|
|||
nn_xqos_fini (old);
|
||||
nn_xqos_init_empty (old);
|
||||
old->present |= QP_TOPIC_NAME | QP_TYPE_NAME;
|
||||
nn_xqos_mergein_missing (old, src);
|
||||
nn_xqos_mergein_missing (old, src, ~(uint64_t)0);
|
||||
old->present &= ~(QP_TOPIC_NAME | QP_TYPE_NAME);
|
||||
}
|
||||
return old;
|
||||
|
|
|
@ -15,6 +15,7 @@
|
|||
#include "dds__qos.h"
|
||||
#include "dds__subscriber.h"
|
||||
#include "dds/ddsi/q_entity.h"
|
||||
#include "dds/ddsi/q_globals.h"
|
||||
#include "dds/version.h"
|
||||
|
||||
DECL_ENTITY_LOCK_UNLOCK (extern inline, dds_subscriber)
|
||||
|
@ -36,15 +37,9 @@ static dds_return_t dds__subscriber_qos_validate (const dds_qos_t *qos, bool ena
|
|||
|
||||
static dds_return_t dds__subscriber_qos_validate (const dds_qos_t *qos, bool enabled)
|
||||
{
|
||||
if ((qos->present & QP_GROUP_DATA) && !validate_octetseq (&qos->group_data))
|
||||
return DDS_RETCODE_INCONSISTENT_POLICY;
|
||||
if ((qos->present & QP_PARTITION) && !validate_stringseq (&qos->partition))
|
||||
return DDS_RETCODE_INCONSISTENT_POLICY;
|
||||
if ((qos->present & QP_PRESENTATION) && validate_presentation_qospolicy (&qos->presentation) < 0)
|
||||
return DDS_RETCODE_INCONSISTENT_POLICY;
|
||||
if ((qos->present & QP_PRISMTECH_ENTITY_FACTORY) && !validate_entityfactory_qospolicy (&qos->entity_factory))
|
||||
return DDS_RETCODE_INCONSISTENT_POLICY;
|
||||
/* FIXME: Improve/check immutable check. */
|
||||
dds_return_t ret;
|
||||
if ((ret = nn_xqos_valid (qos)) < 0)
|
||||
return ret;
|
||||
return (enabled && (qos->present & QP_PRESENTATION)) ? DDS_RETCODE_IMMUTABLE_POLICY : DDS_RETCODE_OK;
|
||||
}
|
||||
|
||||
|
@ -73,16 +68,15 @@ dds_entity_t dds__create_subscriber_l (dds_participant *participant, const dds_q
|
|||
dds_return_t ret;
|
||||
dds_qos_t *new_qos;
|
||||
|
||||
/* Validate qos */
|
||||
if (qos && (ret = dds__subscriber_qos_validate (qos, false)) != DDS_RETCODE_OK)
|
||||
return ret;
|
||||
|
||||
if (qos == NULL)
|
||||
new_qos = NULL;
|
||||
else
|
||||
#define DDS_QOSMASK_SUBSCRIBER (QP_PARTITION | QP_PRESENTATION | QP_GROUP_DATA | QP_PRISMTECH_ENTITY_FACTORY | QP_CYCLONE_IGNORELOCAL)
|
||||
new_qos = dds_create_qos ();
|
||||
if (qos)
|
||||
nn_xqos_mergein_missing (new_qos, qos, DDS_QOSMASK_SUBSCRIBER);
|
||||
nn_xqos_mergein_missing (new_qos, &gv.default_xqos_sub, ~(uint64_t)0);
|
||||
if ((ret = dds__subscriber_qos_validate (new_qos, false)) != DDS_RETCODE_OK)
|
||||
{
|
||||
new_qos = dds_create_qos ();
|
||||
(void) dds_copy_qos (new_qos, qos);
|
||||
dds_delete_qos (new_qos);
|
||||
return ret;
|
||||
}
|
||||
|
||||
sub = dds_alloc (sizeof (*sub));
|
||||
|
|
|
@ -14,6 +14,8 @@
|
|||
#include <ctype.h>
|
||||
|
||||
#include "dds/ddsrt/atomics.h"
|
||||
#include "dds/ddsrt/heap.h"
|
||||
#include "dds/ddsrt/string.h"
|
||||
#include "dds__topic.h"
|
||||
#include "dds__listener.h"
|
||||
#include "dds__qos.h"
|
||||
|
@ -27,6 +29,8 @@
|
|||
#include "dds/ddsi/ddsi_sertopic.h"
|
||||
#include "dds/ddsi/q_ddsi_discovery.h"
|
||||
#include "dds/ddsi/ddsi_iid.h"
|
||||
#include "dds/ddsi/q_plist.h"
|
||||
#include "dds/ddsi/q_globals.h"
|
||||
|
||||
DECL_ENTITY_LOCK_UNLOCK (extern inline, dds_topic)
|
||||
|
||||
|
@ -182,17 +186,10 @@ static dds_return_t dds_topic_qos_validate (const dds_qos_t *qos, bool enabled)
|
|||
|
||||
static dds_return_t dds_topic_qos_validate (const dds_qos_t *qos, bool enabled)
|
||||
{
|
||||
if (!dds_qos_validate_common (qos))
|
||||
return DDS_RETCODE_BAD_PARAMETER;
|
||||
if ((qos->present & QP_GROUP_DATA) && !validate_octetseq (&qos->group_data))
|
||||
return DDS_RETCODE_INCONSISTENT_POLICY;
|
||||
if ((qos->present & QP_DURABILITY_SERVICE) && validate_durability_service_qospolicy(&qos->durability_service) < 0)
|
||||
return DDS_RETCODE_INCONSISTENT_POLICY;
|
||||
if ((qos->present & QP_LIFESPAN) && validate_duration(qos->lifespan.duration) < 0)
|
||||
return DDS_RETCODE_INCONSISTENT_POLICY;
|
||||
if ((qos->present & QP_HISTORY) && (qos->present & QP_RESOURCE_LIMITS) && validate_history_and_resource_limits(&qos->history, &qos->resource_limits) < 0)
|
||||
return DDS_RETCODE_INCONSISTENT_POLICY;
|
||||
return enabled ? dds_qos_validate_mutable_common(qos) : DDS_RETCODE_OK;
|
||||
dds_return_t ret;
|
||||
if ((ret = nn_xqos_valid (qos)) < 0)
|
||||
return ret;
|
||||
return enabled ? dds_qos_validate_mutable_common (qos) : DDS_RETCODE_OK;
|
||||
}
|
||||
|
||||
|
||||
|
@ -333,8 +330,8 @@ dds_entity_t dds_create_topic (dds_entity_t participant, const dds_topic_descrip
|
|||
st->c.status_cb = dds_topic_status_cb;
|
||||
st->c.status_cb_entity = NULL; /* set by dds_create_topic_arbitrary */
|
||||
st->c.name_type_name = key;
|
||||
st->c.name = dds_string_dup (name);
|
||||
st->c.type_name = dds_string_dup (typename);
|
||||
st->c.name = ddsrt_strdup (name);
|
||||
st->c.type_name = ddsrt_strdup (typename);
|
||||
st->c.ops = &ddsi_sertopic_ops_default;
|
||||
st->c.serdata_ops = desc->m_nkeys ? &ddsi_serdata_ops_cdr : &ddsi_serdata_ops_cdr_nokey;
|
||||
st->c.serdata_basehash = ddsi_sertopic_compute_serdata_basehash (st->c.serdata_ops);
|
||||
|
@ -349,13 +346,15 @@ dds_entity_t dds_create_topic (dds_entity_t participant, const dds_topic_descrip
|
|||
st->opt_size = dds_stream_check_optimize (desc);
|
||||
}
|
||||
|
||||
#define DDS_QOSMASK_TOPIC (QP_TOPIC_DATA | QP_DURABILITY | QP_DURABILITY_SERVICE | QP_DEADLINE | QP_LATENCY_BUDGET | QP_OWNERSHIP | QP_LIVELINESS | QP_RELIABILITY | QP_TRANSPORT_PRIORITY | QP_LIFESPAN | QP_DESTINATION_ORDER | QP_HISTORY | QP_RESOURCE_LIMITS)
|
||||
nn_plist_init_empty (&plist);
|
||||
if (new_qos)
|
||||
dds_merge_qos (&plist.qos, new_qos);
|
||||
nn_xqos_mergein_missing (&plist.qos, new_qos, DDS_QOSMASK_TOPIC);
|
||||
nn_xqos_mergein_missing (&plist.qos, &gv.default_xqos_tp, DDS_QOSMASK_TOPIC);
|
||||
|
||||
/* Set Topic meta data (for SEDP publication) */
|
||||
plist.qos.topic_name = dds_string_dup (st->c.name);
|
||||
plist.qos.type_name = dds_string_dup (st->c.type_name);
|
||||
plist.qos.topic_name = ddsrt_strdup (st->c.name);
|
||||
plist.qos.type_name = ddsrt_strdup (st->c.type_name);
|
||||
plist.qos.present |= (QP_TOPIC_NAME | QP_TYPE_NAME);
|
||||
if (desc->m_meta)
|
||||
{
|
||||
|
|
|
@ -208,16 +208,9 @@ static dds_return_t dds_writer_delete (dds_entity *e)
|
|||
|
||||
static dds_return_t dds_writer_qos_validate (const dds_qos_t *qos, bool enabled)
|
||||
{
|
||||
if (!dds_qos_validate_common(qos))
|
||||
return DDS_RETCODE_INCONSISTENT_POLICY;
|
||||
if ((qos->present & QP_USER_DATA) && !validate_octetseq (&qos->user_data))
|
||||
return DDS_RETCODE_INCONSISTENT_POLICY;
|
||||
if ((qos->present & QP_DURABILITY_SERVICE) && validate_durability_service_qospolicy (&qos->durability_service) < 0)
|
||||
return DDS_RETCODE_INCONSISTENT_POLICY;
|
||||
if ((qos->present & QP_LIFESPAN) && validate_duration (qos->lifespan.duration) < 0)
|
||||
return DDS_RETCODE_INCONSISTENT_POLICY;
|
||||
if ((qos->present & QP_HISTORY) && (qos->present & QP_RESOURCE_LIMITS) && validate_history_and_resource_limits(&qos->history, &qos->resource_limits) < 0)
|
||||
return DDS_RETCODE_INCONSISTENT_POLICY;
|
||||
dds_return_t ret;
|
||||
if ((ret = nn_xqos_valid (qos)) < 0)
|
||||
return ret;
|
||||
return enabled ? dds_qos_validate_mutable_common (qos) : DDS_RETCODE_OK;
|
||||
}
|
||||
|
||||
|
@ -316,14 +309,15 @@ dds_entity_t dds_create_writer (dds_entity_t participant_or_publisher, dds_entit
|
|||
assert (pub->m_entity.m_domain == tp->m_entity.m_domain);
|
||||
|
||||
/* Merge Topic & Publisher qos */
|
||||
#define DDS_QOSMASK_WRITER (QP_USER_DATA | QP_DURABILITY | QP_DURABILITY_SERVICE | QP_DEADLINE | QP_LATENCY_BUDGET | QP_OWNERSHIP | QP_OWNERSHIP_STRENGTH | QP_LIVELINESS | QP_RELIABILITY | QP_TRANSPORT_PRIORITY | QP_LIFESPAN | QP_DESTINATION_ORDER | QP_HISTORY | QP_RESOURCE_LIMITS | QP_PRISMTECH_WRITER_DATA_LIFECYCLE | QP_CYCLONE_IGNORELOCAL)
|
||||
wqos = dds_create_qos ();
|
||||
if (qos)
|
||||
(void) dds_copy_qos (wqos, qos);
|
||||
nn_xqos_mergein_missing (wqos, qos, DDS_QOSMASK_WRITER);
|
||||
if (pub->m_entity.m_qos)
|
||||
dds_merge_qos (wqos, pub->m_entity.m_qos);
|
||||
nn_xqos_mergein_missing (wqos, pub->m_entity.m_qos, ~(uint64_t)0);
|
||||
if (tp->m_entity.m_qos)
|
||||
dds_merge_qos (wqos, tp->m_entity.m_qos);
|
||||
nn_xqos_mergein_missing (wqos, &gv.default_xqos_wr);
|
||||
nn_xqos_mergein_missing (wqos, tp->m_entity.m_qos, ~(uint64_t)0);
|
||||
nn_xqos_mergein_missing (wqos, &gv.default_xqos_wr, ~(uint64_t)0);
|
||||
|
||||
if ((rc = dds_writer_qos_validate (wqos, false)) != DDS_RETCODE_OK)
|
||||
{
|
||||
|
|
|
@ -241,7 +241,7 @@ CU_Test(ddsc_reader_create, invalid_qos_participant, .init=reader_init, .fini=re
|
|||
dds_qset_reader_data_lifecycle(qos, DDS_SECS(-1), DDS_SECS(-1));
|
||||
DDSRT_WARNING_MSVC_ON(28020);
|
||||
rdr = dds_create_reader(g_participant, g_topic, qos, NULL);
|
||||
CU_ASSERT_EQUAL_FATAL(rdr, DDS_RETCODE_INCONSISTENT_POLICY);
|
||||
CU_ASSERT_EQUAL_FATAL(rdr, DDS_RETCODE_BAD_PARAMETER);
|
||||
dds_delete_qos(qos);
|
||||
}
|
||||
/*************************************************************************************************/
|
||||
|
@ -256,7 +256,7 @@ CU_Test(ddsc_reader_create, invalid_qos_subscriber, .init=reader_init, .fini=rea
|
|||
dds_qset_reader_data_lifecycle(qos, DDS_SECS(-1), DDS_SECS(-1));
|
||||
DDSRT_WARNING_MSVC_ON(28020);
|
||||
rdr = dds_create_reader(g_subscriber, g_topic, qos, NULL);
|
||||
CU_ASSERT_EQUAL_FATAL(rdr, DDS_RETCODE_INCONSISTENT_POLICY);
|
||||
CU_ASSERT_EQUAL_FATAL(rdr, DDS_RETCODE_BAD_PARAMETER);
|
||||
dds_delete_qos(qos);
|
||||
}
|
||||
/*************************************************************************************************/
|
||||
|
|
|
@ -91,7 +91,7 @@ CU_Test(ddsc_subscriber, create) {
|
|||
sqos = dds_create_qos();
|
||||
dds_qset_presentation(sqos, 123, 1, 1); /* Set invalid presentation policy */
|
||||
subscriber = dds_create_subscriber(participant, sqos, NULL);
|
||||
CU_ASSERT_EQUAL_FATAL(subscriber, DDS_RETCODE_INCONSISTENT_POLICY);
|
||||
CU_ASSERT_EQUAL_FATAL(subscriber, DDS_RETCODE_BAD_PARAMETER);
|
||||
dds_delete_qos(sqos);
|
||||
|
||||
/*** Verify listener parameter ***/
|
||||
|
|
|
@ -105,7 +105,7 @@ CU_Test(ddsc_topic_create, invalid_qos, .init=ddsc_topic_init, .fini=ddsc_topic_
|
|||
dds_entity_t topic;
|
||||
dds_qos_t *qos = dds_create_qos();
|
||||
DDSRT_WARNING_MSVC_OFF(28020); /* Disable SAL warning on intentional misuse of the API */
|
||||
dds_qset_lifespan(qos, DDS_SECS(-1));
|
||||
dds_qset_resource_limits(qos, 1, 1, 2);
|
||||
DDSRT_WARNING_MSVC_OFF(28020);
|
||||
topic = dds_create_topic(g_participant, &RoundTripModule_DataType_desc, "inconsistent", qos, NULL);
|
||||
CU_ASSERT_EQUAL_FATAL(topic, DDS_RETCODE_INCONSISTENT_POLICY);
|
||||
|
@ -417,7 +417,7 @@ CU_Test(ddsc_topic_set_qos, inconsistent, .init=ddsc_topic_init, .fini=ddsc_topi
|
|||
dds_qset_lifespan(g_qos, DDS_SECS(-1));
|
||||
DDSRT_WARNING_MSVC_ON(28020);
|
||||
ret = dds_set_qos(g_topicRtmDataType, g_qos);
|
||||
CU_ASSERT_EQUAL_FATAL(ret, DDS_RETCODE_INCONSISTENT_POLICY);
|
||||
CU_ASSERT_EQUAL_FATAL(ret, DDS_RETCODE_BAD_PARAMETER);
|
||||
}
|
||||
/*************************************************************************************************/
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue