Commit graph

33 commits

Author SHA1 Message Date
Erik Boasson
9b3a71e1ab lift limits on handle allocation and reuse (#95)
The old entity handle mechanism suffered from a number of problems, the
most terrible one being that it would only ever allocate 1000 handles
(not even have at most 1000 in use at the same time).  Secondarily, it
was protected by a single mutex that actually does show up as a limiting
factor in, say, a polling-based throughput test with small messages.
Thirdly, it tried to provide for various use cases that don't exist in
practice but add complexity and overhead.

This commit totally rewrites the mechanism, by replacing the old array
with a hash table and allowing a near-arbitrary number of handles as
well as reuse of handles.  It also removes the entity "kind" bits in the
most significant bits of the handles, because they only resulted in
incorrect checking of argument validity.  All that is taken out, but
there is still more cleaning up to be done.  It furthermore removes an
indirection in the handle-to-entity lookup by embedding the
"dds_handle_link" structure in the entity.

Handle allocation is randomized to avoid the have a high probability of
quickly finding an available handle (the total number of handles is
limited to a number much smaller than the domain from which they are
allocated).  The likelihood of handle reuse is still dependent on the
number of allocated handles -- the fewer handles there are, the longer
the expected time to reuse.  Non-randomized handles would give a few
guarantees more, though.

It moreover moves the code from the "util" to the "core/ddsc" component,
because it really is only used for entities, and besides the new
implementation relies on the deferred freeing (a.k.a. garbage collection
mechanism) implemented in the core.

The actual handle management has two variants, selectable with a macro:
the preferred embodiment uses a concurrent hash table, the actually used
one performs all operations inside a single mutex and uses a
non-concurrent version of the hash table.  The reason the
less-predeferred embodiment is used is that the concurrent version
requires the freeing of entity objects to be deferred (much like the
GUID-to-entity hash tables in DDSI function, or indeed the key value to
instance handle mapping).  That is a fair bit of work, and the
non-concurrent version is a reasonable intermediate step.

Signed-off-by: Erik Boasson <eb@ilities.com>
2019-04-21 16:05:06 +02:00
Erik Boasson
671e73ec98 set DATA_AVAILABLE when deleting writer (#148)
Deleting a writer causes unregisters (and possibly disposes) in the rest
of the network, and these updates to the instances should trigger
DATA_AVAILABLE.

Signed-off-by: Erik Boasson <eb@ilities.com>
2019-04-11 10:09:35 +02:00
Jeroen Koekkoek
cd6742ee12 Rearrange and fixup abstraction layer
- Replace os_result by dds_retcode_t and move DDS return code defines down.
  Eliminates the need to convert between different return code types.

- Move dds_time_t down and remove os_time.
  Eliminates the need to convert between different time representations and
  reduces code duplication.

- Remove use of Microsoft source-code annotation language (SAL).
  SAL annotations are Microsoft specific and not very well documented. This
  makes it very difficult for contributers to write.

- Rearrange the abstraction layer to be feature-based. The previous layout
  falsely assumed that the operating system dictates which implementation is
  best suited. For general purpose operating systems this is mostly true, but
  embedded targets require a slightly different approach and may not even offer
  all features. The new layout makes it possible to mix-and-match feature
  implementations and allows for features to not be implemented at all.

- Replace the os prefix by ddsrt to avoid name collisions.

- Remove various portions of unused and unwanted code.

- Export thread names on all supported platforms.

- Return native thread identifier on POSIX compatible platforms.

- Add timed wait for condition variables that takes an absolute time.

- Remove system abstraction for errno. The os_getErrno and os_setErrno were
  incorrect. Functions that might fail now simply return a DDS return code
  instead.

- Remove thread-specific memory abstraction. os_threadMemGet and accompanying
  functions were a mess and their use has been eliminated by other changes in
  this commit.

- Replace attribute (re)defines by ddsrt_ prefixed equivalents to avoid name
  collisions and problems with faulty __nonnull__ attributes.

Signed-off-by: Jeroen Koekkoek <jeroen@koekkoek.nl>
2019-03-22 15:19:09 +01:00
Erik Boasson
1c963b5c3b add torture test for read, query conditions
The "rhc" test runs a random sequence of operations (writes, reads, &c.)
through an RHC with conditions attached to it.  All possible state masks
are used, and query conditions are tried with a condition that only
tests the key value, and one that tests attribute values.  It depends on
the internal checking logic of the RHC, which is currently enabled only
in Debug builds because of the associated run-time overhead.

Signed-off-by: Erik Boasson <eb@ilities.com>
2019-02-12 14:22:06 +01:00
Erik Boasson
8157d3bec8 fix taking only some samples from an instance using a query condition
and add a test case

Signed-off-by: Erik Boasson <eb@ilities.com>
2019-01-18 12:14:21 +01:00
Erik Boasson
66076817e1 rework built-in topics again
Move details of built-in topics out of the DDSI core (so the only hooks
remain).  For this, rtps_term had to be split, so now it is "stop"
followed by "fini".

Add a notion of local writers that are not bound to a participant ("local
orphans"), so that the local built-in topic writers can be created during
initialization.  This eliminates the "builtin" participant.  This
uncovered in inconsistency in the unit tests: on the one hand, a newly
created participant is expected to have no child entities; on the other
hand, the built-in topics were expected to be returned by find_topic ...
This inconsistency has been resolved by creating them lazily and
accepting that find_topic can't return them until they have been
created.  Special code was in place in dds_create_reader anyway, so it
is not expected to have any real consequence for applications.

Use a special WHC implementation that regenerates the data on the fly
using the internal discovery tables of DDSI, so that the samples are only
stored by readers.  This eliminates the memory overhead of that existed
previously when the WHC of the writers stored the data.

No longer return topic name and type name in the built-in topics, they
have been extracted already and are not accessible through the normal
interface but do cause problems when comparing QoS.

Signed-off-by: Erik Boasson <eb@ilities.com>
2019-01-09 08:38:56 +01:00
Jeroen Koekkoek
0bc263e537 Remove unnecessary os_procName and os_procNamePid functions
Signed-off-by: Jeroen Koekkoek <jeroen@koekkoek.nl>
2019-01-08 16:40:07 +01:00
Jeroen Koekkoek
e25656a4c5 Remove unnecessary CMake modules and fixup os/CMakeLists.txt
Signed-off-by: Jeroen Koekkoek <jeroen@koekkoek.nl>
2019-01-07 18:15:07 +01:00
Erik Boasson
e96a47f3f9 fix test issues detected by address sanitizer
Signed-off-by: Erik Boasson <eb@ilities.com>
2018-12-25 12:40:05 +01:00
eboasson
97c5e06b6a
Merge pull request #69 from FirasSahliADLinktech/rename-functions
Make function names more consistent:

* ``dds_topic_{get,set}_filter`` -> ``dds_{get,set}_topic_filter``
* ``dds_{get,set}_enabled_status`` -> ``dds_{get,set}_status_mask``
* ``dds_instance_lookup`` -> ``dds_lookup_instance``

Plus removal of defunct ddsv2.h.
2018-12-25 12:38:25 +01:00
Erik Boasson
1a0fcea0c2 replace old builtin topics by new ones and add implementation of DCPSSubscription and DCPSPublication
Signed-off-by: Erik Boasson <eb@ilities.com>
2018-12-14 14:02:08 +01:00
Firas Sahli
9f51f6f9dc
Rename get and set filter functions for topic
Signed-off-by: Firas Sahli <firas.sahli@adlinktech.com>
2018-12-11 11:07:09 +01:00
Firas Sahli
05f961dec1
Rename get and set of enabled status to mask
Signed-off-by: Firas Sahli <firas.sahli@adlinktech.com>
2018-12-11 11:07:09 +01:00
Firas Sahli
99f410bc49
Rename dds_instance_lookup to dds_lookup_instance
Signed-off-by: Firas Sahli <firas.sahli@adlinktech.com>
2018-12-11 11:06:50 +01:00
Jeroen Koekkoek
3c5a209389 Fix build warnings by passing a message to CU_PASS
Signed-off-by: Jeroen Koekkoek <jeroen@koekkoek.nl>
2018-12-10 13:05:59 +01:00
Jeroen Koekkoek
74a48c5731 Replace Criterion by CUnit
Signed-off-by: Jeroen Koekkoek <jeroen@koekkoek.nl>
2018-12-06 14:48:30 +01:00
Erik Boasson
e62abe623a fix warnings on qos function names and constness
Signed-off-by: Erik Boasson <eb@ilities.com>
2018-12-01 10:01:13 +01:00
eboasson
69f563be5b
Merge pull request #60 from FirasSahliADLinktech/multiple_tests
Some missing unit tests and correct signature
2018-11-30 12:07:44 +01:00
Firas Sahli
6908e3deea
Correct signature and add tests for dds_instance_get_key
Signed-off-by: Firas Sahli <firas.sahli@adlinktech.com>
2018-11-28 10:52:14 +01:00
Firas Sahli
8aa6ceff81
Add test for dds_qos_copy and extra check to dds_qset_partition
Signed-off-by: Firas Sahli <firas.sahli@adlinktech.com>
2018-11-28 10:41:24 +01:00
Firas Sahli
4b627fd9aa
Add simple test for dds_time
Signed-off-by: Firas Sahli <firas.sahli@adlinktech.com>
2018-11-28 10:38:07 +01:00
Erik Boasson
ec68eeac29 Bring listener operations naming scheme in line with the rest
The main naming scheme is OPER_TYPE (i.e., dds_create_participant) but the listener operations were named TYPE_OPER (i.e., dds_listener_create). This commit brings the listener scheme in line with the rest, retaining the old names as a deprecated interface.

Signed-off-by: Erik Boasson <eb@ilities.com>
2018-11-09 14:18:51 +01:00
Erik Boasson
651bdfee06 Bring QoS operations naming scheme in line with the rest
The main naming scheme is OPER_TYPE (i.e., dds_create_participant) but the QoS operations were named TYPE_OPER (i.e., dds_qos_create). This commit brings the QoS scheme in line with the rest, retaining the old names as a deprecated interface.

Signed-off-by: Erik Boasson <eb@ilities.com>
2018-11-09 14:18:47 +01:00
Erik Boasson
bb92294f4e Let dds_create_participant determine domain id if config specifies "any" (new default)
Note: DDS_DOMAIN_DEFAULT with a configuration specifying "any" results in domain 0.
Signed-off-by: Erik Boasson <eb@ilities.com>
2018-10-14 14:02:47 +08:00
Erik Boasson
b7487b18a6 stricter warning checks and the corresponding fixes
Signed-off-by: Erik Boasson <eb@ilities.com>
2018-08-09 09:23:03 +02:00
Jeroen Koekkoek
70f208cbd3 fix export of CYCLONEDDS_URI in test environment
Signed-off-by: Jeroen Koekkoek <jeroen@koekkoek.nl>
2018-08-06 15:10:29 +02:00
Jeroen Koekkoek
3752f93e78 remove debug message for Criterion_ddsc_config_simple_udp setup
Signed-off-by: Jeroen Koekkoek <jeroen@koekkoek.nl>
2018-08-06 15:10:23 +02:00
Jeroen Koekkoek
a7bd8f05aa use test environment set by add_criterion_executable for Criterion_ddsc_config_simple_udp test
Signed-off-by: Jeroen Koekkoek <jeroen@koekkoek.nl>
2018-08-06 15:10:16 +02:00
Jeroen Koekkoek
7147eac330 add shared library directory to PATH in test environment for Criterion_ddsc_config_simple_udp
Signed-off-by: Jeroen Koekkoek <jeroen@koekkoek.nl>
2018-08-06 15:09:33 +02:00
Erik Boasson
414be4a569 General/EnableLoopback is deprecated and has no effect other than an error, remove it from configs
Signed-off-by: Erik Boasson <eb@ilities.com>
2018-07-11 13:18:52 +02:00
Erik Boasson
e912384500 allow dds_create_topic multiple times for the same topic
Signed-off-by: Erik Boasson <eb@ilities.com>
2018-07-11 13:18:13 +02:00
Erik Boasson
daa17704db Fix dds_sample_info.publication_handle incorrectly set to 1 as well as some corner cases where it ended up at 0 and some related assertion failures (#8)
Signed-off-by: Erik Boasson <eb@ilities.com>
2018-07-06 21:28:23 +02:00
Michiel Beemster
11d9ce37aa Initial contribution 2018-04-10 17:03:59 +02:00