From ef047d6bd556c6b3a572a0377bbf97dbb97d90ca Mon Sep 17 00:00:00 2001
From: Erik Boasson
Date: Tue, 18 Feb 2020 10:36:00 +0100
Subject: [PATCH 01/30] Check all dds_write calls in liveliness tests
Signed-off-by: Erik Boasson
---
src/core/ddsc/tests/liveliness.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/src/core/ddsc/tests/liveliness.c b/src/core/ddsc/tests/liveliness.c
index a11e5ea..04cec98 100644
--- a/src/core/ddsc/tests/liveliness.c
+++ b/src/core/ddsc/tests/liveliness.c
@@ -597,7 +597,7 @@ static void test_create_delete_writer_stress(bool remote_reader)
{
dds_qset_liveliness(wqos, n % 2 ? DDS_LIVELINESS_AUTOMATIC : DDS_LIVELINESS_MANUAL_BY_PARTICIPANT, DDS_MSECS(n % 3 ? ldur + n : ldur - n) + ((n % 3) == 2 ? 1 : 0));
CU_ASSERT_FATAL((writers[n] = dds_create_writer(g_pub_participant, pub_topic, wqos, NULL)) > 0);
- dds_write(writers[n], &sample);
+ CU_ASSERT_EQUAL_FATAL(dds_write(writers[n], &sample), DDS_RETCODE_OK);
if (n % 3 == 2)
dds_delete(writers[n]);
else if (n % 2)
@@ -717,7 +717,7 @@ static void test_status_counts(bool remote_reader)
CU_ASSERT_EQUAL_FATAL(llstatus.total_count_change, 1);
/* write sample and re-check status counts */
- dds_write(writer, &sample);
+ CU_ASSERT_EQUAL_FATAL(dds_write(writer, &sample), DDS_RETCODE_OK);
CU_ASSERT_EQUAL_FATAL(dds_waitset_wait(waitset, &triggered, 1, DDS_SECS(5)), 1);
dds_get_liveliness_changed_status(reader, &lcstatus);
From 9a0ad5e2f557ca05fb90f087a2032a8fa95087a6 Mon Sep 17 00:00:00 2001
From: Erik Boasson
Date: Tue, 18 Feb 2020 10:37:56 +0100
Subject: [PATCH 02/30] ddsperf argument checking improvements
Inspired by Coverity warnings.
Signed-off-by: Erik Boasson
---
src/tools/ddsperf/ddsperf.c | 20 ++++++++++++--------
1 file changed, 12 insertions(+), 8 deletions(-)
diff --git a/src/tools/ddsperf/ddsperf.c b/src/tools/ddsperf/ddsperf.c
index 18eaad7..bed06bd 100644
--- a/src/tools/ddsperf/ddsperf.c
+++ b/src/tools/ddsperf/ddsperf.c
@@ -1749,7 +1749,7 @@ static void set_mode_ping (int *xoptind, int xargc, char * const xargv[])
{
int pos = 0, mult = 1;
double ping_rate;
- if (strcmp (xargv[*xoptind], "inf") == 0 && lookup_multiplier (frequency_units, xargv[*xoptind] + 3) > 0)
+ if (strncmp (xargv[*xoptind], "inf", 3) == 0 && lookup_multiplier (frequency_units, xargv[*xoptind] + 3) > 0)
{
ping_intv = 0;
}
@@ -1891,16 +1891,16 @@ int main (int argc, char *argv[])
while ((opt = getopt (argc, argv, "cd:D:i:n:k:uLK:T:Q:R:h")) != EOF)
{
+ int pos;
switch (opt)
{
case 'c': collect_stats = true; break;
case 'd': {
char *col;
- int pos;
(void) ddsrt_strlcpy (netload_if, optarg, sizeof (netload_if));
if ((col = strrchr (netload_if, ':')) == NULL || col == netload_if ||
(sscanf (col+1, "%lf%n", &netload_bw, &pos) != 1 || (col+1)[pos] != 0))
- error3 ("-d%s: expected DEVICE:BANDWIDTH\n", optarg);
+ error3 ("-d %s: expected DEVICE:BANDWIDTH\n", optarg);
*col = 0;
break;
}
@@ -1917,10 +1917,9 @@ int main (int argc, char *argv[])
else if (strcmp (optarg, "OU") == 0) topicsel = OU;
else if (strcmp (optarg, "UK16") == 0) topicsel = UK16;
else if (strcmp (optarg, "UK1024") == 0) topicsel = UK1024;
- else error3 ("%s: unknown topic\n", optarg);
+ else error3 ("-T %s: unknown topic\n", optarg);
break;
case 'Q': {
- int pos;
double d;
unsigned long n;
if (sscanf (optarg, "rss:%lf%n", &d, &pos) == 1 && (optarg[pos] == 0 || optarg[pos] == '%')) {
@@ -1935,11 +1934,16 @@ int main (int argc, char *argv[])
} else if (sscanf (optarg, "minmatch:%lu%n", &n, &pos) == 1 && optarg[pos] == 0) {
minmatch = (uint32_t) n;
} else {
- error3 ("-Q%s: invalid success criterium\n", optarg);
+ error3 ("-Q %s: invalid success criterium\n", optarg);
}
break;
}
- case 'R': tref = 0; sscanf (optarg, "%"SCNd64, &tref); break;
+ case 'R': {
+ tref = 0;
+ if (sscanf (optarg, "%"SCNd64"%n", &tref, &pos) != 1 || optarg[pos] != 0)
+ error3 ("-R %s: invalid reference time\n", optarg);
+ break;
+ }
case 'h': default: usage (); break;
}
}
@@ -1959,7 +1963,7 @@ int main (int argc, char *argv[])
if (nkeyvals == 0)
nkeyvals = 1;
if (topicsel == OU && nkeyvals != 1)
- error3 ("-n%u invalid: topic OU has no key\n", nkeyvals);
+ error3 ("-n %u invalid: topic OU has no key\n", nkeyvals);
if (topicsel != KS && baggagesize != 0)
error3 ("size %"PRIu32" invalid: only topic KS has a sequence\n", baggagesize);
if (baggagesize != 0 && baggagesize < 12)
From af3604dea72b79d88eb477bd78eeb916efd05e97 Mon Sep 17 00:00:00 2001
From: ChenYing Kuo
Date: Wed, 19 Feb 2020 19:33:39 +0800
Subject: [PATCH 03/30] Fix some typos. (#399)
* Fix some typos.
Signed-off-by: ChenYing Kuo
* Also update q_config.c, cyclonedds.rnc, cyclonedds.xsd for correct
build.
Signed-off-by: ChenYing Kuo
* Remove cdds.md.
Signed-off-by: ChenYing Kuo
---
cdds.md | 1926 ------------------------------
docs/manual/options.md | 2 +-
etc/cyclonedds.rnc | 2 +-
etc/cyclonedds.xsd | 2 +-
examples/helloworld/publisher.c | 2 +-
examples/throughput/subscriber.c | 2 +-
src/core/ddsi/src/q_config.c | 2 +-
7 files changed, 6 insertions(+), 1932 deletions(-)
delete mode 100644 cdds.md
diff --git a/cdds.md b/cdds.md
deleted file mode 100644
index 739d910..0000000
--- a/cdds.md
+++ /dev/null
@@ -1,1926 +0,0 @@
-
-
-# //CycloneDDS
-Children: [Domain](#cycloneddsdomain)
-
-
-CycloneDDS configuration
-
-
-## //CycloneDDS/Domain
-Attributes: [Id](#cycloneddsdomainid)
-
-Children: [Channels](#cycloneddsdomainchannels), [Compatibility](#cycloneddsdomaincompatibility), [Discovery](#cycloneddsdomaindiscovery), [General](#cycloneddsdomaingeneral), [Internal](#cycloneddsdomaininternal), [Partitioning](#cycloneddsdomainpartitioning), [SSL](#cycloneddsdomainssl), [Security](#cycloneddsdomainsecurity), [Sizing](#cycloneddsdomainsizing), [TCP](#cycloneddsdomaintcp), [ThreadPool](#cycloneddsdomainthreadpool), [Threads](#cycloneddsdomainthreads), [Tracing](#cycloneddsdomaintracing)
-
-
-The General element specifying Domain related settings.
-
-
-## //CycloneDDS/Domain[@Id]
-Text
-
-Domain id this configuration applies to, or "any" if it applies to all
-domain ids.
-
-The default value is: "any".
-
-
-### //CycloneDDS/Domain/Channels
-Children: [Channel](#cycloneddsdomainchannelschannel)
-
-
-This element is used to group a set of channels. The channels are
-independent data paths through Cyclone DDS and by using separate threads
-and setting their priorities appropriately, chanenls can be used to map
-transport priorities to operating system scheduler priorities, ensuring
-system-wide end-to-end priority preservation.
-
-
-#### //CycloneDDS/Domain/Channels/Channel
-Attributes: [Name](#cycloneddsdomainchannelschannelname), [TransportPriority](#cycloneddsdomainchannelschanneltransportpriority)
-
-Children: [AuxiliaryBandwidthLimit](#cycloneddsdomainchannelschannelauxiliarybandwidthlimit), [DataBandwidthLimit](#cycloneddsdomainchannelschanneldatabandwidthlimit), [DiffServField](#cycloneddsdomainchannelschanneldiffservfield)
-
-
-This element defines a channel.
-
-
-#### //CycloneDDS/Domain/Channels/Channel[@Name]
-Text
-
-This attribute specifies name of this channel. The name should uniquely
-identify the channel.
-
-
-#### //CycloneDDS/Domain/Channels/Channel[@TransportPriority]
-Integer
-
-This attribute sets the transport priority threshold for the channel.
-Each DCPS data writer has a "transport_priority" QoS and this QoS is used
-to select a channel for use by this writer. The selected channel is the
-one with the largest threshold not greater than the writer's transport
-priority, and if no such channel exists, the channel with the lowest
-threshold.
-
-The default value is: "0".
-
-
-##### //CycloneDDS/Domain/Channels/Channel/AuxiliaryBandwidthLimit
-Number-with-unit
-
-This element specifies the maximum transmit rate of auxiliary traffic on
-this channel (e.g. retransmits, heartbeats, etc). Bandwidth limiting uses
-a leaky bucket scheme. The default value "inf" means Cyclone DDS imposes
-no limitation, the underlying operating system and hardware will likely
-limit the maimum transmit rate.
-
-The unit must be specified explicitly. Recognised units: Xb/s, Xbps for
-bits/s or XB/s, XBps for bytes/s; where X is an optional prefix: k for
-10^3, Ki for 210, M for 106, Mi for 220,
-G for 109, Gi for 230.
-
-The default value is: "inf".
-
-
-##### //CycloneDDS/Domain/Channels/Channel/DataBandwidthLimit
-Number-with-unit
-
-This element specifies the maximum transmit rate of new samples and
-directly related data, for this channel. Bandwidth limiting uses a leaky
-bucket scheme. The default value "inf" means Cyclone DDS imposes no
-limitation, the underlying operating system and hardware will likely
-limit the maimum transmit rate.
-
-The unit must be specified explicitly. Recognised units: Xb/s, Xbps for
-bits/s or XB/s, XBps for bytes/s; where X is an optional prefix: k for
-10^3, Ki for 210, M for 106, Mi for 220,
-G for 109, Gi for 230.
-
-The default value is: "inf".
-
-
-##### //CycloneDDS/Domain/Channels/Channel/DiffServField
-Integer
-
-This element describes the DiffServ setting the channel will apply to the
-networking messages. This parameter determines the value of the diffserv
-field of the IP version 4 packets sent on this channel which allows QoS
-setting to be applied to the network traffic send on this channel.
-
-Windows platform support for setting the diffserv field is dependent on
-the OS version.
-
-For Windows versions XP SP2 and 2003 to use the diffserv field the
-following parameter should be added to the register:
-
-HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\TcpIp\Parameters\DisableUserTOSSetting
-
-The type of this parameter is a DWORD and its value should be set to 0 to
-allow setting of the diffserv field.
-
-For Windows version 7 or higher a new API (qWAVE) has been introduced.
-For these platforms the specified diffserv value is mapped to one of the
-support traffic types.
-
-The mapping is as follows: 1-8 background traffic; 9-40 excellent
-traffic; 41-55 audio/video traffic; 56 voice traffic; 57-63 control
-traffic.
-
-When an application is run without Administrative priveleges then only
-the diffserv value of 0, 8, 40 or 56 is allowed.
-
-The default value is: "0".
-
-
-### //CycloneDDS/Domain/Compatibility
-Children: [AssumeRtiHasPmdEndpoints](#cycloneddsdomaincompatibilityassumertihaspmdendpoints), [ExplicitlyPublishQosSetToDefault](#cycloneddsdomaincompatibilityexplicitlypublishqossettodefault), [ManySocketsMode](#cycloneddsdomaincompatibilitymanysocketsmode), [StandardsConformance](#cycloneddsdomaincompatibilitystandardsconformance)
-
-
-The Compatibility elements allows specifying various settings related to
-compatability with standards and with other DDSI implementations.
-
-
-#### //CycloneDDS/Domain/Compatibility/AssumeRtiHasPmdEndpoints
-Boolean
-
-This option assumes ParticipantMessageData endpoints required by the
-liveliness protocol are present in RTI participants even when not
-properly advertised by the participant discovery protocol.
-
-The default value is: "false".
-
-
-#### //CycloneDDS/Domain/Compatibility/ExplicitlyPublishQosSetToDefault
-Boolean
-
-This element specifies whether QoS settings set to default values are
-explicitly published in the discovery protocol. Implementations are to
-use the default value for QoS settings not published, which allows a
-significant reduction of the amount of data that needs to be exchanged
-for the discovery protocol, but this requires all implementations to
-adhere to the default values specified by the specifications.
-
-When interoperability is required with an implementation that does not
-follow the specifications in this regard, setting this option to true
-will help.
-
-The default value is: "false".
-
-
-#### //CycloneDDS/Domain/Compatibility/ManySocketsMode
-One of: false, true, single, none, many
-
-This option specifies whether a network socket will be created for each
-domain participant on a host. The specification seems to assume that each
-participant has a unique address, and setting this option will ensure
-this to be the case. This is not the defeault.
-
-Disabling it slightly improves performance and reduces network traffic
-somewhat. It also causes the set of port numbers needed by Cyclone DDS to
-become predictable, which may be useful for firewall and NAT
-configuration.
-
-The default value is: "single".
-
-
-#### //CycloneDDS/Domain/Compatibility/StandardsConformance
-One of: lax, strict, pedantic
-
-This element sets the level of standards conformance of this instance of
-the Cyclone DDS Service. Stricter conformance typically means less
-interoperability with other implementations. Currently three modes are
-defined:
-
-* pedantic: very strictly conform to the specification, ultimately for
- compliancy testing, but currently of little value because it adheres even to
- what will most likely turn out to be editing errors in the DDSI standard.
- Arguably, as long as no errata have been published it is the current text
- that is in effect, and that is what pedantic currently does.
-
-* strict: a slightly less strict view of the standard than does pedantic: it
- follows the established behaviour where the standard is obviously in error.
-
-* lax: attempt to provide the smoothest possible interoperability, anticipating
- future revisions of elements in the standard in areas that other
- implementations do not adhere to, even though there is no good reason not to.
-
-The default setting is "lax".
-
-The default value is: "lax".
-
-
-### //CycloneDDS/Domain/Discovery
-Children: [DSGracePeriod](#cycloneddsdomaindiscoverydsgraceperiod), [DefaultMulticastAddress](#cycloneddsdomaindiscoverydefaultmulticastaddress), [EnableTopicDiscovery](#cycloneddsdomaindiscoveryenabletopicdiscovery), [MaxAutoParticipantIndex](#cycloneddsdomaindiscoverymaxautoparticipantindex), [ParticipantIndex](#cycloneddsdomaindiscoveryparticipantindex), [Peers](#cycloneddsdomaindiscoverypeers), [Ports](#cycloneddsdomaindiscoveryports), [SPDPInterval](#cycloneddsdomaindiscoveryspdpinterval), [SPDPMulticastAddress](#cycloneddsdomaindiscoveryspdpmulticastaddress)
-
-
-The Discovery element allows specifying various parameters related to the
-discovery of peers.
-
-
-#### //CycloneDDS/Domain/Discovery/DSGracePeriod
-Number-with-unit
-
-This setting controls for how long endpoints discovered via a Cloud
-discovery service will survive after the discovery service disappeared,
-allowing reconnect without loss of data when the discovery service
-restarts (or another instance takes over).
-
-Valid values are finite durations with an explicit unit or the keyword
-'inf' for infinity. Recognised units: ns, us, ms, s, min, hr, day.
-
-The default value is: "30 s".
-
-
-#### //CycloneDDS/Domain/Discovery/DefaultMulticastAddress
-Text
-
-This element specifies the default multicast address for all traffic
-other than participant discovery packets. It defaults to
-Discovery/SPDPMulticastAddress.
-
-The default value is: "auto".
-
-
-#### //CycloneDDS/Domain/Discovery/EnableTopicDiscovery
-Boolean
-
-Do not use.
-
-The default value is: "true".
-
-
-#### //CycloneDDS/Domain/Discovery/MaxAutoParticipantIndex
-Integer
-
-This element specifies the maximum DDSI participant index selected by
-this instance of the Cyclone DDS service if the
-Discovery/ParticipantIndex is "auto".
-
-The default value is: "9".
-
-
-#### //CycloneDDS/Domain/Discovery/ParticipantIndex
-Text
-
-This element specifies the DDSI participant index used by this instance
-of the Cyclone DDS service for discovery purposes. Only one such
-participant id is used, independent of the number of actual
-DomainParticipants on the node. It is either:
-
-* auto: which will attempt to automatically determine an available participant
- index (see also Discovery/MaxAutoParticipantIndex), or
-
-* a non-negative integer less than 120, or
-
-* none:, which causes it to use arbitrary port numbers for unicast sockets
- which entirely removes the constraints on the participant index but makes
- unicast discovery impossible.
-
-The default is auto. The participant index is part of the port number
-calculation and if predictable port numbers are needed and fixing the
-participant index has no adverse effects, it is recommended that the
-second be option be used.
-
-The default value is: "none".
-
-
-#### //CycloneDDS/Domain/Discovery/Peers
-Children: [Group](#cycloneddsdomaindiscoverypeersgroup), [Peer](#cycloneddsdomaindiscoverypeerspeer)
-
-
-This element statically configures addresses for discovery.
-
-Valid values are finite durations with an explicit unit or the keyword
-'inf' for infinity. Recognised units: ns, us, ms, s, min, hr, day.
-
-
-##### //CycloneDDS/Domain/Discovery/Peers/Group
-Children: [Peer](#cycloneddsdomaindiscoverypeersgrouppeer)
-
-
-This element statically configures a fault tolerant group of addresses
-for discovery. Each member of the group is tried in sequence until one
-succeeds.
-
-
-###### //CycloneDDS/Domain/Discovery/Peers/Group/Peer
-Attributes: [Address](#cycloneddsdomaindiscoverypeersgrouppeeraddress)
-
-
-This element statically configures an addresses for discovery.
-
-
-###### //CycloneDDS/Domain/Discovery/Peers/Group/Peer[@Address]
-Text
-
-This element specifies an IP address to which discovery packets must be
-sent, in addition to the default multicast address (see also
-General/AllowMulticast). Both a hostnames and a numerical IP address is
-accepted; the hostname or IP address may be suffixed with :PORT to
-explicitly set the port to which it must be sent. Multiple Peers may be
-specified.
-
-
-##### //CycloneDDS/Domain/Discovery/Peers/Peer
-Attributes: [Address](#cycloneddsdomaindiscoverypeerspeeraddress)
-
-
-This element statically configures an addresses for discovery.
-
-
-##### //CycloneDDS/Domain/Discovery/Peers/Peer[@Address]
-Text
-
-This element specifies an IP address to which discovery packets must be
-sent, in addition to the default multicast address (see also
-General/AllowMulticast). Both a hostnames and a numerical IP address is
-accepted; the hostname or IP address may be suffixed with :PORT to
-explicitly set the port to which it must be sent. Multiple Peers may be
-specified.
-
-
-#### //CycloneDDS/Domain/Discovery/Ports
-Children: [Base](#cycloneddsdomaindiscoveryportsbase), [DomainGain](#cycloneddsdomaindiscoveryportsdomaingain), [MulticastDataOffset](#cycloneddsdomaindiscoveryportsmulticastdataoffset), [MulticastMetaOffset](#cycloneddsdomaindiscoveryportsmulticastmetaoffset), [ParticipantGain](#cycloneddsdomaindiscoveryportsparticipantgain), [UnicastDataOffset](#cycloneddsdomaindiscoveryportsunicastdataoffset), [UnicastMetaOffset](#cycloneddsdomaindiscoveryportsunicastmetaoffset)
-
-
-The Ports element allows specifying various parameters related to the
-port numbers used for discovery. These all have default values specified
-by the DDSI 2.1 specification and rarely need to be changed.
-
-
-##### //CycloneDDS/Domain/Discovery/Ports/Base
-Integer
-
-This element specifies the base port number (refer to the DDSI 2.1
-specification, section 9.6.1, constant PB).
-
-The default value is: "7400".
-
-
-##### //CycloneDDS/Domain/Discovery/Ports/DomainGain
-Integer
-
-This element specifies the domain gain, relating domain ids to sets of
-port numbers (refer to the DDSI 2.1 specification, section 9.6.1,
-constant DG).
-
-The default value is: "250".
-
-
-##### //CycloneDDS/Domain/Discovery/Ports/MulticastDataOffset
-Integer
-
-This element specifies the port number for multicast meta traffic (refer
-to the DDSI 2.1 specification, section 9.6.1, constant d2).
-
-The default value is: "1".
-
-
-##### //CycloneDDS/Domain/Discovery/Ports/MulticastMetaOffset
-Integer
-
-This element specifies the port number for multicast meta traffic (refer
-to the DDSI 2.1 specification, section 9.6.1, constant d0).
-
-The default value is: "0".
-
-
-##### //CycloneDDS/Domain/Discovery/Ports/ParticipantGain
-Integer
-
-This element specifies the participant gain, relating p0, articipant
-index to sets of port numbers (refer to the DDSI 2.1 specification,
-section 9.6.1, constant PG).
-
-The default value is: "2".
-
-
-##### //CycloneDDS/Domain/Discovery/Ports/UnicastDataOffset
-Integer
-
-This element specifies the port number for unicast meta traffic (refer to
-the DDSI 2.1 specification, section 9.6.1, constant d3).
-
-The default value is: "11".
-
-
-##### //CycloneDDS/Domain/Discovery/Ports/UnicastMetaOffset
-Integer
-
-This element specifies the port number for unicast meta traffic (refer to
-the DDSI 2.1 specification, section 9.6.1, constant d1).
-
-The default value is: "10".
-
-
-#### //CycloneDDS/Domain/Discovery/SPDPInterval
-Number-with-unit
-
-This element specifies the interval between spontaneous transmissions of
-participant discovery packets.
-
-The unit must be specified explicitly. Recognised units: ns, us, ms, s,
-min, hr, day.
-
-The default value is: "30 s".
-
-
-#### //CycloneDDS/Domain/Discovery/SPDPMulticastAddress
-Text
-
-This element specifies the multicast address that is used as the
-destination for the participant discovery packets. In IPv4 mode the
-default is the (standardised) 239.255.0.1, in IPv6 mode it becomes
-ff02::ffff:239.255.0.1, which is a non-standardised link-local multicast
-address.
-
-The default value is: "239.255.0.1".
-
-
-### //CycloneDDS/Domain/General
-Children: [AllowMulticast](#cycloneddsdomaingeneralallowmulticast), [DontRoute](#cycloneddsdomaingeneraldontroute), [EnableMulticastLoopback](#cycloneddsdomaingeneralenablemulticastloopback), [ExternalNetworkAddress](#cycloneddsdomaingeneralexternalnetworkaddress), [ExternalNetworkMask](#cycloneddsdomaingeneralexternalnetworkmask), [FragmentSize](#cycloneddsdomaingeneralfragmentsize), [MaxMessageSize](#cycloneddsdomaingeneralmaxmessagesize), [MulticastRecvNetworkInterfaceAddresses](#cycloneddsdomaingeneralmulticastrecvnetworkinterfaceaddresses), [MulticastTimeToLive](#cycloneddsdomaingeneralmulticasttimetolive), [NetworkInterfaceAddress](#cycloneddsdomaingeneralnetworkinterfaceaddress), [PreferMulticast](#cycloneddsdomaingeneralprefermulticast), [Transport](#cycloneddsdomaingeneraltransport), [UseIPv6](#cycloneddsdomaingeneraluseipv6)
-
-
-The General element specifies overall Cyclone DDS service settings.
-
-
-#### //CycloneDDS/Domain/General/AllowMulticast
-One of:
-* Keyword: default
-* Comma-separated list of: false, spdp, asm, ssm, true
-
-This element controls whether Cyclone DDS uses multicasts for data
-traffic.
-
-It is a comma-separated list of some of the following keywords: "spdp",
-"asm", "ssm", or either of "false" or "true", or "default".
-
-* spdp: enables the use of ASM (any-source multicast) for participant
- discovery, joining the multicast group on the discovery socket, transmitting
- SPDP messages to this group, but never advertising nor using any multicast
- address in any discovery message, thus forcing unicast communications for all
- endpoint discovery and user data.
-
-* asm: enables the use of ASM for all traffic, including receiving SPDP but not
- transmitting SPDP messages via multicast
-
-* ssm: enables the use of SSM (source-specific multicast) for all non-SPDP
- traffic (if supported)
-
-When set to "false" all multicasting is disabled. The default, "true"
-enables full use of multicasts. Listening for multicasts can be
-controlled by General/MulticastRecvNetworkInterfaceAddresses.
-
-"default" maps on spdp if the network is a WiFi network, on true if it is
-a wired network
-
-The default value is: "default".
-
-
-#### //CycloneDDS/Domain/General/DontRoute
-Boolean
-
-This element allows setting the SO_DONTROUTE option for outgoing packets,
-to bypass the local routing tables. This is generally useful only when
-the routing tables cannot be trusted, which is highly unusual.
-
-The default value is: "false".
-
-
-#### //CycloneDDS/Domain/General/EnableMulticastLoopback
-Boolean
-
-This element specifies whether Cyclone DDS allows IP multicast packets to
-be visible to all DDSI participants in the same node, including itself.
-It must be "true" for intra-node multicast communications, but if a node
-runs only a single Cyclone DDS service and does not host any other
-DDSI-capable programs, it should be set to "false" for improved
-performance.
-
-The default value is: "true".
-
-
-#### //CycloneDDS/Domain/General/ExternalNetworkAddress
-Text
-
-This element allows explicitly overruling the network address Cyclone DDS
-advertises in the discovery protocol, which by default is the address of
-the preferred network interface (General/NetworkInterfaceAddress), to
-allow Cyclone DDS to communicate across a Network Address Translation
-(NAT) device.
-
-The default value is: "auto".
-
-
-#### //CycloneDDS/Domain/General/ExternalNetworkMask
-Text
-
-This element specifies the network mask of the external network address.
-This element is relevant only when an external network address
-(General/ExternalNetworkAddress) is explicitly configured. In this case
-locators received via the discovery protocol that are within the same
-external subnet (as defined by this mask) will be translated to an
-internal address by replacing the network portion of the external address
-with the corresponding portion of the preferred network interface
-address. This option is IPv4-only.
-
-The default value is: "0.0.0.0".
-
-
-#### //CycloneDDS/Domain/General/FragmentSize
-Number-with-unit
-
-This element specifies the size of DDSI sample fragments generated by
-Cyclone DDS. Samples larger than FragmentSize are fragmented into
-fragments of FragmentSize bytes each, except the last one, which may be
-smaller. The DDSI spec mandates a minimum fragment size of 1025 bytes,
-but Cyclone DDS will do whatever size is requested, accepting fragments
-of which the size is at least the minimum of 1025 and FragmentSize.
-
-The unit must be specified explicitly. Recognised units: B (bytes), kB &
-KiB (2^10 bytes), MB & MiB (220 bytes), GB & GiB
-(230 bytes).
-
-The default value is: "1280 B".
-
-
-#### //CycloneDDS/Domain/General/MaxMessageSize
-Number-with-unit
-
-This element specifies the maximum size of the UDP payload that Cyclone
-DDS will generate. Cyclone DDS will try to maintain this limit within the
-bounds of the DDSI specification, which means that in some cases
-(especially for very low values of MaxMessageSize) larger payloads may
-sporadically be observed (currently up to 1192 B).
-
-On some networks it may be necessary to set this item to keep the
-packetsize below the MTU to prevent IP fragmentation. In those cases, it
-is generally advisable to also consider reducing Internal/FragmentSize.
-
-The unit must be specified explicitly. Recognised units: B (bytes), kB &
-KiB (2^10 bytes), MB & MiB (220 bytes), GB & GiB
-(230 bytes).
-
-The default value is: "4096 B".
-
-
-#### //CycloneDDS/Domain/General/MulticastRecvNetworkInterfaceAddresses
-Text
-
-This element specifies on which network interfaces Cyclone DDS listens to
-multicasts. The following options are available:
-
-* all: listen for multicasts on all multicast-capable interfaces; or
-
-* any: listen for multicasts on the operating system default interface; or
-
-* preferred: listen for multicasts on the preferred interface
- (General/NetworkInterfaceAddress); or
-
-* none: does not listen for multicasts on any interface; or
-
-* a comma-separated list of network addresses: configures Cyclone DDS to listen
- for multicasts on all of the listed addresses.
-
-If Cyclone DDS is in IPv6 mode and the address of the preferred network
-interface is a link-local address, "all" is treated as a synonym for
-"preferred" and a comma-separated list is treated as "preferred" if it
-contains the preferred interface and as "none" if not.
-
-The default value is: "preferred".
-
-
-#### //CycloneDDS/Domain/General/MulticastTimeToLive
-Integer
-
-This element specifies the time-to-live setting for outgoing multicast
-packets.
-
-The default value is: "32".
-
-
-#### //CycloneDDS/Domain/General/NetworkInterfaceAddress
-Text
-
-This element specifies the preferred network interface for use by Cyclone
-DDS. The preferred network interface determines the IP address that
-Cyclone DDS advertises in the discovery protocol (but see also
-General/ExternalNetworkAddress), and is also the only interface over
-which multicasts are transmitted. The interface can be identified by its
-IP address, network interface name or network portion of the address. If
-the value "auto" is entered here, Cyclone DDS will select what it
-considers the most suitable interface.
-
-The default value is: "auto".
-
-
-#### //CycloneDDS/Domain/General/PreferMulticast
-Boolean
-
-When false (default) Cyclone DDS uses unicast for data whenever there a
-single unicast suffices. Setting this to true makes it prefer
-multicasting data, falling back to unicast only when no multicast address
-is available.
-
-The default value is: "false".
-
-
-#### //CycloneDDS/Domain/General/Transport
-One of: default, udp, udp6, tcp, tcp6, raweth
-
-This element allows selecting the transport to be used (udp, udp6, tcp,
-tcp6, raweth)
-
-The default value is: "default".
-
-
-#### //CycloneDDS/Domain/General/UseIPv6
-One of: false, true, default
-
-Deprecated (use Transport instead)
-
-The default value is: "default".
-
-
-### //CycloneDDS/Domain/Internal
-Children: [AccelerateRexmitBlockSize](#cycloneddsdomaininternalacceleraterexmitblocksize), [AssumeMulticastCapable](#cycloneddsdomaininternalassumemulticastcapable), [AutoReschedNackDelay](#cycloneddsdomaininternalautoreschednackdelay), [AuxiliaryBandwidthLimit](#cycloneddsdomaininternalauxiliarybandwidthlimit), [BuiltinEndpointSet](#cycloneddsdomaininternalbuiltinendpointset), [ControlTopic](#cycloneddsdomaininternalcontroltopic), [DDSI2DirectMaxThreads](#cycloneddsdomaininternalddsi2directmaxthreads), [DefragReliableMaxSamples](#cycloneddsdomaininternaldefragreliablemaxsamples), [DefragUnreliableMaxSamples](#cycloneddsdomaininternaldefragunreliablemaxsamples), [DeliveryQueueMaxSamples](#cycloneddsdomaininternaldeliveryqueuemaxsamples), [EnableExpensiveChecks](#cycloneddsdomaininternalenableexpensivechecks), [GenerateKeyhash](#cycloneddsdomaininternalgeneratekeyhash), [HeartbeatInterval](#cycloneddsdomaininternalheartbeatinterval), [LateAckMode](#cycloneddsdomaininternallateackmode), [LeaseDuration](#cycloneddsdomaininternalleaseduration), [LivelinessMonitoring](#cycloneddsdomaininternallivelinessmonitoring), [MaxParticipants](#cycloneddsdomaininternalmaxparticipants), [MaxQueuedRexmitBytes](#cycloneddsdomaininternalmaxqueuedrexmitbytes), [MaxQueuedRexmitMessages](#cycloneddsdomaininternalmaxqueuedrexmitmessages), [MaxSampleSize](#cycloneddsdomaininternalmaxsamplesize), [MeasureHbToAckLatency](#cycloneddsdomaininternalmeasurehbtoacklatency), [MinimumSocketReceiveBufferSize](#cycloneddsdomaininternalminimumsocketreceivebuffersize), [MinimumSocketSendBufferSize](#cycloneddsdomaininternalminimumsocketsendbuffersize), [MonitorPort](#cycloneddsdomaininternalmonitorport), [MultipleReceiveThreads](#cycloneddsdomaininternalmultiplereceivethreads), [NackDelay](#cycloneddsdomaininternalnackdelay), [PreEmptiveAckDelay](#cycloneddsdomaininternalpreemptiveackdelay), [PrimaryReorderMaxSamples](#cycloneddsdomaininternalprimaryreordermaxsamples), [PrioritizeRetransmit](#cycloneddsdomaininternalprioritizeretransmit), [RediscoveryBlacklistDuration](#cycloneddsdomaininternalrediscoveryblacklistduration), [RetransmitMerging](#cycloneddsdomaininternalretransmitmerging), [RetransmitMergingPeriod](#cycloneddsdomaininternalretransmitmergingperiod), [RetryOnRejectBestEffort](#cycloneddsdomaininternalretryonrejectbesteffort), [SPDPResponseMaxDelay](#cycloneddsdomaininternalspdpresponsemaxdelay), [ScheduleTimeRounding](#cycloneddsdomaininternalscheduletimerounding), [SecondaryReorderMaxSamples](#cycloneddsdomaininternalsecondaryreordermaxsamples), [SendAsync](#cycloneddsdomaininternalsendasync), [SquashParticipants](#cycloneddsdomaininternalsquashparticipants), [SynchronousDeliveryLatencyBound](#cycloneddsdomaininternalsynchronousdeliverylatencybound), [SynchronousDeliveryPriorityThreshold](#cycloneddsdomaininternalsynchronousdeliveryprioritythreshold), [Test](#cycloneddsdomaininternaltest), [UnicastResponseToSPDPMessages](#cycloneddsdomaininternalunicastresponsetospdpmessages), [UseMulticastIfMreqn](#cycloneddsdomaininternalusemulticastifmreqn), [Watermarks](#cycloneddsdomaininternalwatermarks), [WriteBatch](#cycloneddsdomaininternalwritebatch), [WriterLingerDuration](#cycloneddsdomaininternalwriterlingerduration)
-
-
-The Internal elements deal with a variety of settings that evolving and
-that are not necessarily fully supported. For the vast majority of the
-Internal settings, the functionality per-se is supported, but the right
-to change the way the options control the functionality is reserved. This
-includes renaming or moving options.
-
-
-#### //CycloneDDS/Domain/Internal/AccelerateRexmitBlockSize
-Integer
-
-Proxy readers that are assumed to sill be retrieving historical data get
-this many samples retransmitted when they NACK something, even if some of
-these samples have sequence numbers outside the set covered by the NACK.
-
-The default value is: "0".
-
-
-#### //CycloneDDS/Domain/Internal/AssumeMulticastCapable
-Text
-
-This element controls which network interfaces are assumed to be capable
-of multicasting even when the interface flags returned by the operating
-system state it is not (this provides a workaround for some platforms).
-It is a comma-separated lists of patterns (with ? and * wildcards)
-against which the interface names are matched.
-
-The default value is: "".
-
-
-#### //CycloneDDS/Domain/Internal/AutoReschedNackDelay
-Number-with-unit
-
-This setting controls the interval with which a reader will continue
-NACK'ing missing samples in the absence of a response from the writer, as
-a protection mechanism against writers incorrectly stopping the sending
-of HEARTBEAT messages.
-
-Valid values are finite durations with an explicit unit or the keyword
-'inf' for infinity. Recognised units: ns, us, ms, s, min, hr, day.
-
-The default value is: "1 s".
-
-
-#### //CycloneDDS/Domain/Internal/AuxiliaryBandwidthLimit
-Number-with-unit
-
-This element specifies the maximum transmit rate of auxiliary traffic not
-bound to a specific channel, such as discovery traffic, as well as
-auxiliary traffic related to a certain channel if that channel has
-elected to share this global AuxiliaryBandwidthLimit. Bandwidth limiting
-uses a leaky bucket scheme. The default value "inf" means Cyclone DDS
-imposes no limitation, the underlying operating system and hardware will
-likely limit the maimum transmit rate.
-
-The unit must be specified explicitly. Recognised units: Xb/s, Xbps for
-bits/s or XB/s, XBps for bytes/s; where X is an optional prefix: k for
-10^3, Ki for 210, M for 106, Mi for 220,
-G for 109, Gi for 230.
-
-The default value is: "inf".
-
-
-#### //CycloneDDS/Domain/Internal/BuiltinEndpointSet
-One of: full, writers, minimal
-
-This element controls which participants will have which built-in
-endpoints for the discovery and liveliness protocols. Valid values are:
-
-* full: all participants have all endpoints;
-
-* writers: all participants have the writers, but just one has the readers;
-
-* minimal: only one participant has built-in endpoints.
-
-The default is writers, as this is thought to be compliant and reasonably
-efficient. Minimal may or may not be compliant but is most efficient, and
-full is inefficient but certain to be compliant. See also
-Internal/ConservativeBuiltinReaderStartup.
-
-The default value is: "writers".
-
-
-#### //CycloneDDS/Domain/Internal/ControlTopic
-
-The ControlTopic element allows configured whether Cyclone DDS provides a
-special control interface via a predefined topic or not.
-
-
-#### //CycloneDDS/Domain/Internal/DDSI2DirectMaxThreads
-Integer
-
-This element sets the maximum number of extra threads for an
-experimental, undocumented and unsupported direct mode.
-
-The default value is: "1".
-
-
-#### //CycloneDDS/Domain/Internal/DefragReliableMaxSamples
-Integer
-
-This element sets the maximum number of samples that can be defragmented
-simultaneously for a reliable writer. This has to be large enough to
-handle retransmissions of historical data in addition to new samples.
-
-The default value is: "16".
-
-
-#### //CycloneDDS/Domain/Internal/DefragUnreliableMaxSamples
-Integer
-
-This element sets the maximum number of samples that can be defragmented
-simultaneously for a best-effort writers.
-
-The default value is: "4".
-
-
-#### //CycloneDDS/Domain/Internal/DeliveryQueueMaxSamples
-Integer
-
-This element controls the Maximum size of a delivery queue, expressed in
-samples. Once a delivery queue is full, incoming samples destined for
-that queue are dropped until space becomes available again.
-
-The default value is: "256".
-
-
-#### //CycloneDDS/Domain/Internal/EnableExpensiveChecks
-One of:
-* Comma-separated list of: whc, rhc, all
-* Or empty
-
-This element enables expensive checks in builds with assertions enabled
-and is ignored otherwise. Recognised categories are:
-
-* whc: writer history cache checking
-
-* rhc: reader history cache checking
-
-
-
-In addition, there is the keyword all that enables all checks.
-
-The default value is: "".
-
-
-#### //CycloneDDS/Domain/Internal/GenerateKeyhash
-Boolean
-
-When true, include keyhashes in outgoing data for topics with keys.
-
-The default value is: "false".
-
-
-#### //CycloneDDS/Domain/Internal/HeartbeatInterval
-Number-with-unit
-
-This elemnents allows configuring the base interval for sending writer
-heartbeats and the bounds within it can vary.
-
-Valid values are finite durations with an explicit unit or the keyword
-'inf' for infinity. Recognised units: ns, us, ms, s, min, hr, day.
-
-The default value is: "100 ms".
-
-
-#### //CycloneDDS/Domain/Internal/LateAckMode
-Boolean
-
-Ack a sample only when it has been delivered, instead of when committed
-to delivering it.
-
-The default value is: "false".
-
-
-#### //CycloneDDS/Domain/Internal/LeaseDuration
-Number-with-unit
-
-This setting controls the default participant lease duration.
-
-The unit must be specified explicitly. Recognised units: ns, us, ms, s,
-min, hr, day.
-
-The default value is: "10 s".
-
-
-#### //CycloneDDS/Domain/Internal/LivelinessMonitoring
-Boolean
-
-This element controls whether or not implementation should internally
-monitor its own liveliness. If liveliness monitoring is enabled, stack
-traces can be dumped automatically when some thread appears to have
-stopped making progress.
-
-The default value is: "false".
-
-
-#### //CycloneDDS/Domain/Internal/MaxParticipants
-Integer
-
-This elements configures the maximum number of DCPS domain participants
-this Cyclone DDS instance is willing to service. 0 is unlimited.
-
-The default value is: "0".
-
-
-#### //CycloneDDS/Domain/Internal/MaxQueuedRexmitBytes
-Number-with-unit
-
-This setting limits the maximum number of bytes queued for
-retransmission. The default value of 0 is unlimited unless an
-AuxiliaryBandwidthLimit has been set, in which case it becomes NackDelay
-* AuxiliaryBandwidthLimit. It must be large enough to contain the largest
-sample that may need to be retransmitted.
-
-The unit must be specified explicitly. Recognised units: B (bytes), kB &
-KiB (2^10 bytes), MB & MiB (220 bytes), GB & GiB
-(230 bytes).
-
-The default value is: "50 kB".
-
-
-#### //CycloneDDS/Domain/Internal/MaxQueuedRexmitMessages
-Integer
-
-This settings limits the maximum number of samples queued for
-retransmission.
-
-The default value is: "200".
-
-
-#### //CycloneDDS/Domain/Internal/MaxSampleSize
-Number-with-unit
-
-This setting controls the maximum (CDR) serialised size of samples that
-Cyclone DDS will forward in either direction. Samples larger than this
-are discarded with a warning.
-
-The unit must be specified explicitly. Recognised units: B (bytes), kB &
-KiB (2^10 bytes), MB & MiB (220 bytes), GB & GiB
-(230 bytes).
-
-The default value is: "2147483647 B".
-
-
-#### //CycloneDDS/Domain/Internal/MeasureHbToAckLatency
-Boolean
-
-This element enables heartbeat-to-ack latency among Cyclone DDS services
-by prepending timestamps to Heartbeat and AckNack messages and
-calculating round trip times. This is non-standard behaviour. The
-measured latencies are quite noisy and are currently not used anywhere.
-
-The default value is: "false".
-
-
-#### //CycloneDDS/Domain/Internal/MinimumSocketReceiveBufferSize
-Number-with-unit
-
-This setting controls the minimum size of socket receive buffers. The
-operating system provides some size receive buffer upon creation of the
-socket, this option can be used to increase the size of the buffer beyond
-that initially provided by the operating system. If the buffer size
-cannot be increased to the specified size, an error is reported.
-
-The default setting is the word "default", which means Cyclone DDS will
-attempt to increase the buffer size to 1MB, but will silently accept a
-smaller buffer should that attempt fail.
-
-The unit must be specified explicitly. Recognised units: B (bytes), kB &
-KiB (2^10 bytes), MB & MiB (220 bytes), GB & GiB
-(230 bytes).
-
-The default value is: "default".
-
-
-#### //CycloneDDS/Domain/Internal/MinimumSocketSendBufferSize
-Number-with-unit
-
-This setting controls the minimum size of socket send buffers. This
-setting can only increase the size of the send buffer, if the operating
-system by default creates a larger buffer, it is left unchanged.
-
-The unit must be specified explicitly. Recognised units: B (bytes), kB &
-KiB (2^10 bytes), MB & MiB (220 bytes), GB & GiB
-(230 bytes).
-
-The default value is: "64 KiB".
-
-
-#### //CycloneDDS/Domain/Internal/MonitorPort
-Integer
-
-This element allows configuring a service that dumps a text description
-of part the internal state to TCP clients. By default (-1), this is
-disabled; specifying 0 means a kernel-allocated port is used; a positive
-number is used as the TCP port number.
-
-The default value is: "-1".
-
-
-#### //CycloneDDS/Domain/Internal/MultipleReceiveThreads
-Boolean
-
-This element controls whether all traffic is handled by a single receive
-thread or whether multiple receive threads may be used to improve
-latency. Currently multiple receive threads are only used for
-connectionless transport (e.g., UDP) and ManySocketsMode not set to
-single (the default).
-
-The default value is: "true".
-
-
-#### //CycloneDDS/Domain/Internal/NackDelay
-Number-with-unit
-
-This setting controls the delay between receipt of a HEARTBEAT indicating
-missing samples and a NACK (ignored when the HEARTBEAT requires an
-answer). However, no NACK is sent if a NACK had been scheduled already
-for a response earlier than the delay requests: then that NACK will
-incorporate the latest information.
-
-The unit must be specified explicitly. Recognised units: ns, us, ms, s,
-min, hr, day.
-
-The default value is: "10 ms".
-
-
-#### //CycloneDDS/Domain/Internal/PreEmptiveAckDelay
-Number-with-unit
-
-This setting controls the delay between the discovering a remote writer
-and sending a pre-emptive AckNack to discover the range of data
-available.
-
-The unit must be specified explicitly. Recognised units: ns, us, ms, s,
-min, hr, day.
-
-The default value is: "10 ms".
-
-
-#### //CycloneDDS/Domain/Internal/PrimaryReorderMaxSamples
-Integer
-
-This element sets the maximum size in samples of a primary re-order
-administration. Each proxy writer has one primary re-order administration
-to buffer the packet flow in case some packets arrive out of order. Old
-samples are forwarded to secondary re-order administrations associated
-with readers in need of historical data.
-
-The default value is: "128".
-
-
-#### //CycloneDDS/Domain/Internal/PrioritizeRetransmit
-Boolean
-
-This element controls whether retransmits are prioritized over new data,
-speeding up recovery.
-
-The default value is: "true".
-
-
-#### //CycloneDDS/Domain/Internal/RediscoveryBlacklistDuration
-Number-with-unit
-
-This element controls for how long a remote participant that was
-previously deleted will remain on a blacklist to prevent rediscovery,
-giving the software on a node time to perform any cleanup actions it
-needs to do. To some extent this delay is required internally by Cyclone
-DDS, but in the default configuration with the 'enforce' attribute set to
-false, Cyclone DDS will reallow rediscovery as soon as it has cleared its
-internal administration. Setting it to too small a value may result in
-the entry being pruned from the blacklist before Cyclone DDS is ready, it
-is therefore recommended to set it to at least several seconds.
-
-Valid values are finite durations with an explicit unit or the keyword
-'inf' for infinity. Recognised units: ns, us, ms, s, min, hr, day.
-
-The default value is: "10s".
-
-
-#### //CycloneDDS/Domain/Internal/RetransmitMerging
-One of: never, adaptive, always
-
-This elements controls the addressing and timing of retransmits. Possible
-values are:
-
-* never: retransmit only to the NACK-ing reader;
-
-* adaptive: attempt to combine retransmits needed for reliability, but send
- historical (transient-local) data to the requesting reader only;
-
-* always: do not distinguish between different causes, always try to merge.
-
-The default is never. See also Internal/RetransmitMergingPeriod.
-
-The default value is: "never".
-
-
-#### //CycloneDDS/Domain/Internal/RetransmitMergingPeriod
-Number-with-unit
-
-This setting determines the size of the time window in which a NACK of
-some sample is ignored because a retransmit of that sample has been
-multicasted too recently. This setting has no effect on unicasted
-retransmits.
-
-See also Internal/RetransmitMerging.
-
-The unit must be specified explicitly. Recognised units: ns, us, ms, s,
-min, hr, day.
-
-The default value is: "5 ms".
-
-
-#### //CycloneDDS/Domain/Internal/RetryOnRejectBestEffort
-Boolean
-
-Whether or not to locally retry pushing a received best-effort sample
-into the reader caches when resource limits are reached.
-
-The default value is: "false".
-
-
-#### //CycloneDDS/Domain/Internal/SPDPResponseMaxDelay
-Number-with-unit
-
-Maximum pseudo-random delay in milliseconds between discovering a remote
-participant and responding to it.
-
-The unit must be specified explicitly. Recognised units: ns, us, ms, s,
-min, hr, day.
-
-The default value is: "0 ms".
-
-
-#### //CycloneDDS/Domain/Internal/ScheduleTimeRounding
-Number-with-unit
-
-This setting allows the timing of scheduled events to be rounded up so
-that more events can be handled in a single cycle of the event queue. The
-default is 0 and causes no rounding at all, i.e. are scheduled exactly,
-whereas a value of 10ms would mean that events are rounded up to the
-nearest 10 milliseconds.
-
-The unit must be specified explicitly. Recognised units: ns, us, ms, s,
-min, hr, day.
-
-The default value is: "0 ms".
-
-
-#### //CycloneDDS/Domain/Internal/SecondaryReorderMaxSamples
-Integer
-
-This element sets the maximum size in samples of a secondary re-order
-administration. The secondary re-order administration is per reader in
-need of historical data.
-
-The default value is: "128".
-
-
-#### //CycloneDDS/Domain/Internal/SendAsync
-Boolean
-
-This element controls whether the actual sending of packets occurs on the
-same thread that prepares them, or is done asynchronously by another
-thread.
-
-The default value is: "false".
-
-
-#### //CycloneDDS/Domain/Internal/SquashParticipants
-Boolean
-
-This element controls whether Cyclone DDS advertises all the domain
-participants it serves in DDSI (when set to false), or rather only one
-domain participant (the one corresponding to the Cyclone DDS process;
-when set to true). In the latter case Cyclone DDS becomes the virtual
-owner of all readers and writers of all domain participants, dramatically
-reducing discovery traffic (a similar effect can be obtained by setting
-Internal/BuiltinEndpointSet to "minimal" but with less loss of
-information).
-
-The default value is: "false".
-
-
-#### //CycloneDDS/Domain/Internal/SynchronousDeliveryLatencyBound
-Number-with-unit
-
-This element controls whether samples sent by a writer with QoS settings
-transport_priority >= SynchronousDeliveryPriorityThreshold and a
-latency_budget at most this element's value will be delivered
-synchronously from the "recv" thread, all others will be delivered
-asynchronously through delivery queues. This reduces latency at the
-expense of aggregate bandwidth.
-
-Valid values are finite durations with an explicit unit or the keyword
-'inf' for infinity. Recognised units: ns, us, ms, s, min, hr, day.
-
-The default value is: "inf".
-
-
-#### //CycloneDDS/Domain/Internal/SynchronousDeliveryPriorityThreshold
-Integer
-
-This element controls whether samples sent by a writer with QoS settings
-latency_budget <= SynchronousDeliveryLatencyBound and transport_priority
-greater than or equal to this element's value will be delivered
-synchronously from the "recv" thread, all others will be delivered
-asynchronously through delivery queues. This reduces latency at the
-expense of aggregate bandwidth.
-
-The default value is: "0".
-
-
-#### //CycloneDDS/Domain/Internal/Test
-Children: [XmitLossiness](#cycloneddsdomaininternaltestxmitlossiness)
-
-
-Testing options.
-
-
-##### //CycloneDDS/Domain/Internal/Test/XmitLossiness
-Integer
-
-This element controls the fraction of outgoing packets to drop, specified
-as samples per thousand.
-
-The default value is: "0".
-
-
-#### //CycloneDDS/Domain/Internal/UnicastResponseToSPDPMessages
-Boolean
-
-This element controls whether the response to a newly discovered
-participant is sent as a unicasted SPDP packet, instead of rescheduling
-the periodic multicasted one. There is no known benefit to setting this
-to false.
-
-The default value is: "true".
-
-
-#### //CycloneDDS/Domain/Internal/UseMulticastIfMreqn
-Integer
-
-Do not use.
-
-The default value is: "0".
-
-
-#### //CycloneDDS/Domain/Internal/Watermarks
-Children: [WhcAdaptive](#cycloneddsdomaininternalwatermarkswhcadaptive), [WhcHigh](#cycloneddsdomaininternalwatermarkswhchigh), [WhcHighInit](#cycloneddsdomaininternalwatermarkswhchighinit), [WhcLow](#cycloneddsdomaininternalwatermarkswhclow)
-
-
-Watermarks for flow-control.
-
-
-##### //CycloneDDS/Domain/Internal/Watermarks/WhcAdaptive
-Boolean
-
-This element controls whether Cyclone DDS will adapt the high-water mark
-to current traffic conditions, based on retransmit requests and transmit
-pressure.
-
-The default value is: "true".
-
-
-##### //CycloneDDS/Domain/Internal/Watermarks/WhcHigh
-Number-with-unit
-
-This element sets the maximum allowed high-water mark for the Cyclone DDS
-WHCs, expressed in bytes. A writer is suspended when the WHC reaches this
-size.
-
-The unit must be specified explicitly. Recognised units: B (bytes), kB &
-KiB (2^10 bytes), MB & MiB (220 bytes), GB & GiB
-(230 bytes).
-
-The default value is: "100 kB".
-
-
-##### //CycloneDDS/Domain/Internal/Watermarks/WhcHighInit
-Number-with-unit
-
-This element sets the initial level of the high-water mark for the
-Cyclone DDS WHCs, expressed in bytes.
-
-The unit must be specified explicitly. Recognised units: B (bytes), kB &
-KiB (2^10 bytes), MB & MiB (220 bytes), GB & GiB
-(230 bytes).
-
-The default value is: "30 kB".
-
-
-##### //CycloneDDS/Domain/Internal/Watermarks/WhcLow
-Number-with-unit
-
-This element sets the low-water mark for the Cyclone DDS WHCs, expressed
-in bytes. A suspended writer resumes transmitting when its Cyclone DDS
-WHC shrinks to this size.
-
-The unit must be specified explicitly. Recognised units: B (bytes), kB &
-KiB (2^10 bytes), MB & MiB (220 bytes), GB & GiB
-(230 bytes).
-
-The default value is: "1 kB".
-
-
-#### //CycloneDDS/Domain/Internal/WriteBatch
-Boolean
-
-This element enables the batching of write operations. By default each
-write operation writes through the write cache and out onto the
-transport. Enabling write batching causes multiple small write operations
-to be aggregated within the write cache into a single larger write. This
-gives greater throughput at the expense of latency. Currently there is no
-mechanism for the write cache to automatically flush itself, so that if
-write batching is enabled, the application may havee to use the
-dds_write_flush function to ensure thta all samples are written.
-
-The default value is: "false".
-
-
-#### //CycloneDDS/Domain/Internal/WriterLingerDuration
-Number-with-unit
-
-This setting controls the maximum duration for which actual deletion of a
-reliable writer with unacknowledged data in its history will be postponed
-to provide proper reliable transmission.
-
-The unit must be specified explicitly. Recognised units: ns, us, ms, s,
-min, hr, day.
-
-The default value is: "1 s".
-
-
-### //CycloneDDS/Domain/Partitioning
-Children: [IgnoredPartitions](#cycloneddsdomainpartitioningignoredpartitions), [NetworkPartitions](#cycloneddsdomainpartitioningnetworkpartitions), [PartitionMappings](#cycloneddsdomainpartitioningpartitionmappings)
-
-
-The Partitioning element specifies Cyclone DDS network partitions and how
-DCPS partition/topic combinations are mapped onto the network partitions.
-
-
-#### //CycloneDDS/Domain/Partitioning/IgnoredPartitions
-Children: [IgnoredPartition](#cycloneddsdomainpartitioningignoredpartitionsignoredpartition)
-
-
-The IgnoredPartitions element specifies DCPS partition/topic combinations
-that are not distributed over the network.
-
-
-##### //CycloneDDS/Domain/Partitioning/IgnoredPartitions/IgnoredPartition
-Attributes: [DCPSPartitionTopic](#cycloneddsdomainpartitioningignoredpartitionsignoredpartitiondcpspartitiontopic)
-
-
-This element can be used to prevent certain combinations of DCPS
-partition and topic from being transmitted over the network. Cyclone DDS
-will complete ignore readers and writers for which all DCPS partitions as
-well as their topic is ignored, not even creating DDSI readers and
-writers to mirror the DCPS ones.
-
-
-##### //CycloneDDS/Domain/Partitioning/IgnoredPartitions/IgnoredPartition[@DCPSPartitionTopic]
-Text
-
-This attribute specifies a partition and a topic expression, separated by
-a single '.', that are used to determine if a given partition and topic
-will be ignored or not. The expressions may use the usual wildcards '*'
-and '?'. Cyclone DDS will consider an wildcard DCPS partition to match an
-expression iff there exists a string that satisfies both expressions.
-
-
-#### //CycloneDDS/Domain/Partitioning/NetworkPartitions
-Children: [NetworkPartition](#cycloneddsdomainpartitioningnetworkpartitionsnetworkpartition)
-
-
-The NetworkPartitions element specifies the Cyclone DDS network
-partitions.
-
-
-##### //CycloneDDS/Domain/Partitioning/NetworkPartitions/NetworkPartition
-Attributes: [Address](#cycloneddsdomainpartitioningnetworkpartitionsnetworkpartitionaddress), [Connected](#cycloneddsdomainpartitioningnetworkpartitionsnetworkpartitionconnected), [Name](#cycloneddsdomainpartitioningnetworkpartitionsnetworkpartitionname), [SecurityProfile](#cycloneddsdomainpartitioningnetworkpartitionsnetworkpartitionsecurityprofile)
-
-
-This element defines a Cyclone DDS network partition.
-
-
-##### //CycloneDDS/Domain/Partitioning/NetworkPartitions/NetworkPartition[@Address]
-Text
-
-This attribute specifies the multicast addresses associated with the
-network partition as a comma-separated list. Readers matching this
-network partition (cf. Partitioning/PartitionMappings) will listen for
-multicasts on all of these addresses and advertise them in the discovery
-protocol. The writers will select the most suitable address from the
-addresses advertised by the readers.
-
-
-##### //CycloneDDS/Domain/Partitioning/NetworkPartitions/NetworkPartition[@Connected]
-Boolean
-
-This attribute is a placeholder.
-
-The default value is: "true".
-
-
-##### //CycloneDDS/Domain/Partitioning/NetworkPartitions/NetworkPartition[@Name]
-Text
-
-This attribute specifies the name of this Cyclone DDS network partition.
-Two network partitions cannot have the same name.
-
-
-##### //CycloneDDS/Domain/Partitioning/NetworkPartitions/NetworkPartition[@SecurityProfile]
-Text
-
-This attribute selects the Cyclone DDS security profile for encrypting
-the traffic mapped to this Cyclone DDS network partition. The default
-"null" means the network partition is unsecured; any other name refers to
-a security profile defined using the Security/SecurityProfile elements.
-
-The default value is: "null".
-
-
-#### //CycloneDDS/Domain/Partitioning/PartitionMappings
-Children: [PartitionMapping](#cycloneddsdomainpartitioningpartitionmappingspartitionmapping)
-
-
-The PartitionMappings element specifies the mapping from DCPS
-partition/topic combinations to Cyclone DDS network partitions.
-
-
-##### //CycloneDDS/Domain/Partitioning/PartitionMappings/PartitionMapping
-Attributes: [DCPSPartitionTopic](#cycloneddsdomainpartitioningpartitionmappingspartitionmappingdcpspartitiontopic), [NetworkPartition](#cycloneddsdomainpartitioningpartitionmappingspartitionmappingnetworkpartition)
-
-
-This element defines a mapping from a DCPS partition/topic combination to
-a Cyclone DDS network partition. This allows partitioning data flows by
-using special multicast addresses for part of the data and possibly also
-encrypting the data flow.
-
-
-##### //CycloneDDS/Domain/Partitioning/PartitionMappings/PartitionMapping[@DCPSPartitionTopic]
-Text
-
-This attribute specifies a partition and a topic expression, separated by
-a single '.', that are used to determine if a given partition and topic
-maps to the Cyclone DDS network partition named by the NetworkPartition
-attribute in this PartitionMapping element. The expressions may use the
-usual wildcards '*' and '?'. Cyclone DDS will consider a wildcard DCPS
-partition to match an expression if there exists a string that satisfies
-both expressions.
-
-
-##### //CycloneDDS/Domain/Partitioning/PartitionMappings/PartitionMapping[@NetworkPartition]
-Text
-
-This attribute specifies which Cyclone DDS network partition is to be
-used for DCPS partition/topic combinations matching the
-DCPSPartitionTopic attribute within this PartitionMapping element.
-
-
-### //CycloneDDS/Domain/SSL
-Children: [CertificateVerification](#cycloneddsdomainsslcertificateverification), [Ciphers](#cycloneddsdomainsslciphers), [Enable](#cycloneddsdomainsslenable), [EntropyFile](#cycloneddsdomainsslentropyfile), [KeyPassphrase](#cycloneddsdomainsslkeypassphrase), [KeystoreFile](#cycloneddsdomainsslkeystorefile), [MinimumTLSVersion](#cycloneddsdomainsslminimumtlsversion), [SelfSignedCertificates](#cycloneddsdomainsslselfsignedcertificates), [VerifyClient](#cycloneddsdomainsslverifyclient)
-
-
-The SSL element allows specifying various parameters related to using
-SSL/TLS for DDSI over TCP.
-
-
-#### //CycloneDDS/Domain/SSL/CertificateVerification
-Boolean
-
-If disabled this allows SSL connections to occur even if an X509
-certificate fails verification.
-
-The default value is: "true".
-
-
-#### //CycloneDDS/Domain/SSL/Ciphers
-Text
-
-The set of ciphers used by SSL/TLS
-
-The default value is: "ALL:!ADH:!LOW:!EXP:!MD5:@STRENGTH".
-
-
-#### //CycloneDDS/Domain/SSL/Enable
-Boolean
-
-This enables SSL/TLS for TCP.
-
-The default value is: "false".
-
-
-#### //CycloneDDS/Domain/SSL/EntropyFile
-Text
-
-The SSL/TLS random entropy file name.
-
-The default value is: "".
-
-
-#### //CycloneDDS/Domain/SSL/KeyPassphrase
-Text
-
-The SSL/TLS key pass phrase for encrypted keys.
-
-The default value is: "secret".
-
-
-#### //CycloneDDS/Domain/SSL/KeystoreFile
-Text
-
-The SSL/TLS key and certificate store file name. The keystore must be in
-PEM format.
-
-The default value is: "keystore".
-
-
-#### //CycloneDDS/Domain/SSL/MinimumTLSVersion
-Text
-
-The minimum TLS version that may be negotiated, valid values are 1.2 and
-1.3.
-
-The default value is: "1.3".
-
-
-#### //CycloneDDS/Domain/SSL/SelfSignedCertificates
-Boolean
-
-This enables the use of self signed X509 certificates.
-
-The default value is: "false".
-
-
-#### //CycloneDDS/Domain/SSL/VerifyClient
-Boolean
-
-This enables an SSL server checking the X509 certificate of a connecting
-client.
-
-The default value is: "true".
-
-
-### //CycloneDDS/Domain/Security
-Children: [SecurityProfile](#cycloneddsdomainsecuritysecurityprofile)
-
-
-The Security element specifies Cyclone DDS security profiles that can be
-used to encrypt traffic mapped to Cyclone DDS network partitions.
-
-
-#### //CycloneDDS/Domain/Security/SecurityProfile
-Attributes: [Cipher](#cycloneddsdomainsecuritysecurityprofilecipher), [CipherKey](#cycloneddsdomainsecuritysecurityprofilecipherkey), [Name](#cycloneddsdomainsecuritysecurityprofilename)
-
-
-This element defines a Cyclone DDS security profile.
-
-
-#### //CycloneDDS/Domain/Security/SecurityProfile[@Cipher]
-One of: null, blowfish, aes128, aes192, aes256
-
-This attribute specifies the cipher to be used for encrypting traffic
-over network partitions secured by this security profile. The possible
-ciphers are:
-
-* aes128: AES with a 128-bit key;
-
-* aes192: AES with a 192-bit key;
-
-* aes256: AES with a 256-bit key;
-
-* blowfish: the Blowfish cipher with a 128 bit key;
-
-* null: no encryption;
-
-SHA1 is used on conjunction with all ciphers except "null" to ensure data
-integrity.
-
-The default value is: "null".
-
-
-#### //CycloneDDS/Domain/Security/SecurityProfile[@CipherKey]
-Text
-
-The CipherKey attribute is used to define the secret key required by the
-cipher selected using the Cipher attribute. The value can be a URI
-referencing an external file containing the secret key, or the secret key
-can be defined in-place as a string value.
-
-The key must be specified as a hexadecimal string with each character
-representing 4 bits of the key. E.g., 1ABC represents the 16-bit key 0001
-1010 1011 1100. The key should not follow a well-known pattern and must
-exactly match the key length of the selected cipher.
-
-A malformed key will cause the security profile to be marked as invalid,
-and disable all network partitions secured by the (invalid) security
-profile to prevent information leaks.
-
-As all DDS applications require read access to the XML configuration
-file, for security reasons it is recommended to store the secret key in
-an external file in the file system, referenced by its URI. The file
-should be protected against read and write access from other users on the
-host.
-
-The default value is: "".
-
-
-#### //CycloneDDS/Domain/Security/SecurityProfile[@Name]
-Text
-
-This attribute specifies the name of this Cyclone DDS security profile.
-Two security profiles cannot have the same name.
-
-
-### //CycloneDDS/Domain/Sizing
-Children: [ReceiveBufferChunkSize](#cycloneddsdomainsizingreceivebufferchunksize), [ReceiveBufferSize](#cycloneddsdomainsizingreceivebuffersize)
-
-
-The Sizing element specifies a variety of configuration settings dealing
-with expected system sizes, buffer sizes, &c.
-
-
-#### //CycloneDDS/Domain/Sizing/ReceiveBufferChunkSize
-Number-with-unit
-
-This element specifies the size of one allocation unit in the receive
-buffer. Must be greater than the maximum packet size by a modest amount
-(too large packets are dropped). Each allocation is shrunk immediately
-after processing a message, or freed straightaway.
-
-The unit must be specified explicitly. Recognised units: B (bytes), kB &
-KiB (2^10 bytes), MB & MiB (220 bytes), GB & GiB
-(230 bytes).
-
-The default value is: "128 KiB".
-
-
-#### //CycloneDDS/Domain/Sizing/ReceiveBufferSize
-Number-with-unit
-
-This element sets the size of a single receive buffer. Many receive
-buffers may be needed. The minimum workable size a little bit larger than
-Sizing/ReceiveBufferChunkSize, and the value used is taken as the
-configured value and the actual minimum workable size.
-
-The unit must be specified explicitly. Recognised units: B (bytes), kB &
-KiB (2^10 bytes), MB & MiB (220 bytes), GB & GiB
-(230 bytes).
-
-The default value is: "1 MiB".
-
-
-### //CycloneDDS/Domain/TCP
-Children: [AlwaysUsePeeraddrForUnicast](#cycloneddsdomaintcpalwaysusepeeraddrforunicast), [Enable](#cycloneddsdomaintcpenable), [NoDelay](#cycloneddsdomaintcpnodelay), [Port](#cycloneddsdomaintcpport), [ReadTimeout](#cycloneddsdomaintcpreadtimeout), [WriteTimeout](#cycloneddsdomaintcpwritetimeout)
-
-
-The TCP element allows specifying various parameters related to running
-DDSI over TCP.
-
-
-#### //CycloneDDS/Domain/TCP/AlwaysUsePeeraddrForUnicast
-Boolean
-
-Setting this to true means the unicast addresses in SPDP packets will be
-ignored and the peer address from the TCP connection will be used
-instead. This may help work around incorrectly advertised addresses when
-using TCP.
-
-The default value is: "false".
-
-
-#### //CycloneDDS/Domain/TCP/Enable
-One of: false, true, default
-
-This element enables the optional TCP transport - deprecated, use
-General/Transport instead.
-
-The default value is: "default".
-
-
-#### //CycloneDDS/Domain/TCP/NoDelay
-Boolean
-
-This element enables the TCP_NODELAY socket option, preventing multiple
-DDSI messages being sent in the same TCP request. Setting this option
-typically optimises latency over throughput.
-
-The default value is: "true".
-
-
-#### //CycloneDDS/Domain/TCP/Port
-Integer
-
-This element specifies the TCP port number on which Cyclone DDS accepts
-connections. If the port is set it is used in entity locators, published
-with DDSI discovery. Dynamically allocated if zero. Disabled if -1 or not
-configured. If disabled other DDSI services will not be able to establish
-connections with the service, the service can only communicate by
-establishing connections to other services.
-
-The default value is: "-1".
-
-
-#### //CycloneDDS/Domain/TCP/ReadTimeout
-Number-with-unit
-
-This element specifies the timeout for blocking TCP read operations. If
-this timeout expires then the connection is closed.
-
-The unit must be specified explicitly. Recognised units: ns, us, ms, s,
-min, hr, day.
-
-The default value is: "2 s".
-
-
-#### //CycloneDDS/Domain/TCP/WriteTimeout
-Number-with-unit
-
-This element specifies the timeout for blocking TCP write operations. If
-this timeout expires then the connection is closed.
-
-The unit must be specified explicitly. Recognised units: ns, us, ms, s,
-min, hr, day.
-
-The default value is: "2 s".
-
-
-### //CycloneDDS/Domain/ThreadPool
-Children: [Enable](#cycloneddsdomainthreadpoolenable), [ThreadMax](#cycloneddsdomainthreadpoolthreadmax), [Threads](#cycloneddsdomainthreadpoolthreads)
-
-
-The ThreadPool element allows specifying various parameters related to
-using a thread pool to send DDSI messages to multiple unicast addresses
-(TCP or UDP).
-
-
-#### //CycloneDDS/Domain/ThreadPool/Enable
-Boolean
-
-This element enables the optional thread pool.
-
-The default value is: "false".
-
-
-#### //CycloneDDS/Domain/ThreadPool/ThreadMax
-Integer
-
-This elements configures the maximum number of threads in the thread
-pool.
-
-The default value is: "8".
-
-
-#### //CycloneDDS/Domain/ThreadPool/Threads
-Integer
-
-This elements configures the initial number of threads in the thread
-pool.
-
-The default value is: "4".
-
-
-### //CycloneDDS/Domain/Threads
-Children: [Thread](#cycloneddsdomainthreadsthread)
-
-
-This element is used to set thread properties.
-
-
-#### //CycloneDDS/Domain/Threads/Thread
-Attributes: [Name](#cycloneddsdomainthreadsthreadname)
-
-Children: [Scheduling](#cycloneddsdomainthreadsthreadscheduling), [StackSize](#cycloneddsdomainthreadsthreadstacksize)
-
-
-This element is used to set thread properties.
-
-
-#### //CycloneDDS/Domain/Threads/Thread[@Name]
-Text
-
-The Name of the thread for which properties are being set. The following
-threads exist:
-
-* gc: garbage collector thread involved in deleting entities;
-
-* recv: receive thread, taking data from the network and running the protocol
- state machine;
-
-* dq.builtins: delivery thread for DDSI-builtin data, primarily for discovery;
-
-* lease: DDSI liveliness monitoring;
-
-* tev: general timed-event handling, retransmits and discovery;
-
-* xmit.CHAN: transmit thread for channel CHAN;
-
-* dq.CHAN: delivery thread for channel CHAN;
-
-* tev.CHAN: timed-even thread for channel CHAN.
-
-
-##### //CycloneDDS/Domain/Threads/Thread/Scheduling
-Children: [Class](#cycloneddsdomainthreadsthreadschedulingclass), [Priority](#cycloneddsdomainthreadsthreadschedulingpriority)
-
-
-This element configures the scheduling properties of the thread.
-
-
-###### //CycloneDDS/Domain/Threads/Thread/Scheduling/Class
-One of: realtime, timeshare, default
-
-This element specifies the thread scheduling class (realtime, timeshare
-or default). The user may need special privileges from the underlying
-operating system to be able to assign some of the privileged scheduling
-classes.
-
-The default value is: "default".
-
-
-###### //CycloneDDS/Domain/Threads/Thread/Scheduling/Priority
-Text
-
-This element specifies the thread priority (decimal integer or default).
-Only priorities that are supported by the underlying operating system can
-be assigned to this element. The user may need special privileges from
-the underlying operating system to be able to assign some of the
-privileged priorities.
-
-The default value is: "default".
-
-
-##### //CycloneDDS/Domain/Threads/Thread/StackSize
-Number-with-unit
-
-This element configures the stack size for this thread. The default value
-default leaves the stack size at the operating system default.
-
-The unit must be specified explicitly. Recognised units: B (bytes), kB &
-KiB (2^10 bytes), MB & MiB (220 bytes), GB & GiB
-(230 bytes).
-
-The default value is: "default".
-
-
-### //CycloneDDS/Domain/Tracing
-Children: [AppendToFile](#cycloneddsdomaintracingappendtofile), [Category](#cycloneddsdomaintracingcategory), [OutputFile](#cycloneddsdomaintracingoutputfile), [PacketCaptureFile](#cycloneddsdomaintracingpacketcapturefile), [Verbosity](#cycloneddsdomaintracingverbosity)
-
-
-The Tracing element controls the amount and type of information that is
-written into the tracing log by the DDSI service. This is useful to track
-the DDSI service during application development.
-
-
-#### //CycloneDDS/Domain/Tracing/AppendToFile
-Boolean
-
-This option specifies whether the output is to be appended to an existing
-log file. The default is to create a new log file each time, which is
-generally the best option if a detailed log is generated.
-
-The default value is: "false".
-
-
-#### //CycloneDDS/Domain/Tracing/Category
-One of:
-* Comma-separated list of: fatal, error, warning, info, config, discovery, data, radmin, timing, traffic, topic, tcp, plist, whc, throttle, rhc, content, trace
-* Or empty
-
-This element enables individual logging categories. These are enabled in
-addition to those enabled by Tracing/Verbosity. Recognised categories
-are:
-
-* fatal: all fatal errors, errors causing immediate termination
-
-* error: failures probably impacting correctness but not necessarily causing
- immediate termination
-
-* warning: abnormal situations that will likely not impact correctness
-
-* config: full dump of the configuration
-
-* info: general informational notices
-
-* discovery: all discovery activity
-
-* data: include data content of samples in traces
-
-* radmin: receive buffer administration
-
-* timing: periodic reporting of CPU loads per thread
-
-* traffic: periodic reporting of total outgoing data
-
-* whc: tracing of writer history cache changes
-
-* tcp: tracing of TCP-specific activity
-
-* topic: tracing of topic definitions
-
-* >i>plist: tracing of discovery parameter list interpretation
-
-
-
-In addition, there is the keyword trace that enables all but radmin,
-topic, plist and whc.
-
-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
-is trace.
-
-The default value is: "".
-
-
-#### //CycloneDDS/Domain/Tracing/OutputFile
-Text
-
-This option specifies where the logging is printed to. Note that stdout
-and stderr are treated as special values, representing "standard out" and
-"standard error" respectively. No file is created unless logging
-categories are enabled using the Tracing/Verbosity or
-Tracing/EnabledCategory settings.
-
-The default value is: "cyclonedds.log".
-
-
-#### //CycloneDDS/Domain/Tracing/PacketCaptureFile
-Text
-
-This option specifies the file to which received and sent packets will be
-logged in the "pcap" format suitable for analysis using common networking
-tools, such as WireShark. IP and UDP headers are ficitious, in particular
-the destination address of received packets. The TTL may be used to
-distinguish between sent and received packets: it is 255 for sent packets
-and 128 for received ones. Currently IPv4 only.
-
-The default value is: "".
-
-
-#### //CycloneDDS/Domain/Tracing/Verbosity
-One of: finest, finer, fine, config, info, warning, severe, none
-
-This element enables standard groups of categories, based on a desired
-verbosity level. This is in addition to the categories enabled by the
-Tracing/Category setting. Recognised verbosity levels and the categories
-they map to are:
-
-* none: no Cyclone DDS log
-
-* severe: error and fatal
-
-* warning: severe + warning
-
-* info: warning + info
-
-* config: info + config
-
-* fine: config + discovery
-
-* finer: fine + traffic and timing
-
-* finest: finer + trace
-
-While none prevents any message from being written to a Cyclone DDS log
-file.
-
-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.
-
-The default value is: "none".
diff --git a/docs/manual/options.md b/docs/manual/options.md
index 4cef963..a5534b2 100644
--- a/docs/manual/options.md
+++ b/docs/manual/options.md
@@ -1650,7 +1650,7 @@ threads exist:
* dq.CHAN: delivery thread for channel CHAN;
-* tev.CHAN: timed-even thread for channel CHAN.
+* tev.CHAN: timed-event thread for channel CHAN.
##### //CycloneDDS/Domain/Threads/Thread/Scheduling
diff --git a/etc/cyclonedds.rnc b/etc/cyclonedds.rnc
index 22f13bb..0edc899 100644
--- a/etc/cyclonedds.rnc
+++ b/etc/cyclonedds.rnc
@@ -1315,7 +1315,7 @@ discovery;
dq.CHAN: delivery thread for channel CHAN;
-tev.CHAN: timed-even thread for channel CHAN.""" ] ]
+tev.CHAN: timed-event thread for channel CHAN.""" ] ]
attribute Name {
text
}
diff --git a/etc/cyclonedds.xsd b/etc/cyclonedds.xsd
index 894742d..49d4378 100644
--- a/etc/cyclonedds.xsd
+++ b/etc/cyclonedds.xsd
@@ -1781,7 +1781,7 @@ discovery;</li>
<li><i>dq.CHAN</i>: delivery thread for channel CHAN;</li>
-<li><i>tev.CHAN</i>: timed-even thread for channel CHAN.</li></ul>
+<li><i>tev.CHAN</i>: timed-event thread for channel CHAN.</li></ul>
diff --git a/examples/helloworld/publisher.c b/examples/helloworld/publisher.c
index 2dec98e..b75c32d 100644
--- a/examples/helloworld/publisher.c
+++ b/examples/helloworld/publisher.c
@@ -28,7 +28,7 @@ int main (int argc, char ** argv)
/* Create a Writer. */
writer = dds_create_writer (participant, topic, NULL, NULL);
if (writer < 0)
- DDS_FATAL("dds_create_write: %s\n", dds_strretcode(-writer));
+ DDS_FATAL("dds_create_writer: %s\n", dds_strretcode(-writer));
printf("=== [Publisher] Waiting for a reader to be discovered ...\n");
fflush (stdout);
diff --git a/examples/throughput/subscriber.c b/examples/throughput/subscriber.c
index e4c754f..01f6cd6 100644
--- a/examples/throughput/subscriber.c
+++ b/examples/throughput/subscriber.c
@@ -325,7 +325,7 @@ static dds_entity_t prepare_dds(dds_entity_t *reader, const char *partitionName)
participant = dds_create_participant (DDS_DOMAIN_DEFAULT, NULL, NULL);
if (participant < 0)
- DDS_FATAL("dds_create_particpant: %s\n", dds_strretcode(-participant));
+ DDS_FATAL("dds_create_participant: %s\n", dds_strretcode(-participant));
/* A Topic is created for our sample type on the domain participant. */
diff --git a/src/core/ddsi/src/q_config.c b/src/core/ddsi/src/q_config.c
index 63e937b..6a1039e 100644
--- a/src/core/ddsi/src/q_config.c
+++ b/src/core/ddsi/src/q_config.c
@@ -385,7 +385,7 @@ static const struct cfgelem thread_properties_cfgattrs[] = {
tev: general timed-event handling, retransmits and discovery;\n\
xmit.CHAN: transmit thread for channel CHAN;\n\
dq.CHAN: delivery thread for channel CHAN;\n\
-tev.CHAN: timed-even thread for channel CHAN.") },
+tev.CHAN: timed-event thread for channel CHAN.") },
END_MARKER
};
From 754eb4090eab64889215a119501f4e560c66bad7 Mon Sep 17 00:00:00 2001
From: Dennis Potman
Date: Thu, 20 Feb 2020 14:53:54 +0100
Subject: [PATCH 04/30] Fixed issue that Cyclone does not receive multicast
data on Windows when the destination cache of the network stack is in a
certain state. The issue is resolved by binding unicast sockets (incoming
unicast and all outgoing traffic) to the address of the interface instead of
inaddr_any (0.0.0.0). Set the new configuration option
internal/BindUnicastToInterfaceAddr to false to get the old behavior.
Co-authored-by: Erik Boasson
Signed-off-by: Dennis Potman
---
docs/manual/options.md | 11 +++++-
etc/cyclonedds.rnc | 7 ++++
etc/cyclonedds.xsd | 9 +++++
src/core/ddsi/include/dds/ddsi/q_config.h | 1 +
src/core/ddsi/include/dds/ddsi/q_nwif.h | 2 +-
src/core/ddsi/src/q_config.c | 2 ++
src/core/ddsi/src/q_nwif.c | 41 +++++++++++++----------
7 files changed, 54 insertions(+), 19 deletions(-)
diff --git a/docs/manual/options.md b/docs/manual/options.md
index a5534b2..fbdd2aa 100644
--- a/docs/manual/options.md
+++ b/docs/manual/options.md
@@ -554,7 +554,7 @@ The default value is: "default".
### //CycloneDDS/Domain/Internal
-Children: [AccelerateRexmitBlockSize](#cycloneddsdomaininternalacceleraterexmitblocksize), [AssumeMulticastCapable](#cycloneddsdomaininternalassumemulticastcapable), [AutoReschedNackDelay](#cycloneddsdomaininternalautoreschednackdelay), [BuiltinEndpointSet](#cycloneddsdomaininternalbuiltinendpointset), [ControlTopic](#cycloneddsdomaininternalcontroltopic), [DDSI2DirectMaxThreads](#cycloneddsdomaininternalddsi2directmaxthreads), [DefragReliableMaxSamples](#cycloneddsdomaininternaldefragreliablemaxsamples), [DefragUnreliableMaxSamples](#cycloneddsdomaininternaldefragunreliablemaxsamples), [DeliveryQueueMaxSamples](#cycloneddsdomaininternaldeliveryqueuemaxsamples), [EnableExpensiveChecks](#cycloneddsdomaininternalenableexpensivechecks), [GenerateKeyhash](#cycloneddsdomaininternalgeneratekeyhash), [HeartbeatInterval](#cycloneddsdomaininternalheartbeatinterval), [LateAckMode](#cycloneddsdomaininternallateackmode), [LeaseDuration](#cycloneddsdomaininternalleaseduration), [LivelinessMonitoring](#cycloneddsdomaininternallivelinessmonitoring), [MaxParticipants](#cycloneddsdomaininternalmaxparticipants), [MaxQueuedRexmitBytes](#cycloneddsdomaininternalmaxqueuedrexmitbytes), [MaxQueuedRexmitMessages](#cycloneddsdomaininternalmaxqueuedrexmitmessages), [MaxSampleSize](#cycloneddsdomaininternalmaxsamplesize), [MeasureHbToAckLatency](#cycloneddsdomaininternalmeasurehbtoacklatency), [MinimumSocketReceiveBufferSize](#cycloneddsdomaininternalminimumsocketreceivebuffersize), [MinimumSocketSendBufferSize](#cycloneddsdomaininternalminimumsocketsendbuffersize), [MonitorPort](#cycloneddsdomaininternalmonitorport), [MultipleReceiveThreads](#cycloneddsdomaininternalmultiplereceivethreads), [NackDelay](#cycloneddsdomaininternalnackdelay), [PreEmptiveAckDelay](#cycloneddsdomaininternalpreemptiveackdelay), [PrimaryReorderMaxSamples](#cycloneddsdomaininternalprimaryreordermaxsamples), [PrioritizeRetransmit](#cycloneddsdomaininternalprioritizeretransmit), [RediscoveryBlacklistDuration](#cycloneddsdomaininternalrediscoveryblacklistduration), [RetransmitMerging](#cycloneddsdomaininternalretransmitmerging), [RetransmitMergingPeriod](#cycloneddsdomaininternalretransmitmergingperiod), [RetryOnRejectBestEffort](#cycloneddsdomaininternalretryonrejectbesteffort), [SPDPResponseMaxDelay](#cycloneddsdomaininternalspdpresponsemaxdelay), [ScheduleTimeRounding](#cycloneddsdomaininternalscheduletimerounding), [SecondaryReorderMaxSamples](#cycloneddsdomaininternalsecondaryreordermaxsamples), [SendAsync](#cycloneddsdomaininternalsendasync), [SquashParticipants](#cycloneddsdomaininternalsquashparticipants), [SynchronousDeliveryLatencyBound](#cycloneddsdomaininternalsynchronousdeliverylatencybound), [SynchronousDeliveryPriorityThreshold](#cycloneddsdomaininternalsynchronousdeliveryprioritythreshold), [Test](#cycloneddsdomaininternaltest), [UnicastResponseToSPDPMessages](#cycloneddsdomaininternalunicastresponsetospdpmessages), [UseMulticastIfMreqn](#cycloneddsdomaininternalusemulticastifmreqn), [Watermarks](#cycloneddsdomaininternalwatermarks), [WriteBatch](#cycloneddsdomaininternalwritebatch), [WriterLingerDuration](#cycloneddsdomaininternalwriterlingerduration)
+Children: [AccelerateRexmitBlockSize](#cycloneddsdomaininternalacceleraterexmitblocksize), [AssumeMulticastCapable](#cycloneddsdomaininternalassumemulticastcapable), [AutoReschedNackDelay](#cycloneddsdomaininternalautoreschednackdelay), [BindUnicastToInterfaceAddr](#cycloneddsdomaininternalbindunicasttointerfaceaddr), [BuiltinEndpointSet](#cycloneddsdomaininternalbuiltinendpointset), [ControlTopic](#cycloneddsdomaininternalcontroltopic), [DDSI2DirectMaxThreads](#cycloneddsdomaininternalddsi2directmaxthreads), [DefragReliableMaxSamples](#cycloneddsdomaininternaldefragreliablemaxsamples), [DefragUnreliableMaxSamples](#cycloneddsdomaininternaldefragunreliablemaxsamples), [DeliveryQueueMaxSamples](#cycloneddsdomaininternaldeliveryqueuemaxsamples), [EnableExpensiveChecks](#cycloneddsdomaininternalenableexpensivechecks), [GenerateKeyhash](#cycloneddsdomaininternalgeneratekeyhash), [HeartbeatInterval](#cycloneddsdomaininternalheartbeatinterval), [LateAckMode](#cycloneddsdomaininternallateackmode), [LeaseDuration](#cycloneddsdomaininternalleaseduration), [LivelinessMonitoring](#cycloneddsdomaininternallivelinessmonitoring), [MaxParticipants](#cycloneddsdomaininternalmaxparticipants), [MaxQueuedRexmitBytes](#cycloneddsdomaininternalmaxqueuedrexmitbytes), [MaxQueuedRexmitMessages](#cycloneddsdomaininternalmaxqueuedrexmitmessages), [MaxSampleSize](#cycloneddsdomaininternalmaxsamplesize), [MeasureHbToAckLatency](#cycloneddsdomaininternalmeasurehbtoacklatency), [MinimumSocketReceiveBufferSize](#cycloneddsdomaininternalminimumsocketreceivebuffersize), [MinimumSocketSendBufferSize](#cycloneddsdomaininternalminimumsocketsendbuffersize), [MonitorPort](#cycloneddsdomaininternalmonitorport), [MultipleReceiveThreads](#cycloneddsdomaininternalmultiplereceivethreads), [NackDelay](#cycloneddsdomaininternalnackdelay), [PreEmptiveAckDelay](#cycloneddsdomaininternalpreemptiveackdelay), [PrimaryReorderMaxSamples](#cycloneddsdomaininternalprimaryreordermaxsamples), [PrioritizeRetransmit](#cycloneddsdomaininternalprioritizeretransmit), [RediscoveryBlacklistDuration](#cycloneddsdomaininternalrediscoveryblacklistduration), [RetransmitMerging](#cycloneddsdomaininternalretransmitmerging), [RetransmitMergingPeriod](#cycloneddsdomaininternalretransmitmergingperiod), [RetryOnRejectBestEffort](#cycloneddsdomaininternalretryonrejectbesteffort), [SPDPResponseMaxDelay](#cycloneddsdomaininternalspdpresponsemaxdelay), [ScheduleTimeRounding](#cycloneddsdomaininternalscheduletimerounding), [SecondaryReorderMaxSamples](#cycloneddsdomaininternalsecondaryreordermaxsamples), [SendAsync](#cycloneddsdomaininternalsendasync), [SquashParticipants](#cycloneddsdomaininternalsquashparticipants), [SynchronousDeliveryLatencyBound](#cycloneddsdomaininternalsynchronousdeliverylatencybound), [SynchronousDeliveryPriorityThreshold](#cycloneddsdomaininternalsynchronousdeliveryprioritythreshold), [Test](#cycloneddsdomaininternaltest), [UnicastResponseToSPDPMessages](#cycloneddsdomaininternalunicastresponsetospdpmessages), [UseMulticastIfMreqn](#cycloneddsdomaininternalusemulticastifmreqn), [Watermarks](#cycloneddsdomaininternalwatermarks), [WriteBatch](#cycloneddsdomaininternalwritebatch), [WriterLingerDuration](#cycloneddsdomaininternalwriterlingerduration)
The Internal elements deal with a variety of settings that evolving and
@@ -600,6 +600,15 @@ Valid values are finite durations with an explicit unit or the keyword
The default value is: "1 s".
+#### //CycloneDDS/Domain/Internal/BindUnicastToInterfaceAddr
+Boolean
+
+Bind unicast sockets to the address of the preferred interface; if false,
+bind to 0.0.0.0 (IPv4) or its equivalent
+
+The default value is: "true".
+
+
#### //CycloneDDS/Domain/Internal/BuiltinEndpointSet
One of: full, writers, minimal
diff --git a/etc/cyclonedds.rnc b/etc/cyclonedds.rnc
index 0edc899..f3e4395 100644
--- a/etc/cyclonedds.rnc
+++ b/etc/cyclonedds.rnc
@@ -491,6 +491,13 @@ day.
The default value is: "1 s".
""" ] ]
duration_inf
}?
& [ a:documentation [ xml:lang="en" """
+Bind unicast sockets to the address of the preferred interface; if
+false, bind to 0.0.0.0 (IPv4) or its equivalent
The default value
+is: "true".
""" ] ]
+ element BindUnicastToInterfaceAddr {
+ xsd:boolean
+ }?
+ & [ a:documentation [ xml:lang="en" """
This element controls which participants will have which built-in
endpoints for the discovery and liveliness protocols. Valid values
are:
diff --git a/etc/cyclonedds.xsd b/etc/cyclonedds.xsd
index 49d4378..dbcab47 100644
--- a/etc/cyclonedds.xsd
+++ b/etc/cyclonedds.xsd
@@ -638,6 +638,7 @@ reserved. This includes renaming or moving options.</p>
+
@@ -716,6 +717,14 @@ of HEARTBEAT messages.</p>
day.</p><p>The default value is: "1 s".</p>
+
+
+
+<p>Bind unicast sockets to the address of the preferred interface; if
+false, bind to 0.0.0.0 (IPv4) or its equivalent</p><p>The default value
+is: "true".</p>
+
+
diff --git a/src/core/ddsi/include/dds/ddsi/q_config.h b/src/core/ddsi/include/dds/ddsi/q_config.h
index fd66ad2..cb0ba65 100644
--- a/src/core/ddsi/include/dds/ddsi/q_config.h
+++ b/src/core/ddsi/include/dds/ddsi/q_config.h
@@ -332,6 +332,7 @@ struct config
int64_t initial_deaf_mute_reset;
int use_multicast_if_mreqn;
+ int bind_unicast_to_interface_addr;
struct prune_deleted_ppant prune_deleted_ppant;
};
diff --git a/src/core/ddsi/include/dds/ddsi/q_nwif.h b/src/core/ddsi/include/dds/ddsi/q_nwif.h
index 7e4688c..dd27df6 100644
--- a/src/core/ddsi/include/dds/ddsi/q_nwif.h
+++ b/src/core/ddsi/include/dds/ddsi/q_nwif.h
@@ -35,7 +35,7 @@ struct nn_interface {
char *name;
};
-int make_socket (ddsrt_socket_t *socket, uint16_t port, bool stream, bool reuse, const struct ddsi_domaingv *gv);
+int make_socket (ddsrt_socket_t *socket, uint16_t port, bool stream, bool multicast, const struct ddsi_domaingv *gv);
int find_own_ip (struct ddsi_domaingv *gv, const char *requested_address);
uint32_t locator_to_hopefully_unique_uint32 (const nn_locator_t *src);
diff --git a/src/core/ddsi/src/q_config.c b/src/core/ddsi/src/q_config.c
index 6a1039e..d3bc24f 100644
--- a/src/core/ddsi/src/q_config.c
+++ b/src/core/ddsi/src/q_config.c
@@ -578,6 +578,8 @@ static const struct cfgelem unsupp_cfgelems[] = {
BLURB("This element controls whether retransmits are prioritized over new data, speeding up recovery.
") },
{ LEAF("UseMulticastIfMreqn"), 1, "0", ABSOFF(use_multicast_if_mreqn), 0, uf_int, 0, pf_int,
BLURB("Do not use.
") },
+ { LEAF("BindUnicastToInterfaceAddr"), 1, "true", ABSOFF(bind_unicast_to_interface_addr), 0, uf_boolean, 0, pf_boolean,
+ BLURB("Bind unicast sockets to the address of the preferred interface; if false, bind to 0.0.0.0 (IPv4) or its equivalent
") },
{ LEAF("SendAsync"), 1, "false", ABSOFF(xpack_send_async), 0, uf_boolean, 0, pf_boolean,
BLURB("This element controls whether the actual sending of packets occurs on the same thread that prepares them, or is done asynchronously by another thread.
") },
{ LEAF_W_ATTRS("RediscoveryBlacklistDuration", rediscovery_blacklist_duration_attrs), 1, "10s", ABSOFF(prune_deleted_ppant.delay), 0, uf_duration_inf, 0, pf_duration,
diff --git a/src/core/ddsi/src/q_nwif.c b/src/core/ddsi/src/q_nwif.c
index 7b96a2f..5789983 100644
--- a/src/core/ddsi/src/q_nwif.c
+++ b/src/core/ddsi/src/q_nwif.c
@@ -214,32 +214,39 @@ static int set_reuse_options (const struct ddsrt_log_cfg *logcfg, ddsrt_socket_t
return 0;
}
-static int bind_socket (ddsrt_socket_t socket, unsigned short port, const struct ddsi_domaingv *gv)
+static int bind_socket (ddsrt_socket_t socket, unsigned short port, bool multicast, const struct ddsi_domaingv *gv)
{
dds_return_t rc = DDS_RETCODE_ERROR;
#if DDSRT_HAVE_IPV6
if (gv->config.transport_selector == TRANS_TCP6 || gv->config.transport_selector == TRANS_UDP6)
{
- struct sockaddr_in6 socketname;
- memset (&socketname, 0, sizeof (socketname));
- socketname.sin6_family = AF_INET6;
- socketname.sin6_port = htons (port);
- socketname.sin6_addr = ddsrt_in6addr_any;
- if (IN6_IS_ADDR_LINKLOCAL (&socketname.sin6_addr)) {
- socketname.sin6_scope_id = gv->interfaceNo;
+ union {
+ struct sockaddr_storage x;
+ struct sockaddr_in6 a;
+ } socketname;
+ ddsi_ipaddr_from_loc (&socketname.x, &gv->ownloc);
+ if (multicast || !gv->config.bind_unicast_to_interface_addr)
+ socketname.a.sin6_addr = ddsrt_in6addr_any;
+ socketname.a.sin6_port = htons (port);
+ if (IN6_IS_ADDR_LINKLOCAL (&socketname.a.sin6_addr)) {
+ socketname.a.sin6_scope_id = gv->interfaceNo;
}
- rc = ddsrt_bind (socket, (struct sockaddr *) &socketname, sizeof (socketname));
+ rc = ddsrt_bind (socket, (struct sockaddr *) &socketname.a, sizeof (socketname.a));
}
else
#endif
if (gv->config.transport_selector == TRANS_TCP || gv->config.transport_selector == TRANS_UDP)
{
- struct sockaddr_in socketname;
- socketname.sin_family = AF_INET;
- socketname.sin_port = htons (port);
- socketname.sin_addr.s_addr = htonl (INADDR_ANY);
- rc = ddsrt_bind (socket, (struct sockaddr *) &socketname, sizeof (socketname));
+ union {
+ struct sockaddr_storage x;
+ struct sockaddr_in a;
+ } socketname;
+ ddsi_ipaddr_from_loc (&socketname.x, &gv->ownloc);
+ if (multicast || !gv->config.bind_unicast_to_interface_addr)
+ socketname.a.sin_addr.s_addr = htonl (INADDR_ANY);
+ socketname.a.sin_port = htons (port);
+ rc = ddsrt_bind (socket, (struct sockaddr *) &socketname.a, sizeof (socketname.a));
}
if (rc != DDS_RETCODE_OK && rc != DDS_RETCODE_PRECONDITION_NOT_MET)
{
@@ -338,7 +345,7 @@ static int set_mc_options_transmit (ddsrt_socket_t socket, const struct ddsi_dom
}
}
-int make_socket (ddsrt_socket_t *sock, uint16_t port, bool stream, bool reuse, const struct ddsi_domaingv *gv)
+int make_socket (ddsrt_socket_t *sock, uint16_t port, bool stream, bool multicast, const struct ddsi_domaingv *gv)
{
/* FIXME: this stuff has to move to the transports */
int rc = -2;
@@ -366,7 +373,7 @@ int make_socket (ddsrt_socket_t *sock, uint16_t port, bool stream, bool reuse, c
return rc;
}
- if (port && reuse && ((rc = set_reuse_options (&gv->logconfig, *sock)) < 0))
+ if (port && multicast && ((rc = set_reuse_options (&gv->logconfig, *sock)) < 0))
{
goto fail;
}
@@ -376,7 +383,7 @@ int make_socket (ddsrt_socket_t *sock, uint16_t port, bool stream, bool reuse, c
(rc = set_rcvbuf (&gv->logconfig, *sock, &gv->config.socket_min_rcvbuf_size) < 0) ||
(rc = set_sndbuf (&gv->logconfig, *sock, gv->config.socket_min_sndbuf_size) < 0) ||
((rc = maybe_set_dont_route (&gv->logconfig, *sock, &gv->config)) < 0) ||
- ((rc = bind_socket (*sock, port, gv)) < 0)
+ ((rc = bind_socket (*sock, port, multicast, gv)) < 0)
)
{
goto fail;
From 8bd6f34f677300fb5736b4ac11d48992467e099a Mon Sep 17 00:00:00 2001
From: Dennis Potman
Date: Thu, 20 Feb 2020 15:02:38 +0100
Subject: [PATCH 05/30] Renamed unsupp config sections to internal
Signed-off-by: Dennis Potman
---
docs/makernc.pl | 2 +-
src/core/ddsi/src/q_config.c | 12 ++++++------
2 files changed, 7 insertions(+), 7 deletions(-)
diff --git a/docs/makernc.pl b/docs/makernc.pl
index 2daaa57..041d71d 100644
--- a/docs/makernc.pl
+++ b/docs/makernc.pl
@@ -475,7 +475,7 @@ sub conv_table {
$fqname1 = "$fqname/$fs->{name}";
$elems++;
}
- my $prefix1 = ($fs->{table} eq "unsupp_cfgelems") ? "Internal" : $prefix;
+ my $prefix1 = ($fs->{table} eq "internal_cfgelems") ? "Internal" : $prefix;
&$convsub ($fh, $fs, $fs->{name}, $fqname1, $indent, $prefix1, $closure);
}
}
diff --git a/src/core/ddsi/src/q_config.c b/src/core/ddsi/src/q_config.c
index d3bc24f..82d1d71 100644
--- a/src/core/ddsi/src/q_config.c
+++ b/src/core/ddsi/src/q_config.c
@@ -421,13 +421,13 @@ static const struct cfgelem compatibility_cfgelems[] = {
END_MARKER
};
-static const struct cfgelem unsupp_test_cfgelems[] = {
+static const struct cfgelem internal_test_cfgelems[] = {
{ LEAF("XmitLossiness"), 1, "0", ABSOFF(xmit_lossiness), 0, uf_int, 0, pf_int,
BLURB("This element controls the fraction of outgoing packets to drop, specified as samples per thousand.
") },
END_MARKER
};
-static const struct cfgelem unsupp_watermarks_cfgelems[] = {
+static const struct cfgelem internal_watermarks_cfgelems[] = {
{ LEAF("WhcLow"), 1, "1 kB", ABSOFF(whc_lowwater_mark), 0, uf_memsize, 0, pf_memsize,
BLURB("This element sets the low-water mark for the DDSI2E WHCs, expressed in bytes. A suspended writer resumes transmitting when its DDSI2E WHC shrinks to this size.
") },
{ LEAF("WhcHigh"), 1, "100 kB", ABSOFF(whc_highwater_mark), 0, uf_memsize, 0, pf_memsize,
@@ -485,7 +485,7 @@ static const struct cfgelem multiple_recv_threads_attrs[] = {
END_MARKER
};
-static const struct cfgelem unsupp_cfgelems[] = {
+static const struct cfgelem internal_cfgelems[] = {
{ MOVED("MaxMessageSize", "CycloneDDS/General/MaxMessageSize") },
{ MOVED("FragmentSize", "CycloneDDS/General/FragmentSize") },
{ LEAF("DeliveryQueueMaxSamples"), 1, "256", ABSOFF(delivery_queue_maxsamples), 0, uf_uint, 0, pf_uint,
@@ -588,9 +588,9 @@ static const struct cfgelem unsupp_cfgelems[] = {
BLURB("This element controls whether all traffic is handled by a single receive thread (false) or whether multiple receive threads may be used to improve latency (true). By default it is disabled on Windows because it appears that one cannot count on being able to send packets to oneself, which is necessary to stop the thread during shutdown. Currently multiple receive threads are only used for connectionless transport (e.g., UDP) and ManySocketsMode not set to single (the default).
") },
{ MGROUP("ControlTopic", control_topic_cfgelems, control_topic_cfgattrs), 1, 0, 0, 0, 0, 0, 0, 0,
BLURB("The ControlTopic element allows configured whether DDSI2E provides a special control interface via a predefined topic or not.
") },
- { GROUP("Test", unsupp_test_cfgelems),
+ { GROUP("Test", internal_test_cfgelems),
BLURB("
Testing options.
") },
- { GROUP("Watermarks", unsupp_watermarks_cfgelems),
+ { GROUP("Watermarks", internal_watermarks_cfgelems),
BLURB("Watermarks for flow-control.
") },
{ LEAF("EnableExpensiveChecks"), 1, "", ABSOFF(enabled_xchecks), 0, uf_xcheck, 0, pf_xcheck,
BLURB("This element enables expensive checks in builds with assertions enabled and is ignored otherwise. Recognised categories are:
\n\
@@ -794,7 +794,7 @@ static const struct cfgelem domain_cfgelems[] = {
BLURB("The Discovery element allows specifying various parameters related to the discovery of peers.
") },
{ GROUP("Tracing", tracing_cfgelems),
BLURB("The Tracing element controls the amount and type of information that is written into the tracing log by the DDSI service. This is useful to track the DDSI service during application development.
") },
- { GROUP("Internal|Unsupported", unsupp_cfgelems),
+ { GROUP("Internal|Unsupported", internal_cfgelems),
BLURB("The Internal elements deal with a variety of settings that evolving and that are not necessarily fully supported. For the vast majority of the Internal settings, the functionality per-se is supported, but the right to change the way the options control the functionality is reserved. This includes renaming or moving options.
") },
{ GROUP("TCP", tcp_cfgelems),
BLURB("The TCP element allows specifying various parameters related to running DDSI over TCP.
") },
From 6dc28db19766ec6a266839bbfcce89cab60daf4f Mon Sep 17 00:00:00 2001
From: Erik Boasson
Date: Sat, 22 Feb 2020 10:51:08 +0100
Subject: [PATCH 06/30] Fix warning by cleaning up dds_set_qos_locked_raw
gcc 5.4 correctly warned that a null pointer was being passed into the
entity-specific "set_qos" function when changing a topic QoS, where that
parameter was tagged as "non-null". As it was never dereferenced in
this case the resulting behaviour was still correct.
It turns out that the entire function was overly complicated and that
simply passing the entity pointer round allows eliminating a few
arguments as well.
(Oddly none of the more modern toolchains used pick this up.)
Signed-off-by: Erik Boasson
---
src/core/ddsc/src/dds_entity.c | 13 ++++++-------
src/core/ddsc/src/dds_topic.c | 4 +---
2 files changed, 7 insertions(+), 10 deletions(-)
diff --git a/src/core/ddsc/src/dds_entity.c b/src/core/ddsc/src/dds_entity.c
index 2b842af..e6620db 100644
--- a/src/core/ddsc/src/dds_entity.c
+++ b/src/core/ddsc/src/dds_entity.c
@@ -677,8 +677,9 @@ dds_return_t dds_get_qos (dds_entity_t entity, dds_qos_t *qos)
return ret;
}
-static dds_return_t dds_set_qos_locked_raw (dds_entity *e, dds_qos_t **e_qos_ptr, bool e_enabled, const dds_qos_t *qos, uint64_t mask, const struct ddsrt_log_cfg *logcfg, dds_return_t (*set_qos) (struct dds_entity *e, const dds_qos_t *qos, bool enabled) ddsrt_nonnull_all)
+static dds_return_t dds_set_qos_locked_raw (dds_entity *e, dds_qos_t **e_qos_ptr, const dds_qos_t *qos, uint64_t mask, const struct ddsrt_log_cfg *logcfg)
{
+ const bool enabled = ((e->m_flags & DDS_ENTITY_ENABLED) != 0);
dds_return_t ret;
/* Any attempt to do this on a topic ends up doing it on the ktopic instead, so that there is
@@ -692,7 +693,7 @@ static dds_return_t dds_set_qos_locked_raw (dds_entity *e, dds_qos_t **e_qos_ptr
/* invalid or inconsistent QoS settings */
goto error_or_nochange;
}
- else if (!e_enabled)
+ else if (!enabled)
{
/* do as you please while the entity is not enabled */
}
@@ -728,7 +729,7 @@ static dds_return_t dds_set_qos_locked_raw (dds_entity *e, dds_qos_t **e_qos_ptr
}
assert (ret == DDS_RETCODE_OK);
- if ((ret = set_qos (e, newqos, e_enabled)) != DDS_RETCODE_OK)
+ if ((ret = dds_entity_deriver_set_qos (e, newqos, enabled)) != DDS_RETCODE_OK)
goto error_or_nochange;
else
{
@@ -748,7 +749,7 @@ static dds_return_t dds_set_qos_locked_impl (dds_entity *e, const dds_qos_t *qos
dds_entity_kind_t kind = dds_entity_kind (e);
if (kind != DDS_KIND_TOPIC)
{
- return dds_set_qos_locked_raw (e, &e->m_qos, (e->m_flags & DDS_ENTITY_ENABLED) != 0, qos, mask, logcfg, dds_entity_deriver_table[kind]->set_qos);
+ return dds_set_qos_locked_raw (e, &e->m_qos, qos, mask, logcfg);
}
else
{
@@ -767,9 +768,7 @@ static dds_return_t dds_set_qos_locked_impl (dds_entity *e, const dds_qos_t *qos
while (ktp->defer_set_qos != 0)
ddsrt_cond_wait (&pp->m_entity.m_cond, &pp->m_entity.m_mutex);
- /* dds_entity_deriver_table[kind]->set_qos had better avoid looking at the entity! */
- rc = dds_set_qos_locked_raw (NULL, &ktp->qos, (e->m_flags & DDS_ENTITY_ENABLED) != 0, qos, mask, logcfg, dds_entity_deriver_table[kind]->set_qos);
-
+ rc = dds_set_qos_locked_raw (e, &ktp->qos, qos, mask, logcfg);
ddsrt_mutex_unlock (&pp->m_entity.m_mutex);
return rc;
}
diff --git a/src/core/ddsc/src/dds_topic.c b/src/core/ddsc/src/dds_topic.c
index 93db04a..79a4eee 100644
--- a/src/core/ddsc/src/dds_topic.c
+++ b/src/core/ddsc/src/dds_topic.c
@@ -170,10 +170,8 @@ static dds_return_t dds_topic_qos_set (dds_entity *e, const dds_qos_t *qos, bool
{
/* We never actually set the qos of a struct dds_topic and really shouldn't be here,
but the code to check whether set_qos is supported uses the entity's qos_set
- function as a proxy. One of the weird things about the topic's set_qos is that
- this is called with e == NULL. */
+ function as a proxy. */
(void) e; (void) qos; (void) enabled;
- assert (e == NULL);
return DDS_RETCODE_OK;
}
From 5aeace912b367ada69eea9c986d220192756cc12 Mon Sep 17 00:00:00 2001
From: Erik Boasson
Date: Sat, 22 Feb 2020 10:57:09 +0100
Subject: [PATCH 07/30] Converting to timeval/timespec need casts on 32bit
Signed-off-by: Erik Boasson
---
src/ddsrt/src/sync/posix/sync.c | 4 ++--
src/ddsrt/src/time.c | 4 ++--
2 files changed, 4 insertions(+), 4 deletions(-)
diff --git a/src/ddsrt/src/sync/posix/sync.c b/src/ddsrt/src/sync/posix/sync.c
index 929da08..ff03c52 100644
--- a/src/ddsrt/src/sync/posix/sync.c
+++ b/src/ddsrt/src/sync/posix/sync.c
@@ -109,8 +109,8 @@ ddsrt_cond_waituntil(
return true;
}
if (abstime > 0) {
- ts.tv_sec = abstime / DDS_NSECS_IN_SEC;
- ts.tv_nsec = abstime % DDS_NSECS_IN_SEC;
+ ts.tv_sec = (time_t) (abstime / DDS_NSECS_IN_SEC);
+ ts.tv_nsec = (suseconds_t) (abstime % DDS_NSECS_IN_SEC);
}
switch (pthread_cond_timedwait(&cond->cond, &mutex->mutex, &ts)) {
diff --git a/src/ddsrt/src/time.c b/src/ddsrt/src/time.c
index e8c845f..a3d474f 100644
--- a/src/ddsrt/src/time.c
+++ b/src/ddsrt/src/time.c
@@ -26,8 +26,8 @@ void dds_sleepfor(dds_duration_t n)
struct timespec t, r;
if (n >= 0) {
- t.tv_sec = n / DDS_NSECS_IN_SEC;
- t.tv_nsec = n % DDS_NSECS_IN_SEC;
+ t.tv_sec = (time_t) (n / DDS_NSECS_IN_SEC);
+ t.tv_nsec = (long) (n % DDS_NSECS_IN_SEC);
while (nanosleep(&t, &r) == -1 && errno == EINTR) {
t = r;
}
From 6e0faae19643b5a88789c336859387ca6002aae0 Mon Sep 17 00:00:00 2001
From: Dan Rose
Date: Tue, 18 Feb 2020 11:50:09 -0600
Subject: [PATCH 08/30] Fix warning -Wimplicit-int-float-conversion
```
/opt/ros/master/src/eclipse-cyclonedds/cyclonedds/src/tools/pubsub/common.c:586:28: warning: implicit conversion from 'long' to 'double' changes value from 9223372036854775807 to 9223372036854775808 [-Wimplicit-int-float-conversion]
if(nanosec > nextafter(INT64_MAX, 0)) {
~~~~~~~~~ ^~~~~~~~~
/usr/include/stdint.h:134:22: note: expanded from macro 'INT64_MAX'
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/usr/include/stdint.h:116:24: note: expanded from macro '__INT64_C'
^~~~~~
:345:1: note: expanded from here
9223372036854775807L
^~~~~~~~~~~~~~~~~~~~
1 warning generated.
```
Signed-off-by: Dan Rose
---
src/tools/pubsub/common.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/src/tools/pubsub/common.c b/src/tools/pubsub/common.c
index a9b5418..aeb90bf 100644
--- a/src/tools/pubsub/common.c
+++ b/src/tools/pubsub/common.c
@@ -583,7 +583,7 @@ int double_to_dds_duration(dds_duration_t *dd, double d) {
if (d < 0)
return -1;
double nanosec = d * 1e9;
- if(nanosec > INT64_MAX) {
+ if(nanosec > (double)INT64_MAX) {
*dd = DDS_INFINITY;
} else {
*dd = (int64_t) nanosec;
From 1ee2dfe08fc6bbe82f4df722620cff03cc9fe6e2 Mon Sep 17 00:00:00 2001
From: Erik Boasson
Date: Wed, 26 Feb 2020 13:26:20 +0100
Subject: [PATCH 09/30] Avoid race causing thread-state pointer aliasing
The thread_states array resets the "state" to ZERO on thread termination
to indicate that the slot was unused, but it leaves the thread id
unchanged because some platforms don't have a defined value that will
never be used as a thread id. A consequence is that a newly created
thread may result in multiple slots containing their own thread id, but
generally there will only be one that is not in state ZERO.
However, the code for create_thread used to set the state to ALIVE prior
to creating the thread, and so if the events get scheduled like:
1. thread A: X.state = ALIVE
2. create new thread B, storing tid in X.tid
3. thread A: Y.state = ALIVE
4. new thread B: lookup self (and cache pointer)
5. create new thread C, storing tid in Y.tid
6. new thread C: lookup self (and cache pointer)
Then B will observe two slots in the ALIVE state, with X.tid certain to
match and Y.tid undefined (and hence possibly matching). It may
therefore pick Y. C will (in this schedule) of course always choose Y.
They cache the pointer and never look at X and Y again, except for
updating their virtual clocks.
These virtual clocks are updated non-atomically (by design it is private
to the thread) and so if both B & C use Y they can end up racing each
other in updating the virtual clock and cause the nesting level of the
"awake" state controlling garbage collection to get stuck (or wrap
around, or do other horrible things). The consequence can be anything,
from a somewhat benign variant where GC effectively stops and some
operations (deleting readers and writers and shutting down) block
forever, to use-after-free and the undefined behaviour that implies.
This commit avoids looking up the slot in the newly created threads,
instead passing the correct address in the argument. It also adds an
intermediate state INIT that serves to reserve the slot until the new
thread is actually running. It does make the look-up safe (if one were
to do it), and as it is essentially free and gives more insight in the
state of the system when viewed from a debugger, it appears a useful
addition.
Signed-off-by: Erik Boasson
---
src/core/ddsi/include/dds/ddsi/q_thread.h | 33 +++-
src/core/ddsi/src/q_thread.c | 199 +++++++++++++---------
2 files changed, 145 insertions(+), 87 deletions(-)
diff --git a/src/core/ddsi/include/dds/ddsi/q_thread.h b/src/core/ddsi/include/dds/ddsi/q_thread.h
index c899ee1..75c5999 100644
--- a/src/core/ddsi/include/dds/ddsi/q_thread.h
+++ b/src/core/ddsi/include/dds/ddsi/q_thread.h
@@ -50,6 +50,8 @@ typedef int32_t svtime_t; /* signed version */
enum thread_state {
THREAD_STATE_ZERO, /* known to be dead */
+ THREAD_STATE_STOPPED, /* internal thread, stopped-but-not-reaped */
+ THREAD_STATE_INIT, /* internal thread, initializing */
THREAD_STATE_LAZILY_CREATED, /* lazily created in response because an application used it. Reclaimed if the thread terminates, but not considered an error if all of Cyclone is shutdown while this thread hasn't terminated yet */
THREAD_STATE_ALIVE /* known to be alive - for Cyclone internal threads */
};
@@ -67,13 +69,34 @@ struct ddsrt_log_cfg;
*
* gv is constant for internal threads, i.e., for threads with state = ALIVE
* gv is non-NULL for internal threads except thread liveliness monitoring
+ *
+ * Q_THREAD_DEBUG enables some really costly debugging stuff that may not be fully
+ * portable (I used it once, might as well keep it)
*/
+#define Q_THREAD_DEBUG 0
+#if Q_THREAD_DEBUG
+#define Q_THREAD_NSTACKS 20
+#define Q_THREAD_STACKDEPTH 10
+#define Q_THREAD_BASE_DEBUG \
+ void *stks[Q_THREAD_NSTACKS][Q_THREAD_STACKDEPTH]; \
+ int stks_depth[Q_THREAD_NSTACKS]; \
+ int stks_idx;
+
+struct thread_state1;
+void thread_vtime_trace (struct thread_state1 *ts1);
+#else /* Q_THREAD_DEBUG */
+#define Q_THREAD_BASE_DEBUG
+#define thread_vtime_trace(ts1) do { } while (0)
+#endif /* Q_THREAD_DEBUG */
+
#define THREAD_BASE \
ddsrt_atomic_uint32_t vtime; \
- ddsrt_atomic_voidp_t gv; \
enum thread_state state; \
+ ddsrt_atomic_voidp_t gv; \
ddsrt_thread_t tid; \
- ddsrt_thread_t extTid; \
+ uint32_t (*f) (void *arg); \
+ void *f_arg; \
+ Q_THREAD_BASE_DEBUG /* note: no semicolon! */ \
char name[24] /* note: no semicolon! */
struct thread_state_base {
@@ -107,8 +130,6 @@ DDS_EXPORT dds_return_t create_thread (struct thread_state1 **ts, const struct d
DDS_EXPORT struct thread_state1 *lookup_thread_state_real (void);
DDS_EXPORT dds_return_t join_thread (struct thread_state1 *ts1);
DDS_EXPORT void log_stack_traces (const struct ddsrt_log_cfg *logcfg, const struct ddsi_domaingv *gv);
-DDS_EXPORT void reset_thread_state (struct thread_state1 *ts1);
-DDS_EXPORT int thread_exists (const char *name);
DDS_EXPORT inline struct thread_state1 *lookup_thread_state (void) {
struct thread_state1 *ts1 = tsd_thread_state;
@@ -154,6 +175,7 @@ DDS_EXPORT inline void thread_state_asleep (struct thread_state1 *ts1)
assert (vtime_awake_p (vt));
/* nested calls a rare and an extra fence doesn't break things */
ddsrt_atomic_fence_rel ();
+ thread_vtime_trace (ts1);
if ((vt & VTIME_NEST_MASK) == 1)
vt += (1u << VTIME_TIME_SHIFT) - 1u;
else
@@ -167,6 +189,7 @@ DDS_EXPORT inline void thread_state_awake (struct thread_state1 *ts1, const stru
assert ((vt & VTIME_NEST_MASK) < VTIME_NEST_MASK);
assert (gv != NULL);
assert (ts1->state != THREAD_STATE_ALIVE || gv == ddsrt_atomic_ldvoidp (&ts1->gv));
+ thread_vtime_trace (ts1);
ddsrt_atomic_stvoidp (&ts1->gv, (struct ddsi_domaingv *) gv);
ddsrt_atomic_fence_stst ();
ddsrt_atomic_st32 (&ts1->vtime, vt + 1u);
@@ -179,6 +202,7 @@ DDS_EXPORT inline void thread_state_awake_domain_ok (struct thread_state1 *ts1)
vtime_t vt = ddsrt_atomic_ld32 (&ts1->vtime);
assert ((vt & VTIME_NEST_MASK) < VTIME_NEST_MASK);
assert (ddsrt_atomic_ldvoidp (&ts1->gv) != NULL);
+ thread_vtime_trace (ts1);
ddsrt_atomic_st32 (&ts1->vtime, vt + 1u);
/* nested calls a rare and an extra fence doesn't break things */
ddsrt_atomic_fence_acq ();
@@ -196,6 +220,7 @@ DDS_EXPORT inline void thread_state_awake_to_awake_no_nest (struct thread_state1
vtime_t vt = ddsrt_atomic_ld32 (&ts1->vtime);
assert ((vt & VTIME_NEST_MASK) == 1);
ddsrt_atomic_fence_rel ();
+ thread_vtime_trace (ts1);
ddsrt_atomic_st32 (&ts1->vtime, vt + (1u << VTIME_TIME_SHIFT));
ddsrt_atomic_fence_acq ();
}
diff --git a/src/core/ddsi/src/q_thread.c b/src/core/ddsi/src/q_thread.c
index a8190fa..2bed13d 100644
--- a/src/core/ddsi/src/q_thread.c
+++ b/src/core/ddsi/src/q_thread.c
@@ -47,6 +47,24 @@ extern inline void thread_state_awake_to_awake_no_nest (struct thread_state1 *ts
static struct thread_state1 *init_thread_state (const char *tname, const struct ddsi_domaingv *gv, enum thread_state state);
static void reap_thread_state (struct thread_state1 *ts1);
+DDSRT_STATIC_ASSERT(THREAD_STATE_ZERO == 0 &&
+ THREAD_STATE_ZERO < THREAD_STATE_STOPPED &&
+ THREAD_STATE_STOPPED < THREAD_STATE_INIT &&
+ THREAD_STATE_INIT < THREAD_STATE_LAZILY_CREATED &&
+ THREAD_STATE_INIT < THREAD_STATE_ALIVE);
+
+#if Q_THREAD_DEBUG
+#include
+
+void thread_vtime_trace (struct thread_state1 *ts1)
+{
+ if (++ts1->stks_idx == Q_THREAD_NSTACKS)
+ ts1->stks_idx = 0;
+ const int i = ts1->stks_idx;
+ ts1->stks_depth[i] = backtrace (ts1->stks[i], Q_THREAD_STACKDEPTH);
+}
+#endif
+
static void *ddsrt_malloc_aligned_cacheline (size_t size)
{
/* This wastes some space, but we use it only once and it isn't a
@@ -84,15 +102,6 @@ void thread_states_init (unsigned maxthreads)
thread_states.nthreads = maxthreads;
thread_states.ts = ddsrt_malloc_aligned_cacheline (maxthreads * sizeof (*thread_states.ts));
memset (thread_states.ts, 0, maxthreads * sizeof (*thread_states.ts));
- /* The compiler doesn't realize that ts is large enough. */
- DDSRT_WARNING_MSVC_OFF(6386);
- for (uint32_t i = 0; i < thread_states.nthreads; i++)
- {
- thread_states.ts[i].state = THREAD_STATE_ZERO;
- ddsrt_atomic_st32 (&thread_states.ts[i].vtime, 0);
- memset (thread_states.ts[i].name, 0, sizeof (thread_states.ts[i].name));
- }
- DDSRT_WARNING_MSVC_ON(6386);
}
/* This thread should be at the same address as before, or never have had a slot
@@ -126,8 +135,18 @@ bool thread_states_fini (void)
ddsrt_mutex_lock (&thread_states.lock);
for (uint32_t i = 0; i < thread_states.nthreads; i++)
{
- assert (thread_states.ts[i].state != THREAD_STATE_ALIVE);
- others += (thread_states.ts[i].state == THREAD_STATE_LAZILY_CREATED);
+ switch (thread_states.ts[i].state)
+ {
+ case THREAD_STATE_ZERO:
+ break;
+ case THREAD_STATE_LAZILY_CREATED:
+ others++;
+ break;
+ case THREAD_STATE_STOPPED:
+ case THREAD_STATE_INIT:
+ case THREAD_STATE_ALIVE:
+ assert (0);
+ }
}
ddsrt_mutex_unlock (&thread_states.lock);
if (others == 0)
@@ -143,30 +162,35 @@ bool thread_states_fini (void)
}
}
-ddsrt_attribute_no_sanitize (("thread"))
static struct thread_state1 *find_thread_state (ddsrt_thread_t tid)
{
- if (thread_states.ts) {
+ if (thread_states.ts)
+ {
+ ddsrt_mutex_lock (&thread_states.lock);
for (uint32_t i = 0; i < thread_states.nthreads; i++)
{
- if (ddsrt_thread_equal (thread_states.ts[i].tid, tid) && thread_states.ts[i].state != THREAD_STATE_ZERO)
+ if (thread_states.ts[i].state > THREAD_STATE_INIT && ddsrt_thread_equal (thread_states.ts[i].tid, tid))
+ {
+ ddsrt_mutex_unlock (&thread_states.lock);
return &thread_states.ts[i];
+ }
}
+ ddsrt_mutex_unlock (&thread_states.lock);
}
return NULL;
}
static void cleanup_thread_state (void *data)
{
- struct thread_state1 *ts = find_thread_state(ddsrt_thread_self());
- (void)data;
- if (ts)
+ struct thread_state1 *ts1 = find_thread_state (ddsrt_thread_self ());
+ (void) data;
+ if (ts1)
{
- assert(ts->state == THREAD_STATE_LAZILY_CREATED);
- assert(vtime_asleep_p(ddsrt_atomic_ld32 (&ts->vtime)));
- reset_thread_state(ts);
+ assert (ts1->state == THREAD_STATE_LAZILY_CREATED);
+ assert (vtime_asleep_p (ddsrt_atomic_ld32 (&ts1->vtime)));
+ reap_thread_state (ts1);
}
- ddsrt_fini();
+ ddsrt_fini ();
}
static struct thread_state1 *lazy_create_thread_state (ddsrt_thread_t self)
@@ -178,9 +202,9 @@ static struct thread_state1 *lazy_create_thread_state (ddsrt_thread_t self)
char name[128];
ddsrt_thread_getname (name, sizeof (name));
ddsrt_mutex_lock (&thread_states.lock);
- if ((ts1 = init_thread_state (name, NULL, THREAD_STATE_LAZILY_CREATED)) != NULL) {
+ if ((ts1 = init_thread_state (name, NULL, THREAD_STATE_LAZILY_CREATED)) != NULL)
+ {
ddsrt_init ();
- ts1->extTid = self;
ts1->tid = self;
DDS_LOG (DDS_LC_TRACE, "started application thread %s\n", name);
ddsrt_thread_cleanup_push (&cleanup_thread_state, NULL);
@@ -199,38 +223,29 @@ struct thread_state1 *lookup_thread_state_real (void)
ts1 = lazy_create_thread_state (self);
tsd_thread_state = ts1;
}
- assert(ts1 != NULL);
+ assert (ts1 != NULL);
return ts1;
}
-struct thread_context {
- struct thread_state1 *self;
- uint32_t (*f) (void *arg);
- void *arg;
-};
-
static uint32_t create_thread_wrapper (void *ptr)
{
- uint32_t ret;
- struct thread_context *ctx = ptr;
- struct ddsi_domaingv const * const gv = ddsrt_atomic_ldvoidp (&ctx->self->gv);
+ struct thread_state1 * const ts1 = ptr;
+ struct ddsi_domaingv const * const gv = ddsrt_atomic_ldvoidp (&ts1->gv);
if (gv)
- GVTRACE ("started new thread %"PRIdTID": %s\n", ddsrt_gettid (), ctx->self->name);
- ctx->self->tid = ddsrt_thread_self ();
- ret = ctx->f (ctx->arg);
- ddsrt_free (ctx);
+ GVTRACE ("started new thread %"PRIdTID": %s\n", ddsrt_gettid (), ts1->name);
+ assert (ts1->state == THREAD_STATE_INIT);
+ tsd_thread_state = ts1;
+ ddsrt_mutex_lock (&thread_states.lock);
+ ts1->state = THREAD_STATE_ALIVE;
+ ddsrt_mutex_unlock (&thread_states.lock);
+ const uint32_t ret = ts1->f (ts1->f_arg);
+ ddsrt_mutex_lock (&thread_states.lock);
+ ts1->state = THREAD_STATE_STOPPED;
+ ddsrt_mutex_unlock (&thread_states.lock);
+ tsd_thread_state = NULL;
return ret;
}
-static int find_free_slot (const char *name)
-{
- for (uint32_t i = 0; i < thread_states.nthreads; i++)
- if (thread_states.ts[i].state == THREAD_STATE_ZERO)
- return (int) i;
- DDS_FATAL ("create_thread: %s: no free slot\n", name ? name : "(anon)");
- return -1;
-}
-
const struct config_thread_properties_listelem *lookup_thread_properties (const struct config *config, const char *name)
{
const struct config_thread_properties_listelem *e;
@@ -242,36 +257,37 @@ const struct config_thread_properties_listelem *lookup_thread_properties (const
static struct thread_state1 *init_thread_state (const char *tname, const struct ddsi_domaingv *gv, enum thread_state state)
{
- int cand;
- struct thread_state1 *ts;
-
- if ((cand = find_free_slot (tname)) < 0)
+ uint32_t i;
+ for (i = 0; i < thread_states.nthreads; i++)
+ if (thread_states.ts[i].state == THREAD_STATE_ZERO)
+ break;
+ if (i == thread_states.nthreads)
+ {
+ DDS_FATAL ("create_thread: %s: no free slot\n", tname ? tname : "(anon)");
return NULL;
+ }
- ts = &thread_states.ts[cand];
- ddsrt_atomic_stvoidp (&ts->gv, (struct ddsi_domaingv *) gv);
- assert (vtime_asleep_p (ddsrt_atomic_ld32 (&ts->vtime)));
- (void) ddsrt_strlcpy (ts->name, tname, sizeof (ts->name));
- ts->state = state;
-
- return ts;
+ struct thread_state1 * const ts1 = &thread_states.ts[i];
+ assert (vtime_asleep_p (ddsrt_atomic_ld32 (&ts1->vtime)));
+ memset (ts1, 0, sizeof (*ts1));
+ ddsrt_atomic_stvoidp (&ts1->gv, (struct ddsi_domaingv *) gv);
+ (void) ddsrt_strlcpy (ts1->name, tname, sizeof (ts1->name));
+ ts1->state = state;
+ return ts1;
}
-static dds_return_t create_thread_int (struct thread_state1 **ts1, const struct ddsi_domaingv *gv, struct config_thread_properties_listelem const * const tprops, const char *name, uint32_t (*f) (void *arg), void *arg)
+static dds_return_t create_thread_int (struct thread_state1 **ts1_out, const struct ddsi_domaingv *gv, struct config_thread_properties_listelem const * const tprops, const char *name, uint32_t (*f) (void *arg), void *arg)
{
ddsrt_threadattr_t tattr;
- ddsrt_thread_t tid;
- struct thread_context *ctxt;
- ctxt = ddsrt_malloc (sizeof (*ctxt));
+ struct thread_state1 *ts1;
ddsrt_mutex_lock (&thread_states.lock);
- *ts1 = init_thread_state (name, gv, THREAD_STATE_ALIVE);
- if (*ts1 == NULL)
+ ts1 = *ts1_out = init_thread_state (name, gv, THREAD_STATE_INIT);
+ if (ts1 == NULL)
goto fatal;
- ctxt->self = *ts1;
- ctxt->f = f;
- ctxt->arg = arg;
+ ts1->f = f;
+ ts1->f_arg = arg;
ddsrt_threadattr_init (&tattr);
if (tprops != NULL)
{
@@ -286,19 +302,17 @@ static dds_return_t create_thread_int (struct thread_state1 **ts1, const struct
GVTRACE ("create_thread: %s: class %d priority %"PRId32" stack %"PRIu32"\n", name, (int) tattr.schedClass, tattr.schedPriority, tattr.stackSize);
}
- if (ddsrt_thread_create (&tid, name, &tattr, &create_thread_wrapper, ctxt) != DDS_RETCODE_OK)
+ if (ddsrt_thread_create (&ts1->tid, name, &tattr, &create_thread_wrapper, ts1) != DDS_RETCODE_OK)
{
- (*ts1)->state = THREAD_STATE_ZERO;
+ ts1->state = THREAD_STATE_ZERO;
DDS_FATAL ("create_thread: %s: ddsrt_thread_create failed\n", name);
goto fatal;
}
- (*ts1)->extTid = tid; /* overwrite the temporary value with the correct external one */
ddsrt_mutex_unlock (&thread_states.lock);
return DDS_RETCODE_OK;
fatal:
ddsrt_mutex_unlock (&thread_states.lock);
- ddsrt_free (ctxt);
- *ts1 = NULL;
+ *ts1_out = NULL;
abort ();
return DDS_RETCODE_ERROR;
}
@@ -317,34 +331,53 @@ dds_return_t create_thread (struct thread_state1 **ts1, const struct ddsi_domain
static void reap_thread_state (struct thread_state1 *ts1)
{
ddsrt_mutex_lock (&thread_states.lock);
- ts1->state = THREAD_STATE_ZERO;
+ switch (ts1->state)
+ {
+ case THREAD_STATE_INIT:
+ case THREAD_STATE_STOPPED:
+ case THREAD_STATE_LAZILY_CREATED:
+ ts1->state = THREAD_STATE_ZERO;
+ break;
+ case THREAD_STATE_ZERO:
+ case THREAD_STATE_ALIVE:
+ assert (0);
+ }
ddsrt_mutex_unlock (&thread_states.lock);
}
dds_return_t join_thread (struct thread_state1 *ts1)
{
dds_return_t ret;
- assert (ts1->state == THREAD_STATE_ALIVE);
- ret = ddsrt_thread_join (ts1->extTid, NULL);
+ ddsrt_mutex_lock (&thread_states.lock);
+ switch (ts1->state)
+ {
+ case THREAD_STATE_INIT:
+ case THREAD_STATE_STOPPED:
+ case THREAD_STATE_ALIVE:
+ break;
+ case THREAD_STATE_ZERO:
+ case THREAD_STATE_LAZILY_CREATED:
+ assert (0);
+ }
+ ddsrt_mutex_unlock (&thread_states.lock);
+ ret = ddsrt_thread_join (ts1->tid, NULL);
assert (vtime_asleep_p (ddsrt_atomic_ld32 (&ts1->vtime)));
reap_thread_state (ts1);
return ret;
}
-void reset_thread_state (struct thread_state1 *ts1)
-{
- if (ts1)
- reap_thread_state (ts1);
-}
-
void log_stack_traces (const struct ddsrt_log_cfg *logcfg, const struct ddsi_domaingv *gv)
{
for (uint32_t i = 0; i < thread_states.nthreads; i++)
{
- if (thread_states.ts[i].state != THREAD_STATE_ZERO &&
- (gv == NULL || ddsrt_atomic_ldvoidp (&thread_states.ts[i].gv) == gv))
+ struct thread_state1 * const ts1 = &thread_states.ts[i];
+ if (ts1->state > THREAD_STATE_INIT && (gv == NULL || ddsrt_atomic_ldvoidp (&ts1->gv) == gv))
{
- log_stacktrace (logcfg, thread_states.ts[i].name, thread_states.ts[i].tid);
+ /* There's a race condition here that may cause us to call log_stacktrace with an invalid
+ thread id (or even with a thread id mapping to a newly created thread that isn't really
+ relevant in this context!) but this is an optional debug feature, so it's not worth the
+ bother to avoid it. */
+ log_stacktrace (logcfg, ts1->name, ts1->tid);
}
}
}
From d72ebb0ed37acbe5731de130dfee687a1207ba0d Mon Sep 17 00:00:00 2001
From: Dan Rose
Date: Sat, 29 Feb 2020 01:32:02 -0600
Subject: [PATCH 10/30] Don't pass null to memcmp (#413)
* Don't pass null to memcmp
```
SUMMARY: UndefinedBehaviorSanitizer: undefined-behavior /opt/ros/master/src/ros2/rmw_cyclonedds/rmw_cyclonedds_cpp/include/rmw_cyclonedds_cpp/serdes.hpp:135:3 in
/opt/ros/master/src/eclipse-cyclonedds/cyclonedds/src/core/ddsi/src/ddsi_sertopic_default.c:41:15: runtime error: null pointer passed as argument 1, which is declared to never be null
/usr/include/string.h:64:33: note: nonnull attribute specified here
SUMMARY: UndefinedBehaviorSanitizer: undefined-behavior /opt/ros/master/src/eclipse-cyclonedds/cyclonedds/src/core/ddsi/src/ddsi_sertopic_default.c:41:15 in
/opt/ros/master/src/eclipse-cyclonedds/cyclonedds/src/core/ddsi/src/ddsi_sertopic_default.c:41:31: runtime error: null pointer passed as argument 2, which is declared to never be null
/usr/include/string.h:64:33: note: nonnull attribute specified here
SUMMARY: UndefinedBehaviorSanitizer: undefined-behavior /opt/ros/master/src/eclipse-cyclonedds/cyclonedds/src/core/ddsi/src/ddsi_sertopic_default.c:41:31 in
/opt/ros/master/src/eclipse-cyclonedds/cyclonedds/src/core/ddsi/src/ddsi_sertopic_default.c:45:15: runtime error: null pointer passed as argument 1, which is declared to never be null
/usr/include/string.h:64:33: note: nonnull attribute specified here
SUMMARY: UndefinedBehaviorSanitizer: undefined-behavior /opt/ros/master/src/eclipse-cyclonedds/cyclonedds/src/core/ddsi/src/ddsi_sertopic_default.c:45:15 in
/opt/ros/master/src/eclipse-cyclonedds/cyclonedds/src/core/ddsi/src/ddsi_sertopic_default.c:45:30: runtime error: null pointer passed as argument 2, which is declared to never be null
/usr/include/string.h:64:33: note: nonnull attribute specified here
SUMMARY: UndefinedBehaviorSanitizer: undefined-behavior /opt/ros/master/src/eclipse-cyclonedds/cyclonedds/src/core/ddsi/src/ddsi_sertopic_default.c:45:30 in
```
Signed-off-by: Dan Rose
* clearer non-null check
Signed-off-by: Dan Rose
---
src/core/ddsi/src/ddsi_sertopic_default.c | 8 ++++++--
1 file changed, 6 insertions(+), 2 deletions(-)
diff --git a/src/core/ddsi/src/ddsi_sertopic_default.c b/src/core/ddsi/src/ddsi_sertopic_default.c
index a10cb96..d8a05fc 100644
--- a/src/core/ddsi/src/ddsi_sertopic_default.c
+++ b/src/core/ddsi/src/ddsi_sertopic_default.c
@@ -38,11 +38,15 @@ static bool sertopic_default_equal (const struct ddsi_sertopic *acmn, const stru
return false;
if (a->type.m_nkeys != b->type.m_nkeys)
return false;
- if (memcmp (a->type.m_keys, b->type.m_keys, a->type.m_nkeys * sizeof (*a->type.m_keys)) != 0)
+ if (
+ (a->type.m_nkeys > 0) &&
+ memcmp (a->type.m_keys, b->type.m_keys, a->type.m_nkeys * sizeof (*a->type.m_keys)) != 0)
return false;
if (a->type.m_nops != b->type.m_nops)
return false;
- if (memcmp (a->type.m_ops, b->type.m_ops, a->type.m_nops * sizeof (*a->type.m_ops)) != 0)
+ if (
+ (a->type.m_nops > 0) &&
+ memcmp (a->type.m_ops, b->type.m_ops, a->type.m_nops * sizeof (*a->type.m_ops)) != 0)
return false;
assert (a->opt_size == b->opt_size);
return true;
From e8b0931798ff43e7cee3ec1ec74f96dea3cc22fc Mon Sep 17 00:00:00 2001
From: Dan Rose
Date: Sat, 29 Feb 2020 01:38:40 -0600
Subject: [PATCH 11/30] Don't turn on sanitizers for debug builds by default
(#408)
Also, allow multiple sanitizers.
Signed-off-by: Dan Rose
---
CMakeLists.txt | 34 ++++++++++++++++------------------
1 file changed, 16 insertions(+), 18 deletions(-)
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 3180abb..2811e3a 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -170,25 +170,23 @@ if(${CMAKE_GENERATOR} STREQUAL "Xcode")
set (CMAKE_XCODE_ATTRIBUTE_GCC_WARN_ABOUT_MISSING_PROTOTYPES YES)
endif()
-# Make it easy to enable one of Clang's/gcc's analyzers, and default to using
-# the address sanitizer for ordinary debug builds; gcc is giving some grief on
-# Travis, so don't enable it for gcc by default
-if(NOT USE_SANITIZER)
- if("${CMAKE_BUILD_TYPE}" STREQUAL "Debug" AND
- NOT ("${CMAKE_GENERATOR}" STREQUAL "Xcode") AND
- ("${CMAKE_C_COMPILER_ID}" STREQUAL "Clang"
- OR "${CMAKE_C_COMPILER_ID}" STREQUAL "AppleClang"))
- message(STATUS "Enabling address sanitizer; set USE_SANITIZER=none to prevent this")
- set(USE_SANITIZER address)
- else()
- set(USE_SANITIZER none)
+
+# Make it easy to enable Clang's/gcc's analyzers
+set(USE_SANITIZER "" CACHE STRING "Sanitizers to enable on the build.")
+foreach(san "${USE_SANITIZER}")
+ message(STATUS "Enabling sanitizer: '${san}'")
+
+ if("${san}" STREQUAL address)
+ add_compile_options(-fno-omit-frame-pointer)
+ link_libraries(-fno-omit-frame-pointer)
endif()
-endif()
-if(NOT ("${USE_SANITIZER}" STREQUAL "none"))
- message(STATUS "Sanitizer set to ${USE_SANITIZER}")
- add_compile_options(-fno-omit-frame-pointer -fsanitize=${USE_SANITIZER})
- link_libraries(-fno-omit-frame-pointer -fsanitize=${USE_SANITIZER})
-endif()
+
+ if(NOT("${san}" STREQUAL "none"))
+ add_compile_options("-fsanitize=${san}")
+ link_libraries("-fsanitize=${san}")
+ endif()
+endforeach()
+
include(GNUInstallDirs)
include(AnalyzeBuild)
From ca4b5a368f3de4b88c78d076434e57845ac74dff Mon Sep 17 00:00:00 2001
From: Dan Rose
Date: Fri, 28 Feb 2020 15:19:21 -0600
Subject: [PATCH 12/30] Fix undefined behavior when hash function given null
pointer
[test_subscriber-12] /opt/ros/master/src/eclipse-cyclonedds/cyclonedds/src/ddsrt/src/mh3.c:28:53: runtime error: applying zero offset to null pointer
[test_subscriber-12] SUMMARY: UndefinedBehaviorSanitizer: undefined-behavior /opt/ros/master/src/eclipse-cyclonedds/cyclonedds/src/ddsrt/src/mh3.c:28:53 in
Signed-off-by: Dan Rose
---
src/core/ddsi/src/ddsi_sertopic_default.c | 2 +-
src/ddsrt/src/mh3.c | 55 ++++++++++++-----------
2 files changed, 30 insertions(+), 27 deletions(-)
diff --git a/src/core/ddsi/src/ddsi_sertopic_default.c b/src/core/ddsi/src/ddsi_sertopic_default.c
index d8a05fc..ece3872 100644
--- a/src/core/ddsi/src/ddsi_sertopic_default.c
+++ b/src/core/ddsi/src/ddsi_sertopic_default.c
@@ -56,7 +56,7 @@ static uint32_t sertopic_default_hash (const struct ddsi_sertopic *tpcmn)
{
const struct ddsi_sertopic_default *tp = (struct ddsi_sertopic_default *) tpcmn;
uint32_t h = 0;
- h = ddsrt_mh3 (&tp->native_encoding_identifier, sizeof (tp->native_encoding_identifier), 0);
+ h = ddsrt_mh3 (&tp->native_encoding_identifier, sizeof (tp->native_encoding_identifier), h);
h = ddsrt_mh3 (&tp->type.m_size, sizeof (tp->type.m_size), h);
h = ddsrt_mh3 (&tp->type.m_align, sizeof (tp->type.m_align), h);
h = ddsrt_mh3 (&tp->type.m_flagset, sizeof (tp->type.m_flagset), h);
diff --git a/src/ddsrt/src/mh3.c b/src/ddsrt/src/mh3.c
index f186e95..1b57de7 100644
--- a/src/ddsrt/src/mh3.c
+++ b/src/ddsrt/src/mh3.c
@@ -25,38 +25,41 @@ uint32_t ddsrt_mh3 (const void *key, size_t len, uint32_t seed)
const uint32_t c2 = 0x1b873593;
uint32_t h1 = seed;
- const uint32_t *blocks = (const uint32_t *) (data + nblocks * 4);
- for (intptr_t i = -nblocks; i; i++)
- {
- uint32_t k1 = blocks[i];
- k1 *= c1;
- k1 = DDSRT_MH3_ROTL32 (k1, 15);
- k1 *= c2;
+ if(len){
+ const uint32_t *blocks = (const uint32_t *) (data + nblocks * 4);
+ for (intptr_t i = -nblocks; i; i++)
+ {
+ uint32_t k1 = blocks[i];
- h1 ^= k1;
- h1 = DDSRT_MH3_ROTL32 (h1, 13);
- h1 = h1 * 5 + 0xe6546b64;
- }
-
- const uint8_t *tail = data + nblocks * 4;
- uint32_t k1 = 0;
- switch (len & 3)
- {
- case 3:
- k1 ^= (uint32_t) tail[2] << 16;
- /* FALLS THROUGH */
- case 2:
- k1 ^= (uint32_t) tail[1] << 8;
- /* FALLS THROUGH */
- case 1:
- k1 ^= (uint32_t) tail[0];
k1 *= c1;
k1 = DDSRT_MH3_ROTL32 (k1, 15);
k1 *= c2;
+
h1 ^= k1;
- /* FALLS THROUGH */
- };
+ h1 = DDSRT_MH3_ROTL32 (h1, 13);
+ h1 = h1 * 5 + 0xe6546b64;
+ }
+
+ const uint8_t *tail = data + nblocks * 4;
+ uint32_t k1 = 0;
+ switch (len & 3)
+ {
+ case 3:
+ k1 ^= (uint32_t) tail[2] << 16;
+ /* FALLS THROUGH */
+ case 2:
+ k1 ^= (uint32_t) tail[1] << 8;
+ /* FALLS THROUGH */
+ case 1:
+ k1 ^= (uint32_t) tail[0];
+ k1 *= c1;
+ k1 = DDSRT_MH3_ROTL32 (k1, 15);
+ k1 *= c2;
+ h1 ^= k1;
+ /* FALLS THROUGH */
+ }
+ }
/* finalization */
h1 ^= (uint32_t) len;
From dc57685ac3d28349fbb64472f0e34c8fd7e2eeb4 Mon Sep 17 00:00:00 2001
From: Christophe Bedard
Date: Sat, 29 Feb 2020 11:53:33 -0500
Subject: [PATCH 13/30] Make sure USE_SANITIZER is not empty before foreach
Signed-off-by: Christophe Bedard
---
CMakeLists.txt | 24 +++++++++++++-----------
1 file changed, 13 insertions(+), 11 deletions(-)
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 2811e3a..fd7878f 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -173,19 +173,21 @@ endif()
# Make it easy to enable Clang's/gcc's analyzers
set(USE_SANITIZER "" CACHE STRING "Sanitizers to enable on the build.")
-foreach(san "${USE_SANITIZER}")
- message(STATUS "Enabling sanitizer: '${san}'")
+if(NOT("${USE_SANITIZER}" STREQUAL ""))
+ foreach(san "${USE_SANITIZER}")
+ message(STATUS "Enabling sanitizer: '${san}'")
- if("${san}" STREQUAL address)
- add_compile_options(-fno-omit-frame-pointer)
- link_libraries(-fno-omit-frame-pointer)
- endif()
+ if("${san}" STREQUAL address)
+ add_compile_options(-fno-omit-frame-pointer)
+ link_libraries(-fno-omit-frame-pointer)
+ endif()
- if(NOT("${san}" STREQUAL "none"))
- add_compile_options("-fsanitize=${san}")
- link_libraries("-fsanitize=${san}")
- endif()
-endforeach()
+ if(NOT("${san}" STREQUAL "none"))
+ add_compile_options("-fsanitize=${san}")
+ link_libraries("-fsanitize=${san}")
+ endif()
+ endforeach()
+endif()
include(GNUInstallDirs)
From e412f6fab2d8b96c7fe97bd97d6358cb470cd42c Mon Sep 17 00:00:00 2001
From: eboasson
Date: Thu, 5 Mar 2020 15:21:02 +0100
Subject: [PATCH 14/30] Fix issue in dds_create_topic_arbitrary (#422)
* Fix issue in dds_create_topic_arbitrary
Changed the behaviour of dds_create_topic_arbitrary with respect to the
sertopic parameter: the existing function dds_create_topic_arbitrary is
marked deprecated and replaced by dds_create_topic_generic, which returns
the sertopic that is actually used in as an out parameter. This can be eiter
the provided sertopic (if this sertopic was not yet known in the domain) or an
existing sertopic if the sertopic was registered earlier.
Signed-off-by: Dennis Potman
* Fix memory leaks in case topic creation fails.
Signed-off-by: Dennis Potman
---
src/core/ddsc/include/dds/dds.h | 32 +++++++++++++-------
src/core/ddsc/src/dds_builtin.c | 7 ++++-
src/core/ddsc/src/dds_topic.c | 49 ++++++++++++++++++++-----------
src/core/ddsi/src/ddsi_sertopic.c | 1 -
4 files changed, 60 insertions(+), 29 deletions(-)
diff --git a/src/core/ddsc/include/dds/dds.h b/src/core/ddsc/include/dds/dds.h
index dddd300..b78c2e1 100644
--- a/src/core/ddsc/include/dds/dds.h
+++ b/src/core/ddsc/include/dds/dds.h
@@ -998,25 +998,29 @@ dds_create_topic(
const dds_qos_t *qos,
const dds_listener_t *listener);
+
+#define DDS_HAS_CREATE_TOPIC_GENERIC 1
/**
- * @brief Creates a new topic with arbitrary type handling.
+ * @brief Creates a new topic with provided type handling.
*
* The type name for the topic is taken from the provided "sertopic" object. Topic
* matching is done on a combination of topic name and type name. Each successful
* call to dds_create_topic creates a new topic entity sharing the same QoS
* settings with all other topics of the same name.
*
- * If sertopic is not yet known in the domain, it is added and its refcount
- * incremented; if an equivalent sertopic object is already known, then the known
- * one is used instead.
+ * In case this function returns a valid handle, the ownership of the provided
+ * sertopic is handed over to Cyclone. On return, the caller gets in the sertopic parameter a
+ * pointer to the sertopic that is actually used by the topic. This can be the provided sertopic
+ * (if this sertopic was not yet known in the domain), or a sertopic thas was
+ * already known in the domain.
*
- * @param[in] participant Participant on which to create the topic.
- * @param[in] sertopic Internal description of the topic type (includes name).
- * @param[in] qos QoS to set on the new topic (can be NULL).
- * @param[in] listener Any listener functions associated with the new topic (can be NULL).
- * @param[in] sedp_plist Topic description to be published as part of discovery (if NULL, not published).
+ * @param[in] participant Participant on which to create the topic.
+ * @param[in,out] sertopic Internal description of the topic type (includes name). On return, the sertopic parameter is set to the actual sertopic that is used by the topic.
+ * @param[in] qos QoS to set on the new topic (can be NULL).
+ * @param[in] listener Any listener functions associated with the new topic (can be NULL).
+ * @param[in] sedp_plist Topic description to be published as part of discovery (if NULL, not published).
*
- * @returns A valid, unique topic handle or an error code.
+ * @returns A valid, unique topic handle or an error code. Iff a valid handle, the domain takes ownership of provided serdata.
*
* @retval >=0
* A valid unique topic handle.
@@ -1031,6 +1035,14 @@ dds_create_topic(
* topic's type name.
*/
DDS_EXPORT dds_entity_t
+dds_create_topic_generic (
+ dds_entity_t participant,
+ struct ddsi_sertopic **sertopic,
+ const dds_qos_t *qos,
+ const dds_listener_t *listener,
+ const struct ddsi_plist *sedp_plist);
+
+DDS_DEPRECATED_EXPORT dds_entity_t
dds_create_topic_arbitrary (
dds_entity_t participant,
struct ddsi_sertopic *sertopic,
diff --git a/src/core/ddsc/src/dds_builtin.c b/src/core/ddsc/src/dds_builtin.c
index 7956672..ec94bef 100644
--- a/src/core/ddsc/src/dds_builtin.c
+++ b/src/core/ddsc/src/dds_builtin.c
@@ -76,7 +76,12 @@ dds_entity_t dds__get_builtin_topic (dds_entity_t entity, dds_entity_t topic)
}
dds_qos_t *qos = dds__create_builtin_qos ();
- tp = dds_create_topic_arbitrary (par->m_entity.m_hdllink.hdl, sertopic, qos, NULL, NULL);
+ if ((tp = dds_create_topic_generic (par->m_entity.m_hdllink.hdl, &sertopic, qos, NULL, NULL)) > 0)
+ {
+ /* keep ownership for built-in sertopics because there are re-used, lifetime for these
+ sertopics is bound to domain */
+ ddsi_sertopic_ref (sertopic);
+ }
dds_delete_qos (qos);
dds_entity_unpin (e);
return tp;
diff --git a/src/core/ddsc/src/dds_topic.c b/src/core/ddsc/src/dds_topic.c
index 79a4eee..913a8a4 100644
--- a/src/core/ddsc/src/dds_topic.c
+++ b/src/core/ddsc/src/dds_topic.c
@@ -276,7 +276,7 @@ static dds_entity_t create_topic_pp_locked (struct dds_participant *pp, struct d
return hdl;
}
-dds_entity_t dds_create_topic_arbitrary (dds_entity_t participant, struct ddsi_sertopic *sertopic, const dds_qos_t *qos, const dds_listener_t *listener, const ddsi_plist_t *sedp_plist)
+dds_entity_t dds_create_topic_generic (dds_entity_t participant, struct ddsi_sertopic **sertopic, const dds_qos_t *qos, const dds_listener_t *listener, const ddsi_plist_t *sedp_plist)
{
dds_return_t rc;
dds_participant *pp;
@@ -284,7 +284,7 @@ dds_entity_t dds_create_topic_arbitrary (dds_entity_t participant, struct ddsi_s
dds_entity_t hdl;
struct ddsi_sertopic *sertopic_registered;
- if (sertopic == NULL)
+ if (sertopic == NULL || *sertopic == NULL)
return DDS_RETCODE_BAD_PARAMETER;
{
@@ -323,14 +323,14 @@ dds_entity_t dds_create_topic_arbitrary (dds_entity_t participant, struct ddsi_s
/* See if we're allowed to create the topic; ktp is returned pinned & locked
so we can be sure it doesn't disappear and its QoS can't change */
- GVTRACE ("dds_create_topic_arbitrary (pp %p "PGUIDFMT" sertopic %p reg?%s refc %"PRIu32" %s/%s)\n",
- (void *) pp, PGUID (pp->m_entity.m_guid), (void *) sertopic, sertopic->gv ? "yes" : "no",
- ddsrt_atomic_ld32 (&sertopic->refc), sertopic->name, sertopic->type_name);
+ GVTRACE ("dds_create_topic_generic (pp %p "PGUIDFMT" sertopic %p reg?%s refc %"PRIu32" %s/%s)\n",
+ (void *) pp, PGUID (pp->m_entity.m_guid), (void *) (*sertopic), (*sertopic)->gv ? "yes" : "no",
+ ddsrt_atomic_ld32 (&(*sertopic)->refc), (*sertopic)->name, (*sertopic)->type_name);
ddsrt_mutex_lock (&pp->m_entity.m_mutex);
struct dds_ktopic *ktp;
- if ((rc = lookup_and_check_ktopic (&ktp, pp, sertopic->name, sertopic->type_name, new_qos)) != DDS_RETCODE_OK)
+ if ((rc = lookup_and_check_ktopic (&ktp, pp, (*sertopic)->name, (*sertopic)->type_name, new_qos)) != DDS_RETCODE_OK)
{
- GVTRACE ("dds_create_topic_arbitrary: failed after compatibility check: %s\n", dds_strretcode (rc));
+ GVTRACE ("dds_create_topic_generic: failed after compatibility check: %s\n", dds_strretcode (rc));
dds_participant_unlock (pp);
dds_delete_qos (new_qos);
return rc;
@@ -345,8 +345,8 @@ dds_entity_t dds_create_topic_arbitrary (dds_entity_t participant, struct ddsi_s
ktp->defer_set_qos = 0;
ktp->qos = new_qos;
/* have to copy these because the ktopic can outlast any specific sertopic */
- ktp->name = ddsrt_strdup (sertopic->name);
- ktp->type_name = ddsrt_strdup (sertopic->type_name);
+ ktp->name = ddsrt_strdup ((*sertopic)->name);
+ ktp->type_name = ddsrt_strdup ((*sertopic)->type_name);
ddsrt_avl_insert (&participant_ktopics_treedef, &pp->m_ktopics, ktp);
GVTRACE ("create_and_lock_ktopic: ktp %p\n", (void *) ktp);
}
@@ -359,13 +359,13 @@ dds_entity_t dds_create_topic_arbitrary (dds_entity_t participant, struct ddsi_s
/* Sertopic: re-use a previously registered one if possible, else register this one */
{
ddsrt_mutex_lock (&gv->sertopics_lock);
- if ((sertopic_registered = ddsi_sertopic_lookup_locked (gv, sertopic)) != NULL)
- GVTRACE ("dds_create_topic_arbitrary: reuse sertopic %p\n", (void *) sertopic_registered);
+ if ((sertopic_registered = ddsi_sertopic_lookup_locked (gv, *sertopic)) != NULL)
+ GVTRACE ("dds_create_topic_generic: reuse sertopic %p\n", (void *) sertopic_registered);
else
{
- GVTRACE ("dds_create_topic_arbitrary: register new sertopic %p\n", (void *) sertopic);
- ddsi_sertopic_register_locked (gv, sertopic);
- sertopic_registered = sertopic;
+ GVTRACE ("dds_create_topic_generic: register new sertopic %p\n", (void *) (*sertopic));
+ ddsi_sertopic_register_locked (gv, *sertopic);
+ sertopic_registered = *sertopic;
}
ddsrt_mutex_unlock (&gv->sertopics_lock);
}
@@ -373,14 +373,27 @@ dds_entity_t dds_create_topic_arbitrary (dds_entity_t participant, struct ddsi_s
/* Create topic referencing ktopic & sertopic_registered */
/* FIXME: setting "implicit" based on sertopic->ops is a hack */
hdl = create_topic_pp_locked (pp, ktp, (sertopic_registered->ops == &ddsi_sertopic_ops_builtintopic), sertopic_registered, listener, sedp_plist);
+ ddsi_sertopic_unref (*sertopic);
+ *sertopic = sertopic_registered;
dds_participant_unlock (pp);
- GVTRACE ("dds_create_topic_arbitrary: new topic %"PRId32"\n", hdl);
+ GVTRACE ("dds_create_topic_generic: new topic %"PRId32"\n", hdl);
return hdl;
}
+dds_entity_t dds_create_topic_arbitrary (dds_entity_t participant, struct ddsi_sertopic *sertopic, const dds_qos_t *qos, const dds_listener_t *listener, const ddsi_plist_t *sedp_plist)
+{
+ dds_entity_t ret;
+ struct ddsi_sertopic *st = sertopic;
+ ddsi_sertopic_ref (st);
+ if ((ret = dds_create_topic_generic (participant, &st, qos, listener, sedp_plist)) < 0)
+ ddsi_sertopic_unref (st);
+ return ret;
+}
+
dds_entity_t dds_create_topic (dds_entity_t participant, const dds_topic_descriptor_t *desc, const char *name, const dds_qos_t *qos, const dds_listener_t *listener)
{
struct ddsi_sertopic_default *st;
+ struct ddsi_sertopic *st_tmp;
ddsi_plist_t plist;
dds_entity_t hdl;
struct dds_entity *ppent;
@@ -433,8 +446,10 @@ dds_entity_t dds_create_topic (dds_entity_t participant, const dds_topic_descrip
plist.qos.subscription_keys.key_list.strs[index] = dds_string_dup (desc->m_keys[index].m_name);
}
- hdl = dds_create_topic_arbitrary (participant, &st->c, qos, listener, &plist);
- ddsi_sertopic_unref (&st->c);
+ st_tmp = &st->c;
+ hdl = dds_create_topic_generic (participant, &st_tmp, qos, listener, &plist);
+ if (hdl < 0)
+ ddsi_sertopic_unref (st_tmp);
dds_entity_unpin (ppent);
ddsi_plist_fini (&plist);
return hdl;
diff --git a/src/core/ddsi/src/ddsi_sertopic.c b/src/core/ddsi/src/ddsi_sertopic.c
index 8776ede..04052cc 100644
--- a/src/core/ddsi/src/ddsi_sertopic.c
+++ b/src/core/ddsi/src/ddsi_sertopic.c
@@ -74,7 +74,6 @@ struct ddsi_sertopic *ddsi_sertopic_lookup_locked (struct ddsi_domaingv *gv, con
void ddsi_sertopic_register_locked (struct ddsi_domaingv *gv, struct ddsi_sertopic *sertopic)
{
assert (sertopic->gv == NULL);
- assert (ddsrt_atomic_ld32 (&sertopic->refc) == 1);
(void) ddsi_sertopic_ref (sertopic);
sertopic->gv = gv;
From 9c272c98b8b7bfda845db215e03c691a296f779c Mon Sep 17 00:00:00 2001
From: Erik Boasson
Date: Fri, 28 Feb 2020 16:51:13 +0100
Subject: [PATCH 15/30] decode-trace IPv6 support + some minor fixes in it
* IPv6 extensions to patterns
* use full GUID prefix for Cyclone
* pattern fixes to deal with small changes in the formatting of QoS
* suppressinof local built-in topic publications
* asymmetrical disconnect detection improvements (better chance of
detecting it, plus better suppression of spurious notifications)
Signed-off-by: Erik Boasson
---
src/tools/decode-trace | 123 +++++++++++++++++++++++++----------------
1 file changed, 74 insertions(+), 49 deletions(-)
diff --git a/src/tools/decode-trace b/src/tools/decode-trace
index e534669..82ada68 100755
--- a/src/tools/decode-trace
+++ b/src/tools/decode-trace
@@ -72,7 +72,7 @@ my $last_infots;
my %spdp_info;
my $hexmode = 1;
my $sysid_hex;
-my $proto = '(?:udp4?|tcp4?)\/';
+my $proto_ip = "(?:(?:udp[46]?|tcp[46]?)\/)?(?:[0-9.]+|\[[0-9a-fA-F:]+\])";
my %tstamps;
my %topic_qos;
my $recv_packet = 0;
@@ -275,12 +275,14 @@ while(<>) {
check_disccomplete("B", $1);
}
- # Special handling of INFOTS & SPDP for extracting start times of remote nodes and making an
- # informed guess as to whether the remote node learned of our existence because we sent a
- # multicast or a unicast
if (/recv(?:UC|MC)?: INFOTS\((\d+)\.(\d+)\)/) {
+ # Special handling of INFOTS for guessing at source time stamps (in particular also
+ # for guessing at start times of other nodes
$last_infots = ($1 - $t0sec) + ($2/1e3 - $t0usec) / 1e6;
- } elsif ($hexmode ? m/recv: DATA\(((?:[0-9a-f]+:){3}100c2) -> ($guidre)/ : m/recv: DATA\(((?:[0-9a-f]+:){3}65730) -> ($guidre)/) {
+ } elsif ($hexmode ? m/recv(?:UC|MC)?: DATA\(((?:[0-9a-f]+:){3}100c2) -> ($guidre)/ : m/recv(?:UC|MC)?: DATA\(((?:[0-9a-f]+:){3}65730) -> ($guidre)/) {
+ # SPDP for extracting start times of remote nodes and making an informed guess as to
+ # whether the remote node learned of our existence because we sent a multicast or a
+ # unicast
my $src = $1; my $dst = $2;
(my $ppguid = hexify($src)) =~ s/:(100c2|65730)$/:1c1/;
my $directed = ($dst !~ /^0:0:0:/);
@@ -290,23 +292,39 @@ while(<>) {
# relatively long after discovery. "Relatively long" being a pretty difficult
# concept to work with, we use the "discovery complete" flag to see if it is a
# likely asymmetrical disconnect
- if ($proxypp{$ppguid}->{disccompleteflag}) {
+ if ($proxypp{$ppguid}->{disccompleteflag} && $ts > $proxypp{$ppguid}->{tasymdisc} + 5) {
my $sysid = $proxypp{$ppguid}->{sysid};
my $sx = decimal_sysid($sysid);
printf "%9.3f %35s $topfmt ASYM %s (%s; %s; %s) likely asymmetrical disconnect\n", $ts, $sysid, "", $sysid{$sysid}->{ip}, $sx, $sysid{$sysid}->{name}, vendorstr($spdp_info{$ppguid}->{vendor});
+ $proxypp{$ppguid}->{tasymdisc} = $ts;
}
}
+ } elsif (/: ACKNACK\(#\d+:1\/0:\s+(?:$leasere)?([0-9a-f]+(?::[0-9a-f]+){2}:([34])c7) -\>/) {
+ # An ACKNACK that acks nothing, nacks nothing and requests a response (no "F" flag
+ # present) is a tell-tale sign of a pre-emptive ACKNACK. Receipt of one of those
+ # after having received a normal one is indicative of an asymmetrical disconnect.
+ # Detecting when all is well again is too hard. Being lazy, we simply gate it with
+ # the "discovery complete" flag and suppress it within a window of 1s.
+ my $src = $1; my $src_id = $2;
+ (my $ppguid = hexify($src)) =~ s/:[0-9a-f]+$/:1c1/;
+ if (exists $proxypp{$ppguid} && $proxypp{$ppguid}->{disccompleteflag} && $ts > $proxypp{$ppguid}->{tasymdisc} + 1) {
+ my $sysid = $proxypp{$ppguid}->{sysid};
+ my $sx = decimal_sysid($sysid);
+ printf "%9.3f %35s $topfmt ASYM %s (%s; %s; %s) likely asymmetrical disconnect\n", $ts, $sysid, "", $sysid{$sysid}->{ip}, $sx, $sysid{$sysid}->{name}, vendorstr($spdp_info{$ppguid}->{vendor});
+ $proxypp{$ppguid}->{tasymdisc} = $ts;
+ }
}
- if (/: ownip: (?:$proto)?([0-9.]+)/o) {
+ if (/: ownip: ($proto_ip)/o) {
$ownip = $1;
+ $ownip =~ s/^(udp|tcp)[46]?\///;
} elsif (/: PARTICIPANT ($guidre) QOS=\{/o) {
my $guid = hexify($1);
(my $gid = $guid) =~ s/:[^:]+$//;
my $userdata = $_;
if ($userdata =~ s/.*QOS=\{.*?user_data=//) {
$userdata =~ s/\}$//;
- $userdata =~ s/,entity_factory=\d$//;
+ $userdata =~ s/,(?:prismtech_)?entity_factory=\d$//;
$userdata = " userdata:$userdata";
} else {
$userdata = "";
@@ -320,7 +338,7 @@ while(<>) {
}
$pp{$guid} = { gid => $gid, guid => $guid, name => $name, sname => $sname, sub => {}, pub => {} };
if (! $self_seen) {
- my $sysid = $guid;
+ (my $sysid = $guid) =~ s/:1c1$//;
$self_seen = 1;
$sysid{$sysid} = { self => 1, ip => $ownip, name => $name, sname => $sname };
my $sx = decimal_sysid($sysid);
@@ -352,7 +370,9 @@ while(<>) {
$rwguid{$tid} = $guid; # if $is_cyclone;
die "$guid $rwguid{$tid}" unless $guid eq $rwguid{$tid};
my $topic; my $type; my $groupcoh; my $partitions; my $keepall;
- if ($qos =~ /topic(?:_name)?=([^,]+?),type(?:_name)=([^,]+?).*?,partition=\{([^}]*?)\}/) {
+ # GUID prefix of 0:0:0: local built-in writer
+ my $local_builtin = ($guid =~ /^0:0:0:/);
+ if (! $local_builtin && $qos =~ /topic(?:_name)?="?([^,"]+?)"?,type(?:_name)="?([^,"]+?)"?.*?,partition=\{([^}]*?)\}/) {
$topic = $1; $type = $2; $partitions = $3;
die unless $qos =~ /,history=([01]):/; $keepall = $1;
die unless $qos =~ /,presentation=(\d:\d):\d/; $groupcoh = ($1 eq "2:1");
@@ -361,7 +381,7 @@ while(<>) {
}
$rwgid{$tid} = $psguid{$tid} = $psgid{$tid} = "" if 1; # $is_cyclone;
} else {
- # no topic, type: DDSI built-in reader/writer
+ # all-zero GUID prefix or no topic, type: DDSI built-in reader/writer
if (defined $rwgid{$tid} || $ftrflag{$tid}) {
die;
}
@@ -449,43 +469,46 @@ while(<>) {
die;
}
if (!defined ($wr{$wrguid}->{topic})) {
- die;
- }
- my $wr = $wr{$wrguid};
- $cseq = "C#$cseq" if $cseq ne "";
- my $dest = getdest($wrguid);
- $wr->{seq} = $seq;
- if (defined $wr->{cs}) {
- $wr->{cs}->{seq} = $seq unless defined $wr->{cs}->{seq};
- }
- if (scalar (keys %{$wr->{matches}}) > 0) {
- push @ackcheck, { ts => $ts + 1, tswrite => $ts, wrguid => $wrguid, seq => $seq };
- }
- my $op = ($data =~ /^:e:/) ? "W " : $opstr{$st.$dflag};
- my $print = 0;
- my $printlim = $shows{limit};
- $xmit_appdata++;
- $print = show_topic($wr->{topic}) && $shows{out};
- $print = 0 unless $data =~ /$data_filter/o;
- my $sdata = $printlim ? (sprintf "%-100.100s", $data) : (sprintf "%-100s", $data);
- printf "%9.3f %35s $topfmt %s #%-4d %-6s XMT %s -> %s\n", $ts, fmtguid($wrguid), $wr->{stopic}, $op, $seq, $cseq, $sdata, $dest if $print;
- if ($data =~ /^:e:/ && defined $wr->{cs}) {
- # assume empty transaction if no $wr->{cs}
- my $pub = $pub{$wr->{psguid}};
- die unless defined $pub;
- $wr->{cs} = undef;
- if ($pub->{txn} == 0) {
- # presumably an empty transaction
- $pub->{txn} = keys %{$pub->{es}};
- printf "%9.3f %35s $topfmt %16s XMT BEGIN [empty, %d writers]\n", $ts, fmtguid($pub->{guid}), "", "", $pub->{txn} if $shows{out};
+ # PMD looks like regular data but is built-in without a topic name
+ die unless $wrguid =~ /[4c][23]$/;
+ } else {
+ my $wr = $wr{$wrguid};
+ $cseq = "C#$cseq" if $cseq ne "";
+ my $dest = getdest($wrguid);
+ $wr->{seq} = $seq;
+ if (defined $wr->{cs}) {
+ $wr->{cs}->{seq} = $seq unless defined $wr->{cs}->{seq};
}
- if (--$pub->{txn} == 0) {
- printf "%9.3f %35s $topfmt %16s XMT COMMIT\n", $ts, fmtguid($pub->{guid}), "", ""
- if $shows{out};
+ if (scalar (keys %{$wr->{matches}}) > 0) {
+ push @ackcheck, { ts => $ts + 1, tswrite => $ts, wrguid => $wrguid, seq => $seq };
+ }
+ my $op = ($data =~ /^:e:/) ? "W " : $opstr{$st.$dflag};
+ my $print = 0;
+ my $printlim = $shows{limit};
+ $xmit_appdata++;
+ $print = show_topic($wr->{topic}) && $shows{out};
+ $print = 0 unless $data =~ /$data_filter/o;
+ my $sdata = $printlim ? (sprintf "%-100.100s", $data) : (sprintf "%-100s", $data);
+ printf "%9.3f %35s $topfmt %s #%-4d %-6s XMT %s -> %s\n", $ts, fmtguid($wrguid), $wr->{stopic}, $op, $seq, $cseq, $sdata, $dest if $print;
+ if ($data =~ /^:e:/ && defined $wr->{cs}) {
+ # assume empty transaction if no $wr->{cs}
+ my $pub = $pub{$wr->{psguid}};
+ die unless defined $pub;
+ $wr->{cs} = undef;
+ if ($pub->{txn} == 0) {
+ # presumably an empty transaction
+ $pub->{txn} = keys %{$pub->{es}};
+ printf "%9.3f %35s $topfmt %16s XMT BEGIN [empty, %d writers]\n", $ts, fmtguid($pub->{guid}), "", "", $pub->{txn} if $shows{out};
+ }
+ if (--$pub->{txn} == 0) {
+ printf "%9.3f %35s $topfmt %16s XMT COMMIT\n", $ts, fmtguid($pub->{guid}), "", ""
+ if $shows{out};
+ }
}
}
- } elsif (/: (?:SPDP ST\d+)?SPDP ST(\d) ($guidre)\s+bes\s+([0-9a-f]+)\s+.*NEW(?: processguid ($guidre) )?.*?meta(?: (?:$proto)?[0-9.]+:\d+)*? (?:$proto)?([0-9.]+:\d+)\)/o) {
+ } elsif (/: (?:SPDP ST\d+)?SPDP ST(\d) ($guidre)\s+bes\s+([0-9a-f]+)\s+.*NEW(?: processguid ($guidre) )?.*?meta(?: ${proto_ip}:\d+)*? (${proto_ip}:\d+)\)/o) {
my $st = $1; my $ppguid = hexify($2); my $bes = hex $3; my $processguid = $4; my $ip = $5;
+ $ip =~ s/^(udp|tcp)[46]?\///;
my $hostname = $ip;
my $sysid;
if (defined $processguid) {
@@ -499,8 +522,9 @@ while(<>) {
# presumably OSPL: first word is system id
($sysid = $ppguid) =~ s/:.*//;
} else {
- # presumably Cyclone, old format: 2nd word is process id
- ($sysid = $ppguid) =~ s/:[0-9a-f]+:1c1$//;
+ # presumably Cyclone, old format: 2nd word is process id; new format: altogether
+ # crazy -- so don't bother with the old one
+ ($sysid = $ppguid) =~ s/:1c1$//;
}
} else {
($sysid = $ppguid) =~ s/:1c1$//;
@@ -562,6 +586,7 @@ while(<>) {
sname => $sname,
infots => $spdp_info{$ppguid}->{ts},
tcreate => $ts,
+ tasymdisc => $ts,
non_spdp_seen => 0,
disccomplete => init_proxypp_disccomplete($bes),
disccompleteflag => 0,
@@ -625,7 +650,7 @@ while(<>) {
my $h = ($kind eq "READER") ? \%prd : \%pwr;
my $hk = ($kind eq "READER") ? "prd" : "pwr";
my $qos = $3;
- unless ($3 =~ /topic(?:_name)?=([^,]+?),type(?:_name)?=([^,]+?),(?:.+?,)?partition=\{([^}]*?)\}/) {
+ unless ($qos =~ /topic(?:_name)?="?([^,"]+?)"?,type(?:_name)?="?([^,"]+?)"?,(?:.+?,)?partition=\{([^}]*?)\}/) {
die unless $prwguid =~ /[4c][27]$/;
}
my $topic = $1; my $type = $2; my $partitions = $3;
@@ -713,7 +738,7 @@ while(<>) {
my $pwrguid = hexify($1); my $rdguid = hexify($2);
die unless exists $pwr{$pwrguid} || $pwrguid =~ /[4c][23]$/;
die unless exists $rd{$rdguid} || $rdguid =~ /[4c][74]$/;
- die if defined $pwr{$pwrguid}->{tdel};
+ #die if defined $pwr{$pwrguid}->{tdel}; # the order reversal is possible, however unlikely
#next if $pwrguid =~ /[4c]2$/;
$pwr{$pwrguid}->{matches}->{$rdguid} = {};
$rd{$rdguid}->{matches}->{$pwrguid} = {};
@@ -722,7 +747,7 @@ while(<>) {
my $wrguid = hexify($1); my $prdguid = hexify($2); my $bereader = $3 ne '';
die unless exists $wr{$wrguid} || $wrguid =~ /[4c][23]$/;
die unless exists $prd{$prdguid} || $prdguid =~ /[4c][74]$/;
- die if defined $prd{$prdguid}->{tdel};
+ #die if defined $prd{$prdguid}->{tdel}; # the order reversal is possible, however unlikely
#next if $wrguid =~ /[4c]2$/;
my $wr = $wr{$wrguid};
my $prd = $prd{$prdguid};
From 0845337f4749a0c1390b71ebf368718bffa56f4a Mon Sep 17 00:00:00 2001
From: Erik Boasson
Date: Fri, 28 Feb 2020 16:49:09 +0100
Subject: [PATCH 16/30] Test interface dropping incoming/outgoing packets
Signed-off-by: Erik Boasson
---
src/core/ddsc/include/dds/dds.h | 34 +++++++++
src/core/ddsc/src/dds_domain.c | 17 +++++
src/core/ddsi/include/dds/ddsi/q_rtps.h | 15 ++--
src/core/ddsi/src/q_init.c | 35 +++++++++
src/core/ddsi/src/q_receive.c | 97 +------------------------
5 files changed, 96 insertions(+), 102 deletions(-)
diff --git a/src/core/ddsc/include/dds/dds.h b/src/core/ddsc/include/dds/dds.h
index b78c2e1..b50f1d0 100644
--- a/src/core/ddsc/include/dds/dds.h
+++ b/src/core/ddsc/include/dds/dds.h
@@ -3370,6 +3370,40 @@ DDS_EXPORT dds_return_t
dds_assert_liveliness (
dds_entity_t entity);
+/**
+ * @brief This operation allows making the domain's network stack
+ * temporarily deaf and/or mute. It is a support function for testing and,
+ * other special uses and is subject to change.
+ *
+ * @param[in] entity A domain entity or an entity bound to a domain, such
+ * as a participant, reader or writer.
+ * @param[in] deaf Whether to network stack should pretend to be deaf and
+ * ignore any incoming packets.
+ * @param[in] mute Whether to network stack should pretend to be mute and
+ * discard any outgoing packets where it normally would.
+ * pass them to the operating system kernel for transmission.
+ * @param[in] reset_after Any value less than INFINITY will cause it to
+ * set deaf = mute = false after reset_after ns have passed.
+ * This is done by an event scheduled for the appropriate
+ * time and otherwise forgotten. These events are not
+ * affected by subsequent calls to this function.
+ *
+ * @returns A dds_return_t indicating success or failure.
+ *
+ * @retval DDS_RETCODE_OK
+ * The operation was successful.
+ * @retval DDS_BAD_PARAMETER
+ * The entity parameter is not a valid parameter.
+ * @retval DDS_RETCODE_ILLEGAL_OPERATION
+ * The operation is invoked on an inappropriate object.
+*/
+DDS_EXPORT dds_return_t
+dds_domain_set_deafmute (
+ dds_entity_t entity,
+ bool deaf,
+ bool mute,
+ dds_duration_t reset_after);
+
#if defined (__cplusplus)
}
#endif
diff --git a/src/core/ddsc/src/dds_domain.c b/src/core/ddsc/src/dds_domain.c
index 489b49c..dcc25a3 100644
--- a/src/core/ddsc/src/dds_domain.c
+++ b/src/core/ddsc/src/dds_domain.c
@@ -286,6 +286,23 @@ static dds_return_t dds_domain_free (dds_entity *vdomain)
return DDS_RETCODE_NO_DATA;
}
+dds_return_t dds_domain_set_deafmute (dds_entity_t entity, bool deaf, bool mute, dds_duration_t reset_after)
+{
+ struct dds_entity *e;
+ dds_return_t rc;
+ if ((rc = dds_entity_pin (entity, &e)) < 0)
+ return rc;
+ if (e->m_domain == NULL)
+ rc = DDS_RETCODE_ILLEGAL_OPERATION;
+ else
+ {
+ ddsi_set_deafmute (&e->m_domain->gv, deaf, mute, reset_after);
+ rc = DDS_RETCODE_OK;
+ }
+ dds_entity_unpin (e);
+ return rc;
+}
+
#include "dds__entity.h"
static void pushdown_set_batch (struct dds_entity *e, bool enable)
{
diff --git a/src/core/ddsi/include/dds/ddsi/q_rtps.h b/src/core/ddsi/include/dds/ddsi/q_rtps.h
index a822d4e..384a15e 100644
--- a/src/core/ddsi/include/dds/ddsi/q_rtps.h
+++ b/src/core/ddsi/include/dds/ddsi/q_rtps.h
@@ -12,6 +12,7 @@
#ifndef NN_RTPS_H
#define NN_RTPS_H
+#include "dds/export.h"
#include "dds/ddsi/ddsi_vendor.h"
#include "dds/ddsi/ddsi_guid.h"
@@ -59,12 +60,14 @@ typedef int64_t seqno_t;
struct cfgst;
struct ddsi_domaingv;
-int rtps_config_prep (struct ddsi_domaingv *config, struct cfgst *cfgst);
-int rtps_config_open_trace (struct ddsi_domaingv *config);
-int rtps_init (struct ddsi_domaingv *config);
-int rtps_start (struct ddsi_domaingv *config);
-void rtps_stop (struct ddsi_domaingv *config);
-void rtps_fini (struct ddsi_domaingv *config);
+int rtps_config_prep (struct ddsi_domaingv *gv, struct cfgst *cfgst);
+int rtps_config_open_trace (struct ddsi_domaingv *gv);
+int rtps_init (struct ddsi_domaingv *gv);
+int rtps_start (struct ddsi_domaingv *gv);
+void rtps_stop (struct ddsi_domaingv *gv);
+void rtps_fini (struct ddsi_domaingv *gv);
+
+DDS_EXPORT void ddsi_set_deafmute (struct ddsi_domaingv *gv, bool deaf, bool mute, int64_t reset_after);
#if defined (__cplusplus)
}
diff --git a/src/core/ddsi/src/q_init.c b/src/core/ddsi/src/q_init.c
index 3d48219..46ac147 100644
--- a/src/core/ddsi/src/q_init.c
+++ b/src/core/ddsi/src/q_init.c
@@ -926,11 +926,35 @@ static uint32_t ddsi_sertopic_hash_wrap (const void *tp)
return ddsi_sertopic_hash (tp);
}
+static void reset_deaf_mute (struct xevent *xev, void *varg, UNUSED_ARG (nn_mtime_t tnow))
+{
+ struct ddsi_domaingv *gv = varg;
+ gv->deaf = 0;
+ gv->mute = 0;
+ GVLOGDISC ("DEAFMUTE auto-reset to [deaf, mute]=[%d, %d]\n", gv->deaf, gv->mute);
+ delete_xevent (xev);
+}
+
+void ddsi_set_deafmute (struct ddsi_domaingv *gv, bool deaf, bool mute, int64_t reset_after)
+{
+ gv->deaf = deaf;
+ gv->mute = mute;
+ GVLOGDISC (" DEAFMUTE set [deaf, mute]=[%d, %d]", gv->deaf, gv->mute);
+ if (reset_after < DDS_INFINITY)
+ {
+ nn_mtime_t when = add_duration_to_mtime (now_mt (), reset_after);
+ GVTRACE (" reset after %"PRId64".%09u ns", reset_after / DDS_NSECS_IN_SEC, (unsigned) (reset_after % DDS_NSECS_IN_SEC));
+ qxev_callback (gv->xevents, when, reset_deaf_mute, gv);
+ }
+ GVLOGDISC ("\n");
+}
+
int rtps_init (struct ddsi_domaingv *gv)
{
uint32_t port_disc_uc = 0;
uint32_t port_data_uc = 0;
bool mc_available = true;
+ nn_mtime_t reset_deaf_mute_time = { T_NEVER };
gv->tstart = now (); /* wall clock time, used in logs */
@@ -954,6 +978,15 @@ int rtps_init (struct ddsi_domaingv *gv)
GVLOG (DDS_LC_CONFIG, "started at %d.06%d -- %s\n", sec, usec, str);
}
+ /* Allow configuration to set "deaf_mute" in case we want to start out that way */
+ gv->deaf = gv->config.initial_deaf;
+ gv->mute = gv->config.initial_mute;
+ if (gv->deaf || gv->mute)
+ {
+ GVLOG (DDS_LC_CONFIG | DDS_LC_DISCOVERY, "DEAFMUTE initial deaf=%d mute=%d reset after %"PRId64"d ns\n", gv->deaf, gv->mute, gv->config.initial_deaf_mute_reset);
+ reset_deaf_mute_time = add_duration_to_mtime (now_mt (), gv->config.initial_deaf_mute_reset);
+ }
+
/* Initialize thread pool */
if (gv->config.tp_enable)
{
@@ -1400,6 +1433,8 @@ int rtps_init (struct ddsi_domaingv *gv)
gv->user_dqueue = nn_dqueue_new ("user", gv, gv->config.delivery_queue_maxsamples, user_dqueue_handler, NULL);
#endif
+ if (reset_deaf_mute_time.v < T_NEVER)
+ qxev_callback (gv->xevents, reset_deaf_mute_time, reset_deaf_mute, gv);
return 0;
err_mc_conn:
diff --git a/src/core/ddsi/src/q_receive.c b/src/core/ddsi/src/q_receive.c
index 7f0bf28..6ae7d41 100644
--- a/src/core/ddsi/src/q_receive.c
+++ b/src/core/ddsi/src/q_receive.c
@@ -3140,97 +3140,6 @@ static int recv_thread_waitset_add_conn (os_sockWaitset ws, ddsi_tran_conn_t con
}
}
-enum local_deaf_state_recover {
- LDSR_NORMAL = 0, /* matches gv.deaf for normal operation */
- LDSR_DEAF = 1, /* matches gv.deaf for "deaf" state */
- LDSR_REJOIN = 2
-};
-
-struct local_deaf_state {
- enum local_deaf_state_recover state;
- nn_mtime_t tnext;
-};
-
-static int check_and_handle_deafness_recover (struct ddsi_domaingv *gv, struct local_deaf_state *st, unsigned num_fixed_uc)
-{
- int rebuildws = 0;
- if (now_mt().v < st->tnext.v)
- {
- GVTRACE ("check_and_handle_deafness_recover: state %d too early\n", (int)st->state);
- return 0;
- }
- switch (st->state)
- {
- case LDSR_NORMAL:
- assert(0);
- break;
- case LDSR_DEAF: {
- ddsi_tran_conn_t disc = gv->disc_conn_mc, data = gv->data_conn_mc;
- GVTRACE ("check_and_handle_deafness_recover: state %d create new sockets\n", (int) st->state);
- if (!create_multicast_sockets (gv))
- goto error;
- GVTRACE ("check_and_handle_deafness_recover: state %d transfer group membership admin\n", (int) st->state);
- ddsi_transfer_group_membership (gv->mship, disc, gv->disc_conn_mc);
- ddsi_transfer_group_membership (gv->mship, data, gv->data_conn_mc);
- GVTRACE ("check_and_handle_deafness_recover: state %d drop from waitset and add new\n", (int) st->state);
- /* see waitset construction code in recv_thread */
- os_sockWaitsetPurge (gv->recv_threads[0].arg.u.many.ws, num_fixed_uc);
- if (recv_thread_waitset_add_conn (gv->recv_threads[0].arg.u.many.ws, gv->disc_conn_mc) < 0)
- DDS_FATAL("check_and_handle_deafness_recover: failed to add disc_conn_mc to waitset\n");
- if (recv_thread_waitset_add_conn (gv->recv_threads[0].arg.u.many.ws, gv->data_conn_mc) < 0)
- DDS_FATAL("check_and_handle_deafness_recover: failed to add data_conn_mc to waitset\n");
- GVTRACE ("check_and_handle_deafness_recover: state %d close sockets\n", (int)st->state);
- ddsi_conn_free(disc);
- ddsi_conn_free(data);
- rebuildws = 1;
- st->state = LDSR_REJOIN;
- }
- /* FALLS THROUGH */
- case LDSR_REJOIN:
- GVTRACE ("check_and_handle_deafness_recover: state %d rejoin on disc socket\n", (int)st->state);
- if (ddsi_rejoin_transferred_mcgroups (gv, gv->mship, gv->disc_conn_mc) < 0)
- goto error;
- GVTRACE ("check_and_handle_deafness_recover: state %d rejoin on data socket\n", (int)st->state);
- if (ddsi_rejoin_transferred_mcgroups (gv, gv->mship, gv->data_conn_mc) < 0)
- goto error;
- GVTRACE ("check_and_handle_deafness_recover: state %d done\n", (int)st->state);
- st->state = LDSR_NORMAL;
- break;
- }
- GVTRACE ("check_and_handle_deafness_recover: state %d returning %d\n", (int)st->state, rebuildws);
- return rebuildws;
-error:
- GVTRACE ("check_and_handle_deafness_recover: state %d failed, returning %d\n", (int)st->state, rebuildws);
- st->state = LDSR_DEAF;
- st->tnext = add_duration_to_mtime(now_mt(), T_SECOND);
- return rebuildws;
-}
-
-static int check_and_handle_deafness (struct ddsi_domaingv *gv, struct local_deaf_state *st, unsigned num_fixed_uc)
-{
- const int gv_deaf = gv->deaf;
- assert (gv_deaf == 0 || gv_deaf == 1);
- if (gv_deaf == (int)st->state)
- return 0;
- else if (gv_deaf)
- {
- GVTRACE ("check_and_handle_deafness: going deaf (%d -> %d)\n", (int)st->state, (int)LDSR_DEAF);
- st->state = LDSR_DEAF;
- st->tnext = now_mt();
- return 0;
- }
- else if (!gv->config.allowMulticast)
- {
- GVTRACE ("check_and_handle_deafness: no longer deaf (multicast disabled)\n");
- st->state = LDSR_NORMAL;
- return 0;
- }
- else
- {
- return check_and_handle_deafness_recover (gv, st, num_fixed_uc);
- }
-}
-
void trigger_recv_threads (const struct ddsi_domaingv *gv)
{
for (uint32_t i = 0; i < gv->n_recv_threads; i++)
@@ -3283,9 +3192,6 @@ uint32_t recv_thread (void *vrecv_thread_arg)
struct local_participant_set lps;
unsigned num_fixed = 0, num_fixed_uc = 0;
os_sockWaitsetCtx ctx;
- struct local_deaf_state lds;
- lds.state = gv->deaf ? LDSR_DEAF : LDSR_NORMAL;
- lds.tnext = now_mt();
local_participant_set_init (&lps, &gv->participant_set_generation);
if (gv->m_factory->m_connless)
{
@@ -3307,9 +3213,8 @@ uint32_t recv_thread (void *vrecv_thread_arg)
while (ddsrt_atomic_ld32 (&gv->rtps_keepgoing))
{
- int rebuildws;
+ int rebuildws = 0;
LOG_THREAD_CPUTIME (&gv->logconfig, next_thread_cputime);
- rebuildws = check_and_handle_deafness (gv, &lds, num_fixed_uc);
if (gv->config.many_sockets_mode != MSM_MANY_UNICAST)
{
/* no other sockets to check */
From 9e673769ce8ffc90ff7bfe393537b2cbb123d0df Mon Sep 17 00:00:00 2001
From: Erik Boasson
Date: Fri, 28 Feb 2020 16:50:28 +0100
Subject: [PATCH 17/30] Add "deaf/mute" to pubsub
Signed-off-by: Erik Boasson
---
src/tools/pubsub/pubsub.c | 56 ++++++++++++++++++++++++++++++++++++++-
1 file changed, 55 insertions(+), 1 deletion(-)
diff --git a/src/tools/pubsub/pubsub.c b/src/tools/pubsub/pubsub.c
index 3c5a9c4..f5d0b70 100644
--- a/src/tools/pubsub/pubsub.c
+++ b/src/tools/pubsub/pubsub.c
@@ -411,7 +411,7 @@ static int read_value(char *command, int *key, struct tstamp_t *tstamp, char **a
return 1;
}
break;
- case 'p': case 'S': case ':': case 'Q': {
+ case 'p': case 'S': case 'C': case ':': case 'Q': {
int i = 0;
*command = (char) c;
while ((c = getc(stdin)) != EOF && !isspace((unsigned char) c)) {
@@ -1164,6 +1164,53 @@ static void pub_do_auto(const struct writerspec *spec) {
dds_free(handle);
}
+static void do_deafmute(const char *args)
+{
+ const char *a = args;
+ bool deaf = false;
+ bool mute = false;
+ dds_duration_t duration = 0;
+ double durfloat;
+ int pos;
+ if (strncmp(a, "self", 4) == 0) {
+ a += 4;
+ } else {
+ printf ("deafmute: invalid args: %s\n", args);
+ return;
+ }
+ if (*a++ != ';') {
+ printf ("deafmute: invalid args: %s\n", args);
+ return;
+ }
+ while (*a && *a != ';') {
+ switch (*a++) {
+ case 'm': mute = true; break;
+ case 'd': deaf = true; break;
+ default: printf ("deafmute: invalid flags: %s\n", args); return;
+ }
+ }
+ if (*a++ != ';') {
+ printf ("deafmute: invalid args: %s\n", args);
+ return;
+ }
+ if (strcmp(a, "inf") == 0) {
+ duration = DDS_INFINITY;
+ } else if (sscanf(a, "%lf%n", &durfloat, &pos) == 1 && a[pos] == 0) {
+ if (durfloat <= 0.0) {
+ printf ("deafmute: invalid duration (<= 0): %s\n", args);
+ return;
+ }
+ if (durfloat > (double) (DDS_INFINITY / DDS_NSECS_IN_SEC))
+ duration = DDS_INFINITY;
+ else
+ duration = (dds_duration_t) (durfloat * 1e9);
+ } else {
+ printf ("deafmute: invalid args: %s\n", args);
+ return;
+ }
+ dds_domain_set_deafmute (dp, deaf, mute, duration);
+}
+
static char *pub_do_nonarb(const struct writerspec *spec, uint32_t *seq) {
struct tstamp_t tstamp_spec = { .isabs = 0, .t = 0 };
int result;
@@ -1278,6 +1325,9 @@ static char *pub_do_nonarb(const struct writerspec *spec, uint32_t *seq) {
case 'Y': case 'B': case 'E': case 'W':
non_data_operation(command, spec->wr);
break;
+ case 'C':
+ do_deafmute(arg);
+ break;
case ':':
break;
default:
@@ -1362,6 +1412,10 @@ static char *pub_do_nonarb(const struct writerspec *spec, uint32_t *seq) {
// case 'Y': case 'B': case 'E': case 'W':
// non_data_operation(*line, spec->wr);
// break;
+// case 'C':
+// do_deafmute(arg);
+// line = NULL;
+// break;
// case 'S':
// make_persistent_snapshot(line+1);
// line = NULL;
From d1ed8df9f343b1cd441e3cd7ceaa750b480b7ce9 Mon Sep 17 00:00:00 2001
From: Erik Boasson
Date: Sat, 7 Mar 2020 17:47:18 +0100
Subject: [PATCH 18/30] Create a separate socket for transmitting data
This is a workaround for interoperability issues, ultimately driven by a
Windows quirk that makes multicast delivery within a machine utterly
unreliable if the transmitting socket is bound to 0.0.0.0 (despite all
sockets having multicast interfaces set correctly) when there are also
sockets transmitting to the same multicast group that have been bound to
non-0.0.0.0. (Note: there may be other factors at play, but this is
what it looks like after experimentation.)
At least Fast-RTPS in some versions binds the socket it uses for
transmitting multicasts to non-0.0.0.0, so interoperability with
Fast-RTPS on Windows requires us to bind the socket we use for
transmitting multicasts (which was the same as the one we use for
receiving unicast data) also to non-0.0.0.0 or our multicasts get
dropped often.
This would work fine if other implementations honoured the set of
advertised addresses. However, at least Fast-RTPS and Connext (in some
versions) fail to do this and happily substitute 127.0.0.1 for the
advertised IP address. If we bind to, e.g., 192.168.1.1, then suddenly
those packets won't arrive anymore, breaking interoperability.
The only work around is to use a separate socket for sending.
Signed-off-by: Erik Boasson
---
docs/manual/options.md | 11 +-----
etc/cyclonedds.rnc | 7 ----
etc/cyclonedds.xsd | 9 -----
src/core/ddsc/src/dds_writer.c | 3 +-
.../ddsi/include/dds/ddsi/ddsi_domaingv.h | 32 +++++++++++++----
src/core/ddsi/include/dds/ddsi/ddsi_tran.h | 22 ++++++------
src/core/ddsi/include/dds/ddsi/q_config.h | 1 -
src/core/ddsi/include/dds/ddsi/q_nwif.h | 2 +-
src/core/ddsi/src/ddsi_raweth.c | 4 +--
src/core/ddsi/src/ddsi_tcp.c | 6 ++--
src/core/ddsi/src/ddsi_tran.c | 17 ++-------
src/core/ddsi/src/ddsi_udp.c | 35 +++++++++++++++----
src/core/ddsi/src/q_config.c | 2 --
src/core/ddsi/src/q_entity.c | 3 +-
src/core/ddsi/src/q_init.c | 33 ++++++++---------
src/core/ddsi/src/q_nwif.c | 21 +++++------
src/core/ddsi/src/q_receive.c | 2 +-
17 files changed, 102 insertions(+), 108 deletions(-)
diff --git a/docs/manual/options.md b/docs/manual/options.md
index fbdd2aa..a5534b2 100644
--- a/docs/manual/options.md
+++ b/docs/manual/options.md
@@ -554,7 +554,7 @@ The default value is: "default".
### //CycloneDDS/Domain/Internal
-Children: [AccelerateRexmitBlockSize](#cycloneddsdomaininternalacceleraterexmitblocksize), [AssumeMulticastCapable](#cycloneddsdomaininternalassumemulticastcapable), [AutoReschedNackDelay](#cycloneddsdomaininternalautoreschednackdelay), [BindUnicastToInterfaceAddr](#cycloneddsdomaininternalbindunicasttointerfaceaddr), [BuiltinEndpointSet](#cycloneddsdomaininternalbuiltinendpointset), [ControlTopic](#cycloneddsdomaininternalcontroltopic), [DDSI2DirectMaxThreads](#cycloneddsdomaininternalddsi2directmaxthreads), [DefragReliableMaxSamples](#cycloneddsdomaininternaldefragreliablemaxsamples), [DefragUnreliableMaxSamples](#cycloneddsdomaininternaldefragunreliablemaxsamples), [DeliveryQueueMaxSamples](#cycloneddsdomaininternaldeliveryqueuemaxsamples), [EnableExpensiveChecks](#cycloneddsdomaininternalenableexpensivechecks), [GenerateKeyhash](#cycloneddsdomaininternalgeneratekeyhash), [HeartbeatInterval](#cycloneddsdomaininternalheartbeatinterval), [LateAckMode](#cycloneddsdomaininternallateackmode), [LeaseDuration](#cycloneddsdomaininternalleaseduration), [LivelinessMonitoring](#cycloneddsdomaininternallivelinessmonitoring), [MaxParticipants](#cycloneddsdomaininternalmaxparticipants), [MaxQueuedRexmitBytes](#cycloneddsdomaininternalmaxqueuedrexmitbytes), [MaxQueuedRexmitMessages](#cycloneddsdomaininternalmaxqueuedrexmitmessages), [MaxSampleSize](#cycloneddsdomaininternalmaxsamplesize), [MeasureHbToAckLatency](#cycloneddsdomaininternalmeasurehbtoacklatency), [MinimumSocketReceiveBufferSize](#cycloneddsdomaininternalminimumsocketreceivebuffersize), [MinimumSocketSendBufferSize](#cycloneddsdomaininternalminimumsocketsendbuffersize), [MonitorPort](#cycloneddsdomaininternalmonitorport), [MultipleReceiveThreads](#cycloneddsdomaininternalmultiplereceivethreads), [NackDelay](#cycloneddsdomaininternalnackdelay), [PreEmptiveAckDelay](#cycloneddsdomaininternalpreemptiveackdelay), [PrimaryReorderMaxSamples](#cycloneddsdomaininternalprimaryreordermaxsamples), [PrioritizeRetransmit](#cycloneddsdomaininternalprioritizeretransmit), [RediscoveryBlacklistDuration](#cycloneddsdomaininternalrediscoveryblacklistduration), [RetransmitMerging](#cycloneddsdomaininternalretransmitmerging), [RetransmitMergingPeriod](#cycloneddsdomaininternalretransmitmergingperiod), [RetryOnRejectBestEffort](#cycloneddsdomaininternalretryonrejectbesteffort), [SPDPResponseMaxDelay](#cycloneddsdomaininternalspdpresponsemaxdelay), [ScheduleTimeRounding](#cycloneddsdomaininternalscheduletimerounding), [SecondaryReorderMaxSamples](#cycloneddsdomaininternalsecondaryreordermaxsamples), [SendAsync](#cycloneddsdomaininternalsendasync), [SquashParticipants](#cycloneddsdomaininternalsquashparticipants), [SynchronousDeliveryLatencyBound](#cycloneddsdomaininternalsynchronousdeliverylatencybound), [SynchronousDeliveryPriorityThreshold](#cycloneddsdomaininternalsynchronousdeliveryprioritythreshold), [Test](#cycloneddsdomaininternaltest), [UnicastResponseToSPDPMessages](#cycloneddsdomaininternalunicastresponsetospdpmessages), [UseMulticastIfMreqn](#cycloneddsdomaininternalusemulticastifmreqn), [Watermarks](#cycloneddsdomaininternalwatermarks), [WriteBatch](#cycloneddsdomaininternalwritebatch), [WriterLingerDuration](#cycloneddsdomaininternalwriterlingerduration)
+Children: [AccelerateRexmitBlockSize](#cycloneddsdomaininternalacceleraterexmitblocksize), [AssumeMulticastCapable](#cycloneddsdomaininternalassumemulticastcapable), [AutoReschedNackDelay](#cycloneddsdomaininternalautoreschednackdelay), [BuiltinEndpointSet](#cycloneddsdomaininternalbuiltinendpointset), [ControlTopic](#cycloneddsdomaininternalcontroltopic), [DDSI2DirectMaxThreads](#cycloneddsdomaininternalddsi2directmaxthreads), [DefragReliableMaxSamples](#cycloneddsdomaininternaldefragreliablemaxsamples), [DefragUnreliableMaxSamples](#cycloneddsdomaininternaldefragunreliablemaxsamples), [DeliveryQueueMaxSamples](#cycloneddsdomaininternaldeliveryqueuemaxsamples), [EnableExpensiveChecks](#cycloneddsdomaininternalenableexpensivechecks), [GenerateKeyhash](#cycloneddsdomaininternalgeneratekeyhash), [HeartbeatInterval](#cycloneddsdomaininternalheartbeatinterval), [LateAckMode](#cycloneddsdomaininternallateackmode), [LeaseDuration](#cycloneddsdomaininternalleaseduration), [LivelinessMonitoring](#cycloneddsdomaininternallivelinessmonitoring), [MaxParticipants](#cycloneddsdomaininternalmaxparticipants), [MaxQueuedRexmitBytes](#cycloneddsdomaininternalmaxqueuedrexmitbytes), [MaxQueuedRexmitMessages](#cycloneddsdomaininternalmaxqueuedrexmitmessages), [MaxSampleSize](#cycloneddsdomaininternalmaxsamplesize), [MeasureHbToAckLatency](#cycloneddsdomaininternalmeasurehbtoacklatency), [MinimumSocketReceiveBufferSize](#cycloneddsdomaininternalminimumsocketreceivebuffersize), [MinimumSocketSendBufferSize](#cycloneddsdomaininternalminimumsocketsendbuffersize), [MonitorPort](#cycloneddsdomaininternalmonitorport), [MultipleReceiveThreads](#cycloneddsdomaininternalmultiplereceivethreads), [NackDelay](#cycloneddsdomaininternalnackdelay), [PreEmptiveAckDelay](#cycloneddsdomaininternalpreemptiveackdelay), [PrimaryReorderMaxSamples](#cycloneddsdomaininternalprimaryreordermaxsamples), [PrioritizeRetransmit](#cycloneddsdomaininternalprioritizeretransmit), [RediscoveryBlacklistDuration](#cycloneddsdomaininternalrediscoveryblacklistduration), [RetransmitMerging](#cycloneddsdomaininternalretransmitmerging), [RetransmitMergingPeriod](#cycloneddsdomaininternalretransmitmergingperiod), [RetryOnRejectBestEffort](#cycloneddsdomaininternalretryonrejectbesteffort), [SPDPResponseMaxDelay](#cycloneddsdomaininternalspdpresponsemaxdelay), [ScheduleTimeRounding](#cycloneddsdomaininternalscheduletimerounding), [SecondaryReorderMaxSamples](#cycloneddsdomaininternalsecondaryreordermaxsamples), [SendAsync](#cycloneddsdomaininternalsendasync), [SquashParticipants](#cycloneddsdomaininternalsquashparticipants), [SynchronousDeliveryLatencyBound](#cycloneddsdomaininternalsynchronousdeliverylatencybound), [SynchronousDeliveryPriorityThreshold](#cycloneddsdomaininternalsynchronousdeliveryprioritythreshold), [Test](#cycloneddsdomaininternaltest), [UnicastResponseToSPDPMessages](#cycloneddsdomaininternalunicastresponsetospdpmessages), [UseMulticastIfMreqn](#cycloneddsdomaininternalusemulticastifmreqn), [Watermarks](#cycloneddsdomaininternalwatermarks), [WriteBatch](#cycloneddsdomaininternalwritebatch), [WriterLingerDuration](#cycloneddsdomaininternalwriterlingerduration)
The Internal elements deal with a variety of settings that evolving and
@@ -600,15 +600,6 @@ Valid values are finite durations with an explicit unit or the keyword
The default value is: "1 s".
-#### //CycloneDDS/Domain/Internal/BindUnicastToInterfaceAddr
-Boolean
-
-Bind unicast sockets to the address of the preferred interface; if false,
-bind to 0.0.0.0 (IPv4) or its equivalent
-
-The default value is: "true".
-
-
#### //CycloneDDS/Domain/Internal/BuiltinEndpointSet
One of: full, writers, minimal
diff --git a/etc/cyclonedds.rnc b/etc/cyclonedds.rnc
index f3e4395..0edc899 100644
--- a/etc/cyclonedds.rnc
+++ b/etc/cyclonedds.rnc
@@ -491,13 +491,6 @@ day.The default value is: "1 s".
""" ] ]
duration_inf
}?
& [ a:documentation [ xml:lang="en" """
-Bind unicast sockets to the address of the preferred interface; if
-false, bind to 0.0.0.0 (IPv4) or its equivalent
The default value
-is: "true".
""" ] ]
- element BindUnicastToInterfaceAddr {
- xsd:boolean
- }?
- & [ a:documentation [ xml:lang="en" """
This element controls which participants will have which built-in
endpoints for the discovery and liveliness protocols. Valid values
are:
diff --git a/etc/cyclonedds.xsd b/etc/cyclonedds.xsd
index dbcab47..49d4378 100644
--- a/etc/cyclonedds.xsd
+++ b/etc/cyclonedds.xsd
@@ -638,7 +638,6 @@ reserved. This includes renaming or moving options.</p>
-
@@ -717,14 +716,6 @@ of HEARTBEAT messages.</p>
day.</p><p>The default value is: "1 s".</p>
-
-
-
-<p>Bind unicast sockets to the address of the preferred interface; if
-false, bind to 0.0.0.0 (IPv4) or its equivalent</p><p>The default value
-is: "true".</p>
-
-
diff --git a/src/core/ddsc/src/dds_writer.c b/src/core/ddsc/src/dds_writer.c
index a2e341f..caedd81 100644
--- a/src/core/ddsc/src/dds_writer.c
+++ b/src/core/ddsc/src/dds_writer.c
@@ -292,8 +292,6 @@ dds_entity_t dds_create_writer (dds_entity_t participant_or_publisher, dds_entit
}
}
- ddsi_tran_conn_t conn = pub->m_entity.m_domain->gv.data_conn_uc;
-
if ((rc = dds_topic_pin (topic, &tp)) != DDS_RETCODE_OK)
goto err_pin_topic;
assert (tp->m_stopic);
@@ -331,6 +329,7 @@ dds_entity_t dds_create_writer (dds_entity_t participant_or_publisher, dds_entit
}
/* Create writer */
+ ddsi_tran_conn_t conn = pub->m_entity.m_domain->gv.xmit_conn;
struct dds_writer * const wr = dds_alloc (sizeof (*wr));
const dds_entity_t writer = dds_entity_init (&wr->m_entity, &pub->m_entity, DDS_KIND_WRITER, false, wqos, listener, DDS_WRITER_STATUS_MASK);
wr->m_topic = tp;
diff --git a/src/core/ddsi/include/dds/ddsi/ddsi_domaingv.h b/src/core/ddsi/include/dds/ddsi/ddsi_domaingv.h
index caadcb1..b5747a7 100644
--- a/src/core/ddsi/include/dds/ddsi/ddsi_domaingv.h
+++ b/src/core/ddsi/include/dds/ddsi/ddsi_domaingv.h
@@ -115,18 +115,40 @@ struct ddsi_domaingv {
DCPS participant of DDSI2 itself will be mirrored in a DDSI
participant, and in multi-socket mode that one gets its own
socket. */
-
struct ddsi_tran_conn * disc_conn_mc;
struct ddsi_tran_conn * data_conn_mc;
struct ddsi_tran_conn * disc_conn_uc;
struct ddsi_tran_conn * data_conn_uc;
- /* TCP listener */
+ /* Connection used for all output (for connectionless transports), this
+ used to simply be data_conn_uc, but:
+ - Windows has a quirk that makes multicast delivery within a machine
+ utterly unreliable if the transmitting socket is bound to 0.0.0.0
+ (despite all sockets having multicast interfaces set correctly),
+ but apparently only in the presence of sockets transmitting to the
+ same multicast group that have been bound to non-0.0.0.0 ...
+ - At least Fast-RTPS and Connext fail to honour the set of advertised
+ addresses and substitute 127.0.0.1 for the advertised IP address and
+ expect it to work.
+ - Fast-RTPS (at least) binds the socket it uses for transmitting
+ multicasts to non-0.0.0.0
+
+ So binding to 0.0.0.0 means the unicasts from Fast-RTPS & Connext will
+ arrive but the multicasts from Cyclone get dropped often on Windows
+ when trying to interoperate; and binding to the IP address means
+ unicast messages from the others fail to arrive (because they fail to
+ arrive).
+
+ The only work around is to use a separate socket for sending. It is
+ rather sad that Cyclone needs to work around the bugs of the others,
+ but it seems the only way to get the users what they expect. */
+ struct ddsi_tran_conn * xmit_conn;
+
+ /* TCP listener */
struct ddsi_tran_listener * listener;
/* Thread pool */
-
struct ddsrt_thread_pool_s * thread_pool;
/* In many sockets mode, the receive threads maintain a local array
@@ -249,10 +271,6 @@ struct ddsi_domaingv {
delivery queue; currently just SEDP and PMD */
struct nn_dqueue *builtins_dqueue;
- /* Connection used by general timed-event queue for transmitting data */
-
- struct ddsi_tran_conn * tev_conn;
-
struct debug_monitor *debmon;
#ifndef DDSI_INCLUDE_NETWORK_CHANNELS
diff --git a/src/core/ddsi/include/dds/ddsi/ddsi_tran.h b/src/core/ddsi/include/dds/ddsi/ddsi_tran.h
index 4d7d0e4..c6ccc8f 100644
--- a/src/core/ddsi/include/dds/ddsi/ddsi_tran.h
+++ b/src/core/ddsi/include/dds/ddsi/ddsi_tran.h
@@ -46,7 +46,7 @@ typedef struct ddsi_tran_base * ddsi_tran_base_t;
typedef struct ddsi_tran_conn * ddsi_tran_conn_t;
typedef struct ddsi_tran_listener * ddsi_tran_listener_t;
typedef struct ddsi_tran_factory * ddsi_tran_factory_t;
-typedef struct ddsi_tran_qos * ddsi_tran_qos_t;
+typedef struct ddsi_tran_qos ddsi_tran_qos_t;
/* Function pointer types */
@@ -60,8 +60,8 @@ typedef void (*ddsi_tran_free_fn_t) (ddsi_tran_factory_t);
typedef void (*ddsi_tran_peer_locator_fn_t) (ddsi_tran_conn_t, nn_locator_t *);
typedef void (*ddsi_tran_disable_multiplexing_fn_t) (ddsi_tran_conn_t);
typedef ddsi_tran_conn_t (*ddsi_tran_accept_fn_t) (ddsi_tran_listener_t);
-typedef ddsi_tran_conn_t (*ddsi_tran_create_conn_fn_t) (ddsi_tran_factory_t fact, uint32_t, ddsi_tran_qos_t);
-typedef ddsi_tran_listener_t (*ddsi_tran_create_listener_fn_t) (ddsi_tran_factory_t fact, uint32_t port, ddsi_tran_qos_t);
+typedef ddsi_tran_conn_t (*ddsi_tran_create_conn_fn_t) (ddsi_tran_factory_t fact, uint32_t, const struct ddsi_tran_qos *);
+typedef ddsi_tran_listener_t (*ddsi_tran_create_listener_fn_t) (ddsi_tran_factory_t fact, uint32_t port, const struct ddsi_tran_qos *);
typedef void (*ddsi_tran_release_conn_fn_t) (ddsi_tran_conn_t);
typedef void (*ddsi_tran_close_conn_fn_t) (ddsi_tran_conn_t);
typedef void (*ddsi_tran_unblock_listener_fn_t) (ddsi_tran_listener_t);
@@ -189,11 +189,15 @@ struct ddsi_tran_factory
ddsi_tran_factory_t m_factory;
};
+enum ddsi_tran_qos_purpose {
+ DDSI_TRAN_QOS_XMIT,
+ DDSI_TRAN_QOS_RECV_UC,
+ DDSI_TRAN_QOS_RECV_MC
+};
+
struct ddsi_tran_qos
{
- /* QoS Data */
-
- bool m_multicast;
+ enum ddsi_tran_qos_purpose m_purpose;
int m_diffserv;
};
@@ -210,20 +214,18 @@ inline bool ddsi_factory_supports (const struct ddsi_tran_factory *factory, int3
inline int ddsi_is_valid_port (ddsi_tran_factory_t factory, uint32_t port) {
return factory->m_is_valid_port_fn (factory, port);
}
-inline ddsi_tran_conn_t ddsi_factory_create_conn (ddsi_tran_factory_t factory, uint32_t port, ddsi_tran_qos_t qos) {
+inline ddsi_tran_conn_t ddsi_factory_create_conn (ddsi_tran_factory_t factory, uint32_t port, const struct ddsi_tran_qos *qos) {
if (!ddsi_is_valid_port (factory, port))
return NULL;
return factory->m_create_conn_fn (factory, port, qos);
}
-inline ddsi_tran_listener_t ddsi_factory_create_listener (ddsi_tran_factory_t factory, uint32_t port, ddsi_tran_qos_t qos) {
+inline ddsi_tran_listener_t ddsi_factory_create_listener (ddsi_tran_factory_t factory, uint32_t port, const struct ddsi_tran_qos *qos) {
if (!ddsi_is_valid_port (factory, port))
return NULL;
return factory->m_create_listener_fn (factory, port, qos);
}
void ddsi_tran_free (ddsi_tran_base_t base);
-void ddsi_tran_free_qos (ddsi_tran_qos_t qos);
-ddsi_tran_qos_t ddsi_tran_create_qos (void);
inline ddsrt_socket_t ddsi_tran_handle (ddsi_tran_base_t base) {
return base->m_handle_fn (base);
}
diff --git a/src/core/ddsi/include/dds/ddsi/q_config.h b/src/core/ddsi/include/dds/ddsi/q_config.h
index cb0ba65..fd66ad2 100644
--- a/src/core/ddsi/include/dds/ddsi/q_config.h
+++ b/src/core/ddsi/include/dds/ddsi/q_config.h
@@ -332,7 +332,6 @@ struct config
int64_t initial_deaf_mute_reset;
int use_multicast_if_mreqn;
- int bind_unicast_to_interface_addr;
struct prune_deleted_ppant prune_deleted_ppant;
};
diff --git a/src/core/ddsi/include/dds/ddsi/q_nwif.h b/src/core/ddsi/include/dds/ddsi/q_nwif.h
index dd27df6..12f232e 100644
--- a/src/core/ddsi/include/dds/ddsi/q_nwif.h
+++ b/src/core/ddsi/include/dds/ddsi/q_nwif.h
@@ -35,7 +35,7 @@ struct nn_interface {
char *name;
};
-int make_socket (ddsrt_socket_t *socket, uint16_t port, bool stream, bool multicast, const struct ddsi_domaingv *gv);
+int make_socket (ddsrt_socket_t *socket, uint16_t port, bool stream, bool reuse_addr, bool bind_to_any, const struct ddsi_domaingv *gv);
int find_own_ip (struct ddsi_domaingv *gv, const char *requested_address);
uint32_t locator_to_hopefully_unique_uint32 (const nn_locator_t *src);
diff --git a/src/core/ddsi/src/ddsi_raweth.c b/src/core/ddsi/src/ddsi_raweth.c
index 1f7ed6a..6e0bca2 100644
--- a/src/core/ddsi/src/ddsi_raweth.c
+++ b/src/core/ddsi/src/ddsi_raweth.c
@@ -175,13 +175,13 @@ static int ddsi_raweth_conn_locator (ddsi_tran_factory_t fact, ddsi_tran_base_t
return ret;
}
-static ddsi_tran_conn_t ddsi_raweth_create_conn (ddsi_tran_factory_t fact, uint32_t port, ddsi_tran_qos_t qos)
+static ddsi_tran_conn_t ddsi_raweth_create_conn (ddsi_tran_factory_t fact, uint32_t port, const struct ddsi_tran_qos *qos)
{
ddsrt_socket_t sock;
dds_return_t rc;
ddsi_raweth_conn_t uc = NULL;
struct sockaddr_ll addr;
- bool mcast = (bool) (qos ? qos->m_multicast : 0);
+ bool mcast = (qos->m_purpose == DDSI_TRAN_QOS_RECV_MC);
/* If port is zero, need to create dynamic port */
diff --git a/src/core/ddsi/src/ddsi_tcp.c b/src/core/ddsi/src/ddsi_tcp.c
index 5a7ed06..5a87fd1 100644
--- a/src/core/ddsi/src/ddsi_tcp.c
+++ b/src/core/ddsi/src/ddsi_tcp.c
@@ -167,7 +167,7 @@ static void ddsi_tcp_sock_free (const struct ddsrt_log_cfg *logcfg, ddsrt_socket
static void ddsi_tcp_sock_new (ddsrt_socket_t *sock, unsigned short port, const struct ddsi_domaingv *gv)
{
- if (make_socket (sock, port, true, true, gv) != 0)
+ if (make_socket (sock, port, true, true, true, gv) != 0)
{
*sock = DDSRT_INVALID_SOCKET;
}
@@ -706,7 +706,7 @@ static int ddsi_tcp_locator (struct ddsi_tran_factory *fact_cmn, ddsi_tran_base_
return 0;
}
-static ddsi_tran_conn_t ddsi_tcp_create_conn (struct ddsi_tran_factory *fact_cmn, uint32_t port, ddsi_tran_qos_t qos)
+static ddsi_tran_conn_t ddsi_tcp_create_conn (struct ddsi_tran_factory *fact_cmn, uint32_t port, const struct ddsi_tran_qos *qos)
{
struct ddsi_tran_factory_tcp * const fact = (struct ddsi_tran_factory_tcp *) fact_cmn;
(void) qos;
@@ -853,7 +853,7 @@ static ddsi_tcp_conn_t ddsi_tcp_new_conn (struct ddsi_tran_factory_tcp *fact, dd
return conn;
}
-static ddsi_tran_listener_t ddsi_tcp_create_listener (ddsi_tran_factory_t fact, uint32_t port, ddsi_tran_qos_t qos)
+static ddsi_tran_listener_t ddsi_tcp_create_listener (ddsi_tran_factory_t fact, uint32_t port, const struct ddsi_tran_qos *qos)
{
char buff[DDSI_LOCSTRLEN];
ddsrt_socket_t sock;
diff --git a/src/core/ddsi/src/ddsi_tran.c b/src/core/ddsi/src/ddsi_tran.c
index 2bdda5d..fdf1fcf 100644
--- a/src/core/ddsi/src/ddsi_tran.c
+++ b/src/core/ddsi/src/ddsi_tran.c
@@ -24,13 +24,13 @@
extern inline uint32_t ddsi_conn_type (ddsi_tran_conn_t conn);
extern inline uint32_t ddsi_conn_port (ddsi_tran_conn_t conn);
-extern inline ddsi_tran_listener_t ddsi_factory_create_listener (ddsi_tran_factory_t factory, uint32_t port, ddsi_tran_qos_t qos);
+extern inline ddsi_tran_listener_t ddsi_factory_create_listener (ddsi_tran_factory_t factory, uint32_t port, const struct ddsi_tran_qos *qos);
extern inline bool ddsi_factory_supports (const struct ddsi_tran_factory *factory, int32_t kind);
extern inline int ddsi_is_valid_port (ddsi_tran_factory_t factory, uint32_t port);
extern inline ddsrt_socket_t ddsi_conn_handle (ddsi_tran_conn_t conn);
extern inline int ddsi_conn_locator (ddsi_tran_conn_t conn, nn_locator_t * loc);
extern inline ddsrt_socket_t ddsi_tran_handle (ddsi_tran_base_t base);
-extern inline ddsi_tran_conn_t ddsi_factory_create_conn (ddsi_tran_factory_t factory, uint32_t port, ddsi_tran_qos_t qos);
+extern inline ddsi_tran_conn_t ddsi_factory_create_conn (ddsi_tran_factory_t factory, uint32_t port, const struct ddsi_tran_qos *qos);
extern inline int ddsi_listener_locator (ddsi_tran_listener_t listener, nn_locator_t * loc);
extern inline int ddsi_listener_listen (ddsi_tran_listener_t listener);
extern inline ddsi_tran_conn_t ddsi_listener_accept (ddsi_tran_listener_t listener);
@@ -182,11 +182,6 @@ bool ddsi_conn_peer_locator (ddsi_tran_conn_t conn, nn_locator_t * loc)
return false;
}
-void ddsi_tran_free_qos (ddsi_tran_qos_t qos)
-{
- ddsrt_free (qos);
-}
-
int ddsi_conn_join_mc (ddsi_tran_conn_t conn, const nn_locator_t *srcloc, const nn_locator_t *mcloc, const struct nn_interface *interf)
{
return conn->m_factory->m_join_mc_fn (conn, srcloc, mcloc, interf);
@@ -197,14 +192,6 @@ int ddsi_conn_leave_mc (ddsi_tran_conn_t conn, const nn_locator_t *srcloc, const
return conn->m_factory->m_leave_mc_fn (conn, srcloc, mcloc, interf);
}
-ddsi_tran_qos_t ddsi_tran_create_qos (void)
-{
- ddsi_tran_qos_t qos;
- qos = (ddsi_tran_qos_t) ddsrt_malloc (sizeof (*qos));
- memset (qos, 0, sizeof (*qos));
- return qos;
-}
-
void ddsi_tran_free (ddsi_tran_base_t base)
{
if (base)
diff --git a/src/core/ddsi/src/ddsi_udp.c b/src/core/ddsi/src/ddsi_udp.c
index 8720468..ede09e7 100644
--- a/src/core/ddsi/src/ddsi_udp.c
+++ b/src/core/ddsi/src/ddsi_udp.c
@@ -218,16 +218,37 @@ static unsigned short get_socket_port (const struct ddsrt_log_cfg *logcfg, ddsrt
return ddsrt_sockaddr_get_port((struct sockaddr *)&addr);
}
-static ddsi_tran_conn_t ddsi_udp_create_conn (ddsi_tran_factory_t fact, uint32_t port, ddsi_tran_qos_t qos)
+static ddsi_tran_conn_t ddsi_udp_create_conn (ddsi_tran_factory_t fact, uint32_t port, const ddsi_tran_qos_t *qos)
{
int ret;
ddsrt_socket_t sock;
ddsi_udp_conn_t uc = NULL;
- bool mcast = (bool) (qos ? qos->m_multicast : false);
+ bool reuse_addr = false, bind_to_any = false;
+ const char *purpose_str = NULL;
+
+ switch (qos->m_purpose)
+ {
+ case DDSI_TRAN_QOS_XMIT:
+ reuse_addr = false;
+ bind_to_any = false;
+ purpose_str = "transmit";
+ break;
+ case DDSI_TRAN_QOS_RECV_UC:
+ reuse_addr = false;
+ bind_to_any = true;
+ purpose_str = "unicast";
+ break;
+ case DDSI_TRAN_QOS_RECV_MC:
+ reuse_addr = true;
+ bind_to_any = true;
+ purpose_str = "multicast";
+ break;
+ }
+ assert (purpose_str != NULL);
/* If port is zero, need to create dynamic port */
- ret = make_socket (&sock, (unsigned short) port, false, mcast, fact->gv);
+ ret = make_socket (&sock, (unsigned short) port, false, reuse_addr, bind_to_any, fact->gv);
if (ret == 0)
{
@@ -235,7 +256,7 @@ static ddsi_tran_conn_t ddsi_udp_create_conn (ddsi_tran_factory_t fact, uint32_t
memset (uc, 0, sizeof (*uc));
uc->m_sock = sock;
- uc->m_diffserv = qos ? qos->m_diffserv : 0;
+ uc->m_diffserv = qos->m_diffserv;
#if defined _WIN32 && !defined WINCE
uc->m_sockEvent = WSACreateEvent();
WSAEventSelect(uc->m_sock, uc->m_sockEvent, FD_WRITE);
@@ -244,7 +265,7 @@ static ddsi_tran_conn_t ddsi_udp_create_conn (ddsi_tran_factory_t fact, uint32_t
ddsi_factory_conn_init (fact, &uc->m_base);
uc->m_base.m_base.m_port = get_socket_port (&fact->gv->logconfig, sock);
uc->m_base.m_base.m_trantype = DDSI_TRAN_CONN;
- uc->m_base.m_base.m_multicast = mcast;
+ uc->m_base.m_base.m_multicast = (qos->m_purpose == DDSI_TRAN_QOS_RECV_MC);
uc->m_base.m_base.m_handle_fn = ddsi_udp_conn_handle;
uc->m_base.m_read_fn = ddsi_udp_conn_read;
@@ -254,7 +275,7 @@ static ddsi_tran_conn_t ddsi_udp_create_conn (ddsi_tran_factory_t fact, uint32_t
DDS_CTRACE (&fact->gv->logconfig,
"ddsi_udp_create_conn %s socket %"PRIdSOCK" port %"PRIu32"\n",
- mcast ? "multicast" : "unicast",
+ purpose_str,
uc->m_sock,
uc->m_base.m_base.m_port);
#ifdef DDSI_INCLUDE_NETWORK_CHANNELS
@@ -271,7 +292,7 @@ static ddsi_tran_conn_t ddsi_udp_create_conn (ddsi_tran_factory_t fact, uint32_t
{
if (fact->gv->config.participantIndex != PARTICIPANT_INDEX_AUTO)
{
- DDS_CERROR (&fact->gv->logconfig, "UDP make_socket failed for %s port %"PRIu32"\n", mcast ? "multicast" : "unicast", port);
+ DDS_CERROR (&fact->gv->logconfig, "UDP make_socket failed for %s port %"PRIu32"\n", purpose_str, port);
}
}
diff --git a/src/core/ddsi/src/q_config.c b/src/core/ddsi/src/q_config.c
index 82d1d71..2f3fbf6 100644
--- a/src/core/ddsi/src/q_config.c
+++ b/src/core/ddsi/src/q_config.c
@@ -578,8 +578,6 @@ static const struct cfgelem internal_cfgelems[] = {
BLURB("This element controls whether retransmits are prioritized over new data, speeding up recovery.
") },
{ LEAF("UseMulticastIfMreqn"), 1, "0", ABSOFF(use_multicast_if_mreqn), 0, uf_int, 0, pf_int,
BLURB("Do not use.
") },
- { LEAF("BindUnicastToInterfaceAddr"), 1, "true", ABSOFF(bind_unicast_to_interface_addr), 0, uf_boolean, 0, pf_boolean,
- BLURB("Bind unicast sockets to the address of the preferred interface; if false, bind to 0.0.0.0 (IPv4) or its equivalent
") },
{ LEAF("SendAsync"), 1, "false", ABSOFF(xpack_send_async), 0, uf_boolean, 0, pf_boolean,
BLURB("This element controls whether the actual sending of packets occurs on the same thread that prepares them, or is done asynchronously by another thread.
") },
{ LEAF_W_ATTRS("RediscoveryBlacklistDuration", rediscovery_blacklist_duration_attrs), 1, "10s", ABSOFF(prune_deleted_ppant.delay), 0, uf_duration_inf, 0, pf_duration,
diff --git a/src/core/ddsi/src/q_entity.c b/src/core/ddsi/src/q_entity.c
index f52cddb..0790a00 100644
--- a/src/core/ddsi/src/q_entity.c
+++ b/src/core/ddsi/src/q_entity.c
@@ -652,7 +652,8 @@ dds_return_t new_participant_guid (const ddsi_guid_t *ppguid, struct ddsi_domain
if (gv->config.many_sockets_mode == MSM_MANY_UNICAST)
{
- pp->m_conn = ddsi_factory_create_conn (gv->m_factory, 0, NULL);
+ const ddsi_tran_qos_t qos = { .m_purpose = DDSI_TRAN_QOS_RECV_UC, .m_diffserv = 0 };
+ pp->m_conn = ddsi_factory_create_conn (gv->m_factory, 0, &qos);
ddsi_conn_locator (pp->m_conn, &pp->m_locator);
}
else
diff --git a/src/core/ddsi/src/q_init.c b/src/core/ddsi/src/q_init.c
index 46ac147..7cb0fb3 100644
--- a/src/core/ddsi/src/q_init.c
+++ b/src/core/ddsi/src/q_init.c
@@ -96,14 +96,15 @@ static enum make_uc_sockets_ret make_uc_sockets (struct ddsi_domaingv *gv, uint3
if (!ddsi_is_valid_port (gv->m_factory, *pdisc) || !ddsi_is_valid_port (gv->m_factory, *pdata))
return MUSRET_INVALID_PORTS;
- gv->disc_conn_uc = ddsi_factory_create_conn (gv->m_factory, *pdisc, NULL);
+ const ddsi_tran_qos_t qos = { .m_purpose = DDSI_TRAN_QOS_RECV_UC, .m_diffserv = 0 };
+ gv->disc_conn_uc = ddsi_factory_create_conn (gv->m_factory, *pdisc, &qos);
if (gv->disc_conn_uc)
{
/* Check not configured to use same unicast port for data and discovery */
if (*pdata != 0 && (*pdata != *pdisc))
{
- gv->data_conn_uc = ddsi_factory_create_conn (gv->m_factory, *pdata, NULL);
+ gv->data_conn_uc = ddsi_factory_create_conn (gv->m_factory, *pdata, &qos);
}
else
{
@@ -663,10 +664,9 @@ int joinleave_spdp_defmcip (struct ddsi_domaingv *gv, int dojoin)
int create_multicast_sockets (struct ddsi_domaingv *gv)
{
- ddsi_tran_qos_t qos = ddsi_tran_create_qos ();
+ const ddsi_tran_qos_t qos = { .m_purpose = DDSI_TRAN_QOS_RECV_MC, .m_diffserv = 0 };
ddsi_tran_conn_t disc, data;
uint32_t port;
- qos->m_multicast = 1;
port = ddsi_get_port (&gv->config, DDSI_PORT_MULTI_DISC, 0);
if (!ddsi_is_valid_port (gv->m_factory, port))
@@ -675,7 +675,7 @@ int create_multicast_sockets (struct ddsi_domaingv *gv)
gv->config.extDomainId.value, port);
goto err_disc;
}
- if ((disc = ddsi_factory_create_conn (gv->m_factory, port, qos)) == NULL)
+ if ((disc = ddsi_factory_create_conn (gv->m_factory, port, &qos)) == NULL)
goto err_disc;
if (gv->config.many_sockets_mode == MSM_NO_UNICAST)
{
@@ -691,12 +691,11 @@ int create_multicast_sockets (struct ddsi_domaingv *gv)
gv->config.extDomainId.value, port);
goto err_disc;
}
- if ((data = ddsi_factory_create_conn (gv->m_factory, port, qos)) == NULL)
+ if ((data = ddsi_factory_create_conn (gv->m_factory, port, &qos)) == NULL)
{
goto err_data;
}
}
- ddsi_tran_free_qos (qos);
gv->disc_conn_mc = disc;
gv->data_conn_mc = data;
@@ -707,7 +706,6 @@ int create_multicast_sockets (struct ddsi_domaingv *gv)
err_data:
ddsi_conn_free (disc);
err_disc:
- ddsi_tran_free_qos (qos);
return 0;
}
@@ -964,7 +962,7 @@ int rtps_init (struct ddsi_domaingv *gv)
gv->data_conn_uc = NULL;
gv->disc_conn_mc = NULL;
gv->data_conn_mc = NULL;
- gv->tev_conn = NULL;
+ gv->xmit_conn = NULL;
gv->listener = NULL;
gv->thread_pool = NULL;
gv->debmon = NULL;
@@ -1280,9 +1278,6 @@ int rtps_init (struct ddsi_domaingv *gv)
}
else
{
- /* Must have a data_conn_uc/tev_conn/transmit_conn */
- gv->data_conn_uc = ddsi_factory_create_conn (gv->m_factory, 0, NULL);
-
if (gv->config.tcp_port == -1)
; /* nop */
else if (!ddsi_is_valid_port (gv->m_factory, (uint32_t) gv->config.tcp_port))
@@ -1311,9 +1306,10 @@ int rtps_init (struct ddsi_domaingv *gv)
}
/* Create shared transmit connection */
-
- gv->tev_conn = gv->data_conn_uc;
- GVLOG (DDS_LC_CONFIG, "Timed event transmit port: %d\n", (int) ddsi_conn_port (gv->tev_conn));
+ {
+ const ddsi_tran_qos_t qos = { .m_purpose = DDSI_TRAN_QOS_XMIT, .m_diffserv = 0 };
+ gv->xmit_conn = ddsi_factory_create_conn (gv->m_factory, 0, &qos);
+ }
#ifdef DDSI_INCLUDE_NETWORK_CHANNELS
{
@@ -1376,7 +1372,7 @@ int rtps_init (struct ddsi_domaingv *gv)
gv->xevents = xeventq_new
(
- gv->tev_conn,
+ gv->xmit_conn,
gv->config.max_queued_rexmit_bytes,
gv->config.max_queued_rexmit_msgs,
#ifdef DDSI_INCLUDE_BANDWIDTH_LIMITING
@@ -1438,6 +1434,8 @@ int rtps_init (struct ddsi_domaingv *gv)
return 0;
err_mc_conn:
+ if (gv->xmit_conn)
+ ddsi_conn_free (gv->xmit_conn);
if (gv->disc_conn_mc)
ddsi_conn_free (gv->disc_conn_mc);
if (gv->data_conn_mc && gv->data_conn_mc != gv->disc_conn_mc)
@@ -1762,6 +1760,7 @@ void rtps_fini (struct ddsi_domaingv *gv)
(void) joinleave_spdp_defmcip (gv, 0);
+ ddsi_conn_free (gv->xmit_conn);
ddsi_conn_free (gv->disc_conn_mc);
if (gv->data_conn_mc != gv->disc_conn_mc)
ddsi_conn_free (gv->data_conn_mc);
@@ -1770,8 +1769,6 @@ void rtps_fini (struct ddsi_domaingv *gv)
if (gv->data_conn_uc != gv->disc_conn_uc)
ddsi_conn_free (gv->data_conn_uc);
- /* Not freeing gv->tev_conn: it aliases data_conn_uc */
-
free_group_membership(gv->mship);
ddsi_tran_factories_fini (gv);
diff --git a/src/core/ddsi/src/q_nwif.c b/src/core/ddsi/src/q_nwif.c
index 5789983..9bbbb5c 100644
--- a/src/core/ddsi/src/q_nwif.c
+++ b/src/core/ddsi/src/q_nwif.c
@@ -214,7 +214,7 @@ static int set_reuse_options (const struct ddsrt_log_cfg *logcfg, ddsrt_socket_t
return 0;
}
-static int bind_socket (ddsrt_socket_t socket, unsigned short port, bool multicast, const struct ddsi_domaingv *gv)
+static int bind_socket (ddsrt_socket_t socket, unsigned short port, bool bind_to_any, const struct ddsi_domaingv *gv)
{
dds_return_t rc = DDS_RETCODE_ERROR;
@@ -226,7 +226,7 @@ static int bind_socket (ddsrt_socket_t socket, unsigned short port, bool multica
struct sockaddr_in6 a;
} socketname;
ddsi_ipaddr_from_loc (&socketname.x, &gv->ownloc);
- if (multicast || !gv->config.bind_unicast_to_interface_addr)
+ if (bind_to_any)
socketname.a.sin6_addr = ddsrt_in6addr_any;
socketname.a.sin6_port = htons (port);
if (IN6_IS_ADDR_LINKLOCAL (&socketname.a.sin6_addr)) {
@@ -243,7 +243,7 @@ static int bind_socket (ddsrt_socket_t socket, unsigned short port, bool multica
struct sockaddr_in a;
} socketname;
ddsi_ipaddr_from_loc (&socketname.x, &gv->ownloc);
- if (multicast || !gv->config.bind_unicast_to_interface_addr)
+ if (bind_to_any)
socketname.a.sin_addr.s_addr = htonl (INADDR_ANY);
socketname.a.sin_port = htons (port);
rc = ddsrt_bind (socket, (struct sockaddr *) &socketname.a, sizeof (socketname.a));
@@ -345,7 +345,7 @@ static int set_mc_options_transmit (ddsrt_socket_t socket, const struct ddsi_dom
}
}
-int make_socket (ddsrt_socket_t *sock, uint16_t port, bool stream, bool multicast, const struct ddsi_domaingv *gv)
+int make_socket (ddsrt_socket_t *sock, uint16_t port, bool stream, bool reuse_addr, bool bind_to_any, const struct ddsi_domaingv *gv)
{
/* FIXME: this stuff has to move to the transports */
int rc = -2;
@@ -373,18 +373,15 @@ int make_socket (ddsrt_socket_t *sock, uint16_t port, bool stream, bool multicas
return rc;
}
- if (port && multicast && ((rc = set_reuse_options (&gv->logconfig, *sock)) < 0))
+ if (port && reuse_addr && ((rc = set_reuse_options (&gv->logconfig, *sock)) < 0))
{
goto fail;
}
- if
- (
- (rc = set_rcvbuf (&gv->logconfig, *sock, &gv->config.socket_min_rcvbuf_size) < 0) ||
- (rc = set_sndbuf (&gv->logconfig, *sock, gv->config.socket_min_sndbuf_size) < 0) ||
- ((rc = maybe_set_dont_route (&gv->logconfig, *sock, &gv->config)) < 0) ||
- ((rc = bind_socket (*sock, port, multicast, gv)) < 0)
- )
+ if ((rc = set_rcvbuf (&gv->logconfig, *sock, &gv->config.socket_min_rcvbuf_size) < 0) ||
+ (rc = set_sndbuf (&gv->logconfig, *sock, gv->config.socket_min_sndbuf_size) < 0) ||
+ ((rc = maybe_set_dont_route (&gv->logconfig, *sock, &gv->config)) < 0) ||
+ ((rc = bind_socket (*sock, port, bind_to_any, gv)) < 0))
{
goto fail;
}
diff --git a/src/core/ddsi/src/q_receive.c b/src/core/ddsi/src/q_receive.c
index 6ae7d41..7b138a8 100644
--- a/src/core/ddsi/src/q_receive.c
+++ b/src/core/ddsi/src/q_receive.c
@@ -3156,7 +3156,7 @@ void trigger_recv_threads (const struct ddsi_domaingv *gv)
iov.iov_base = &dummy;
iov.iov_len = 1;
GVTRACE ("trigger_recv_threads: %d single %s\n", i, ddsi_locator_to_string (buf, sizeof (buf), dst));
- ddsi_conn_write (gv->data_conn_uc, dst, 1, &iov, 0);
+ ddsi_conn_write (gv->xmit_conn, dst, 1, &iov, 0);
break;
}
case RTM_MANY: {
From 2c16dfa23e2cb313188bb60848a2eb873c25285d Mon Sep 17 00:00:00 2001
From: Dan Rose
Date: Mon, 9 Mar 2020 13:36:10 -0500
Subject: [PATCH 19/30] Don't link winsock1
wsock32.lib is only needed for the legacy version of Winsock and is not needed with Winsock2 (the current version).
This appears to be a root cause of the multicast issue on Win10 and may allow us to reverse #404
Signed-off-by: Dan Rose
---
src/ddsrt/CMakeLists.txt | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/src/ddsrt/CMakeLists.txt b/src/ddsrt/CMakeLists.txt
index db0deaa..72de16d 100644
--- a/src/ddsrt/CMakeLists.txt
+++ b/src/ddsrt/CMakeLists.txt
@@ -236,7 +236,7 @@ if(NOT WITH_FREERTOS)
endif()
if(WIN32)
- target_link_libraries(ddsrt INTERFACE wsock32 ws2_32 iphlpapi bcrypt)
+ target_link_libraries(ddsrt INTERFACE ws2_32 iphlpapi bcrypt)
elseif(UNIX)
check_library_exists(c clock_gettime "" HAVE_CLOCK_GETTIME)
if(NOT HAVE_CLOCK_GETTIME)
From 269f18e98a1f015e942c0f3242a0cdb409456c24 Mon Sep 17 00:00:00 2001
From: Thijs Sassen
Date: Wed, 11 Mar 2020 16:23:06 +0100
Subject: [PATCH 20/30] Updated version for ros2 package
Signed-off-by: Thijs Sassen
---
package.xml | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/package.xml b/package.xml
index 9d0980d..efb8e8a 100644
--- a/package.xml
+++ b/package.xml
@@ -2,7 +2,7 @@
cyclonedds
- 0.1.0
+ 0.5.1
Eclipse Cyclone DDS is a very performant and robust open-source DDS implementation. Cyclone DDS is developed completely in the open as an Eclipse IoT project.
Eclipse Foundation, Inc.
Eclipse Public License 2.0
From 39c7997c67425f7fb11b1249a2838348e6a65200 Mon Sep 17 00:00:00 2001
From: Erik Boasson
Date: Mon, 9 Mar 2020 14:01:35 +0100
Subject: [PATCH 21/30] Remove unused dds_sleepuntil
Signed-off-by: Erik Boasson
---
src/ddsrt/include/dds/ddsrt/time.h | 10 ----------
src/ddsrt/src/time.c | 8 --------
2 files changed, 18 deletions(-)
diff --git a/src/ddsrt/include/dds/ddsrt/time.h b/src/ddsrt/include/dds/ddsrt/time.h
index a604a5e..61992f8 100644
--- a/src/ddsrt/include/dds/ddsrt/time.h
+++ b/src/ddsrt/include/dds/ddsrt/time.h
@@ -86,16 +86,6 @@ DDS_EXPORT dds_time_t dds_time(void);
*/
DDS_EXPORT void dds_sleepfor (dds_duration_t reltime);
-/**
- * @brief Suspend execution of calling thread until absolute time n elapsed.
- *
- * Execution is suspended until the given absolute time elapsed. Should the
- * call be interrupted, it is re-entered with the remaining time.
- *
- * @param[in] abstime Absolute time in nanoseconds since UNIX Epoch.
- */
-DDS_EXPORT void dds_sleepuntil (dds_time_t abstime);
-
/**
* @brief Get high resolution, monotonic time.
*
diff --git a/src/ddsrt/src/time.c b/src/ddsrt/src/time.c
index a3d474f..8dfa587 100644
--- a/src/ddsrt/src/time.c
+++ b/src/ddsrt/src/time.c
@@ -35,14 +35,6 @@ void dds_sleepfor(dds_duration_t n)
}
#endif
-void dds_sleepuntil(dds_time_t abstime)
-{
- dds_time_t now = dds_time();
-
- if (abstime > now)
- dds_sleepfor (abstime - now);
-}
-
size_t
ddsrt_ctime(dds_time_t n, char *str, size_t size)
{
From 763ed6795871f4c0844cb868896ab52874bb7872 Mon Sep 17 00:00:00 2001
From: Erik Boasson
Date: Mon, 9 Mar 2020 14:02:30 +0100
Subject: [PATCH 22/30] Replace T_NEVER by DDS_NEVER, DDS_INFINITY
Signed-off-by: Erik Boasson
---
.../ddsi/include/dds/ddsi/ddsi_deadline.h | 12 +++---
.../ddsi/include/dds/ddsi/ddsi_lifespan.h | 4 +-
src/core/ddsi/include/dds/ddsi/q_time.h | 7 ++--
src/core/ddsi/include/dds/ddsi/q_xevent.h | 4 +-
src/core/ddsi/src/ddsi_plist.c | 14 +++----
src/core/ddsi/src/q_config.c | 6 +--
src/core/ddsi/src/q_ddsi_discovery.c | 8 ++--
src/core/ddsi/src/q_entity.c | 38 ++++++++-----------
src/core/ddsi/src/q_init.c | 4 +-
src/core/ddsi/src/q_lease.c | 10 ++---
src/core/ddsi/src/q_receive.c | 5 +--
src/core/ddsi/src/q_time.c | 14 +++----
src/core/ddsi/src/q_transmit.c | 4 +-
src/core/ddsi/src/q_xevent.c | 28 +++++++-------
src/core/ddsi/src/q_xmsg.c | 2 +-
15 files changed, 76 insertions(+), 84 deletions(-)
diff --git a/src/core/ddsi/include/dds/ddsi/ddsi_deadline.h b/src/core/ddsi/include/dds/ddsi/ddsi_deadline.h
index 4903eca..7bb1044 100644
--- a/src/core/ddsi/include/dds/ddsi/ddsi_deadline.h
+++ b/src/core/ddsi/include/dds/ddsi/ddsi_deadline.h
@@ -48,30 +48,30 @@ DDS_EXPORT void deadline_renew_instance_real (struct deadline_adm *deadline_adm,
inline void deadline_register_instance_locked (struct deadline_adm *deadline_adm, struct deadline_elem *elem, nn_mtime_t tnow)
{
- if (deadline_adm->dur != T_NEVER)
+ if (deadline_adm->dur != DDS_INFINITY)
deadline_register_instance_real (deadline_adm, elem, tnow, tnow);
}
inline void deadline_reregister_instance_locked (struct deadline_adm *deadline_adm, struct deadline_elem *elem, nn_mtime_t tnow)
{
- if (deadline_adm->dur != T_NEVER)
+ if (deadline_adm->dur != DDS_INFINITY)
deadline_register_instance_real (deadline_adm, elem, elem->t_deadline, tnow);
}
inline void deadline_unregister_instance_locked (struct deadline_adm *deadline_adm, struct deadline_elem *elem)
{
- if (deadline_adm->dur != T_NEVER)
+ if (deadline_adm->dur != DDS_INFINITY)
{
- assert (elem->t_deadline.v != T_NEVER);
+ assert (elem->t_deadline.v != DDS_NEVER);
deadline_unregister_instance_real (deadline_adm, elem);
}
}
inline void deadline_renew_instance_locked (struct deadline_adm *deadline_adm, struct deadline_elem *elem)
{
- if (deadline_adm->dur != T_NEVER)
+ if (deadline_adm->dur != DDS_INFINITY)
{
- assert (elem->t_deadline.v != T_NEVER);
+ assert (elem->t_deadline.v != DDS_NEVER);
deadline_renew_instance_real (deadline_adm, elem);
}
}
diff --git a/src/core/ddsi/include/dds/ddsi/ddsi_lifespan.h b/src/core/ddsi/include/dds/ddsi/ddsi_lifespan.h
index 7c1843c..e8202ee 100644
--- a/src/core/ddsi/include/dds/ddsi/ddsi_lifespan.h
+++ b/src/core/ddsi/include/dds/ddsi/ddsi_lifespan.h
@@ -43,13 +43,13 @@ DDS_EXPORT void lifespan_unregister_sample_real (struct lifespan_adm *lifespan_a
inline void lifespan_register_sample_locked (struct lifespan_adm *lifespan_adm, struct lifespan_fhnode *node)
{
- if (node->t_expire.v != T_NEVER)
+ if (node->t_expire.v != DDS_NEVER)
lifespan_register_sample_real (lifespan_adm, node);
}
inline void lifespan_unregister_sample_locked (struct lifespan_adm *lifespan_adm, struct lifespan_fhnode *node)
{
- if (node->t_expire.v != T_NEVER)
+ if (node->t_expire.v != DDS_NEVER)
lifespan_unregister_sample_real (lifespan_adm, node);
}
diff --git a/src/core/ddsi/include/dds/ddsi/q_time.h b/src/core/ddsi/include/dds/ddsi/q_time.h
index 3b22bee..1b99ee1 100644
--- a/src/core/ddsi/include/dds/ddsi/q_time.h
+++ b/src/core/ddsi/include/dds/ddsi/q_time.h
@@ -20,7 +20,6 @@
extern "C" {
#endif
-#define T_NEVER 0x7fffffffffffffffll
#define T_MILLISECOND 1000000ll
#define T_SECOND (1000 * T_MILLISECOND)
#define T_MICROSECOND (T_MILLISECOND/1000)
@@ -46,9 +45,9 @@ typedef struct {
int64_t v;
} nn_etime_t;
-#define NN_MTIME_NEVER ((nn_mtime_t) { T_NEVER })
-#define NN_WCTIME_NEVER ((nn_wctime_t) { T_NEVER })
-#define NN_ETIME_NEVER ((nn_etime_t) { T_NEVER })
+#define NN_MTIME_NEVER ((nn_mtime_t) { DDS_NEVER })
+#define NN_WCTIME_NEVER ((nn_wctime_t) { DDS_NEVER })
+#define NN_ETIME_NEVER ((nn_etime_t) { DDS_NEVER })
#define NN_WCTIME_INVALID ((nn_wctime_t) { INT64_MIN })
int valid_ddsi_timestamp (ddsi_time_t t);
diff --git a/src/core/ddsi/include/dds/ddsi/q_xevent.h b/src/core/ddsi/include/dds/ddsi/q_xevent.h
index 6f43bac..3925ba6 100644
--- a/src/core/ddsi/include/dds/ddsi/q_xevent.h
+++ b/src/core/ddsi/include/dds/ddsi/q_xevent.h
@@ -43,7 +43,7 @@ struct xeventq *xeventq_new
uint32_t auxiliary_bandwidth_limit
);
-/* xeventq_free calls callback handlers with t = T_NEVER, at which point they are required to free
+/* xeventq_free calls callback handlers with t = NEVER, at which point they are required to free
whatever memory is claimed for the argument and call delete_xevent. */
DDS_EXPORT void xeventq_free (struct xeventq *evq);
DDS_EXPORT dds_return_t xeventq_start (struct xeventq *evq, const char *name); /* <0 => error, =0 => ok */
@@ -68,7 +68,7 @@ DDS_EXPORT struct xevent *qxev_spdp (struct xeventq *evq, nn_mtime_t tsched, con
DDS_EXPORT struct xevent *qxev_pmd_update (struct xeventq *evq, nn_mtime_t tsched, const ddsi_guid_t *pp_guid);
DDS_EXPORT struct xevent *qxev_delete_writer (struct xeventq *evq, nn_mtime_t tsched, const ddsi_guid_t *guid);
-/* cb will be called with now = T_NEVER if the event is still enqueued when when xeventq_free starts cleaning up */
+/* cb will be called with now = NEVER if the event is still enqueued when when xeventq_free starts cleaning up */
DDS_EXPORT struct xevent *qxev_callback (struct xeventq *evq, nn_mtime_t tsched, void (*cb) (struct xevent *xev, void *arg, nn_mtime_t now), void *arg);
#if defined (__cplusplus)
diff --git a/src/core/ddsi/src/ddsi_plist.c b/src/core/ddsi/src/ddsi_plist.c
index 1ccac80..d967662 100644
--- a/src/core/ddsi/src/ddsi_plist.c
+++ b/src/core/ddsi/src/ddsi_plist.c
@@ -2803,14 +2803,14 @@ static void xqos_init_default_common (dds_qos_t *xqos)
xqos->durability.kind = DDS_DURABILITY_VOLATILE;
xqos->present |= QP_DEADLINE;
- xqos->deadline.deadline = T_NEVER;
+ xqos->deadline.deadline = DDS_INFINITY;
xqos->present |= QP_LATENCY_BUDGET;
xqos->latency_budget.duration = 0;
xqos->present |= QP_LIVELINESS;
xqos->liveliness.kind = DDS_LIVELINESS_AUTOMATIC;
- xqos->liveliness.lease_duration = T_NEVER;
+ xqos->liveliness.lease_duration = DDS_INFINITY;
xqos->present |= QP_DESTINATION_ORDER;
xqos->destination_order.kind = DDS_DESTINATIONORDER_BY_RECEPTION_TIMESTAMP;
@@ -2866,12 +2866,12 @@ void ddsi_xqos_init_default_reader (dds_qos_t *xqos)
xqos->time_based_filter.minimum_separation = 0;
xqos->present |= QP_PRISMTECH_READER_DATA_LIFECYCLE;
- xqos->reader_data_lifecycle.autopurge_nowriter_samples_delay = T_NEVER;
- xqos->reader_data_lifecycle.autopurge_disposed_samples_delay = T_NEVER;
+ xqos->reader_data_lifecycle.autopurge_nowriter_samples_delay = DDS_INFINITY;
+ xqos->reader_data_lifecycle.autopurge_disposed_samples_delay = DDS_INFINITY;
xqos->present |= QP_PRISMTECH_READER_LIFESPAN;
xqos->reader_lifespan.use_lifespan = 0;
- xqos->reader_lifespan.duration = T_NEVER;
+ xqos->reader_lifespan.duration = DDS_INFINITY;
xqos->present |= QP_PRISMTECH_SUBSCRIPTION_KEYS;
xqos->subscription_keys.use_key_list = 0;
@@ -2902,7 +2902,7 @@ void ddsi_xqos_init_default_writer (dds_qos_t *xqos)
xqos->transport_priority.value = 0;
xqos->present |= QP_LIFESPAN;
- xqos->lifespan.duration = T_NEVER;
+ xqos->lifespan.duration = DDS_INFINITY;
xqos->present |= QP_PRISMTECH_WRITER_DATA_LIFECYCLE;
xqos->writer_data_lifecycle.autodispose_unregistered_instances = 1;
@@ -2934,7 +2934,7 @@ void ddsi_xqos_init_default_topic (dds_qos_t *xqos)
xqos->transport_priority.value = 0;
xqos->present |= QP_LIFESPAN;
- xqos->lifespan.duration = T_NEVER;
+ xqos->lifespan.duration = DDS_INFINITY;
xqos->present |= QP_PRISMTECH_SUBSCRIPTION_KEYS;
xqos->subscription_keys.use_key_list = 0;
diff --git a/src/core/ddsi/src/q_config.c b/src/core/ddsi/src/q_config.c
index 2f3fbf6..4c666ff 100644
--- a/src/core/ddsi/src/q_config.c
+++ b/src/core/ddsi/src/q_config.c
@@ -1910,10 +1910,10 @@ static enum update_result uf_duration_inf (struct cfgst *cfgst, void *parent, st
{
if (ddsrt_strcasecmp (value, "inf") == 0) {
int64_t * const elem = cfg_address (cfgst, parent, cfgelem);
- *elem = T_NEVER;
+ *elem = DDS_INFINITY;
return URES_SUCCESS;
} else {
- return uf_duration_gen (cfgst, parent, cfgelem, value, 0, 0, T_NEVER - 1);
+ return uf_duration_gen (cfgst, parent, cfgelem, value, 0, 0, DDS_INFINITY - 1);
}
}
@@ -1940,7 +1940,7 @@ static enum update_result uf_duration_100ms_1hr (struct cfgst *cfgst, void *pare
static void pf_duration (struct cfgst *cfgst, void *parent, struct cfgelem const * const cfgelem, uint32_t sources)
{
int64_t const * const elem = cfg_address (cfgst, parent, cfgelem);
- if (*elem == T_NEVER)
+ if (*elem == DDS_INFINITY)
cfg_logelem (cfgst, sources, "inf");
else
pf_int64_unit (cfgst, *elem, sources, unittab_duration, "s");
diff --git a/src/core/ddsi/src/q_ddsi_discovery.c b/src/core/ddsi/src/q_ddsi_discovery.c
index 0d3484d..f893b98 100644
--- a/src/core/ddsi/src/q_ddsi_discovery.c
+++ b/src/core/ddsi/src/q_ddsi_discovery.c
@@ -662,7 +662,7 @@ static int handle_SPDP_alive (const struct receiver_state *rst, seqno_t seq, nn_
GVLOGDISC (" (depends on "PGUIDFMT")", PGUID (privileged_pp_guid));
/* never expire lease for this proxy: it won't actually expire
until the "privileged" one expires anyway */
- lease_duration = T_NEVER;
+ lease_duration = DDS_INFINITY;
}
else if (vendor_is_eclipse_or_opensplice (rst->vendor) && !(custom_flags & CF_PARTICIPANT_IS_DDSI2))
{
@@ -674,7 +674,7 @@ static int handle_SPDP_alive (const struct receiver_state *rst, seqno_t seq, nn_
else
{
privileged_pp_guid.prefix = ddsi2->e.guid.prefix;
- lease_duration = T_NEVER;
+ lease_duration = DDS_INFINITY;
GVLOGDISC (" (depends on "PGUIDFMT")", PGUID (privileged_pp_guid));
}
}
@@ -1086,7 +1086,7 @@ static struct proxy_participant *implicitly_create_proxypp (struct ddsi_domaingv
doing anything about (1). That means we fall back to the legacy mode of locally generating
GIDs but leaving the system id unchanged if the remote is OSPL. */
actual_vendorid = (datap->present & PP_VENDORID) ? datap->vendorid : vendorid;
- new_proxy_participant(gv, ppguid, 0, &privguid, new_addrset(), new_addrset(), &pp_plist, T_NEVER, actual_vendorid, CF_IMPLICITLY_CREATED_PROXYPP, timestamp, seq);
+ new_proxy_participant(gv, ppguid, 0, &privguid, new_addrset(), new_addrset(), &pp_plist, DDS_INFINITY, actual_vendorid, CF_IMPLICITLY_CREATED_PROXYPP, timestamp, seq);
}
else if (ppguid->prefix.u[0] == src_guid_prefix->u[0] && vendor_is_eclipse_or_opensplice (vendorid))
{
@@ -1120,7 +1120,7 @@ static struct proxy_participant *implicitly_create_proxypp (struct ddsi_domaingv
ddsrt_mutex_unlock (&privpp->e.lock);
pp_plist.prismtech_participant_version_info.flags &= ~NN_PRISMTECH_FL_PARTICIPANT_IS_DDSI2;
- new_proxy_participant (gv, ppguid, 0, &privguid, as_default, as_meta, &pp_plist, T_NEVER, vendorid, CF_IMPLICITLY_CREATED_PROXYPP | CF_PROXYPP_NO_SPDP, timestamp, seq);
+ new_proxy_participant (gv, ppguid, 0, &privguid, as_default, as_meta, &pp_plist, DDS_INFINITY, vendorid, CF_IMPLICITLY_CREATED_PROXYPP | CF_PROXYPP_NO_SPDP, timestamp, seq);
}
}
diff --git a/src/core/ddsi/src/q_entity.c b/src/core/ddsi/src/q_entity.c
index 0790a00..cf587ea 100644
--- a/src/core/ddsi/src/q_entity.c
+++ b/src/core/ddsi/src/q_entity.c
@@ -417,7 +417,7 @@ static void remember_deleted_participant_guid (struct deleted_participants_admin
if ((n = ddsrt_malloc (sizeof (*n))) != NULL)
{
n->guid = *guid;
- n->t_prune.v = T_NEVER;
+ n->t_prune = NN_MTIME_NEVER;
n->for_what = DPG_LOCAL | DPG_REMOTE;
ddsrt_avl_insert_ipath (&deleted_participants_treedef, &admin->deleted_participants, n, &path);
}
@@ -811,7 +811,7 @@ dds_return_t new_participant_guid (const ddsi_guid_t *ppguid, struct ddsi_domain
{
nn_mtime_t tsched;
- tsched.v = (pp->lease_duration == T_NEVER) ? T_NEVER : 0;
+ tsched = (pp->lease_duration == DDS_INFINITY) ? NN_MTIME_NEVER : (nn_mtime_t){0};
pp->pmd_update_xevent = qxev_pmd_update (gv->xevents, tsched, &pp->e.guid);
}
return 0;
@@ -1089,7 +1089,7 @@ dds_duration_t pp_get_pmd_interval (struct participant *pp)
dds_duration_t intv;
ddsrt_mutex_lock (&pp->e.lock);
ldur_node = ddsrt_fibheap_min (&ldur_fhdef, &pp->ldur_auto_wr);
- intv = (ldur_node != NULL) ? ldur_node->ldur : T_NEVER;
+ intv = (ldur_node != NULL) ? ldur_node->ldur : DDS_INFINITY;
if (pp->lease_duration < intv)
intv = pp->lease_duration;
ddsrt_mutex_unlock (&pp->e.lock);
@@ -2920,7 +2920,7 @@ void writer_set_alive_may_unlock (struct writer *wr, bool notify)
ddsrt_mutex_lock (&wr->c.pp->e.lock);
wr->alive = true;
wr->alive_vclock++;
- if (wr->xqos->liveliness.lease_duration != T_NEVER)
+ if (wr->xqos->liveliness.lease_duration != DDS_INFINITY)
{
if (wr->xqos->liveliness.kind == DDS_LIVELINESS_MANUAL_BY_PARTICIPANT)
participant_add_wr_lease_locked (wr->c.pp, wr);
@@ -2943,7 +2943,7 @@ static int writer_set_notalive_locked (struct writer *wr, bool notify)
ddsrt_mutex_lock (&wr->c.pp->e.lock);
wr->alive = false;
wr->alive_vclock++;
- if (wr->xqos->liveliness.lease_duration != T_NEVER && wr->xqos->liveliness.kind == DDS_LIVELINESS_MANUAL_BY_PARTICIPANT)
+ if (wr->xqos->liveliness.lease_duration != DDS_INFINITY && wr->xqos->liveliness.kind == DDS_LIVELINESS_MANUAL_BY_PARTICIPANT)
participant_remove_wr_lease_locked (wr->c.pp, wr);
ddsrt_mutex_unlock (&wr->c.pp->e.lock);
@@ -3089,22 +3089,16 @@ static void new_writer_guid_common_init (struct writer *wr, const struct ddsi_se
}
/* heartbeat event will be deleted when the handler can't find a
- writer for it in the hash table. T_NEVER => won't ever be
+ writer for it in the hash table. NEVER => won't ever be
scheduled, and this can only change by writing data, which won't
happen until after it becomes visible. */
if (wr->reliable)
- {
- nn_mtime_t tsched;
- tsched.v = T_NEVER;
- wr->heartbeat_xevent = qxev_heartbeat (wr->evq, tsched, &wr->e.guid);
- }
+ wr->heartbeat_xevent = qxev_heartbeat (wr->evq, NN_MTIME_NEVER, &wr->e.guid);
else
- {
wr->heartbeat_xevent = NULL;
- }
assert (wr->xqos->present & QP_LIVELINESS);
- if (wr->xqos->liveliness.lease_duration != T_NEVER)
+ if (wr->xqos->liveliness.lease_duration != DDS_INFINITY)
{
wr->lease_duration = ddsrt_malloc (sizeof(*wr->lease_duration));
wr->lease_duration->ldur = wr->xqos->liveliness.lease_duration;
@@ -3181,7 +3175,7 @@ static dds_return_t new_writer_guid (struct writer **wr_out, const struct ddsi_g
if (wr->lease_duration != NULL)
{
- assert (wr->lease_duration->ldur != T_NEVER);
+ assert (wr->lease_duration->ldur != DDS_INFINITY);
assert (!is_builtin_entityid (wr->e.guid.entityid, NN_VENDORID_ECLIPSE));
if (wr->xqos->liveliness.kind == DDS_LIVELINESS_AUTOMATIC)
{
@@ -3278,7 +3272,7 @@ static void gc_delete_writer (struct gcreq *gcreq)
if (wr->heartbeat_xevent)
{
- wr->hbcontrol.tsched.v = T_NEVER;
+ wr->hbcontrol.tsched = NN_MTIME_NEVER;
delete_xevent (wr->heartbeat_xevent);
}
@@ -4026,7 +4020,7 @@ void new_proxy_participant (struct ddsi_domaingv *gv, const struct ddsi_guid *pp
lease that doesn't expire now and that has a "reasonable" lease duration. That way the lease renewal in
the data path is fine, and we only need to do something special in SEDP handling. */
nn_etime_t texp = add_duration_to_etime (now_et(), tlease_dur);
- dds_duration_t dur = (tlease_dur == T_NEVER) ? gv->config.lease_duration : tlease_dur;
+ dds_duration_t dur = (tlease_dur == DDS_INFINITY) ? gv->config.lease_duration : tlease_dur;
proxypp->lease = lease_new (texp, dur, &proxypp->e);
proxypp->owns_lease = 1;
@@ -4529,7 +4523,7 @@ int new_proxy_writer (struct ddsi_domaingv *gv, const struct ddsi_guid *ppguid,
#endif
assert (pwr->c.xqos->present & QP_LIVELINESS);
- if (pwr->c.xqos->liveliness.lease_duration != T_NEVER)
+ if (pwr->c.xqos->liveliness.lease_duration != DDS_INFINITY)
{
nn_etime_t texpire = add_duration_to_etime (now_et (), pwr->c.xqos->liveliness.lease_duration);
pwr->lease = lease_new (texpire, pwr->c.xqos->liveliness.lease_duration, &pwr->e);
@@ -4689,7 +4683,7 @@ static void gc_delete_proxy_writer (struct gcreq *gcreq)
free_pwr_rd_match (m);
}
local_reader_ary_fini (&pwr->rdary);
- if (pwr->c.xqos->liveliness.lease_duration != T_NEVER)
+ if (pwr->c.xqos->liveliness.lease_duration != DDS_INFINITY)
lease_free (pwr->lease);
proxy_endpoint_common_fini (&pwr->e, &pwr->c);
nn_defrag_free (pwr->defrag);
@@ -4722,7 +4716,7 @@ int delete_proxy_writer (struct ddsi_domaingv *gv, const struct ddsi_guid *guid,
builtintopic_write (gv->builtin_topic_interface, &pwr->e, timestamp, false);
entidx_remove_proxy_writer_guid (gv->entity_index, pwr);
ddsrt_mutex_unlock (&gv->lock);
- if (pwr->c.xqos->liveliness.lease_duration != T_NEVER &&
+ if (pwr->c.xqos->liveliness.lease_duration != DDS_INFINITY &&
pwr->c.xqos->liveliness.kind == DDS_LIVELINESS_MANUAL_BY_TOPIC)
lease_unregister (pwr->lease);
if (proxy_writer_set_notalive (pwr, false) != DDS_RETCODE_OK)
@@ -4768,7 +4762,7 @@ void proxy_writer_set_alive_may_unlock (struct proxy_writer *pwr, bool notify)
ddsrt_mutex_lock (&pwr->c.proxypp->e.lock);
pwr->alive = true;
pwr->alive_vclock++;
- if (pwr->c.xqos->liveliness.lease_duration != T_NEVER)
+ if (pwr->c.xqos->liveliness.lease_duration != DDS_INFINITY)
{
if (pwr->c.xqos->liveliness.kind != DDS_LIVELINESS_MANUAL_BY_TOPIC)
proxy_participant_add_pwr_lease_locked (pwr->c.proxypp, pwr);
@@ -4795,7 +4789,7 @@ int proxy_writer_set_notalive (struct proxy_writer *pwr, bool notify)
ddsrt_mutex_lock (&pwr->c.proxypp->e.lock);
pwr->alive = false;
pwr->alive_vclock++;
- if (pwr->c.xqos->liveliness.lease_duration != T_NEVER && pwr->c.xqos->liveliness.kind != DDS_LIVELINESS_MANUAL_BY_TOPIC)
+ if (pwr->c.xqos->liveliness.lease_duration != DDS_INFINITY && pwr->c.xqos->liveliness.kind != DDS_LIVELINESS_MANUAL_BY_TOPIC)
proxy_participant_remove_pwr_lease_locked (pwr->c.proxypp, pwr);
ddsrt_mutex_unlock (&pwr->c.proxypp->e.lock);
diff --git a/src/core/ddsi/src/q_init.c b/src/core/ddsi/src/q_init.c
index 7cb0fb3..2de55a2 100644
--- a/src/core/ddsi/src/q_init.c
+++ b/src/core/ddsi/src/q_init.c
@@ -952,7 +952,7 @@ int rtps_init (struct ddsi_domaingv *gv)
uint32_t port_disc_uc = 0;
uint32_t port_data_uc = 0;
bool mc_available = true;
- nn_mtime_t reset_deaf_mute_time = { T_NEVER };
+ nn_mtime_t reset_deaf_mute_time = NN_MTIME_NEVER;
gv->tstart = now (); /* wall clock time, used in logs */
@@ -1429,7 +1429,7 @@ int rtps_init (struct ddsi_domaingv *gv)
gv->user_dqueue = nn_dqueue_new ("user", gv, gv->config.delivery_queue_maxsamples, user_dqueue_handler, NULL);
#endif
- if (reset_deaf_mute_time.v < T_NEVER)
+ if (reset_deaf_mute_time.v < DDS_NEVER)
qxev_callback (gv->xevents, reset_deaf_mute_time, reset_deaf_mute, gv);
return 0;
diff --git a/src/core/ddsi/src/q_lease.c b/src/core/ddsi/src/q_lease.c
index 7e8f9f3..e6e1747 100644
--- a/src/core/ddsi/src/q_lease.c
+++ b/src/core/ddsi/src/q_lease.c
@@ -110,7 +110,7 @@ void lease_register (struct lease *l) /* FIXME: make lease admin struct */
ddsrt_mutex_lock (&gv->leaseheap_lock);
assert (l->tsched.v == TSCHED_NOT_ON_HEAP);
int64_t tend = (int64_t) ddsrt_atomic_ld64 (&l->tend);
- if (tend != T_NEVER)
+ if (tend != DDS_NEVER)
{
l->tsched.v = tend;
ddsrt_fibheap_insert (&lease_fhdef, &gv->leaseheap, l);
@@ -175,7 +175,7 @@ void lease_renew (struct lease *l, nn_etime_t tnowE)
/* Only at this point we can assume that gv can be recovered from the entity in the
* lease (i.e. the entity still exists). In cases where dereferencing l->entity->gv
* is not safe (e.g. the deletion of entities), the early out in the loop above
- * will be the case because tend is set to T_NEVER. */
+ * will be the case because tend is set to DDS_NEVER. */
trace_lease_renew (l, "", tend_new);
}
@@ -197,7 +197,7 @@ void lease_set_expiry (struct lease *l, nn_etime_t when)
trace_lease_renew (l, "earlier ", when);
trigger = true;
}
- else if (l->tsched.v == TSCHED_NOT_ON_HEAP && when.v < T_NEVER)
+ else if (l->tsched.v == TSCHED_NOT_ON_HEAP && when.v < DDS_NEVER)
{
/* not currently scheduled, with a finite new expiry time */
l->tsched = when;
@@ -229,7 +229,7 @@ int64_t check_and_handle_lease_expiration (struct ddsi_domaingv *gv, nn_etime_t
int64_t tend = (int64_t) ddsrt_atomic_ld64 (&l->tend);
if (tnowE.v < tend)
{
- if (tend == T_NEVER) {
+ if (tend == DDS_NEVER) {
/* don't reinsert if it won't expire */
l->tsched.v = TSCHED_NOT_ON_HEAP;
} else {
@@ -302,7 +302,7 @@ int64_t check_and_handle_lease_expiration (struct ddsi_domaingv *gv, nn_etime_t
ddsrt_mutex_lock (&gv->leaseheap_lock);
}
- delay = (l == NULL) ? T_NEVER : (l->tsched.v - tnowE.v);
+ delay = (l == NULL) ? DDS_INFINITY : (l->tsched.v - tnowE.v);
ddsrt_mutex_unlock (&gv->leaseheap_lock);
return delay;
}
diff --git a/src/core/ddsi/src/q_receive.c b/src/core/ddsi/src/q_receive.c
index 7b138a8..07cb3cd 100644
--- a/src/core/ddsi/src/q_receive.c
+++ b/src/core/ddsi/src/q_receive.c
@@ -1072,8 +1072,7 @@ static void handle_Heartbeat_helper (struct pwr_rd_match * const wn, struct hand
once, regardless of which readers care about it. */
if (wn->acknack_xevent)
{
- nn_mtime_t tsched;
- tsched.v = T_NEVER;
+ nn_mtime_t tsched = NN_MTIME_NEVER;
if (pwr->last_seq > refseq)
{
RSTTRACE ("/NAK");
@@ -1142,7 +1141,7 @@ static int handle_Heartbeat (struct receiver_state *rst, nn_etime_t tnow, struct
ddsrt_mutex_lock (&pwr->e.lock);
if (msg->smhdr.flags & HEARTBEAT_FLAG_LIVELINESS &&
pwr->c.xqos->liveliness.kind != DDS_LIVELINESS_AUTOMATIC &&
- pwr->c.xqos->liveliness.lease_duration != T_NEVER)
+ pwr->c.xqos->liveliness.lease_duration != DDS_INFINITY)
{
if ((lease = ddsrt_atomic_ldvoidp (&pwr->c.proxypp->minl_man)) != NULL)
lease_renew (lease, tnow);
diff --git a/src/core/ddsi/src/q_time.c b/src/core/ddsi/src/q_time.c
index 79cfcf3..4fe4e69 100644
--- a/src/core/ddsi/src/q_time.c
+++ b/src/core/ddsi/src/q_time.c
@@ -75,7 +75,7 @@ nn_mtime_t mtime_round_up (nn_mtime_t t, int64_t round)
t is nanoseconds, round is milliseconds. Avoid functions from
maths libraries to keep code portable */
assert (t.v >= 0 && round >= 0);
- if (round == 0 || t.v == T_NEVER)
+ if (round == 0 || t.v == DDS_INFINITY)
{
return t;
}
@@ -100,12 +100,12 @@ static int64_t add_duration_to_time (int64_t t, int64_t d)
uint64_t sum;
assert (t >= 0 && d >= 0);
sum = (uint64_t)t + (uint64_t)d;
- return sum >= T_NEVER ? T_NEVER : (int64_t)sum;
+ return sum >= DDS_NEVER ? DDS_NEVER : (int64_t)sum;
}
nn_mtime_t add_duration_to_mtime (nn_mtime_t t, int64_t d)
{
- /* assumed T_NEVER <=> MAX_INT64 */
+ /* assumed DDS_NEVER <=> MAX_INT64 */
nn_mtime_t u;
u.v = add_duration_to_time (t.v, d);
return u;
@@ -113,7 +113,7 @@ nn_mtime_t add_duration_to_mtime (nn_mtime_t t, int64_t d)
nn_wctime_t add_duration_to_wctime (nn_wctime_t t, int64_t d)
{
- /* assumed T_NEVER <=> MAX_INT64 */
+ /* assumed DDS_NEVER <=> MAX_INT64 */
nn_wctime_t u;
u.v = add_duration_to_time (t.v, d);
return u;
@@ -121,7 +121,7 @@ nn_wctime_t add_duration_to_wctime (nn_wctime_t t, int64_t d)
nn_etime_t add_duration_to_etime (nn_etime_t t, int64_t d)
{
- /* assumed T_NEVER <=> MAX_INT64 */
+ /* assumed DDS_NEVER <=> MAX_INT64 */
nn_etime_t u;
u.v = add_duration_to_time (t.v, d);
return u;
@@ -134,7 +134,7 @@ int valid_ddsi_timestamp (ddsi_time_t t)
static ddsi_time_t nn_to_ddsi_time (int64_t t)
{
- if (t == T_NEVER)
+ if (t == DDS_NEVER)
return DDSI_TIME_INFINITE;
else
{
@@ -157,7 +157,7 @@ ddsi_time_t nn_wctime_to_ddsi_time (nn_wctime_t t)
static int64_t nn_from_ddsi_time (ddsi_time_t x)
{
if (x.seconds == DDSI_TIME_INFINITE.seconds && x.fraction == DDSI_TIME_INFINITE.fraction)
- return T_NEVER;
+ return DDS_NEVER;
else
{
/* Round-to-nearest conversion of DDSI time fraction to nanoseconds */
diff --git a/src/core/ddsi/src/q_transmit.c b/src/core/ddsi/src/q_transmit.c
index d412613..ef41d6d 100644
--- a/src/core/ddsi/src/q_transmit.c
+++ b/src/core/ddsi/src/q_transmit.c
@@ -58,7 +58,7 @@ void writer_hbcontrol_init (struct hbcontrol *hbc)
hbc->t_of_last_write.v = 0;
hbc->t_of_last_hb.v = 0;
hbc->t_of_last_ackhb.v = 0;
- hbc->tsched.v = T_NEVER;
+ hbc->tsched = NN_MTIME_NEVER;
hbc->hbs_since_last_write = 0;
hbc->last_packetid = 0;
}
@@ -306,7 +306,7 @@ struct nn_xmsg *writer_hbcontrol_piggyback (struct writer *wr, const struct whc_
ETRACE (wr, "heartbeat(wr "PGUIDFMT"%s) piggybacked, resched in %g s (min-ack %"PRId64"%s, avail-seq %"PRId64", xmit %"PRId64")\n",
PGUID (wr->e.guid),
*hbansreq ? "" : " final",
- (hbc->tsched.v == T_NEVER) ? INFINITY : (double) (hbc->tsched.v - tnow.v) / 1e9,
+ (hbc->tsched.v == DDS_NEVER) ? INFINITY : (double) (hbc->tsched.v - tnow.v) / 1e9,
ddsrt_avl_is_empty (&wr->readers) ? -1 : root_rdmatch (wr)->min_seq,
ddsrt_avl_is_empty (&wr->readers) || root_rdmatch (wr)->all_have_replied_to_hb ? "" : "!",
whcst->max_seq, writer_read_seq_xmit (wr));
diff --git a/src/core/ddsi/src/q_xevent.c b/src/core/ddsi/src/q_xevent.c
index 7c3b777..7860d75 100644
--- a/src/core/ddsi/src/q_xevent.c
+++ b/src/core/ddsi/src/q_xevent.c
@@ -321,7 +321,7 @@ void delete_xevent (struct xevent *ev)
/* Can delete it only once, no matter how we implement it internally */
assert (ev->tsched.v != TSCHED_DELETE);
assert (TSCHED_DELETE < ev->tsched.v);
- if (ev->tsched.v != T_NEVER)
+ if (ev->tsched.v != DDS_NEVER)
{
ev->tsched.v = TSCHED_DELETE;
ddsrt_fibheap_decrease_key (&evq_xevents_fhdef, &evq->xevents, ev);
@@ -343,13 +343,13 @@ void delete_xevent_callback (struct xevent *ev)
assert (ev->kind == XEVK_CALLBACK);
ddsrt_mutex_lock (&evq->lock);
/* wait until neither scheduled nor executing; loop in case the callback reschedules the event */
- while (ev->tsched.v != T_NEVER || ev->u.callback.executing)
+ while (ev->tsched.v != DDS_NEVER || ev->u.callback.executing)
{
- if (ev->tsched.v != T_NEVER)
+ if (ev->tsched.v != DDS_NEVER)
{
assert (ev->tsched.v != TSCHED_DELETE);
ddsrt_fibheap_delete (&evq_xevents_fhdef, &evq->xevents, ev);
- ev->tsched.v = T_NEVER;
+ ev->tsched.v = DDS_NEVER;
}
if (ev->u.callback.executing)
{
@@ -364,7 +364,7 @@ int resched_xevent_if_earlier (struct xevent *ev, nn_mtime_t tsched)
{
struct xeventq *evq = ev->evq;
int is_resched;
- if (tsched.v == T_NEVER)
+ if (tsched.v == DDS_NEVER)
return 0;
ddsrt_mutex_lock (&evq->lock);
/* If you want to delete it, you to say so by calling the right
@@ -377,7 +377,7 @@ int resched_xevent_if_earlier (struct xevent *ev, nn_mtime_t tsched)
else
{
nn_mtime_t tbefore = earliest_in_xeventq (evq);
- if (ev->tsched.v != T_NEVER)
+ if (ev->tsched.v != DDS_NEVER)
{
ev->tsched = tsched;
ddsrt_fibheap_decrease_key (&evq_xevents_fhdef, &evq->xevents, ev);
@@ -405,7 +405,7 @@ static struct xevent *qxev_common (struct xeventq *evq, nn_mtime_t tsched, enum
ASSERT_MUTEX_HELD (&evq->lock);
/* round up the scheduled time if required */
- if (tsched.v != T_NEVER && evq->gv->config.schedule_time_rounding != 0)
+ if (tsched.v != DDS_NEVER && evq->gv->config.schedule_time_rounding != 0)
{
nn_mtime_t tsched_rounded = mtime_round_up (tsched, evq->gv->config.schedule_time_rounding);
EVQTRACE ("rounded event scheduled for %"PRId64" to %"PRId64"\n", tsched.v, tsched_rounded.v);
@@ -440,7 +440,7 @@ static void qxev_insert (struct xevent *ev)
event administration. */
struct xeventq *evq = ev->evq;
ASSERT_MUTEX_HELD (&evq->lock);
- if (ev->tsched.v != T_NEVER)
+ if (ev->tsched.v != DDS_NEVER)
{
nn_mtime_t tbefore = earliest_in_xeventq (evq);
ddsrt_fibheap_insert (&evq_xevents_fhdef, &evq->xevents, ev);
@@ -606,7 +606,7 @@ static void handle_xevk_heartbeat (struct nn_xpack *xp, struct xevent *ev, nn_mt
{
hbansreq = 1; /* just for trace */
msg = NULL; /* Need not send it now, and no need to schedule it for the future */
- t_next.v = T_NEVER;
+ t_next.v = DDS_NEVER;
}
else if (!writer_hbcontrol_must_send (wr, &whcst, tnow))
{
@@ -625,7 +625,7 @@ static void handle_xevk_heartbeat (struct nn_xpack *xp, struct xevent *ev, nn_mt
PGUID (wr->e.guid),
hbansreq ? "" : " final",
msg ? "sent" : "suppressed",
- (t_next.v == T_NEVER) ? INFINITY : (double)(t_next.v - tnow.v) / 1e9,
+ (t_next.v == DDS_NEVER) ? INFINITY : (double)(t_next.v - tnow.v) / 1e9,
ddsrt_avl_is_empty (&wr->readers) ? (seqno_t) -1 : ((struct wr_prd_match *) ddsrt_avl_root_non_empty (&wr_readers_treedef, &wr->readers))->min_seq,
ddsrt_avl_is_empty (&wr->readers) || ((struct wr_prd_match *) ddsrt_avl_root_non_empty (&wr_readers_treedef, &wr->readers))->all_have_replied_to_hb ? "" : "!",
whcst.max_seq, writer_read_seq_xmit (wr));
@@ -1111,9 +1111,9 @@ static void handle_xevk_pmd_update (struct thread_state1 * const ts1, struct nn_
write_pmd_message (ts1, xp, pp, PARTICIPANT_MESSAGE_DATA_KIND_AUTOMATIC_LIVELINESS_UPDATE);
intv = pp_get_pmd_interval (pp);
- if (intv == T_NEVER)
+ if (intv == DDS_INFINITY)
{
- tnext.v = T_NEVER;
+ tnext.v = DDS_NEVER;
GVTRACE ("resched pmd("PGUIDFMT"): never\n", PGUID (pp->e.guid));
}
else
@@ -1258,7 +1258,7 @@ static void handle_xevents (struct thread_state1 * const ts1, struct xeventq *xe
determine whether it is currently on the heap or not (i.e.,
scheduled or not), so set to TSCHED_NEVER to indicate it
currently isn't. */
- xev->tsched.v = T_NEVER;
+ xev->tsched.v = DDS_NEVER;
thread_state_awake_to_awake_no_nest (ts1);
handle_timed_xevent (ts1, xev, xp, tnow);
}
@@ -1314,7 +1314,7 @@ static uint32_t xevent_thread (struct xeventq * xevq)
else
{
nn_mtime_t twakeup = earliest_in_xeventq (xevq);
- if (twakeup.v == T_NEVER)
+ if (twakeup.v == DDS_NEVER)
{
/* no scheduled events nor any non-timed events */
ddsrt_cond_wait (&xevq->cond, &xevq->lock);
diff --git a/src/core/ddsi/src/q_xmsg.c b/src/core/ddsi/src/q_xmsg.c
index 6a3de18..dffe31a 100644
--- a/src/core/ddsi/src/q_xmsg.c
+++ b/src/core/ddsi/src/q_xmsg.c
@@ -952,7 +952,7 @@ static void nn_xpack_reinit (struct nn_xpack *xp)
xp->call_flags = 0;
xp->msg_len.length = 0;
xp->included_msgs.latest = NULL;
- xp->maxdelay = T_NEVER;
+ xp->maxdelay = DDS_INFINITY;
#ifdef DDSI_INCLUDE_NETWORK_PARTITIONS
xp->encoderId = 0;
#endif
From 1611adc20a3149fd6672882aeabe17017eaffebf Mon Sep 17 00:00:00 2001
From: Erik Boasson
Date: Mon, 9 Mar 2020 14:13:59 +0100
Subject: [PATCH 23/30] Replace T_SECOND etc. by DDS_ equivalents
Signed-off-by: Erik Boasson
---
src/core/ddsi/include/dds/ddsi/q_log.h | 2 +-
src/core/ddsi/include/dds/ddsi/q_time.h | 4 ----
src/core/ddsi/src/ddsi_plist.c | 4 ++--
src/core/ddsi/src/q_config.c | 22 +++++++++++-----------
src/core/ddsi/src/q_ddsi_discovery.c | 2 +-
src/core/ddsi/src/q_entity.c | 13 ++++++-------
src/core/ddsi/src/q_gc.c | 4 ++--
src/core/ddsi/src/q_init.c | 6 +++---
src/core/ddsi/src/q_lease.c | 2 +-
src/core/ddsi/src/q_receive.c | 4 ++--
src/core/ddsi/src/q_time.c | 14 +++++++-------
src/core/ddsi/src/q_transmit.c | 2 +-
src/core/ddsi/src/q_xevent.c | 22 +++++++++++-----------
src/core/ddsi/src/q_xmsg.c | 6 +++---
src/tools/pubsub/pubsub.c | 17 ++++++++---------
15 files changed, 59 insertions(+), 65 deletions(-)
diff --git a/src/core/ddsi/include/dds/ddsi/q_log.h b/src/core/ddsi/include/dds/ddsi/q_log.h
index d983864..fb7c5b7 100644
--- a/src/core/ddsi/include/dds/ddsi/q_log.h
+++ b/src/core/ddsi/include/dds/ddsi/q_log.h
@@ -55,7 +55,7 @@ extern "C" {
"thread_cputime %d.%09d\n", \
(int)(usage.stime / DDS_NSECS_IN_SEC), \
(int)(usage.stime % DDS_NSECS_IN_SEC)); \
- (guard).v = tnowlt.v + T_SECOND; \
+ (guard).v = tnowlt.v + DDS_NSECS_IN_SEC; \
} \
} \
} \
diff --git a/src/core/ddsi/include/dds/ddsi/q_time.h b/src/core/ddsi/include/dds/ddsi/q_time.h
index 1b99ee1..03b5b5e 100644
--- a/src/core/ddsi/include/dds/ddsi/q_time.h
+++ b/src/core/ddsi/include/dds/ddsi/q_time.h
@@ -20,10 +20,6 @@
extern "C" {
#endif
-#define T_MILLISECOND 1000000ll
-#define T_SECOND (1000 * T_MILLISECOND)
-#define T_MICROSECOND (T_MILLISECOND/1000)
-
typedef struct {
int32_t seconds;
uint32_t fraction;
diff --git a/src/core/ddsi/src/ddsi_plist.c b/src/core/ddsi/src/ddsi_plist.c
index d967662..0707f2f 100644
--- a/src/core/ddsi/src/ddsi_plist.c
+++ b/src/core/ddsi/src/ddsi_plist.c
@@ -2893,7 +2893,7 @@ void ddsi_xqos_init_default_writer (dds_qos_t *xqos)
xqos->present |= QP_RELIABILITY;
xqos->reliability.kind = DDS_RELIABILITY_RELIABLE;
- xqos->reliability.max_blocking_time = 100 * T_MILLISECOND;
+ xqos->reliability.max_blocking_time = DDS_MSECS (100);
xqos->present |= QP_OWNERSHIP_STRENGTH;
xqos->ownership_strength.value = 0;
@@ -2928,7 +2928,7 @@ void ddsi_xqos_init_default_topic (dds_qos_t *xqos)
xqos->present |= QP_RELIABILITY;
xqos->reliability.kind = DDS_RELIABILITY_BEST_EFFORT;
- xqos->reliability.max_blocking_time = 100 * T_MILLISECOND;
+ xqos->reliability.max_blocking_time = DDS_MSECS (100);
xqos->present |= QP_TRANSPORT_PRIORITY;
xqos->transport_priority.value = 0;
diff --git a/src/core/ddsi/src/q_config.c b/src/core/ddsi/src/q_config.c
index 4c666ff..c8d0e40 100644
--- a/src/core/ddsi/src/q_config.c
+++ b/src/core/ddsi/src/q_config.c
@@ -860,12 +860,12 @@ static const struct cfgelem root_cfgelem = {
static const struct unit unittab_duration[] = {
{ "ns", 1 },
- { "us", 1000 },
- { "ms", T_MILLISECOND },
- { "s", T_SECOND },
- { "min", 60 * T_SECOND },
- { "hr", 3600 * T_SECOND },
- { "day", 24 * 3600 * T_SECOND },
+ { "us", DDS_USECS (1) },
+ { "ms", DDS_MSECS (1) },
+ { "s", DDS_SECS (1) },
+ { "min", DDS_SECS (60) },
+ { "hr", DDS_SECS (3600) },
+ { "day", DDS_SECS (24 * 3600) },
{ NULL, 0 }
};
@@ -1919,22 +1919,22 @@ static enum update_result uf_duration_inf (struct cfgst *cfgst, void *parent, st
static enum update_result uf_duration_ms_1hr (struct cfgst *cfgst, void *parent, struct cfgelem const * const cfgelem, UNUSED_ARG (int first), const char *value)
{
- return uf_duration_gen (cfgst, parent, cfgelem, value, T_MILLISECOND, 0, 3600 * T_SECOND);
+ return uf_duration_gen (cfgst, parent, cfgelem, value, DDS_MSECS (1), 0, DDS_SECS (3600));
}
static enum update_result uf_duration_ms_1s (struct cfgst *cfgst, void *parent, struct cfgelem const * const cfgelem, UNUSED_ARG (int first), const char *value)
{
- return uf_duration_gen (cfgst, parent, cfgelem, value, T_MILLISECOND, 0, T_SECOND);
+ return uf_duration_gen (cfgst, parent, cfgelem, value, DDS_MSECS (1), 0, DDS_SECS (1));
}
static enum update_result uf_duration_us_1s (struct cfgst *cfgst, void *parent, struct cfgelem const * const cfgelem, UNUSED_ARG (int first), const char *value)
{
- return uf_duration_gen (cfgst, parent, cfgelem, value, 1000, 0, T_SECOND);
+ return uf_duration_gen (cfgst, parent, cfgelem, value, DDS_USECS (1), 0, DDS_SECS (1));
}
static enum update_result uf_duration_100ms_1hr (struct cfgst *cfgst, void *parent, struct cfgelem const * const cfgelem, UNUSED_ARG (int first), const char *value)
{
- return uf_duration_gen (cfgst, parent, cfgelem, value, 0, 100 * T_MILLISECOND, 3600 * T_SECOND);
+ return uf_duration_gen (cfgst, parent, cfgelem, value, 0, DDS_MSECS (100), DDS_SECS (3600));
}
static void pf_duration (struct cfgst *cfgst, void *parent, struct cfgelem const * const cfgelem, uint32_t sources)
@@ -2578,7 +2578,7 @@ static int set_default_channel (struct config *cfg)
c->next = NULL;
c->name = ddsrt_strdup ("user");
c->priority = 0;
- c->resolution = 1 * T_MILLISECOND;
+ c->resolution = DDS_MSECS (1);
#ifdef DDSI_INCLUDE_BANDWIDTH_LIMITING
c->data_bandwidth_limit = 0;
c->auxiliary_bandwidth_limit = 0;
diff --git a/src/core/ddsi/src/q_ddsi_discovery.c b/src/core/ddsi/src/q_ddsi_discovery.c
index f893b98..f758125 100644
--- a/src/core/ddsi/src/q_ddsi_discovery.c
+++ b/src/core/ddsi/src/q_ddsi_discovery.c
@@ -628,7 +628,7 @@ static int handle_SPDP_alive (const struct receiver_state *rst, seqno_t seq, nn_
else
{
GVLOGDISC (" (PARTICIPANT_LEASE_DURATION defaulting to 100s)");
- lease_duration = 100 * T_SECOND;
+ lease_duration = DDS_SECS (100);
}
if (datap->present & PP_PRISMTECH_PARTICIPANT_VERSION_INFO) {
diff --git a/src/core/ddsi/src/q_entity.c b/src/core/ddsi/src/q_entity.c
index cf587ea..6a34aaf 100644
--- a/src/core/ddsi/src/q_entity.c
+++ b/src/core/ddsi/src/q_entity.c
@@ -806,7 +806,7 @@ dds_return_t new_participant_guid (const ddsi_guid_t *ppguid, struct ddsi_domain
fire before the calls return. If the initial sample wasn't
accepted, all is lost, but we continue nonetheless, even though
the participant won't be able to discover or be discovered. */
- pp->spdp_xevent = qxev_spdp (gv->xevents, add_duration_to_mtime (now_mt (), 100 * T_MILLISECOND), &pp->e.guid, NULL);
+ pp->spdp_xevent = qxev_spdp (gv->xevents, add_duration_to_mtime (now_mt (), DDS_MSECS (100)), &pp->e.guid, NULL);
}
{
@@ -1908,7 +1908,7 @@ static void writer_add_connection (struct writer *wr, struct proxy_reader *prd)
ensure a heartbeat is scheduled soon. */
if (wr->heartbeat_xevent)
{
- const int64_t delta = 1 * T_MILLISECOND;
+ const int64_t delta = DDS_MSECS (1);
const nn_mtime_t tnext = add_duration_to_mtime (now_mt (), delta);
ddsrt_mutex_lock (&wr->e.lock);
/* To make sure that we keep sending heartbeats at a higher rate
@@ -2185,11 +2185,10 @@ static void proxy_writer_add_connection (struct proxy_writer *pwr, struct reader
}
m->count = init_count;
/* Spec says we may send a pre-emptive AckNack (8.4.2.3.4), hence we
- schedule it for the configured delay * T_MILLISECOND. From then
- on it it'll keep sending pre-emptive ones until the proxy writer
- receives a heartbeat. (We really only need a pre-emptive AckNack
- per proxy writer, but hopefully it won't make that much of a
- difference in practice.) */
+ schedule it for the configured delay. From then on it it'll keep
+ sending pre-emptive ones until the proxy writer receives a heartbeat.
+ (We really only need a pre-emptive AckNack per proxy writer, but
+ hopefully it won't make that much of a difference in practice.) */
if (rd->reliable)
{
m->acknack_xevent = qxev_acknack (pwr->evq, add_duration_to_mtime (tnow, pwr->e.gv->config.preemptive_ack_delay), &pwr->e.guid, &rd->e.guid);
diff --git a/src/core/ddsi/src/q_gc.c b/src/core/ddsi/src/q_gc.c
index 4444112..8d205b5 100644
--- a/src/core/ddsi/src/q_gc.c
+++ b/src/core/ddsi/src/q_gc.c
@@ -91,8 +91,8 @@ static uint32_t gcreq_queue_thread (struct gcreq_queue *q)
struct thread_state1 * const ts1 = lookup_thread_state ();
nn_mtime_t next_thread_cputime = { 0 };
nn_mtime_t t_trigger_recv_threads = { 0 };
- int64_t shortsleep = 1 * T_MILLISECOND;
- int64_t delay = T_MILLISECOND; /* force evaluation after startup */
+ int64_t shortsleep = DDS_MSECS (1);
+ int64_t delay = DDS_MSECS (1); /* force evaluation after startup */
struct gcreq *gcreq = NULL;
int trace_shortsleep = 1;
ddsrt_mutex_lock (&q->lock);
diff --git a/src/core/ddsi/src/q_init.c b/src/core/ddsi/src/q_init.c
index 2de55a2..13173eb 100644
--- a/src/core/ddsi/src/q_init.c
+++ b/src/core/ddsi/src/q_init.c
@@ -130,7 +130,7 @@ static void make_builtin_endpoint_xqos (dds_qos_t *q, const dds_qos_t *template)
{
ddsi_xqos_copy (q, template);
q->reliability.kind = DDS_RELIABILITY_RELIABLE;
- q->reliability.max_blocking_time = 100 * T_MILLISECOND;
+ q->reliability.max_blocking_time = DDS_MSECS (100);
q->durability.kind = DDS_DURABILITY_TRANSIENT_LOCAL;
}
@@ -734,7 +734,7 @@ static void wait_for_receive_threads_helper (struct xevent *xev, void *varg, nn_
if (arg->count++ == arg->gv->config.recv_thread_stop_maxretries)
abort ();
trigger_recv_threads (arg->gv);
- (void) resched_xevent_if_earlier (xev, add_duration_to_mtime (tnow, T_SECOND));
+ (void) resched_xevent_if_earlier (xev, add_duration_to_mtime (tnow, DDS_SECS (1)));
}
static void wait_for_receive_threads (struct ddsi_domaingv *gv)
@@ -743,7 +743,7 @@ static void wait_for_receive_threads (struct ddsi_domaingv *gv)
struct wait_for_receive_threads_helper_arg cbarg;
cbarg.gv = gv;
cbarg.count = 0;
- if ((trigev = qxev_callback (gv->xevents, add_duration_to_mtime (now_mt (), T_SECOND), wait_for_receive_threads_helper, &cbarg)) == NULL)
+ if ((trigev = qxev_callback (gv->xevents, add_duration_to_mtime (now_mt (), DDS_SECS (1)), wait_for_receive_threads_helper, &cbarg)) == NULL)
{
/* retrying is to deal a packet geting lost because the socket buffer is full or because the
macOS firewall (and perhaps others) likes to ask if the process is allowed to receive data,
diff --git a/src/core/ddsi/src/q_lease.c b/src/core/ddsi/src/q_lease.c
index e6e1747..0469a46 100644
--- a/src/core/ddsi/src/q_lease.c
+++ b/src/core/ddsi/src/q_lease.c
@@ -273,7 +273,7 @@ int64_t check_and_handle_lease_expiration (struct ddsi_domaingv *gv, nn_etime_t
entidx_lookup_proxy_participant_guid (gv->entity_index, &proxypp->privileged_pp_guid) != NULL)
{
GVLOGDISC ("but postponing because privileged pp "PGUIDFMT" is still live\n", PGUID (proxypp->privileged_pp_guid));
- l->tsched = add_duration_to_etime (tnowE, 200 * T_MILLISECOND);
+ l->tsched = add_duration_to_etime (tnowE, DDS_MSECS (200));
ddsrt_fibheap_insert (&lease_fhdef, &gv->leaseheap, l);
continue;
}
diff --git a/src/core/ddsi/src/q_receive.c b/src/core/ddsi/src/q_receive.c
index 07cb3cd..54e5d7b 100644
--- a/src/core/ddsi/src/q_receive.c
+++ b/src/core/ddsi/src/q_receive.c
@@ -603,7 +603,7 @@ static int accept_ack_or_hb_w_timeout (nn_count_t new_count, nn_count_t *exp_cou
This combined procedure should give the best of all worlds, and
is not more expensive in the common case. */
- const int64_t timeout = 2 * T_SECOND;
+ const int64_t timeout = DDS_SECS (2);
if (new_count < *exp_count && tnow.v - t_last_accepted->v < timeout && !force_accept)
return 0;
@@ -714,7 +714,7 @@ static int handle_AckNack (struct receiver_state *rst, nn_etime_t tnow, const Ac
{
nn_wctime_t tstamp_now = now ();
nn_lat_estim_update (&rn->hb_to_ack_latency, tstamp_now.v - timestamp.v);
- if ((rst->gv->logconfig.c.mask & DDS_LC_TRACE) && tstamp_now.v > rn->hb_to_ack_latency_tlastlog.v + 10 * T_SECOND)
+ if ((rst->gv->logconfig.c.mask & DDS_LC_TRACE) && tstamp_now.v > rn->hb_to_ack_latency_tlastlog.v + DDS_SECS (10))
{
nn_lat_estim_log (DDS_LC_TRACE, &rst->gv->logconfig, NULL, &rn->hb_to_ack_latency);
rn->hb_to_ack_latency_tlastlog = tstamp_now;
diff --git a/src/core/ddsi/src/q_time.c b/src/core/ddsi/src/q_time.c
index 4fe4e69..d25dd02 100644
--- a/src/core/ddsi/src/q_time.c
+++ b/src/core/ddsi/src/q_time.c
@@ -49,8 +49,8 @@ nn_etime_t now_et (void)
static void time_to_sec_usec (int32_t * __restrict sec, int32_t * __restrict usec, int64_t t)
{
- *sec = (int32_t) (t / T_SECOND);
- *usec = (int32_t) (t % T_SECOND) / 1000;
+ *sec = (int32_t) (t / DDS_NSECS_IN_SEC);
+ *usec = (int32_t) (t % DDS_NSECS_IN_SEC) / 1000;
}
void mtime_to_sec_usec (int32_t * __restrict sec, int32_t * __restrict usec, nn_mtime_t t)
@@ -142,9 +142,9 @@ static ddsi_time_t nn_to_ddsi_time (int64_t t)
because that would break backwards compatibility, but round-to-nearest
of the inverse is correctly rounded anyway, so it shouldn't ever matter. */
ddsi_time_t x;
- int ns = (int) (t % T_SECOND);
- x.seconds = (int) (t / T_SECOND);
- x.fraction = (unsigned) (((T_SECOND-1) + ((int64_t) ns << 32)) / T_SECOND);
+ int ns = (int) (t % DDS_NSECS_IN_SEC);
+ x.seconds = (int) (t / DDS_NSECS_IN_SEC);
+ x.fraction = (unsigned) (((DDS_NSECS_IN_SEC-1) + ((int64_t) ns << 32)) / DDS_NSECS_IN_SEC);
return x;
}
}
@@ -161,8 +161,8 @@ static int64_t nn_from_ddsi_time (ddsi_time_t x)
else
{
/* Round-to-nearest conversion of DDSI time fraction to nanoseconds */
- int ns = (int) (((int64_t) 2147483648u + (int64_t) x.fraction * T_SECOND) >> 32);
- return x.seconds * (int64_t) T_SECOND + ns;
+ int ns = (int) (((int64_t) 2147483648u + (int64_t) x.fraction * DDS_NSECS_IN_SEC) >> 32);
+ return x.seconds * DDS_NSECS_IN_SEC + ns;
}
}
diff --git a/src/core/ddsi/src/q_transmit.c b/src/core/ddsi/src/q_transmit.c
index ef41d6d..79cb661 100644
--- a/src/core/ddsi/src/q_transmit.c
+++ b/src/core/ddsi/src/q_transmit.c
@@ -1072,7 +1072,7 @@ static int maybe_grow_whc (struct writer *wr)
if (!wr->retransmitting && gv->config.whc_adaptive && wr->whc_high < gv->config.whc_highwater_mark)
{
nn_etime_t tnow = now_et();
- nn_etime_t tgrow = add_duration_to_etime (wr->t_whc_high_upd, 10 * T_MILLISECOND);
+ nn_etime_t tgrow = add_duration_to_etime (wr->t_whc_high_upd, DDS_MSECS (10));
if (tnow.v >= tgrow.v)
{
uint32_t m = (gv->config.whc_highwater_mark - wr->whc_high) / 32;
diff --git a/src/core/ddsi/src/q_xevent.c b/src/core/ddsi/src/q_xevent.c
index 7860d75..4fa7554 100644
--- a/src/core/ddsi/src/q_xevent.c
+++ b/src/core/ddsi/src/q_xevent.c
@@ -913,12 +913,12 @@ static void handle_xevk_acknack (UNUSED_ARG (struct nn_xpack *xp), struct xevent
msg = NULL;
}
- if (!pwr->have_seen_heartbeat && tnow.v - rwn->tcreate.v <= 300 * T_SECOND)
+ if (!pwr->have_seen_heartbeat && tnow.v - rwn->tcreate.v <= DDS_SECS (300))
{
/* Force pre-emptive AckNacks out until we receive a heartbeat,
but let the frequency drop over time and stop after a couple
of minutes. */
- int intv, age = (int) ((tnow.v - rwn->tcreate.v) / T_SECOND + 1);
+ int intv, age = (int) ((tnow.v - rwn->tcreate.v) / DDS_NSECS_IN_SEC + 1);
if (age <= 10)
intv = 1;
else if (age <= 60)
@@ -927,7 +927,7 @@ static void handle_xevk_acknack (UNUSED_ARG (struct nn_xpack *xp), struct xevent
intv = 5;
else
intv = 10;
- (void) resched_xevent_if_earlier (ev, add_duration_to_mtime (tnow, intv * T_SECOND));
+ (void) resched_xevent_if_earlier (ev, add_duration_to_mtime (tnow, intv * DDS_NSECS_IN_SEC));
}
ddsrt_mutex_unlock (&pwr->e.lock);
@@ -940,7 +940,7 @@ static void handle_xevk_acknack (UNUSED_ARG (struct nn_xpack *xp), struct xevent
outofmem:
/* What to do if out of memory? Crash or burn? */
ddsrt_mutex_unlock (&pwr->e.lock);
- (void) resched_xevent_if_earlier (ev, add_duration_to_mtime (tnow, 100 * T_MILLISECOND));
+ (void) resched_xevent_if_earlier (ev, add_duration_to_mtime (tnow, DDS_MSECS (100)));
}
static bool resend_spdp_sample_by_guid_key (struct writer *wr, const ddsi_guid_t *guid, struct proxy_reader *prd)
@@ -1056,11 +1056,11 @@ static void handle_xevk_spdp (UNUSED_ARG (struct nn_xpack *xp), struct xevent *e
{
/* Directed events are used to send SPDP packets to newly
discovered peers, and used just once. */
- if (--ev->u.spdp.directed == 0 || gv->config.spdp_interval < T_SECOND || pp->lease_duration < T_SECOND)
+ if (--ev->u.spdp.directed == 0 || gv->config.spdp_interval < DDS_SECS (1) || pp->lease_duration < DDS_SECS (1))
delete_xevent (ev);
else
{
- nn_mtime_t tnext = add_duration_to_mtime (tnow, T_SECOND);
+ nn_mtime_t tnext = add_duration_to_mtime (tnow, DDS_SECS (1));
GVTRACE ("xmit spdp "PGUIDFMT" to %"PRIx32":%"PRIx32":%"PRIx32":%x (resched %gs)\n",
PGUID (pp->e.guid),
PGUIDPREFIX (ev->u.spdp.dest_proxypp_guid_prefix), NN_ENTITYID_SPDP_BUILTIN_PARTICIPANT_READER,
@@ -1073,17 +1073,17 @@ static void handle_xevk_spdp (UNUSED_ARG (struct nn_xpack *xp), struct xevent *e
/* schedule next when 80% of the interval has elapsed, or 2s
before the lease ends, whichever comes first (similar to PMD),
but never wait longer than spdp_interval */
- const dds_duration_t mindelta = 10 * T_MILLISECOND;
+ const dds_duration_t mindelta = DDS_MSECS (10);
const dds_duration_t ldur = pp->lease_duration;
nn_mtime_t tnext;
int64_t intv;
if (ldur < 5 * mindelta / 4)
intv = mindelta;
- else if (ldur < 10 * T_SECOND)
+ else if (ldur < DDS_SECS (10))
intv = 4 * ldur / 5;
else
- intv = ldur - 2 * T_SECOND;
+ intv = ldur - DDS_SECS (2);
if (intv > gv->config.spdp_interval)
intv = gv->config.spdp_interval;
@@ -1120,8 +1120,8 @@ static void handle_xevk_pmd_update (struct thread_state1 * const ts1, struct nn_
{
/* schedule next when 80% of the interval has elapsed, or 2s
before the lease ends, whichever comes first */
- if (intv >= 10 * T_SECOND)
- tnext.v = tnow.v + intv - 2 * T_SECOND;
+ if (intv >= DDS_SECS (10))
+ tnext.v = tnow.v + intv - DDS_SECS (2);
else
tnext.v = tnow.v + 4 * intv / 5;
GVTRACE ("resched pmd("PGUIDFMT"): %gs\n", PGUID (pp->e.guid), (double)(tnext.v - tnow.v) / 1e9);
diff --git a/src/core/ddsi/src/q_xmsg.c b/src/core/ddsi/src/q_xmsg.c
index dffe31a..ef76893 100644
--- a/src/core/ddsi/src/q_xmsg.c
+++ b/src/core/ddsi/src/q_xmsg.c
@@ -885,8 +885,8 @@ static void nn_xmsg_chain_add (struct nn_xmsg_chain *chain, struct nn_xmsg *m)
* If data is send too fast, a sleep is inserted to get the used bandwidth at the configured rate.
*/
-#define NN_BW_LIMIT_MAX_BUFFER (-30 * T_MILLISECOND)
-#define NN_BW_LIMIT_MIN_SLEEP (2 * T_MILLISECOND)
+#define NN_BW_LIMIT_MAX_BUFFER (DDS_MSECS (-30))
+#define NN_BW_LIMIT_MIN_SLEEP (DDS_MSECS (2))
static void nn_bw_limit_sleep_if_needed (struct ddsi_domaingv const * const gv, struct nn_bw_limiter *this, ssize_t size)
{
if ( this->bandwidth > 0 ) {
@@ -898,7 +898,7 @@ static void nn_bw_limit_sleep_if_needed (struct ddsi_domaingv const * const gv,
actual_interval = tnow.v - this->last_update.v;
this->last_update = tnow;
- target_interval = T_SECOND*size/this->bandwidth;
+ target_interval = DDS_NSECS_IN_SEC*size/this->bandwidth;
this->balance += (target_interval - actual_interval);
diff --git a/src/tools/pubsub/pubsub.c b/src/tools/pubsub/pubsub.c
index f5d0b70..b83e748 100644
--- a/src/tools/pubsub/pubsub.c
+++ b/src/tools/pubsub/pubsub.c
@@ -77,7 +77,6 @@ static enum tgprint_mode printmode = TGPM_FIELDS;
static unsigned print_metadata = PM_STATE;
static int printtype = 0;
-#define T_SECOND ((int64_t) 1000000000)
struct tstamp_t {
int isabs;
int64_t t;
@@ -351,7 +350,7 @@ static int read_int_w_tstamp(struct tstamp_t *tstamp, char *buf, int bufsize, in
posoff = 1;
}
if (read_int(buf, bufsize, pos + posoff, 1))
- tstamp->t = atoi(buf + pos) * T_SECOND;
+ tstamp->t = atoi(buf + pos) * DDS_NSECS_IN_SEC;
else
return 0;
while ((c = getc(stdin)) != EOF && isspace((unsigned char) c))
@@ -1256,7 +1255,7 @@ static char *pub_do_nonarb(const struct writerspec *spec, uint32_t *seq) {
tstamp = dds_time();
tstamp_spec.t += tstamp;
}
- tstamp = (tstamp_spec.t % T_SECOND) + ((int) (tstamp_spec.t / T_SECOND) * DDS_NSECS_IN_SEC);
+ tstamp = (tstamp_spec.t % DDS_NSECS_IN_SEC) + ((int) (tstamp_spec.t / DDS_NSECS_IN_SEC) * DDS_NSECS_IN_SEC);
if ((result = fn(spec->wr, &d, tstamp)) != DDS_RETCODE_OK) {
printf ("%s %d: error %d (%s)\n", get_write_operstr(command), k, (int) result, dds_err_str(result));
if (flushflag) {
@@ -1360,7 +1359,7 @@ static char *pub_do_nonarb(const struct writerspec *spec, uint32_t *seq) {
// command = *line++;
// if (*line == '@') {
// if (*++line == '=') { ++line; tstamp_spec.isabs = 1; }
-// tstamp_spec.t = T_SECOND * strtol(line, (char **) &line, 10);
+// tstamp_spec.t = DDS_NSECS_IN_SEC * strtol(line, (char **) &line, 10);
// }
// case '{': {
// write_oper_t fn = get_write_oper(command);
@@ -1373,10 +1372,10 @@ static char *pub_do_nonarb(const struct writerspec *spec, uint32_t *seq) {
// int diddodup = 0;
// if (!tstamp_spec.isabs) {
// DDS_DomainParticipant_get_current_time(dp, &tstamp);
-// tstamp_spec.t += tstamp.sec * T_SECOND + tstamp.nanosec;
+// tstamp_spec.t += tstamp.sec * DDS_NSECS_IN_SEC + tstamp.nanosec;
// }
-// tstamp.sec = (int) (tstamp_spec.t / T_SECOND);
-// tstamp.nanosec = (unsigned) (tstamp_spec.t % T_SECOND);
+// tstamp.sec = (int) (tstamp_spec.t / DDS_NSECS_IN_SEC);
+// tstamp.nanosec = (unsigned) (tstamp_spec.t % DDS_NSECS_IN_SEC);
// line = endp;
// result = fn(spec->wr, arb, DDS_HANDLE_NIL, &tstamp);
// if (result == DDS_RETCODE_OK && spec->dupwr) {
@@ -2684,8 +2683,8 @@ int main(int argc, char *argv[]) {
// }
// tnow = dds_time();
// if (m != 0 && tnow < tend) {
-// uint64_t tdelta = (tend-tnow) < T_SECOND/10 ? tend-tnow : T_SECOND/10;
-// os_time delay = { (os_timeSec) (tdelta / T_SECOND), (os_int32) (tdelta % T_SECOND)};
+// uint64_t tdelta = (tend-tnow) < DDS_NSECS_IN_SEC/10 ? tend-tnow : DDS_NSECS_IN_SEC/10;
+// os_time delay = { (os_timeSec) (tdelta / DDS_NSECS_IN_SEC), (os_int32) (tdelta % DDS_NSECS_IN_SEC)};
// os_nanoSleep(delay);
// tnow = dds_time();
// }
From 77c3545f5e8a20587478c59368a7b24765dc0248 Mon Sep 17 00:00:00 2001
From: Erik Boasson
Date: Mon, 9 Mar 2020 14:33:31 +0100
Subject: [PATCH 24/30] Move all time support to ddsrt
* Move wctime, mtime, etime types to ddsrt
* Add ddsrt_time_wallclock
* Change ddsrt_time_monontic, elapsed to use mtime, etime types
* Remove now, now_mt, now_et
* Rename X_to_sec_usec to ddsrt_X_to_sec_usec
* add_duration_to_X to ddsrt_X_add_duration (to be in line with the
existing ddsrt_time_add_duration)
* elimination of ddsrt/timeconv.h, it added more in the way of
complications than it did in making things more elegant
* rename of q_time.[ch] to ddsi_time.[ch]: that now only deals with DDSI
timestamps and durations on the wire
Signed-off-by: Erik Boasson
---
src/core/ddsc/src/dds__builtin.h | 2 +-
src/core/ddsc/src/dds__rhc_default.h | 4 +-
src/core/ddsc/src/dds_builtin.c | 4 +-
src/core/ddsc/src/dds_domain.c | 2 +-
src/core/ddsc/src/dds_rhc_default.c | 26 +--
src/core/ddsc/src/dds_whc.c | 23 ++-
src/core/ddsc/src/dds_whc_builtintopic.c | 2 +-
src/core/ddsc/src/dds_write.c | 6 +-
src/core/ddsi/CMakeLists.txt | 4 +-
.../include/dds/ddsi/ddsi_builtin_topic_if.h | 5 +-
.../ddsi/include/dds/ddsi/ddsi_deadline.h | 14 +-
.../ddsi/include/dds/ddsi/ddsi_domaingv.h | 2 +-
.../ddsi/include/dds/ddsi/ddsi_lifespan.h | 8 +-
src/core/ddsi/include/dds/ddsi/ddsi_pmd.h | 4 +-
src/core/ddsi/include/dds/ddsi/ddsi_rhc.h | 4 +-
src/core/ddsi/include/dds/ddsi/ddsi_serdata.h | 5 +-
src/core/ddsi/include/dds/ddsi/ddsi_time.h | 44 +++++
src/core/ddsi/include/dds/ddsi/q_entity.h | 42 ++--
src/core/ddsi/include/dds/ddsi/q_hbcontrol.h | 20 +-
src/core/ddsi/include/dds/ddsi/q_lease.h | 11 +-
src/core/ddsi/include/dds/ddsi/q_log.h | 4 +-
src/core/ddsi/include/dds/ddsi/q_pcap.h | 6 +-
src/core/ddsi/include/dds/ddsi/q_protocol.h | 2 +-
src/core/ddsi/include/dds/ddsi/q_radmin.h | 4 +-
src/core/ddsi/include/dds/ddsi/q_time.h | 71 -------
src/core/ddsi/include/dds/ddsi/q_whc.h | 8 +-
src/core/ddsi/include/dds/ddsi/q_xevent.h | 14 +-
src/core/ddsi/include/dds/ddsi/q_xmsg.h | 2 +-
src/core/ddsi/src/ddsi_deadline.c | 28 +--
src/core/ddsi/src/ddsi_lifespan.c | 15 +-
src/core/ddsi/src/ddsi_plist.c | 10 +-
src/core/ddsi/src/ddsi_pmd.c | 9 +-
src/core/ddsi/src/ddsi_threadmon.c | 6 +-
src/core/ddsi/src/ddsi_time.c | 70 +++++++
src/core/ddsi/src/ddsi_udp.c | 4 +-
src/core/ddsi/src/q_ddsi_discovery.c | 34 ++--
src/core/ddsi/src/q_debmon.c | 1 -
src/core/ddsi/src/q_entity.c | 177 +++++++++--------
src/core/ddsi/src/q_gc.c | 9 +-
src/core/ddsi/src/q_init.c | 18 +-
src/core/ddsi/src/q_lease.c | 20 +-
src/core/ddsi/src/q_pcap.c | 9 +-
src/core/ddsi/src/q_qosmatch.c | 1 -
src/core/ddsi/src/q_radmin.c | 2 +-
src/core/ddsi/src/q_receive.c | 70 +++----
src/core/ddsi/src/q_time.c | 185 ------------------
src/core/ddsi/src/q_transmit.c | 51 +++--
src/core/ddsi/src/q_whc.c | 3 +-
src/core/ddsi/src/q_xevent.c | 95 +++++----
src/core/ddsi/src/q_xmsg.c | 4 +-
src/core/xtests/rhc_torture/rhc_torture.c | 10 +-
src/ddsrt/include/dds/ddsrt/time.h | 155 ++++++++++++++-
src/ddsrt/src/process/windows/process.c | 1 -
src/ddsrt/src/sync/freertos/sync.c | 2 +-
src/ddsrt/src/sync/posix/sync.c | 2 +-
src/ddsrt/src/sync/solaris2.6/sync.c | 2 +-
src/ddsrt/src/sync/windows/sync.c | 2 +-
src/ddsrt/src/time.c | 29 ++-
src/ddsrt/src/time/darwin/time.c | 18 +-
src/ddsrt/src/time/freertos/time.c | 13 +-
.../src/time/include/dds/ddsrt/timeconv.h | 51 -----
src/ddsrt/src/time/posix/time.c | 21 +-
src/ddsrt/src/time/solaris2.6/time.c | 14 +-
src/ddsrt/src/time/windows/time.c | 15 +-
src/ddsrt/tests/hopscotch.c | 4 +-
65 files changed, 757 insertions(+), 746 deletions(-)
create mode 100644 src/core/ddsi/include/dds/ddsi/ddsi_time.h
delete mode 100644 src/core/ddsi/include/dds/ddsi/q_time.h
create mode 100644 src/core/ddsi/src/ddsi_time.c
delete mode 100644 src/core/ddsi/src/q_time.c
diff --git a/src/core/ddsc/src/dds__builtin.h b/src/core/ddsc/src/dds__builtin.h
index 1c1f80c..5aed56f 100644
--- a/src/core/ddsc/src/dds__builtin.h
+++ b/src/core/ddsc/src/dds__builtin.h
@@ -32,7 +32,7 @@ void dds__builtin_init (struct dds_domain *dom);
void dds__builtin_fini (struct dds_domain *dom);
struct entity_common;
-struct ddsi_serdata *dds__builtin_make_sample (const struct entity_common *e, nn_wctime_t timestamp, bool alive);
+struct ddsi_serdata *dds__builtin_make_sample (const struct entity_common *e, ddsrt_wctime_t timestamp, bool alive);
#if defined (__cplusplus)
}
diff --git a/src/core/ddsc/src/dds__rhc_default.h b/src/core/ddsc/src/dds__rhc_default.h
index cf8fab3..9e3f65a 100644
--- a/src/core/ddsc/src/dds__rhc_default.h
+++ b/src/core/ddsc/src/dds__rhc_default.h
@@ -26,10 +26,10 @@ struct rhc_sample;
DDS_EXPORT struct dds_rhc *dds_rhc_default_new_xchecks (dds_reader *reader, struct ddsi_domaingv *gv, const struct ddsi_sertopic *topic, bool xchecks);
DDS_EXPORT struct dds_rhc *dds_rhc_default_new (struct dds_reader *reader, const struct ddsi_sertopic *topic);
#ifdef DDSI_INCLUDE_LIFESPAN
-DDS_EXPORT nn_mtime_t dds_rhc_default_sample_expired_cb(void *hc, nn_mtime_t tnow);
+DDS_EXPORT ddsrt_mtime_t dds_rhc_default_sample_expired_cb(void *hc, ddsrt_mtime_t tnow);
#endif
#ifdef DDSI_INCLUDE_DEADLINE_MISSED
-DDS_EXPORT nn_mtime_t dds_rhc_default_deadline_missed_cb(void *hc, nn_mtime_t tnow);
+DDS_EXPORT ddsrt_mtime_t dds_rhc_default_deadline_missed_cb(void *hc, ddsrt_mtime_t tnow);
#endif
#if defined (__cplusplus)
diff --git a/src/core/ddsc/src/dds_builtin.c b/src/core/ddsc/src/dds_builtin.c
index ec94bef..22a76a5 100644
--- a/src/core/ddsc/src/dds_builtin.c
+++ b/src/core/ddsc/src/dds_builtin.c
@@ -189,7 +189,7 @@ static struct ddsi_tkmap_instance *dds__builtin_get_tkmap_entry (const struct dd
return tk;
}
-struct ddsi_serdata *dds__builtin_make_sample (const struct entity_common *e, nn_wctime_t timestamp, bool alive)
+struct ddsi_serdata *dds__builtin_make_sample (const struct entity_common *e, ddsrt_wctime_t timestamp, bool alive)
{
/* initialize to avoid gcc warning ultimately caused by C's horrible type system */
struct dds_domain *dom = e->gv->builtin_topic_interface->arg;
@@ -219,7 +219,7 @@ struct ddsi_serdata *dds__builtin_make_sample (const struct entity_common *e, nn
return serdata;
}
-static void dds__builtin_write (const struct entity_common *e, nn_wctime_t timestamp, bool alive, void *vdomain)
+static void dds__builtin_write (const struct entity_common *e, ddsrt_wctime_t timestamp, bool alive, void *vdomain)
{
struct dds_domain *dom = vdomain;
if (dds__builtin_is_visible (&e->guid, get_entity_vendorid (e), dom))
diff --git a/src/core/ddsc/src/dds_domain.c b/src/core/ddsc/src/dds_domain.c
index dcc25a3..eca5fdc 100644
--- a/src/core/ddsc/src/dds_domain.c
+++ b/src/core/ddsc/src/dds_domain.c
@@ -59,7 +59,7 @@ static dds_entity_t dds_domain_init (dds_domain *domain, dds_domainid_t domain_i
domain->m_entity.m_domain = domain;
domain->m_entity.m_iid = ddsi_iid_gen ();
- domain->gv.tstart = now ();
+ domain->gv.tstart = ddsrt_time_wallclock ();
/* | domain_id | domain id in config | result
+-----------+---------------------+----------
diff --git a/src/core/ddsc/src/dds_rhc_default.c b/src/core/ddsc/src/dds_rhc_default.c
index 7c68b68..50313ed 100644
--- a/src/core/ddsc/src/dds_rhc_default.c
+++ b/src/core/ddsc/src/dds_rhc_default.c
@@ -274,7 +274,7 @@ struct rhc_instance {
uint32_t no_writers_gen; /* __/ */
int32_t strength; /* "current" ownership strength */
ddsi_guid_t wr_guid; /* guid of last writer (if wr_iid != 0 then wr_guid is the corresponding guid, else undef) */
- nn_wctime_t tstamp; /* source time stamp of last update */
+ ddsrt_wctime_t tstamp; /* source time stamp of last update */
struct ddsrt_circlist_elem nonempty_list; /* links non-empty instances in arbitrary ordering */
#ifdef DDSI_INCLUDE_DEADLINE_MISSED
struct deadline_elem deadline; /* element in deadline missed administration */
@@ -594,11 +594,11 @@ static void drop_expired_samples (struct dds_rhc_default *rhc, struct rhc_sample
TRACE (")\n");
}
-nn_mtime_t dds_rhc_default_sample_expired_cb(void *hc, nn_mtime_t tnow)
+ddsrt_mtime_t dds_rhc_default_sample_expired_cb(void *hc, ddsrt_mtime_t tnow)
{
struct dds_rhc_default *rhc = hc;
struct rhc_sample *sample;
- nn_mtime_t tnext;
+ ddsrt_mtime_t tnext;
ddsrt_mutex_lock (&rhc->lock);
while ((tnext = lifespan_next_expired_locked (&rhc->lifespan, tnow, (void **)&sample)).v == 0)
drop_expired_samples (rhc, sample);
@@ -608,11 +608,11 @@ nn_mtime_t dds_rhc_default_sample_expired_cb(void *hc, nn_mtime_t tnow)
#endif /* DDSI_INCLUDE_LIFESPAN */
#ifdef DDSI_INCLUDE_DEADLINE_MISSED
-nn_mtime_t dds_rhc_default_deadline_missed_cb(void *hc, nn_mtime_t tnow)
+ddsrt_mtime_t dds_rhc_default_deadline_missed_cb(void *hc, ddsrt_mtime_t tnow)
{
struct dds_rhc_default *rhc = hc;
void *vinst;
- nn_mtime_t tnext;
+ ddsrt_mtime_t tnext;
ddsrt_mutex_lock (&rhc->lock);
while ((tnext = deadline_next_missed_locked (&rhc->deadline, tnow, &vinst)).v == 0)
{
@@ -630,7 +630,7 @@ nn_mtime_t dds_rhc_default_deadline_missed_cb(void *hc, nn_mtime_t tnow)
dds_reader_status_cb (&rhc->reader->m_entity, &cb_data);
ddsrt_mutex_lock (&rhc->lock);
- tnow = now_mt ();
+ tnow = ddsrt_time_monotonic ();
}
ddsrt_mutex_unlock (&rhc->lock);
return tnext;
@@ -837,7 +837,7 @@ static void free_instance_rhc_free_wrap (void *vnode, void *varg)
static void dds_rhc_default_free (struct dds_rhc_default *rhc)
{
#ifdef DDSI_INCLUDE_LIFESPAN
- dds_rhc_default_sample_expired_cb (rhc, NN_MTIME_NEVER);
+ dds_rhc_default_sample_expired_cb (rhc, DDSRT_MTIME_NEVER);
lifespan_fini (&rhc->lifespan);
#endif
#ifdef DDSI_INCLUDE_DEADLINE_MISSED
@@ -1067,7 +1067,7 @@ static int inst_accepts_sample (const struct dds_rhc_default *rhc, const struct
return 1;
}
-static void update_inst (struct rhc_instance *inst, const struct ddsi_writer_info * __restrict wrinfo, bool wr_iid_valid, nn_wctime_t tstamp)
+static void update_inst (struct rhc_instance *inst, const struct ddsi_writer_info * __restrict wrinfo, bool wr_iid_valid, ddsrt_wctime_t tstamp)
{
inst->tstamp = tstamp;
inst->wr_iid_islive = wr_iid_valid;
@@ -1264,7 +1264,7 @@ static int rhc_unregister_isreg_w_sideeffects (struct dds_rhc_default *rhc, cons
}
}
-static int rhc_unregister_updateinst (struct dds_rhc_default *rhc, struct rhc_instance *inst, const struct ddsi_writer_info * __restrict wrinfo, nn_wctime_t tstamp, struct trigger_info_qcond *trig_qc, bool *nda)
+static int rhc_unregister_updateinst (struct dds_rhc_default *rhc, struct rhc_instance *inst, const struct ddsi_writer_info * __restrict wrinfo, ddsrt_wctime_t tstamp, struct trigger_info_qcond *trig_qc, bool *nda)
{
assert (inst->wrcount > 0);
@@ -1327,7 +1327,7 @@ static int rhc_unregister_updateinst (struct dds_rhc_default *rhc, struct rhc_in
}
}
-static bool dds_rhc_unregister (struct dds_rhc_default *rhc, struct rhc_instance *inst, const struct ddsi_writer_info * __restrict wrinfo, nn_wctime_t tstamp, struct trigger_info_post *post, struct trigger_info_qcond *trig_qc)
+static bool dds_rhc_unregister (struct dds_rhc_default *rhc, struct rhc_instance *inst, const struct ddsi_writer_info * __restrict wrinfo, ddsrt_wctime_t tstamp, struct trigger_info_post *post, struct trigger_info_qcond *trig_qc)
{
bool notify_data_available = false;
@@ -1384,7 +1384,7 @@ static struct rhc_instance *alloc_new_instance (struct dds_rhc_default *rhc, con
#ifdef DDSI_INCLUDE_DEADLINE_MISSED
if (!inst->isdisposed)
- deadline_register_instance_locked (&rhc->deadline, &inst->deadline, now_mt ());
+ deadline_register_instance_locked (&rhc->deadline, &inst->deadline, ddsrt_time_monotonic ());
#endif
return inst;
@@ -1598,7 +1598,7 @@ static bool dds_rhc_default_store (struct dds_rhc_default * __restrict rhc, cons
inst->disposed_gen++;
#ifdef DDSI_INCLUDE_DEADLINE_MISSED
if (!is_dispose)
- deadline_register_instance_locked (&rhc->deadline, &inst->deadline, now_mt ());
+ deadline_register_instance_locked (&rhc->deadline, &inst->deadline, ddsrt_time_monotonic ());
#endif
}
if (is_dispose)
@@ -1639,7 +1639,7 @@ static bool dds_rhc_default_store (struct dds_rhc_default * __restrict rhc, cons
{
inst->isdisposed = 0;
#ifdef DDSI_INCLUDE_DEADLINE_MISSED
- deadline_register_instance_locked (&rhc->deadline, &inst->deadline, now_mt ());
+ deadline_register_instance_locked (&rhc->deadline, &inst->deadline, ddsrt_time_monotonic ());
#endif
}
goto error_or_nochange;
diff --git a/src/core/ddsc/src/dds_whc.c b/src/core/ddsc/src/dds_whc.c
index d9b46e7..440746b 100644
--- a/src/core/ddsc/src/dds_whc.c
+++ b/src/core/ddsc/src/dds_whc.c
@@ -28,7 +28,6 @@
#include "dds/ddsi/q_unused.h"
#include "dds/ddsi/q_config.h"
#include "dds/ddsi/ddsi_tkmap.h"
-#include "dds/ddsi/q_time.h"
#include "dds/ddsi/q_rtps.h"
#include "dds/ddsi/q_freelist.h"
#include "dds/ddsi/ddsi_domaingv.h"
@@ -51,7 +50,7 @@ struct whc_node {
struct ddsi_plist *plist; /* 0 if nothing special */
unsigned unacked: 1; /* counted in whc::unacked_bytes iff 1 */
unsigned borrowed: 1; /* at most one can borrow it at any time */
- nn_mtime_t last_rexmit_ts;
+ ddsrt_mtime_t last_rexmit_ts;
uint32_t rexmit_count;
#ifdef DDSI_INCLUDE_LIFESPAN
struct lifespan_fhnode lifespan; /* fibheap node for lifespan */
@@ -155,7 +154,7 @@ static uint32_t whc_default_remove_acked_messages_full (struct whc_impl *whc, se
static uint32_t whc_default_remove_acked_messages (struct whc *whc, seqno_t max_drop_seq, struct whc_state *whcst, struct whc_node **deferred_free_list);
static void whc_default_free_deferred_free_list (struct whc *whc, struct whc_node *deferred_free_list);
static void whc_default_get_state (const struct whc *whc, struct whc_state *st);
-static int whc_default_insert (struct whc *whc, seqno_t max_drop_seq, seqno_t seq, nn_mtime_t exp, struct ddsi_plist *plist, struct ddsi_serdata *serdata, struct ddsi_tkmap_instance *tk);
+static int whc_default_insert (struct whc *whc, seqno_t max_drop_seq, seqno_t seq, ddsrt_mtime_t exp, struct ddsi_plist *plist, struct ddsi_serdata *serdata, struct ddsi_tkmap_instance *tk);
static seqno_t whc_default_next_seq (const struct whc *whc, seqno_t seq);
static bool whc_default_borrow_sample (const struct whc *whc, seqno_t seq, struct whc_borrowed_sample *sample);
static bool whc_default_borrow_sample_key (const struct whc *whc, const struct ddsi_serdata *serdata_key, struct whc_borrowed_sample *sample);
@@ -377,11 +376,11 @@ static struct whc_node *whc_findkey (const struct whc_impl *whc, const struct dd
}
#ifdef DDSI_INCLUDE_LIFESPAN
-static nn_mtime_t whc_sample_expired_cb(void *hc, nn_mtime_t tnow)
+static ddsrt_mtime_t whc_sample_expired_cb(void *hc, ddsrt_mtime_t tnow)
{
struct whc_impl *whc = hc;
void *sample;
- nn_mtime_t tnext;
+ ddsrt_mtime_t tnext;
ddsrt_mutex_lock (&whc->lock);
while ((tnext = lifespan_next_expired_locked (&whc->lifespan, tnow, &sample)).v == 0)
whc_delete_one (whc, sample);
@@ -392,11 +391,11 @@ static nn_mtime_t whc_sample_expired_cb(void *hc, nn_mtime_t tnow)
#endif
#ifdef DDSI_INCLUDE_DEADLINE_MISSED
-static nn_mtime_t whc_deadline_missed_cb(void *hc, nn_mtime_t tnow)
+static ddsrt_mtime_t whc_deadline_missed_cb(void *hc, ddsrt_mtime_t tnow)
{
struct whc_impl *whc = hc;
void *vidxnode;
- nn_mtime_t tnext;
+ ddsrt_mtime_t tnext;
ddsrt_mutex_lock (&whc->lock);
while ((tnext = deadline_next_missed_locked (&whc->deadline, tnow, &vidxnode)).v == 0)
{
@@ -412,7 +411,7 @@ static nn_mtime_t whc_deadline_missed_cb(void *hc, nn_mtime_t tnow)
dds_writer_status_cb (&whc->wrinfo.writer->m_entity, &cb_data);
ddsrt_mutex_lock (&whc->lock);
- tnow = now_mt ();
+ tnow = ddsrt_time_monotonic ();
}
ddsrt_mutex_unlock (&whc->lock);
return tnext;
@@ -510,7 +509,7 @@ void whc_default_free (struct whc *whc_generic)
check_whc (whc);
#ifdef DDSI_INCLUDE_LIFESPAN
- whc_sample_expired_cb (whc, NN_MTIME_NEVER);
+ whc_sample_expired_cb (whc, DDSRT_MTIME_NEVER);
lifespan_fini (&whc->lifespan);
#endif
@@ -1156,7 +1155,7 @@ static uint32_t whc_default_remove_acked_messages (struct whc *whc_generic, seqn
return cnt;
}
-static struct whc_node *whc_default_insert_seq (struct whc_impl *whc, seqno_t max_drop_seq, seqno_t seq, nn_mtime_t exp, struct ddsi_plist *plist, struct ddsi_serdata *serdata)
+static struct whc_node *whc_default_insert_seq (struct whc_impl *whc, seqno_t max_drop_seq, seqno_t seq, ddsrt_mtime_t exp, struct ddsi_plist *plist, struct ddsi_serdata *serdata)
{
struct whc_node *newn = NULL;
@@ -1228,7 +1227,7 @@ static struct whc_node *whc_default_insert_seq (struct whc_impl *whc, seqno_t ma
return newn;
}
-static int whc_default_insert (struct whc *whc_generic, seqno_t max_drop_seq, seqno_t seq, nn_mtime_t exp, struct ddsi_plist *plist, struct ddsi_serdata *serdata, struct ddsi_tkmap_instance *tk)
+static int whc_default_insert (struct whc *whc_generic, seqno_t max_drop_seq, seqno_t seq, ddsrt_mtime_t exp, struct ddsi_plist *plist, struct ddsi_serdata *serdata, struct ddsi_tkmap_instance *tk)
{
struct whc_impl * const whc = (struct whc_impl *)whc_generic;
struct whc_node *newn = NULL;
@@ -1364,7 +1363,7 @@ static int whc_default_insert (struct whc *whc_generic, seqno_t max_drop_seq, se
if (!ddsrt_hh_add (whc->idx_hash, idxn))
assert (0);
#ifdef DDSI_INCLUDE_DEADLINE_MISSED
- deadline_register_instance_locked (&whc->deadline, &idxn->deadline, now_mt ());
+ deadline_register_instance_locked (&whc->deadline, &idxn->deadline, ddsrt_time_monotonic ());
#endif
}
else
diff --git a/src/core/ddsc/src/dds_whc_builtintopic.c b/src/core/ddsc/src/dds_whc_builtintopic.c
index 361f515..a96d74d 100644
--- a/src/core/ddsc/src/dds_whc_builtintopic.c
+++ b/src/core/ddsc/src/dds_whc_builtintopic.c
@@ -143,7 +143,7 @@ static void bwhc_get_state (const struct whc *whc, struct whc_state *st)
st->unacked_bytes = 0;
}
-static int bwhc_insert (struct whc *whc, seqno_t max_drop_seq, seqno_t seq, nn_mtime_t exp, struct ddsi_plist *plist, struct ddsi_serdata *serdata, struct ddsi_tkmap_instance *tk)
+static int bwhc_insert (struct whc *whc, seqno_t max_drop_seq, seqno_t seq, ddsrt_mtime_t exp, struct ddsi_plist *plist, struct ddsi_serdata *serdata, struct ddsi_tkmap_instance *tk)
{
(void)whc;
(void)max_drop_seq;
diff --git a/src/core/ddsc/src/dds_write.c b/src/core/ddsc/src/dds_write.c
index 7519548..a2b978b 100644
--- a/src/core/ddsc/src/dds_write.c
+++ b/src/core/ddsc/src/dds_write.c
@@ -90,7 +90,7 @@ struct local_sourceinfo {
const struct ddsi_sertopic *src_topic;
struct ddsi_serdata *src_payload;
struct ddsi_tkmap_instance *src_tk;
- nn_mtime_t timeout;
+ ddsrt_mtime_t timeout;
};
static struct ddsi_serdata *local_make_sample (struct ddsi_tkmap_instance **tk, struct ddsi_domaingv *gv, struct ddsi_sertopic const * const topic, void *vsourceinfo)
@@ -136,9 +136,9 @@ static dds_return_t local_on_delivery_failure_fastpath (struct entity_common *so
assert (source_entity->kind == EK_WRITER);
struct writer *wr = (struct writer *) source_entity;
struct local_sourceinfo *si = vsourceinfo;
- nn_mtime_t tnow = now_mt ();
+ ddsrt_mtime_t tnow = ddsrt_time_monotonic ();
if (si->timeout.v == 0)
- si->timeout = add_duration_to_mtime (tnow, wr->xqos->reliability.max_blocking_time);
+ si->timeout = ddsrt_mtime_add_duration (tnow, wr->xqos->reliability.max_blocking_time);
if (tnow.v >= si->timeout.v)
return DDS_RETCODE_TIMEOUT;
else
diff --git a/src/core/ddsi/CMakeLists.txt b/src/core/ddsi/CMakeLists.txt
index 87b9c47..af84a9b 100644
--- a/src/core/ddsi/CMakeLists.txt
+++ b/src/core/ddsi/CMakeLists.txt
@@ -34,6 +34,7 @@ PREPEND(srcs_ddsi "${CMAKE_CURRENT_LIST_DIR}/src"
ddsi_deliver_locally.c
ddsi_plist.c
ddsi_cdrstream.c
+ ddsi_time.c
q_addrset.c
q_bitset_inlines.c
q_bswap.c
@@ -53,7 +54,6 @@ PREPEND(srcs_ddsi "${CMAKE_CURRENT_LIST_DIR}/src"
q_receive.c
q_sockwaitset.c
q_thread.c
- q_time.c
q_transmit.c
q_inverse_uint32_set.c
q_whc.c
@@ -99,6 +99,7 @@ PREPEND(hdrs_private_ddsi "${CMAKE_CURRENT_LIST_DIR}/include/dds/ddsi"
ddsi_plist.h
ddsi_xqos.h
ddsi_cdrstream.h
+ ddsi_time.h
q_addrset.h
q_bitset.h
q_bswap.h
@@ -123,7 +124,6 @@ PREPEND(hdrs_private_ddsi "${CMAKE_CURRENT_LIST_DIR}/include/dds/ddsi"
q_rtps.h
q_sockwaitset.h
q_thread.h
- q_time.h
q_transmit.h
q_inverse_uint32_set.h
q_unused.h
diff --git a/src/core/ddsi/include/dds/ddsi/ddsi_builtin_topic_if.h b/src/core/ddsi/include/dds/ddsi/ddsi_builtin_topic_if.h
index fdfac07..a841e12 100644
--- a/src/core/ddsi/include/dds/ddsi/ddsi_builtin_topic_if.h
+++ b/src/core/ddsi/include/dds/ddsi/ddsi_builtin_topic_if.h
@@ -13,7 +13,6 @@
#define _DDSI_BUILTIN_TOPIC_IF_H_
#include "dds/ddsi/ddsi_vendor.h"
-#include "dds/ddsi/q_time.h"
#if defined (__cplusplus)
extern "C" {
@@ -30,7 +29,7 @@ struct ddsi_builtin_topic_interface {
bool (*builtintopic_is_builtintopic) (const struct ddsi_sertopic *topic, void *arg);
bool (*builtintopic_is_visible) (const struct ddsi_guid *guid, nn_vendorid_t vendorid, void *arg);
struct ddsi_tkmap_instance * (*builtintopic_get_tkmap_entry) (const struct ddsi_guid *guid, void *arg);
- void (*builtintopic_write) (const struct entity_common *e, nn_wctime_t timestamp, bool alive, void *arg);
+ void (*builtintopic_write) (const struct entity_common *e, ddsrt_wctime_t timestamp, bool alive, void *arg);
};
inline bool builtintopic_is_visible (const struct ddsi_builtin_topic_interface *btif, const struct ddsi_guid *guid, nn_vendorid_t vendorid) {
@@ -42,7 +41,7 @@ inline bool builtintopic_is_builtintopic (const struct ddsi_builtin_topic_interf
inline struct ddsi_tkmap_instance *builtintopic_get_tkmap_entry (const struct ddsi_builtin_topic_interface *btif, const struct ddsi_guid *guid) {
return btif ? btif->builtintopic_get_tkmap_entry (guid, btif->arg) : NULL;
}
-inline void builtintopic_write (const struct ddsi_builtin_topic_interface *btif, const struct entity_common *e, nn_wctime_t timestamp, bool alive) {
+inline void builtintopic_write (const struct ddsi_builtin_topic_interface *btif, const struct entity_common *e, ddsrt_wctime_t timestamp, bool alive) {
if (btif) btif->builtintopic_write (e, timestamp, alive, btif->arg);
}
diff --git a/src/core/ddsi/include/dds/ddsi/ddsi_deadline.h b/src/core/ddsi/include/dds/ddsi/ddsi_deadline.h
index 7bb1044..917352e 100644
--- a/src/core/ddsi/include/dds/ddsi/ddsi_deadline.h
+++ b/src/core/ddsi/include/dds/ddsi/ddsi_deadline.h
@@ -13,7 +13,7 @@
#define DDSI_DEADLINE_H
#include "dds/ddsrt/circlist.h"
-#include "dds/ddsi/q_time.h"
+#include "dds/ddsrt/time.h"
#include "dds/ddsi/ddsi_domaingv.h"
#include "dds/ddsi/q_xevent.h"
@@ -21,7 +21,7 @@
extern "C" {
#endif
-typedef nn_mtime_t (*deadline_missed_cb_t)(void *hc, nn_mtime_t tnow);
+typedef ddsrt_mtime_t (*deadline_missed_cb_t)(void *hc, ddsrt_mtime_t tnow);
struct deadline_adm {
struct ddsrt_circlist list; /* linked list for deadline missed */
@@ -34,25 +34,25 @@ struct deadline_adm {
struct deadline_elem {
struct ddsrt_circlist_elem e;
- nn_mtime_t t_deadline;
+ ddsrt_mtime_t t_deadline;
};
DDS_EXPORT void deadline_init (const struct ddsi_domaingv *gv, struct deadline_adm *deadline_adm, size_t list_offset, size_t elem_offset, deadline_missed_cb_t deadline_missed_cb);
DDS_EXPORT void deadline_stop (const struct deadline_adm *deadline_adm);
DDS_EXPORT void deadline_clear (struct deadline_adm *deadline_adm);
DDS_EXPORT void deadline_fini (const struct deadline_adm *deadline_adm);
-DDS_EXPORT nn_mtime_t deadline_next_missed_locked (struct deadline_adm *deadline_adm, nn_mtime_t tnow, void **instance);
-DDS_EXPORT void deadline_register_instance_real (struct deadline_adm *deadline_adm, struct deadline_elem *elem, nn_mtime_t tprev, nn_mtime_t tnow);
+DDS_EXPORT ddsrt_mtime_t deadline_next_missed_locked (struct deadline_adm *deadline_adm, ddsrt_mtime_t tnow, void **instance);
+DDS_EXPORT void deadline_register_instance_real (struct deadline_adm *deadline_adm, struct deadline_elem *elem, ddsrt_mtime_t tprev, ddsrt_mtime_t tnow);
DDS_EXPORT void deadline_unregister_instance_real (struct deadline_adm *deadline_adm, struct deadline_elem *elem);
DDS_EXPORT void deadline_renew_instance_real (struct deadline_adm *deadline_adm, struct deadline_elem *elem);
-inline void deadline_register_instance_locked (struct deadline_adm *deadline_adm, struct deadline_elem *elem, nn_mtime_t tnow)
+inline void deadline_register_instance_locked (struct deadline_adm *deadline_adm, struct deadline_elem *elem, ddsrt_mtime_t tnow)
{
if (deadline_adm->dur != DDS_INFINITY)
deadline_register_instance_real (deadline_adm, elem, tnow, tnow);
}
-inline void deadline_reregister_instance_locked (struct deadline_adm *deadline_adm, struct deadline_elem *elem, nn_mtime_t tnow)
+inline void deadline_reregister_instance_locked (struct deadline_adm *deadline_adm, struct deadline_elem *elem, ddsrt_mtime_t tnow)
{
if (deadline_adm->dur != DDS_INFINITY)
deadline_register_instance_real (deadline_adm, elem, elem->t_deadline, tnow);
diff --git a/src/core/ddsi/include/dds/ddsi/ddsi_domaingv.h b/src/core/ddsi/include/dds/ddsi/ddsi_domaingv.h
index b5747a7..27c9d3a 100644
--- a/src/core/ddsi/include/dds/ddsi/ddsi_domaingv.h
+++ b/src/core/ddsi/include/dds/ddsi/ddsi_domaingv.h
@@ -240,7 +240,7 @@ struct ddsi_domaingv {
/* Start time of the DDSI2 service, for logging relative time stamps,
should I ever so desire. */
- nn_wctime_t tstart;
+ ddsrt_wctime_t tstart;
/* Default QoSs for participant, readers and writers (needed for
eliminating default values in outgoing discovery packets, and for
diff --git a/src/core/ddsi/include/dds/ddsi/ddsi_lifespan.h b/src/core/ddsi/include/dds/ddsi/ddsi_lifespan.h
index e8202ee..b5e3e66 100644
--- a/src/core/ddsi/include/dds/ddsi/ddsi_lifespan.h
+++ b/src/core/ddsi/include/dds/ddsi/ddsi_lifespan.h
@@ -13,14 +13,14 @@
#define DDSI_LIFESPAN_H
#include "dds/ddsrt/fibheap.h"
-#include "dds/ddsi/q_time.h"
+#include "dds/ddsrt/time.h"
#include "dds/ddsi/ddsi_domaingv.h"
#if defined (__cplusplus)
extern "C" {
#endif
-typedef nn_mtime_t (*sample_expired_cb_t)(void *hc, nn_mtime_t tnow);
+typedef ddsrt_mtime_t (*sample_expired_cb_t)(void *hc, ddsrt_mtime_t tnow);
struct lifespan_adm {
ddsrt_fibheap_t ls_exp_heap; /* heap for sample expiration (lifespan) */
@@ -32,12 +32,12 @@ struct lifespan_adm {
struct lifespan_fhnode {
ddsrt_fibheap_node_t heapnode;
- nn_mtime_t t_expire;
+ ddsrt_mtime_t t_expire;
};
DDS_EXPORT void lifespan_init (const struct ddsi_domaingv *gv, struct lifespan_adm *lifespan_adm, size_t fh_offset, size_t fh_node_offset, sample_expired_cb_t sample_expired_cb);
DDS_EXPORT void lifespan_fini (const struct lifespan_adm *lifespan_adm);
-DDS_EXPORT nn_mtime_t lifespan_next_expired_locked (const struct lifespan_adm *lifespan_adm, nn_mtime_t tnow, void **sample);
+DDS_EXPORT ddsrt_mtime_t lifespan_next_expired_locked (const struct lifespan_adm *lifespan_adm, ddsrt_mtime_t tnow, void **sample);
DDS_EXPORT void lifespan_register_sample_real (struct lifespan_adm *lifespan_adm, struct lifespan_fhnode *node);
DDS_EXPORT void lifespan_unregister_sample_real (struct lifespan_adm *lifespan_adm, struct lifespan_fhnode *node);
diff --git a/src/core/ddsi/include/dds/ddsi/ddsi_pmd.h b/src/core/ddsi/include/dds/ddsi/ddsi_pmd.h
index a2b1daf..0948247 100644
--- a/src/core/ddsi/include/dds/ddsi/ddsi_pmd.h
+++ b/src/core/ddsi/include/dds/ddsi/ddsi_pmd.h
@@ -12,7 +12,7 @@
#ifndef DDSI_PMD_H
#define DDSI_PMD_H
-#include "dds/ddsi/q_time.h"
+#include "dds/ddsrt/time.h"
#if defined (__cplusplus)
extern "C" {
@@ -27,7 +27,7 @@ struct receiver_state;
void write_pmd_message_guid (struct ddsi_domaingv * const gv, struct ddsi_guid *pp_guid, unsigned pmd_kind);
void write_pmd_message (struct thread_state1 * const ts1, struct nn_xpack *xp, struct participant *pp, unsigned pmd_kind);
-void handle_pmd_message (const struct receiver_state *rst, nn_wctime_t timestamp, uint32_t statusinfo, const void *vdata, uint32_t len);
+void handle_pmd_message (const struct receiver_state *rst, ddsrt_wctime_t timestamp, uint32_t statusinfo, const void *vdata, uint32_t len);
#if defined (__cplusplus)
}
diff --git a/src/core/ddsi/include/dds/ddsi/ddsi_rhc.h b/src/core/ddsi/include/dds/ddsi/ddsi_rhc.h
index 506e407..92c560f 100644
--- a/src/core/ddsi/include/dds/ddsi/ddsi_rhc.h
+++ b/src/core/ddsi/include/dds/ddsi/ddsi_rhc.h
@@ -20,8 +20,8 @@
/* DDS_EXPORT inline i.c.w. __attributes__((visibility...)) and some compilers: */
#include "dds/ddsrt/attributes.h"
+#include "dds/ddsrt/time.h"
#include "dds/ddsi/ddsi_guid.h"
-#include "dds/ddsi/q_time.h"
#if defined (__cplusplus)
extern "C" {
@@ -40,7 +40,7 @@ struct ddsi_writer_info
int32_t ownership_strength;
uint64_t iid;
#ifdef DDSI_INCLUDE_LIFESPAN
- nn_mtime_t lifespan_exp;
+ ddsrt_mtime_t lifespan_exp;
#endif
};
diff --git a/src/core/ddsi/include/dds/ddsi/ddsi_serdata.h b/src/core/ddsi/include/dds/ddsi/ddsi_serdata.h
index ceb5112..7b9559b 100644
--- a/src/core/ddsi/include/dds/ddsi/ddsi_serdata.h
+++ b/src/core/ddsi/include/dds/ddsi/ddsi_serdata.h
@@ -13,7 +13,6 @@
#define DDSI_SERDATA_H
#include "dds/ddsrt/sockets.h"
-#include "dds/ddsi/q_time.h"
#include "dds/ddsi/ddsi_sertopic.h"
#if defined (__cplusplus)
@@ -37,11 +36,11 @@ struct ddsi_serdata {
const struct ddsi_sertopic *topic;
/* these get set by generic code after creating the serdata */
- nn_wctime_t timestamp;
+ ddsrt_wctime_t timestamp;
uint32_t statusinfo;
/* FIXME: can I get rid of this one? */
- nn_mtime_t twrite; /* write time, not source timestamp, set post-throttling */
+ ddsrt_mtime_t twrite; /* write time, not source timestamp, set post-throttling */
};
/* Serialised size of sample inclusive of DDSI encoding header
diff --git a/src/core/ddsi/include/dds/ddsi/ddsi_time.h b/src/core/ddsi/include/dds/ddsi/ddsi_time.h
new file mode 100644
index 0000000..baac1f5
--- /dev/null
+++ b/src/core/ddsi/include/dds/ddsi/ddsi_time.h
@@ -0,0 +1,44 @@
+/*
+ * Copyright(c) 2006 to 2018 ADLINK Technology Limited and others
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v. 2.0 which is available at
+ * http://www.eclipse.org/legal/epl-2.0, or the Eclipse Distribution License
+ * v. 1.0 which is available at
+ * http://www.eclipse.org/org/documents/edl-v10.php.
+ *
+ * SPDX-License-Identifier: EPL-2.0 OR BSD-3-Clause
+ */
+#ifndef DDSI_TIME_H
+#define DDSI_TIME_H
+
+#include
+
+#include "dds/export.h"
+#include "dds/ddsrt/time.h"
+
+#if defined (__cplusplus)
+extern "C" {
+#endif
+
+typedef struct {
+ int32_t seconds;
+ uint32_t fraction;
+} ddsi_time_t;
+#define DDSI_TIME_INFINITE ((ddsi_time_t) { INT32_MAX, UINT32_MAX })
+#define DDSI_TIME_INVALID ((ddsi_time_t) { -1, UINT32_MAX })
+
+typedef ddsi_time_t ddsi_duration_t;
+
+bool ddsi_is_valid_timestamp (ddsi_time_t t);
+
+DDS_EXPORT ddsi_time_t ddsi_wctime_to_ddsi_time (ddsrt_wctime_t t);
+DDS_EXPORT ddsrt_wctime_t ddsi_wctime_from_ddsi_time (ddsi_time_t x);
+DDS_EXPORT ddsi_duration_t ddsi_to_ddsi_duration (dds_duration_t t);
+DDS_EXPORT dds_duration_t ddsi_from_ddsi_duration (ddsi_duration_t x);
+
+#if defined (__cplusplus)
+}
+#endif
+
+#endif /* DDSI_TIME_H */
diff --git a/src/core/ddsi/include/dds/ddsi/q_entity.h b/src/core/ddsi/include/dds/ddsi/q_entity.h
index c90e2bc..ab017c3 100644
--- a/src/core/ddsi/include/dds/ddsi/q_entity.h
+++ b/src/core/ddsi/include/dds/ddsi/q_entity.h
@@ -119,9 +119,9 @@ struct wr_prd_match {
ddsi_guid_t arbitrary_unacked_reader;
nn_count_t next_acknack; /* next acceptable acknack sequence number */
nn_count_t next_nackfrag; /* next acceptable nackfrag sequence number */
- nn_etime_t t_acknack_accepted; /* (local) time an acknack was last accepted */
+ ddsrt_etime_t t_acknack_accepted; /* (local) time an acknack was last accepted */
struct nn_lat_estim hb_to_ack_latency;
- nn_wctime_t hb_to_ack_latency_tlastlog;
+ ddsrt_wctime_t hb_to_ack_latency_tlastlog;
uint32_t non_responsive_count;
uint32_t rexmit_requests;
};
@@ -135,12 +135,12 @@ enum pwr_rd_match_syncstate {
struct pwr_rd_match {
ddsrt_avl_node_t avlnode;
ddsi_guid_t rd_guid;
- nn_mtime_t tcreate;
+ ddsrt_mtime_t tcreate;
nn_count_t count; /* most recent acknack sequence number */
nn_count_t next_heartbeat; /* next acceptable heartbeat (see also add_proxy_writer_to_reader) */
- nn_wctime_t hb_timestamp; /* time of most recent heartbeat that rescheduled the ack event */
- nn_etime_t t_heartbeat_accepted; /* (local) time a heartbeat was last accepted */
- nn_mtime_t t_last_nack; /* (local) time we last sent a NACK */ /* FIXME: probably elapsed time is better */
+ ddsrt_wctime_t hb_timestamp; /* time of most recent heartbeat that rescheduled the ack event */
+ ddsrt_etime_t t_heartbeat_accepted; /* (local) time a heartbeat was last accepted */
+ ddsrt_mtime_t t_last_nack; /* (local) time we last sent a NACK */ /* FIXME: probably elapsed time is better */
seqno_t seq_last_nack; /* last seq for which we requested a retransmit */
struct xevent *acknack_xevent; /* entry in xevent queue for sending acknacks */
enum pwr_rd_match_syncstate in_sync; /* whether in sync with the proxy writer */
@@ -159,7 +159,7 @@ struct ddsi_tkmap_instance;
struct entity_common {
enum entity_kind kind;
ddsi_guid_t guid;
- nn_wctime_t tupdate; /* timestamp of last update */
+ ddsrt_wctime_t tupdate; /* timestamp of last update */
char *name;
uint64_t iid;
struct ddsi_tkmap_instance *tk;
@@ -271,8 +271,8 @@ struct writer
struct ldur_fhnode *lease_duration; /* fibheap node to keep lease duration for this writer, NULL in case of automatic liveliness with inifite duration */
struct whc *whc; /* WHC tracking history, T-L durability service history + samples by sequence number for retransmit */
uint32_t whc_low, whc_high; /* watermarks for WHC in bytes (counting only unack'd data) */
- nn_etime_t t_rexmit_end; /* time of last 1->0 transition of "retransmitting" */
- nn_etime_t t_whc_high_upd; /* time "whc_high" was last updated for controlled ramp-up of throughput */
+ ddsrt_etime_t t_rexmit_end; /* time of last 1->0 transition of "retransmitting" */
+ ddsrt_etime_t t_whc_high_upd; /* time "whc_high" was last updated for controlled ramp-up of throughput */
int32_t num_reliable_readers; /* number of matching reliable PROXY readers */
ddsrt_avl_tree_t readers; /* all matching PROXY readers, see struct wr_prd_match */
ddsrt_avl_tree_t local_readers; /* all matching LOCAL readers, see struct wr_rd_match */
@@ -653,11 +653,11 @@ int writer_set_notalive (struct writer *wr, bool notify);
/* Set when this proxy participant is not to be announced on the built-in topics yet */
#define CF_PROXYPP_NO_SPDP (1 << 3)
-void new_proxy_participant (struct ddsi_domaingv *gv, const struct ddsi_guid *guid, uint32_t bes, const struct ddsi_guid *privileged_pp_guid, struct addrset *as_default, struct addrset *as_meta, const struct ddsi_plist *plist, dds_duration_t tlease_dur, nn_vendorid_t vendor, unsigned custom_flags, nn_wctime_t timestamp, seqno_t seq);
-int delete_proxy_participant_by_guid (struct ddsi_domaingv *gv, const struct ddsi_guid *guid, nn_wctime_t timestamp, int isimplicit);
+void new_proxy_participant (struct ddsi_domaingv *gv, const struct ddsi_guid *guid, uint32_t bes, const struct ddsi_guid *privileged_pp_guid, struct addrset *as_default, struct addrset *as_meta, const struct ddsi_plist *plist, dds_duration_t tlease_dur, nn_vendorid_t vendor, unsigned custom_flags, ddsrt_wctime_t timestamp, seqno_t seq);
+int delete_proxy_participant_by_guid (struct ddsi_domaingv *gv, const struct ddsi_guid *guid, ddsrt_wctime_t timestamp, int isimplicit);
-int update_proxy_participant_plist_locked (struct proxy_participant *proxypp, seqno_t seq, const struct ddsi_plist *datap, nn_wctime_t timestamp);
-int update_proxy_participant_plist (struct proxy_participant *proxypp, seqno_t seq, const struct ddsi_plist *datap, nn_wctime_t timestamp);
+int update_proxy_participant_plist_locked (struct proxy_participant *proxypp, seqno_t seq, const struct ddsi_plist *datap, ddsrt_wctime_t timestamp);
+int update_proxy_participant_plist (struct proxy_participant *proxypp, seqno_t seq, const struct ddsi_plist *datap, ddsrt_wctime_t timestamp);
void proxy_participant_reassign_lease (struct proxy_participant *proxypp, struct lease *newlease);
void purge_proxy_participants (struct ddsi_domaingv *gv, const nn_locator_t *loc, bool delete_from_as_disc);
@@ -665,8 +665,8 @@ void purge_proxy_participants (struct ddsi_domaingv *gv, const nn_locator_t *loc
/* To create a new proxy writer or reader; the proxy participant is
determined from the GUID and must exist. */
- int new_proxy_writer (struct ddsi_domaingv *gv, const struct ddsi_guid *ppguid, const struct ddsi_guid *guid, struct addrset *as, const struct ddsi_plist *plist, struct nn_dqueue *dqueue, struct xeventq *evq, nn_wctime_t timestamp, seqno_t seq);
-int new_proxy_reader (struct ddsi_domaingv *gv, const struct ddsi_guid *ppguid, const struct ddsi_guid *guid, struct addrset *as, const struct ddsi_plist *plist, nn_wctime_t timestamp, seqno_t seq
+ int new_proxy_writer (struct ddsi_domaingv *gv, const struct ddsi_guid *ppguid, const struct ddsi_guid *guid, struct addrset *as, const struct ddsi_plist *plist, struct nn_dqueue *dqueue, struct xeventq *evq, ddsrt_wctime_t timestamp, seqno_t seq);
+int new_proxy_reader (struct ddsi_domaingv *gv, const struct ddsi_guid *ppguid, const struct ddsi_guid *guid, struct addrset *as, const struct ddsi_plist *plist, ddsrt_wctime_t timestamp, seqno_t seq
#ifdef DDSI_INCLUDE_SSM
, int favours_ssm
#endif
@@ -677,19 +677,19 @@ int new_proxy_reader (struct ddsi_domaingv *gv, const struct ddsi_guid *ppguid,
reader or writer. Actual deletion is scheduled in the future, when
no outstanding references may still exist (determined by checking
thread progress, &c.). */
-int delete_proxy_writer (struct ddsi_domaingv *gv, const struct ddsi_guid *guid, nn_wctime_t timestamp, int isimplicit);
-int delete_proxy_reader (struct ddsi_domaingv *gv, const struct ddsi_guid *guid, nn_wctime_t timestamp, int isimplicit);
+int delete_proxy_writer (struct ddsi_domaingv *gv, const struct ddsi_guid *guid, ddsrt_wctime_t timestamp, int isimplicit);
+int delete_proxy_reader (struct ddsi_domaingv *gv, const struct ddsi_guid *guid, ddsrt_wctime_t timestamp, int isimplicit);
-void update_proxy_reader (struct proxy_reader *prd, seqno_t seq, struct addrset *as, const struct dds_qos *xqos, nn_wctime_t timestamp);
-void update_proxy_writer (struct proxy_writer *pwr, seqno_t seq, struct addrset *as, const struct dds_qos *xqos, nn_wctime_t timestamp);
+void update_proxy_reader (struct proxy_reader *prd, seqno_t seq, struct addrset *as, const struct dds_qos *xqos, ddsrt_wctime_t timestamp);
+void update_proxy_writer (struct proxy_writer *pwr, seqno_t seq, struct addrset *as, const struct dds_qos *xqos, ddsrt_wctime_t timestamp);
void proxy_writer_set_alive_may_unlock (struct proxy_writer *pwr, bool notify);
int proxy_writer_set_notalive (struct proxy_writer *pwr, bool notify);
-int new_proxy_group (const struct ddsi_guid *guid, const char *name, const struct dds_qos *xqos, nn_wctime_t timestamp);
+int new_proxy_group (const struct ddsi_guid *guid, const char *name, const struct dds_qos *xqos, ddsrt_wctime_t timestamp);
struct entity_index;
-void delete_proxy_group (struct entity_index *entidx, const struct ddsi_guid *guid, nn_wctime_t timestamp, int isimplicit);
+void delete_proxy_group (struct entity_index *entidx, const struct ddsi_guid *guid, ddsrt_wctime_t timestamp, int isimplicit);
/* Call this to empty all address sets of all writers to stop all outgoing traffic, or to
rebuild them all (which only makes sense after previously having emptied them all). */
diff --git a/src/core/ddsi/include/dds/ddsi/q_hbcontrol.h b/src/core/ddsi/include/dds/ddsi/q_hbcontrol.h
index ca6a56f..389e29a 100644
--- a/src/core/ddsi/include/dds/ddsi/q_hbcontrol.h
+++ b/src/core/ddsi/include/dds/ddsi/q_hbcontrol.h
@@ -20,21 +20,21 @@ struct writer;
struct whc_state;
struct hbcontrol {
- nn_mtime_t t_of_last_write;
- nn_mtime_t t_of_last_hb;
- nn_mtime_t t_of_last_ackhb;
- nn_mtime_t tsched;
+ ddsrt_mtime_t t_of_last_write;
+ ddsrt_mtime_t t_of_last_hb;
+ ddsrt_mtime_t t_of_last_ackhb;
+ ddsrt_mtime_t tsched;
uint32_t hbs_since_last_write;
uint32_t last_packetid;
};
void writer_hbcontrol_init (struct hbcontrol *hbc);
-int64_t writer_hbcontrol_intv (const struct writer *wr, const struct whc_state *whcst, nn_mtime_t tnow);
-void writer_hbcontrol_note_asyncwrite (struct writer *wr, nn_mtime_t tnow);
-int writer_hbcontrol_ack_required (const struct writer *wr, const struct whc_state *whcst, nn_mtime_t tnow);
-struct nn_xmsg *writer_hbcontrol_piggyback (struct writer *wr, const struct whc_state *whcst, nn_mtime_t tnow, uint32_t packetid, int *hbansreq);
-int writer_hbcontrol_must_send (const struct writer *wr, const struct whc_state *whcst, nn_mtime_t tnow);
-struct nn_xmsg *writer_hbcontrol_create_heartbeat (struct writer *wr, const struct whc_state *whcst, nn_mtime_t tnow, int hbansreq, int issync);
+int64_t writer_hbcontrol_intv (const struct writer *wr, const struct whc_state *whcst, ddsrt_mtime_t tnow);
+void writer_hbcontrol_note_asyncwrite (struct writer *wr, ddsrt_mtime_t tnow);
+int writer_hbcontrol_ack_required (const struct writer *wr, const struct whc_state *whcst, ddsrt_mtime_t tnow);
+struct nn_xmsg *writer_hbcontrol_piggyback (struct writer *wr, const struct whc_state *whcst, ddsrt_mtime_t tnow, uint32_t packetid, int *hbansreq);
+int writer_hbcontrol_must_send (const struct writer *wr, const struct whc_state *whcst, ddsrt_mtime_t tnow);
+struct nn_xmsg *writer_hbcontrol_create_heartbeat (struct writer *wr, const struct whc_state *whcst, ddsrt_mtime_t tnow, int hbansreq, int issync);
#if defined (__cplusplus)
}
diff --git a/src/core/ddsi/include/dds/ddsi/q_lease.h b/src/core/ddsi/include/dds/ddsi/q_lease.h
index b6c5f5c..e427cc0 100644
--- a/src/core/ddsi/include/dds/ddsi/q_lease.h
+++ b/src/core/ddsi/include/dds/ddsi/q_lease.h
@@ -15,7 +15,6 @@
#include "dds/ddsrt/atomics.h"
#include "dds/ddsrt/fibheap.h"
#include "dds/ddsrt/time.h"
-#include "dds/ddsi/q_time.h"
#if defined (__cplusplus)
extern "C" {
@@ -29,7 +28,7 @@ struct ddsi_domaingv; /* FIXME: make a special for the lease admin */
struct lease {
ddsrt_fibheap_node_t heapnode;
ddsrt_fibheap_node_t pp_heapnode;
- nn_etime_t tsched; /* access guarded by leaseheap_lock */
+ ddsrt_etime_t tsched; /* access guarded by leaseheap_lock */
ddsrt_atomic_uint64_t tend; /* really an nn_etime_t */
dds_duration_t tdur; /* constant (renew depends on it) */
struct entity_common *entity; /* constant */
@@ -39,14 +38,14 @@ int compare_lease_tsched (const void *va, const void *vb);
int compare_lease_tdur (const void *va, const void *vb);
void lease_management_init (struct ddsi_domaingv *gv);
void lease_management_term (struct ddsi_domaingv *gv);
-struct lease *lease_new (nn_etime_t texpire, int64_t tdur, struct entity_common *e);
+struct lease *lease_new (ddsrt_etime_t texpire, int64_t tdur, struct entity_common *e);
struct lease *lease_clone (const struct lease *l);
void lease_register (struct lease *l);
void lease_unregister (struct lease *l);
void lease_free (struct lease *l);
-void lease_renew (struct lease *l, nn_etime_t tnow);
-void lease_set_expiry (struct lease *l, nn_etime_t when);
-int64_t check_and_handle_lease_expiration (struct ddsi_domaingv *gv, nn_etime_t tnow);
+void lease_renew (struct lease *l, ddsrt_etime_t tnow);
+void lease_set_expiry (struct lease *l, ddsrt_etime_t when);
+int64_t check_and_handle_lease_expiration (struct ddsi_domaingv *gv, ddsrt_etime_t tnow);
#if defined (__cplusplus)
}
diff --git a/src/core/ddsi/include/dds/ddsi/q_log.h b/src/core/ddsi/include/dds/ddsi/q_log.h
index fb7c5b7..64d3c0f 100644
--- a/src/core/ddsi/include/dds/ddsi/q_log.h
+++ b/src/core/ddsi/include/dds/ddsi/q_log.h
@@ -15,7 +15,7 @@
#include
#include "dds/ddsrt/log.h"
-#include "dds/ddsi/q_time.h"
+#include "dds/ddsi/ddsi_time.h"
#include "dds/ddsrt/rusage.h"
#if defined (__cplusplus)
@@ -45,7 +45,7 @@ extern "C" {
#define LOG_THREAD_CPUTIME(logcfg, guard) \
do { \
if ((logcfg)->c.mask & DDS_LC_TIMING) { \
- nn_mtime_t tnowlt = now_mt(); \
+ ddsrt_mtime_t tnowlt = ddsrt_time_monotonic (); \
if (tnowlt.v >= (guard).v) { \
ddsrt_rusage_t usage; \
if (ddsrt_getrusage(DDSRT_RUSAGE_THREAD, &usage) == 0) { \
diff --git a/src/core/ddsi/include/dds/ddsi/q_pcap.h b/src/core/ddsi/include/dds/ddsi/q_pcap.h
index 94f7d22..6ae6d66 100644
--- a/src/core/ddsi/include/dds/ddsi/q_pcap.h
+++ b/src/core/ddsi/include/dds/ddsi/q_pcap.h
@@ -13,7 +13,7 @@
#define Q_PCAP_H
#include
-#include "dds/ddsi/q_time.h"
+#include "dds/ddsrt/time.h"
#if defined (__cplusplus)
extern "C" {
@@ -23,8 +23,8 @@ struct msghdr;
FILE * new_pcap_file (const struct ddsrt_log_cfg *logcfg, const char *name);
-void write_pcap_received (struct ddsi_domaingv *gv, nn_wctime_t tstamp, const struct sockaddr_storage *src, const struct sockaddr_storage *dst, unsigned char *buf, size_t sz);
-void write_pcap_sent (struct ddsi_domaingv *gv, nn_wctime_t tstamp, const struct sockaddr_storage *src,
+void write_pcap_received (struct ddsi_domaingv *gv, ddsrt_wctime_t tstamp, const struct sockaddr_storage *src, const struct sockaddr_storage *dst, unsigned char *buf, size_t sz);
+void write_pcap_sent (struct ddsi_domaingv *gv, ddsrt_wctime_t tstamp, const struct sockaddr_storage *src,
const ddsrt_msghdr_t *hdr, size_t sz);
#if defined (__cplusplus)
diff --git a/src/core/ddsi/include/dds/ddsi/q_protocol.h b/src/core/ddsi/include/dds/ddsi/q_protocol.h
index e158df9..1bae50a 100644
--- a/src/core/ddsi/include/dds/ddsi/q_protocol.h
+++ b/src/core/ddsi/include/dds/ddsi/q_protocol.h
@@ -17,7 +17,7 @@
#include "dds/ddsi/q_feature_check.h"
#include "dds/ddsi/q_rtps.h"
-#include "dds/ddsi/q_time.h"
+#include "dds/ddsi/ddsi_time.h"
#if defined (__cplusplus)
extern "C" {
diff --git a/src/core/ddsi/include/dds/ddsi/q_radmin.h b/src/core/ddsi/include/dds/ddsi/q_radmin.h
index 9ded3d4..af5e3d0 100644
--- a/src/core/ddsi/include/dds/ddsi/q_radmin.h
+++ b/src/core/ddsi/include/dds/ddsi/q_radmin.h
@@ -120,8 +120,8 @@ struct nn_rsample_info {
struct proxy_writer *pwr;
uint32_t size;
uint32_t fragsize;
- nn_wctime_t timestamp;
- nn_wctime_t reception_timestamp; /* OpenSplice extension -- but we get it essentially for free, so why not? */
+ ddsrt_wctime_t timestamp;
+ ddsrt_wctime_t reception_timestamp; /* OpenSplice extension -- but we get it essentially for free, so why not? */
unsigned statusinfo: 2; /* just the two defined bits from the status info */
unsigned pt_wr_info_zoff: 16; /* PrismTech writer info offset */
unsigned bswap: 1; /* so we can extract well formatted writer info quicker */
diff --git a/src/core/ddsi/include/dds/ddsi/q_time.h b/src/core/ddsi/include/dds/ddsi/q_time.h
deleted file mode 100644
index 03b5b5e..0000000
--- a/src/core/ddsi/include/dds/ddsi/q_time.h
+++ /dev/null
@@ -1,71 +0,0 @@
-/*
- * Copyright(c) 2006 to 2018 ADLINK Technology Limited and others
- *
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v. 2.0 which is available at
- * http://www.eclipse.org/legal/epl-2.0, or the Eclipse Distribution License
- * v. 1.0 which is available at
- * http://www.eclipse.org/org/documents/edl-v10.php.
- *
- * SPDX-License-Identifier: EPL-2.0 OR BSD-3-Clause
- */
-#ifndef NN_TIME_H
-#define NN_TIME_H
-
-#include
-
-#include "dds/export.h"
-
-#if defined (__cplusplus)
-extern "C" {
-#endif
-
-typedef struct {
- int32_t seconds;
- uint32_t fraction;
-} ddsi_time_t;
-#define DDSI_TIME_INFINITE ((ddsi_time_t) { INT32_MAX, UINT32_MAX })
-#define DDSI_TIME_INVALID ((ddsi_time_t) { -1, UINT32_MAX })
-
-typedef ddsi_time_t ddsi_duration_t;
-
-typedef struct {
- int64_t v;
-} nn_mtime_t;
-
-typedef struct {
- int64_t v;
-} nn_wctime_t;
-
-typedef struct {
- int64_t v;
-} nn_etime_t;
-
-#define NN_MTIME_NEVER ((nn_mtime_t) { DDS_NEVER })
-#define NN_WCTIME_NEVER ((nn_wctime_t) { DDS_NEVER })
-#define NN_ETIME_NEVER ((nn_etime_t) { DDS_NEVER })
-#define NN_WCTIME_INVALID ((nn_wctime_t) { INT64_MIN })
-
-int valid_ddsi_timestamp (ddsi_time_t t);
-
-DDS_EXPORT nn_wctime_t now (void); /* wall clock time */
-DDS_EXPORT nn_mtime_t now_mt (void); /* monotonic time */
-DDS_EXPORT nn_etime_t now_et (void); /* elapsed time */
-DDS_EXPORT void mtime_to_sec_usec (int32_t * __restrict sec, int32_t * __restrict usec, nn_mtime_t t);
-DDS_EXPORT void wctime_to_sec_usec (int32_t * __restrict sec, int32_t * __restrict usec, nn_wctime_t t);
-DDS_EXPORT void etime_to_sec_usec (int32_t * __restrict sec, int32_t * __restrict usec, nn_etime_t t);
-DDS_EXPORT nn_mtime_t mtime_round_up (nn_mtime_t t, int64_t round);
-DDS_EXPORT nn_mtime_t add_duration_to_mtime (nn_mtime_t t, int64_t d);
-DDS_EXPORT nn_wctime_t add_duration_to_wctime (nn_wctime_t t, int64_t d);
-DDS_EXPORT nn_etime_t add_duration_to_etime (nn_etime_t t, int64_t d);
-
-DDS_EXPORT ddsi_time_t nn_wctime_to_ddsi_time (nn_wctime_t t);
-DDS_EXPORT nn_wctime_t nn_wctime_from_ddsi_time (ddsi_time_t x);
-DDS_EXPORT ddsi_duration_t nn_to_ddsi_duration (int64_t t);
-DDS_EXPORT int64_t nn_from_ddsi_duration (ddsi_duration_t x);
-
-#if defined (__cplusplus)
-}
-#endif
-
-#endif /* NN_TIME_H */
diff --git a/src/core/ddsi/include/dds/ddsi/q_whc.h b/src/core/ddsi/include/dds/ddsi/q_whc.h
index 40622a8..d654755 100644
--- a/src/core/ddsi/include/dds/ddsi/q_whc.h
+++ b/src/core/ddsi/include/dds/ddsi/q_whc.h
@@ -13,7 +13,7 @@
#define Q_WHC_H
#include
-#include "dds/ddsi/q_time.h"
+#include "dds/ddsrt/time.h"
#if defined (__cplusplus)
extern "C" {
@@ -30,7 +30,7 @@ struct whc_borrowed_sample {
struct ddsi_serdata *serdata;
struct ddsi_plist *plist;
bool unacked;
- nn_mtime_t last_rexmit_ts;
+ ddsrt_mtime_t last_rexmit_ts;
unsigned rexmit_count;
};
@@ -73,7 +73,7 @@ typedef void (*whc_free_t)(struct whc *whc);
reliable readers that have not acknowledged all data */
/* max_drop_seq must go soon, it's way too ugly. */
/* plist may be NULL or ddsrt_malloc'd, WHC takes ownership of plist */
-typedef int (*whc_insert_t)(struct whc *whc, seqno_t max_drop_seq, seqno_t seq, nn_mtime_t exp, struct ddsi_plist *plist, struct ddsi_serdata *serdata, struct ddsi_tkmap_instance *tk);
+typedef int (*whc_insert_t)(struct whc *whc, seqno_t max_drop_seq, seqno_t seq, ddsrt_mtime_t exp, struct ddsi_plist *plist, struct ddsi_serdata *serdata, struct ddsi_tkmap_instance *tk);
typedef uint32_t (*whc_downgrade_to_volatile_t)(struct whc *whc, struct whc_state *st);
typedef uint32_t (*whc_remove_acked_messages_t)(struct whc *whc, seqno_t max_drop_seq, struct whc_state *whcst, struct whc_node **deferred_free_list);
typedef void (*whc_free_deferred_free_list_t)(struct whc *whc, struct whc_node *deferred_free_list);
@@ -121,7 +121,7 @@ inline bool whc_sample_iter_borrow_next (struct whc_sample_iter *it, struct whc_
inline void whc_free (struct whc *whc) {
whc->ops->free (whc);
}
-inline int whc_insert (struct whc *whc, seqno_t max_drop_seq, seqno_t seq, nn_mtime_t exp, struct ddsi_plist *plist, struct ddsi_serdata *serdata, struct ddsi_tkmap_instance *tk) {
+inline int whc_insert (struct whc *whc, seqno_t max_drop_seq, seqno_t seq, ddsrt_mtime_t exp, struct ddsi_plist *plist, struct ddsi_serdata *serdata, struct ddsi_tkmap_instance *tk) {
return whc->ops->insert (whc, max_drop_seq, seq, exp, plist, serdata, tk);
}
inline unsigned whc_downgrade_to_volatile (struct whc *whc, struct whc_state *st) {
diff --git a/src/core/ddsi/include/dds/ddsi/q_xevent.h b/src/core/ddsi/include/dds/ddsi/q_xevent.h
index 3925ba6..41bd5b1 100644
--- a/src/core/ddsi/include/dds/ddsi/q_xevent.h
+++ b/src/core/ddsi/include/dds/ddsi/q_xevent.h
@@ -60,16 +60,16 @@ DDS_EXPORT int qxev_msg_rexmit_wrlock_held (struct xeventq *evq, struct nn_xmsg
/* All of the following lock EVQ for the duration of the operation */
DDS_EXPORT void delete_xevent (struct xevent *ev);
DDS_EXPORT void delete_xevent_callback (struct xevent *ev);
-DDS_EXPORT int resched_xevent_if_earlier (struct xevent *ev, nn_mtime_t tsched);
+DDS_EXPORT int resched_xevent_if_earlier (struct xevent *ev, ddsrt_mtime_t tsched);
-DDS_EXPORT struct xevent *qxev_heartbeat (struct xeventq *evq, nn_mtime_t tsched, const ddsi_guid_t *wr_guid);
-DDS_EXPORT struct xevent *qxev_acknack (struct xeventq *evq, nn_mtime_t tsched, const ddsi_guid_t *pwr_guid, const ddsi_guid_t *rd_guid);
-DDS_EXPORT struct xevent *qxev_spdp (struct xeventq *evq, nn_mtime_t tsched, const ddsi_guid_t *pp_guid, const ddsi_guid_t *proxypp_guid);
-DDS_EXPORT struct xevent *qxev_pmd_update (struct xeventq *evq, nn_mtime_t tsched, const ddsi_guid_t *pp_guid);
-DDS_EXPORT struct xevent *qxev_delete_writer (struct xeventq *evq, nn_mtime_t tsched, const ddsi_guid_t *guid);
+DDS_EXPORT struct xevent *qxev_heartbeat (struct xeventq *evq, ddsrt_mtime_t tsched, const ddsi_guid_t *wr_guid);
+DDS_EXPORT struct xevent *qxev_acknack (struct xeventq *evq, ddsrt_mtime_t tsched, const ddsi_guid_t *pwr_guid, const ddsi_guid_t *rd_guid);
+DDS_EXPORT struct xevent *qxev_spdp (struct xeventq *evq, ddsrt_mtime_t tsched, const ddsi_guid_t *pp_guid, const ddsi_guid_t *proxypp_guid);
+DDS_EXPORT struct xevent *qxev_pmd_update (struct xeventq *evq, ddsrt_mtime_t tsched, const ddsi_guid_t *pp_guid);
+DDS_EXPORT struct xevent *qxev_delete_writer (struct xeventq *evq, ddsrt_mtime_t tsched, const ddsi_guid_t *guid);
/* cb will be called with now = NEVER if the event is still enqueued when when xeventq_free starts cleaning up */
-DDS_EXPORT struct xevent *qxev_callback (struct xeventq *evq, nn_mtime_t tsched, void (*cb) (struct xevent *xev, void *arg, nn_mtime_t now), void *arg);
+DDS_EXPORT struct xevent *qxev_callback (struct xeventq *evq, ddsrt_mtime_t tsched, void (*cb) (struct xevent *xev, void *arg, ddsrt_mtime_t now), void *arg);
#if defined (__cplusplus)
}
diff --git a/src/core/ddsi/include/dds/ddsi/q_xmsg.h b/src/core/ddsi/include/dds/ddsi/q_xmsg.h
index ed717b7..b002e67 100644
--- a/src/core/ddsi/include/dds/ddsi/q_xmsg.h
+++ b/src/core/ddsi/include/dds/ddsi/q_xmsg.h
@@ -117,7 +117,7 @@ void nn_xmsg_shrink (struct nn_xmsg *m, struct nn_xmsg_marker marker, size_t sz)
void nn_xmsg_serdata (struct nn_xmsg *m, struct ddsi_serdata *serdata, size_t off, size_t len);
void nn_xmsg_submsg_setnext (struct nn_xmsg *msg, struct nn_xmsg_marker marker);
void nn_xmsg_submsg_init (struct nn_xmsg *msg, struct nn_xmsg_marker marker, SubmessageKind_t smkind);
-void nn_xmsg_add_timestamp (struct nn_xmsg *m, nn_wctime_t t);
+void nn_xmsg_add_timestamp (struct nn_xmsg *m, ddsrt_wctime_t t);
void nn_xmsg_add_entityid (struct nn_xmsg * m);
void *nn_xmsg_addpar (struct nn_xmsg *m, nn_parameterid_t pid, size_t len);
void nn_xmsg_addpar_keyhash (struct nn_xmsg *m, const struct ddsi_serdata *serdata);
diff --git a/src/core/ddsi/src/ddsi_deadline.c b/src/core/ddsi/src/ddsi_deadline.c
index 56ab8e4..3c07034 100644
--- a/src/core/ddsi/src/ddsi_deadline.c
+++ b/src/core/ddsi/src/ddsi_deadline.c
@@ -12,22 +12,22 @@
#include
#include
#include "dds/ddsrt/circlist.h"
+#include "dds/ddsrt/time.h"
#include "dds/ddsi/ddsi_deadline.h"
-#include "dds/ddsi/q_time.h"
#include "dds/ddsi/q_xevent.h"
-static void instance_deadline_missed_cb (struct xevent *xev, void *varg, nn_mtime_t tnow)
+static void instance_deadline_missed_cb (struct xevent *xev, void *varg, ddsrt_mtime_t tnow)
{
struct deadline_adm * const deadline_adm = varg;
- nn_mtime_t next_valid = deadline_adm->deadline_missed_cb((char *)deadline_adm - deadline_adm->list_offset, tnow);
+ ddsrt_mtime_t next_valid = deadline_adm->deadline_missed_cb((char *)deadline_adm - deadline_adm->list_offset, tnow);
resched_xevent_if_earlier (xev, next_valid);
}
/* Gets the instance from the list in deadline admin that has the earliest missed deadline and
* removes the instance element from the list. If no more instances with missed deadline exist
* in the list, the deadline (nn_mtime_t) for the first instance to 'expire' is returned. If the
- * list is empty, NN_MTIME_NEVER is returned */
-nn_mtime_t deadline_next_missed_locked (struct deadline_adm *deadline_adm, nn_mtime_t tnow, void **instance)
+ * list is empty, DDSRT_MTIME_NEVER is returned */
+ddsrt_mtime_t deadline_next_missed_locked (struct deadline_adm *deadline_adm, ddsrt_mtime_t tnow, void **instance)
{
struct deadline_elem *elem = NULL;
if (!ddsrt_circlist_isempty (&deadline_adm->list))
@@ -39,18 +39,18 @@ nn_mtime_t deadline_next_missed_locked (struct deadline_adm *deadline_adm, nn_mt
ddsrt_circlist_remove (&deadline_adm->list, &elem->e);
if (instance != NULL)
*instance = (char *)elem - deadline_adm->elem_offset;
- return (nn_mtime_t) { 0 };
+ return (ddsrt_mtime_t) { 0 };
}
}
if (instance != NULL)
*instance = NULL;
- return (elem != NULL) ? elem->t_deadline : NN_MTIME_NEVER;
+ return (elem != NULL) ? elem->t_deadline : DDSRT_MTIME_NEVER;
}
void deadline_init (const struct ddsi_domaingv *gv, struct deadline_adm *deadline_adm, size_t list_offset, size_t elem_offset, deadline_missed_cb_t deadline_missed_cb)
{
ddsrt_circlist_init (&deadline_adm->list);
- deadline_adm->evt = qxev_callback (gv->xevents, NN_MTIME_NEVER, instance_deadline_missed_cb, deadline_adm);
+ deadline_adm->evt = qxev_callback (gv->xevents, DDSRT_MTIME_NEVER, instance_deadline_missed_cb, deadline_adm);
deadline_adm->deadline_missed_cb = deadline_missed_cb;
deadline_adm->list_offset = list_offset;
deadline_adm->elem_offset = elem_offset;
@@ -63,7 +63,7 @@ void deadline_stop (const struct deadline_adm *deadline_adm)
void deadline_clear (struct deadline_adm *deadline_adm)
{
- while ((deadline_next_missed_locked (deadline_adm, NN_MTIME_NEVER, NULL)).v == 0);
+ while ((deadline_next_missed_locked (deadline_adm, DDSRT_MTIME_NEVER, NULL)).v == 0);
}
void deadline_fini (const struct deadline_adm *deadline_adm)
@@ -72,10 +72,10 @@ void deadline_fini (const struct deadline_adm *deadline_adm)
(void) deadline_adm;
}
-extern inline void deadline_register_instance_locked (struct deadline_adm *deadline_adm, struct deadline_elem *elem, nn_mtime_t tnow);
-extern inline void deadline_reregister_instance_locked (struct deadline_adm *deadline_adm, struct deadline_elem *elem, nn_mtime_t tnow);
+extern inline void deadline_register_instance_locked (struct deadline_adm *deadline_adm, struct deadline_elem *elem, ddsrt_mtime_t tnow);
+extern inline void deadline_reregister_instance_locked (struct deadline_adm *deadline_adm, struct deadline_elem *elem, ddsrt_mtime_t tnow);
-void deadline_register_instance_real (struct deadline_adm *deadline_adm, struct deadline_elem *elem, nn_mtime_t tprev, nn_mtime_t tnow)
+void deadline_register_instance_real (struct deadline_adm *deadline_adm, struct deadline_elem *elem, ddsrt_mtime_t tprev, ddsrt_mtime_t tnow)
{
ddsrt_circlist_append(&deadline_adm->list, &elem->e);
elem->t_deadline = (tprev.v + deadline_adm->dur >= tnow.v) ? tprev : tnow;
@@ -92,7 +92,7 @@ void deadline_unregister_instance_real (struct deadline_adm *deadline_adm, struc
* this removed element expires. Only remove the element from the
* deadline list */
- elem->t_deadline = NN_MTIME_NEVER;
+ elem->t_deadline = DDSRT_MTIME_NEVER;
ddsrt_circlist_remove(&deadline_adm->list, &elem->e);
}
@@ -106,7 +106,7 @@ void deadline_renew_instance_real (struct deadline_adm *deadline_adm, struct dea
the callback the deadline (which will be the updated value) will be
checked for expiry */
ddsrt_circlist_remove(&deadline_adm->list, &elem->e);
- elem->t_deadline = now_mt();
+ elem->t_deadline = ddsrt_time_monotonic();
elem->t_deadline.v += deadline_adm->dur;
ddsrt_circlist_append(&deadline_adm->list, &elem->e);
}
diff --git a/src/core/ddsi/src/ddsi_lifespan.c b/src/core/ddsi/src/ddsi_lifespan.c
index 3ad8737..ddd0224 100644
--- a/src/core/ddsi/src/ddsi_lifespan.c
+++ b/src/core/ddsi/src/ddsi_lifespan.c
@@ -14,7 +14,6 @@
#include "dds/ddsrt/heap.h"
#include "dds/ddsrt/fibheap.h"
#include "dds/ddsi/ddsi_lifespan.h"
-#include "dds/ddsi/q_time.h"
#include "dds/ddsi/q_xevent.h"
static int compare_lifespan_texp (const void *va, const void *vb)
@@ -26,33 +25,33 @@ static int compare_lifespan_texp (const void *va, const void *vb)
const ddsrt_fibheap_def_t lifespan_fhdef = DDSRT_FIBHEAPDEF_INITIALIZER(offsetof (struct lifespan_fhnode, heapnode), compare_lifespan_texp);
-static void lifespan_rhc_node_exp (struct xevent *xev, void *varg, nn_mtime_t tnow)
+static void lifespan_rhc_node_exp (struct xevent *xev, void *varg, ddsrt_mtime_t tnow)
{
struct lifespan_adm * const lifespan_adm = varg;
- nn_mtime_t next_valid = lifespan_adm->sample_expired_cb((char *)lifespan_adm - lifespan_adm->fh_offset, tnow);
+ ddsrt_mtime_t next_valid = lifespan_adm->sample_expired_cb((char *)lifespan_adm - lifespan_adm->fh_offset, tnow);
resched_xevent_if_earlier (xev, next_valid);
}
/* Gets the sample from the fibheap in lifespan admin that was expired first. If no more
* expired samples exist in the fibheap, the expiry time (nn_mtime_t) for the next sample to
- * expire is returned. If the fibheap contains no more samples, NN_MTIME_NEVER is returned */
-nn_mtime_t lifespan_next_expired_locked (const struct lifespan_adm *lifespan_adm, nn_mtime_t tnow, void **sample)
+ * expire is returned. If the fibheap contains no more samples, DDSRT_MTIME_NEVER is returned */
+ddsrt_mtime_t lifespan_next_expired_locked (const struct lifespan_adm *lifespan_adm, ddsrt_mtime_t tnow, void **sample)
{
struct lifespan_fhnode *node;
if ((node = ddsrt_fibheap_min(&lifespan_fhdef, &lifespan_adm->ls_exp_heap)) != NULL && node->t_expire.v <= tnow.v)
{
*sample = (char *)node - lifespan_adm->fhn_offset;
- return (nn_mtime_t) { 0 };
+ return (ddsrt_mtime_t) { 0 };
}
*sample = NULL;
- return (node != NULL) ? node->t_expire : NN_MTIME_NEVER;
+ return (node != NULL) ? node->t_expire : DDSRT_MTIME_NEVER;
}
void lifespan_init (const struct ddsi_domaingv *gv, struct lifespan_adm *lifespan_adm, size_t fh_offset, size_t fh_node_offset, sample_expired_cb_t sample_expired_cb)
{
ddsrt_fibheap_init (&lifespan_fhdef, &lifespan_adm->ls_exp_heap);
- lifespan_adm->evt = qxev_callback (gv->xevents, NN_MTIME_NEVER, lifespan_rhc_node_exp, lifespan_adm);
+ lifespan_adm->evt = qxev_callback (gv->xevents, DDSRT_MTIME_NEVER, lifespan_rhc_node_exp, lifespan_adm);
lifespan_adm->sample_expired_cb = sample_expired_cb;
lifespan_adm->fh_offset = fh_offset;
lifespan_adm->fhn_offset = fh_node_offset;
diff --git a/src/core/ddsi/src/ddsi_plist.c b/src/core/ddsi/src/ddsi_plist.c
index 0707f2f..ffa7f44 100644
--- a/src/core/ddsi/src/ddsi_plist.c
+++ b/src/core/ddsi/src/ddsi_plist.c
@@ -25,7 +25,7 @@
#include "dds/ddsi/q_bswap.h"
#include "dds/ddsi/q_unused.h"
#include "dds/ddsi/ddsi_plist.h"
-#include "dds/ddsi/q_time.h"
+#include "dds/ddsi/ddsi_time.h"
#include "dds/ddsi/q_xmsg.h"
#include "dds/ddsi/ddsi_vendor.h"
#include "dds/ddsi/ddsi_udp.h" /* nn_mc4gen_address_t */
@@ -215,7 +215,7 @@ static dds_return_t deser_reliability (void * __restrict dst, size_t * __restric
if (validate_external_duration (&mbt) < 0)
return DDS_RETCODE_BAD_PARAMETER;
x->kind = (enum dds_reliability_kind) (kind - 1);
- x->max_blocking_time = nn_from_ddsi_duration (mbt);
+ x->max_blocking_time = ddsi_from_ddsi_duration (mbt);
*dstoff += sizeof (*x);
*flagset->present |= flag;
return 0;
@@ -226,7 +226,7 @@ static dds_return_t ser_reliability (struct nn_xmsg *xmsg, nn_parameterid_t pid,
DDSRT_STATIC_ASSERT (DDS_EXTERNAL_RELIABILITY_BEST_EFFORT == 1 && DDS_EXTERNAL_RELIABILITY_RELIABLE == 2 &&
DDS_RELIABILITY_BEST_EFFORT == 0 && DDS_RELIABILITY_RELIABLE == 1);
dds_reliability_qospolicy_t const * const x = deser_generic_src (src, &srcoff, alignof (dds_reliability_qospolicy_t));
- ddsi_duration_t mbt = nn_to_ddsi_duration (x->max_blocking_time);
+ ddsi_duration_t mbt = ddsi_to_ddsi_duration (x->max_blocking_time);
uint32_t * const p = nn_xmsg_addpar (xmsg, pid, 3 * sizeof (uint32_t));
p[0] = 1 + (uint32_t) x->kind;
p[1] = (uint32_t) mbt.seconds;
@@ -551,7 +551,7 @@ static dds_return_t deser_generic (void * __restrict dst, size_t * __restrict ds
goto fail;
if (validate_external_duration (&tmp))
goto fail;
- x[i] = nn_from_ddsi_duration (tmp);
+ x[i] = ddsi_from_ddsi_duration (tmp);
}
*dstoff += cnt * sizeof (*x);
break;
@@ -796,7 +796,7 @@ static dds_return_t ser_generic_embeddable (char * const data, size_t *dstoff, c
uint32_t * const p = ser_generic_align4 (data, dstoff);
for (uint32_t i = 0; i < cnt; i++)
{
- ddsi_duration_t tmp = nn_to_ddsi_duration (x[i]);
+ ddsi_duration_t tmp = ddsi_to_ddsi_duration (x[i]);
p[2 * i + 0] = (uint32_t) tmp.seconds;
p[2 * i + 1] = tmp.fraction;
}
diff --git a/src/core/ddsi/src/ddsi_pmd.c b/src/core/ddsi/src/ddsi_pmd.c
index 9a6df62..9e7db55 100644
--- a/src/core/ddsi/src/ddsi_pmd.c
+++ b/src/core/ddsi/src/ddsi_pmd.c
@@ -25,7 +25,6 @@
#include "dds/ddsi/q_protocol.h"
#include "dds/ddsi/q_radmin.h"
#include "dds/ddsi/q_rtps.h"
-#include "dds/ddsi/q_time.h"
#include "dds/ddsi/q_transmit.h"
#include "dds/ddsi/q_xmsg.h"
@@ -57,7 +56,7 @@ void write_pmd_message_guid (struct ddsi_domaingv * const gv, struct ddsi_guid *
else
{
if ((lease = ddsrt_atomic_ldvoidp (&pp->minl_man)) != NULL)
- lease_renew (lease, now_et());
+ lease_renew (lease, ddsrt_time_elapsed());
write_pmd_message (ts1, NULL, pp, pmd_kind);
}
thread_state_asleep (ts1);
@@ -93,7 +92,7 @@ void write_pmd_message (struct thread_state1 * const ts1, struct nn_xpack *xp, s
.keysize = 16
};
serdata = ddsi_serdata_from_sample (gv->rawcdr_topic, SDK_DATA, &raw);
- serdata->timestamp = now ();
+ serdata->timestamp = ddsrt_time_wallclock ();
tk = ddsi_tkmap_lookup_instance_ref (gv->m_tkmap, serdata);
write_sample_nogc (ts1, xp, wr, serdata, tk);
@@ -101,7 +100,7 @@ void write_pmd_message (struct thread_state1 * const ts1, struct nn_xpack *xp, s
#undef PMD_DATA_LENGTH
}
-void handle_pmd_message (const struct receiver_state *rst, nn_wctime_t timestamp, uint32_t statusinfo, const void *vdata, uint32_t len)
+void handle_pmd_message (const struct receiver_state *rst, ddsrt_wctime_t timestamp, uint32_t statusinfo, const void *vdata, uint32_t len)
{
const struct CDRHeader *data = vdata; /* built-ins not deserialized (yet) */
const int bswap = (data->identifier == CDR_LE) ^ (DDSRT_ENDIAN == DDSRT_LITTLE_ENDIAN);
@@ -139,7 +138,7 @@ void handle_pmd_message (const struct receiver_state *rst, nn_wctime_t timestamp
(l = ddsrt_atomic_ldvoidp (&proxypp->minl_man)) != NULL)
{
/* Renew lease for entity with shortest manual-by-participant lease */
- lease_renew (l, now_et ());
+ lease_renew (l, ddsrt_time_elapsed ());
}
}
break;
diff --git a/src/core/ddsi/src/ddsi_threadmon.c b/src/core/ddsi/src/ddsi_threadmon.c
index 2d1a453..b92e2d1 100644
--- a/src/core/ddsi/src/ddsi_threadmon.c
+++ b/src/core/ddsi/src/ddsi_threadmon.c
@@ -13,6 +13,7 @@
#include "dds/ddsrt/heap.h"
#include "dds/ddsrt/sync.h"
+#include "dds/ddsrt/time.h"
#include "dds/ddsrt/threads.h"
#include "dds/ddsrt/hopscotch.h"
@@ -20,7 +21,6 @@
#include "dds/ddsi/q_config.h"
#include "dds/ddsi/q_log.h"
#include "dds/ddsi/q_thread.h"
-#include "dds/ddsi/q_time.h"
#include "dds/ddsi/q_unused.h"
#include "dds/ddsi/ddsi_domaingv.h" /* for mattr, cattr */
#include "dds/ddsi/q_receive.h"
@@ -64,7 +64,7 @@ static uint32_t threadmon_thread (struct ddsi_threadmon *sl)
reason why it has to be 100ms), regardless of the lease settings.
Note: can't trust sl->self, may have been scheduled before the
assignment. */
- nn_mtime_t tlast = { 0 };
+ ddsrt_mtime_t tlast = { 0 };
bool was_alive = true;
for (uint32_t i = 0; i < thread_states.nthreads; i++)
{
@@ -80,7 +80,7 @@ static uint32_t threadmon_thread (struct ddsi_threadmon *sl)
/* Check progress only if enough time has passed: there is no
guarantee that os_cond_timedwait wont ever return early, and we
do want to avoid spurious warnings. */
- nn_mtime_t tnow = now_mt ();
+ ddsrt_mtime_t tnow = ddsrt_time_monotonic ();
if (tnow.v < tlast.v)
continue;
diff --git a/src/core/ddsi/src/ddsi_time.c b/src/core/ddsi/src/ddsi_time.c
new file mode 100644
index 0000000..d387034
--- /dev/null
+++ b/src/core/ddsi/src/ddsi_time.c
@@ -0,0 +1,70 @@
+/*
+ * Copyright(c) 2006 to 2018 ADLINK Technology Limited and others
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v. 2.0 which is available at
+ * http://www.eclipse.org/legal/epl-2.0, or the Eclipse Distribution License
+ * v. 1.0 which is available at
+ * http://www.eclipse.org/org/documents/edl-v10.php.
+ *
+ * SPDX-License-Identifier: EPL-2.0 OR BSD-3-Clause
+ */
+#include
+
+#include "dds/ddsrt/time.h"
+#include "dds/ddsi/ddsi_time.h"
+
+bool ddsi_is_valid_timestamp (ddsi_time_t t)
+{
+ return t.seconds != DDSI_TIME_INVALID.seconds && t.fraction != DDSI_TIME_INVALID.fraction;
+}
+
+static ddsi_time_t to_ddsi_time (int64_t t)
+{
+ if (t == DDS_NEVER)
+ return DDSI_TIME_INFINITE;
+ else
+ {
+ /* ceiling(ns * 2^32/10^9) -- can't change the ceiling to round-to-nearest
+ because that would break backwards compatibility, but round-to-nearest
+ of the inverse is correctly rounded anyway, so it shouldn't ever matter. */
+ ddsi_time_t x;
+ int ns = (int) (t % DDS_NSECS_IN_SEC);
+ x.seconds = (int) (t / DDS_NSECS_IN_SEC);
+ x.fraction = (unsigned) (((DDS_NSECS_IN_SEC-1) + ((int64_t) ns << 32)) / DDS_NSECS_IN_SEC);
+ return x;
+ }
+}
+
+ddsi_time_t ddsi_wctime_to_ddsi_time (ddsrt_wctime_t t)
+{
+ return to_ddsi_time (t.v);
+}
+
+static int64_t from_ddsi_time (ddsi_time_t x)
+{
+ if (x.seconds == DDSI_TIME_INFINITE.seconds && x.fraction == DDSI_TIME_INFINITE.fraction)
+ return DDS_NEVER;
+ else
+ {
+ /* Round-to-nearest conversion of DDSI time fraction to nanoseconds */
+ int ns = (int) (((int64_t) 2147483648u + (int64_t) x.fraction * DDS_NSECS_IN_SEC) >> 32);
+ return x.seconds * DDS_NSECS_IN_SEC + ns;
+ }
+}
+
+ddsrt_wctime_t ddsi_wctime_from_ddsi_time (ddsi_time_t x)
+{
+ return (ddsrt_wctime_t) { from_ddsi_time (x) };
+}
+
+ddsi_duration_t ddsi_to_ddsi_duration (dds_duration_t x)
+{
+ return to_ddsi_time (x);
+}
+
+dds_duration_t ddsi_from_ddsi_duration (ddsi_duration_t x)
+{
+ return from_ddsi_time (x);
+}
+
diff --git a/src/core/ddsi/src/ddsi_udp.c b/src/core/ddsi/src/ddsi_udp.c
index ede09e7..d30d319 100644
--- a/src/core/ddsi/src/ddsi_udp.c
+++ b/src/core/ddsi/src/ddsi_udp.c
@@ -76,7 +76,7 @@ static ssize_t ddsi_udp_conn_read (ddsi_tran_conn_t conn, unsigned char * buf, s
socklen_t dest_len = sizeof (dest);
if (ddsrt_getsockname (((ddsi_udp_conn_t) conn)->m_sock, (struct sockaddr *) &dest, &dest_len) != DDS_RETCODE_OK)
memset(&dest, 0, sizeof(dest));
- write_pcap_received(conn->m_base.gv, now(), &src, &dest, buf, (size_t) ret);
+ write_pcap_received(conn->m_base.gv, ddsrt_time_wallclock(), &src, &dest, buf, (size_t) ret);
}
/* Check for udp packet truncation */
@@ -155,7 +155,7 @@ static ssize_t ddsi_udp_conn_write (ddsi_tran_conn_t conn, const nn_locator_t *d
socklen_t alen = sizeof (sa);
if (ddsrt_getsockname (((ddsi_udp_conn_t) conn)->m_sock, (struct sockaddr *) &sa, &alen) != DDS_RETCODE_OK)
memset(&sa, 0, sizeof(sa));
- write_pcap_sent (conn->m_base.gv, now (), &sa, &msg, (size_t) ret);
+ write_pcap_sent (conn->m_base.gv, ddsrt_time_wallclock (), &sa, &msg, (size_t) ret);
}
else if (rc != DDS_RETCODE_OK &&
rc != DDS_RETCODE_NOT_ALLOWED &&
diff --git a/src/core/ddsi/src/q_ddsi_discovery.c b/src/core/ddsi/src/q_ddsi_discovery.c
index f758125..8c6f331 100644
--- a/src/core/ddsi/src/q_ddsi_discovery.c
+++ b/src/core/ddsi/src/q_ddsi_discovery.c
@@ -179,7 +179,7 @@ static int write_mpayload (struct writer *wr, int alive, nn_parameterid_t keypar
nn_xmsg_payload_to_plistsample (&plist_sample, keyparam, mpayload);
serdata = ddsi_serdata_from_sample (wr->e.gv->plist_topic, alive ? SDK_DATA : SDK_KEY, &plist_sample);
serdata->statusinfo = alive ? 0 : NN_STATUSINFO_DISPOSE | NN_STATUSINFO_UNREGISTER;
- serdata->timestamp = now ();
+ serdata->timestamp = ddsrt_time_wallclock ();
return write_sample_nogc_notk (ts1, NULL, wr, serdata);
}
@@ -362,7 +362,7 @@ int spdp_dispose_unregister (struct participant *pp)
return ret;
}
-static unsigned pseudo_random_delay (const ddsi_guid_t *x, const ddsi_guid_t *y, nn_mtime_t tnow)
+static unsigned pseudo_random_delay (const ddsi_guid_t *x, const ddsi_guid_t *y, ddsrt_mtime_t tnow)
{
/* You know, an ordinary random generator would be even better, but
the C library doesn't have a reentrant one and I don't feel like
@@ -395,7 +395,7 @@ static void respond_to_spdp (const struct ddsi_domaingv *gv, const ddsi_guid_t *
{
struct entidx_enum_participant est;
struct participant *pp;
- nn_mtime_t tnow = now_mt ();
+ ddsrt_mtime_t tnow = ddsrt_time_monotonic ();
entidx_enum_participant_init (&est, gv->entity_index);
while ((pp = entidx_enum_participant_next (&est)) != NULL)
{
@@ -405,7 +405,7 @@ static void respond_to_spdp (const struct ddsi_domaingv *gv, const ddsi_guid_t *
unsigned delay_norm = delay_base >> 2;
int64_t delay_max_ms = gv->config.spdp_response_delay_max / 1000000;
int64_t delay = (int64_t) delay_norm * delay_max_ms / 1000;
- nn_mtime_t tsched = add_duration_to_mtime (tnow, delay);
+ ddsrt_mtime_t tsched = ddsrt_mtime_add_duration (tnow, delay);
GVTRACE (" %"PRId64, delay);
if (!pp->e.gv->config.unicast_response_to_spdp_messages)
/* pp can't reach gc_delete_participant => can safely reschedule */
@@ -416,7 +416,7 @@ static void respond_to_spdp (const struct ddsi_domaingv *gv, const ddsi_guid_t *
entidx_enum_participant_fini (&est);
}
-static int handle_SPDP_dead (const struct receiver_state *rst, nn_wctime_t timestamp, const ddsi_plist_t *datap, unsigned statusinfo)
+static int handle_SPDP_dead (const struct receiver_state *rst, ddsrt_wctime_t timestamp, const ddsi_plist_t *datap, unsigned statusinfo)
{
struct ddsi_domaingv * const gv = rst->gv;
ddsi_guid_t guid;
@@ -478,7 +478,7 @@ static struct proxy_participant *find_ddsi2_proxy_participant (const struct enti
return pp;
}
-static void make_participants_dependent_on_ddsi2 (struct ddsi_domaingv *gv, const ddsi_guid_t *ddsi2guid, nn_wctime_t timestamp)
+static void make_participants_dependent_on_ddsi2 (struct ddsi_domaingv *gv, const ddsi_guid_t *ddsi2guid, ddsrt_wctime_t timestamp)
{
struct entidx_enum_proxy_participant it;
struct proxy_participant *pp, *d2pp;
@@ -514,7 +514,7 @@ static void make_participants_dependent_on_ddsi2 (struct ddsi_domaingv *gv, cons
}
}
-static int handle_SPDP_alive (const struct receiver_state *rst, seqno_t seq, nn_wctime_t timestamp, const ddsi_plist_t *datap)
+static int handle_SPDP_alive (const struct receiver_state *rst, seqno_t seq, ddsrt_wctime_t timestamp, const ddsi_plist_t *datap)
{
struct ddsi_domaingv * const gv = rst->gv;
const unsigned bes_sedp_announcer_mask =
@@ -596,7 +596,7 @@ static int handle_SPDP_alive (const struct receiver_state *rst, seqno_t seq, nn_
that are not alive are not set alive here. This is done only when
data is received from a particular pwr (in handle_regular) */
if ((lease = ddsrt_atomic_ldvoidp (&proxypp->minl_auto)) != NULL)
- lease_renew (lease, now_et ());
+ lease_renew (lease, ddsrt_time_elapsed ());
ddsrt_mutex_lock (&proxypp->e.lock);
if (proxypp->implicitly_created || seq > proxypp->seq)
{
@@ -797,7 +797,7 @@ static int handle_SPDP_alive (const struct receiver_state *rst, seqno_t seq, nn_
return 1;
}
-static void handle_SPDP (const struct receiver_state *rst, seqno_t seq, nn_wctime_t timestamp, unsigned statusinfo, const void *vdata, uint32_t len)
+static void handle_SPDP (const struct receiver_state *rst, seqno_t seq, ddsrt_wctime_t timestamp, unsigned statusinfo, const void *vdata, uint32_t len)
{
struct ddsi_domaingv * const gv = rst->gv;
const struct CDRHeader *data = vdata; /* built-ins not deserialized (yet) */
@@ -1049,7 +1049,7 @@ static const char *durability_to_string (dds_durability_kind_t k)
return "undefined-durability";
}
-static struct proxy_participant *implicitly_create_proxypp (struct ddsi_domaingv *gv, const ddsi_guid_t *ppguid, ddsi_plist_t *datap /* note: potentially modifies datap */, const ddsi_guid_prefix_t *src_guid_prefix, nn_vendorid_t vendorid, nn_wctime_t timestamp, seqno_t seq)
+static struct proxy_participant *implicitly_create_proxypp (struct ddsi_domaingv *gv, const ddsi_guid_t *ppguid, ddsi_plist_t *datap /* note: potentially modifies datap */, const ddsi_guid_prefix_t *src_guid_prefix, nn_vendorid_t vendorid, ddsrt_wctime_t timestamp, seqno_t seq)
{
ddsi_guid_t privguid;
ddsi_plist_t pp_plist;
@@ -1129,7 +1129,7 @@ static struct proxy_participant *implicitly_create_proxypp (struct ddsi_domaingv
return entidx_lookup_proxy_participant_guid (gv->entity_index, ppguid);
}
-static void handle_SEDP_alive (const struct receiver_state *rst, seqno_t seq, ddsi_plist_t *datap /* note: potentially modifies datap */, const ddsi_guid_prefix_t *src_guid_prefix, nn_vendorid_t vendorid, nn_wctime_t timestamp)
+static void handle_SEDP_alive (const struct receiver_state *rst, seqno_t seq, ddsi_plist_t *datap /* note: potentially modifies datap */, const ddsi_guid_prefix_t *src_guid_prefix, nn_vendorid_t vendorid, ddsrt_wctime_t timestamp)
{
#define E(msg, lbl) do { GVLOGDISC (msg); goto lbl; } while (0)
struct ddsi_domaingv * const gv = rst->gv;
@@ -1225,7 +1225,7 @@ static void handle_SEDP_alive (const struct receiver_state *rst, seqno_t seq, dd
GVLOGDISC (" "PGUIDFMT" attach-to-DS "PGUIDFMT, PGUID(pp->e.guid), PGUIDPREFIX(*src_guid_prefix), pp->privileged_pp_guid.entityid.u);
ddsrt_mutex_lock (&pp->e.lock);
pp->privileged_pp_guid.prefix = *src_guid_prefix;
- lease_set_expiry(pp->lease, NN_ETIME_NEVER);
+ lease_set_expiry(pp->lease, DDSRT_ETIME_NEVER);
ddsrt_mutex_unlock (&pp->e.lock);
}
GVLOGDISC ("\n");
@@ -1324,7 +1324,7 @@ err:
#undef E
}
-static void handle_SEDP_dead (const struct receiver_state *rst, ddsi_plist_t *datap, nn_wctime_t timestamp)
+static void handle_SEDP_dead (const struct receiver_state *rst, ddsi_plist_t *datap, ddsrt_wctime_t timestamp)
{
struct ddsi_domaingv * const gv = rst->gv;
int res;
@@ -1341,7 +1341,7 @@ static void handle_SEDP_dead (const struct receiver_state *rst, ddsi_plist_t *da
GVLOGDISC (" %s\n", (res < 0) ? " unknown" : " delete");
}
-static void handle_SEDP (const struct receiver_state *rst, seqno_t seq, nn_wctime_t timestamp, unsigned statusinfo, const void *vdata, uint32_t len)
+static void handle_SEDP (const struct receiver_state *rst, seqno_t seq, ddsrt_wctime_t timestamp, unsigned statusinfo, const void *vdata, uint32_t len)
{
struct ddsi_domaingv * const gv = rst->gv;
const struct CDRHeader *data = vdata; /* built-ins not deserialized (yet) */
@@ -1477,7 +1477,7 @@ int builtins_dqueue_handler (const struct nn_rsample_info *sampleinfo, const str
unsigned char *datap;
int needs_free;
uint32_t datasz = sampleinfo->size;
- nn_wctime_t timestamp;
+ ddsrt_wctime_t timestamp;
needs_free = defragment (&datap, fragchain, sampleinfo->size);
@@ -1625,10 +1625,10 @@ int builtins_dqueue_handler (const struct nn_rsample_info *sampleinfo, const str
goto done_upd_deliv;
}
- if (sampleinfo->timestamp.v != NN_WCTIME_INVALID.v)
+ if (sampleinfo->timestamp.v != DDSRT_WCTIME_INVALID.v)
timestamp = sampleinfo->timestamp;
else
- timestamp = now ();
+ timestamp = ddsrt_time_wallclock ();
switch (srcguid.entityid.u)
{
case NN_ENTITYID_SPDP_BUILTIN_PARTICIPANT_WRITER:
diff --git a/src/core/ddsi/src/q_debmon.c b/src/core/ddsi/src/q_debmon.c
index fbf33a0..68f72af 100644
--- a/src/core/ddsi/src/q_debmon.c
+++ b/src/core/ddsi/src/q_debmon.c
@@ -22,7 +22,6 @@
#include "dds/ddsi/q_entity.h"
#include "dds/ddsi/q_config.h"
-#include "dds/ddsi/q_time.h"
#include "dds/ddsi/q_misc.h"
#include "dds/ddsi/q_log.h"
#include "dds/ddsi/ddsi_plist.h"
diff --git a/src/core/ddsi/src/q_entity.c b/src/core/ddsi/src/q_entity.c
index 6a34aaf..3cb3ee7 100644
--- a/src/core/ddsi/src/q_entity.c
+++ b/src/core/ddsi/src/q_entity.c
@@ -23,7 +23,6 @@
#include "dds/ddsi/q_entity.h"
#include "dds/ddsi/q_config.h"
-#include "dds/ddsi/q_time.h"
#include "dds/ddsi/q_misc.h"
#include "dds/ddsi/q_log.h"
#include "dds/ddsrt/avl.h"
@@ -54,7 +53,7 @@ struct deleted_participant {
ddsrt_avl_node_t avlnode;
ddsi_guid_t guid;
unsigned for_what;
- nn_mtime_t t_prune;
+ ddsrt_mtime_t t_prune;
};
struct deleted_participants_admin {
@@ -110,7 +109,7 @@ static int gcreq_proxy_reader (struct proxy_reader *prd);
extern inline bool builtintopic_is_visible (const struct ddsi_builtin_topic_interface *btif, const struct ddsi_guid *guid, nn_vendorid_t vendorid);
extern inline bool builtintopic_is_builtintopic (const struct ddsi_builtin_topic_interface *btif, const struct ddsi_sertopic *topic);
extern inline struct ddsi_tkmap_instance *builtintopic_get_tkmap_entry (const struct ddsi_builtin_topic_interface *btif, const struct ddsi_guid *guid);
-extern inline void builtintopic_write (const struct ddsi_builtin_topic_interface *btif, const struct entity_common *e, nn_wctime_t timestamp, bool alive);
+extern inline void builtintopic_write (const struct ddsi_builtin_topic_interface *btif, const struct entity_common *e, ddsrt_wctime_t timestamp, bool alive);
extern inline seqno_t writer_read_seq_xmit (const struct writer *wr);
extern inline void writer_update_seq_xmit (struct writer *wr, seqno_t nv);
@@ -209,7 +208,7 @@ const ddsrt_fibheap_def_t ldur_fhdef = DDSRT_FIBHEAPDEF_INITIALIZER(offsetof (st
/* used in (proxy)participant for writer liveliness monitoring */
const ddsrt_fibheap_def_t lease_fhdef_pp = DDSRT_FIBHEAPDEF_INITIALIZER(offsetof (struct lease, pp_heapnode), compare_lease_tdur);
-static void entity_common_init (struct entity_common *e, struct ddsi_domaingv *gv, const struct ddsi_guid *guid, const char *name, enum entity_kind kind, nn_wctime_t tcreate, nn_vendorid_t vendorid, bool onlylocal)
+static void entity_common_init (struct entity_common *e, struct ddsi_domaingv *gv, const struct ddsi_guid *guid, const char *name, enum entity_kind kind, ddsrt_wctime_t tcreate, nn_vendorid_t vendorid, bool onlylocal)
{
e->guid = *guid;
e->kind = kind;
@@ -355,9 +354,9 @@ void ddsi_make_writer_info(struct ddsi_writer_info *wrinfo, const struct entity_
wrinfo->iid = e->iid;
#ifdef DDSI_INCLUDE_LIFESPAN
if (xqos->lifespan.duration != DDS_INFINITY && (statusinfo & (NN_STATUSINFO_UNREGISTER | NN_STATUSINFO_DISPOSE)) == 0)
- wrinfo->lifespan_exp = add_duration_to_mtime(now_mt(), xqos->lifespan.duration);
+ wrinfo->lifespan_exp = ddsrt_mtime_add_duration(ddsrt_time_monotonic(), xqos->lifespan.duration);
else
- wrinfo->lifespan_exp = NN_MTIME_NEVER;
+ wrinfo->lifespan_exp = DDSRT_MTIME_NEVER;
#endif
}
@@ -380,7 +379,7 @@ void deleted_participants_admin_free (struct deleted_participants_admin *admin)
ddsrt_free (admin);
}
-static void prune_deleted_participant_guids_unlocked (struct deleted_participants_admin *admin, nn_mtime_t tnow)
+static void prune_deleted_participant_guids_unlocked (struct deleted_participants_admin *admin, ddsrt_mtime_t tnow)
{
/* Could do a better job of finding prunable ones efficiently under
all circumstances, but I expect the tree to be very small at all
@@ -400,7 +399,7 @@ static void prune_deleted_participant_guids_unlocked (struct deleted_participant
}
}
-static void prune_deleted_participant_guids (struct deleted_participants_admin *admin, nn_mtime_t tnow)
+static void prune_deleted_participant_guids (struct deleted_participants_admin *admin, ddsrt_mtime_t tnow)
{
ddsrt_mutex_lock (&admin->deleted_participants_lock);
prune_deleted_participant_guids_unlocked (admin, tnow);
@@ -417,7 +416,7 @@ static void remember_deleted_participant_guid (struct deleted_participants_admin
if ((n = ddsrt_malloc (sizeof (*n))) != NULL)
{
n->guid = *guid;
- n->t_prune = NN_MTIME_NEVER;
+ n->t_prune = DDSRT_MTIME_NEVER;
n->for_what = DPG_LOCAL | DPG_REMOTE;
ddsrt_avl_insert_ipath (&deleted_participants_treedef, &admin->deleted_participants, n, &path);
}
@@ -430,7 +429,7 @@ int is_deleted_participant_guid (struct deleted_participants_admin *admin, const
struct deleted_participant *n;
int known;
ddsrt_mutex_lock (&admin->deleted_participants_lock);
- prune_deleted_participant_guids_unlocked (admin, now_mt ());
+ prune_deleted_participant_guids_unlocked (admin, ddsrt_time_monotonic ());
if ((n = ddsrt_avl_lookup (&deleted_participants_treedef, &admin->deleted_participants, guid)) == NULL)
known = 0;
else
@@ -445,12 +444,12 @@ static void remove_deleted_participant_guid (struct deleted_participants_admin *
DDS_CLOG (DDS_LC_DISCOVERY, admin->logcfg, "remove_deleted_participant_guid("PGUIDFMT" for_what=%x)\n", PGUID (*guid), for_what);
ddsrt_mutex_lock (&admin->deleted_participants_lock);
if ((n = ddsrt_avl_lookup (&deleted_participants_treedef, &admin->deleted_participants, guid)) != NULL)
- n->t_prune = add_duration_to_mtime (now_mt (), admin->delay);
+ n->t_prune = ddsrt_mtime_add_duration (ddsrt_time_monotonic (), admin->delay);
ddsrt_mutex_unlock (&admin->deleted_participants_lock);
}
/* PARTICIPANT ------------------------------------------------------ */
-static bool update_qos_locked (struct entity_common *e, dds_qos_t *ent_qos, const dds_qos_t *xqos, nn_wctime_t timestamp)
+static bool update_qos_locked (struct entity_common *e, dds_qos_t *ent_qos, const dds_qos_t *xqos, ddsrt_wctime_t timestamp)
{
uint64_t mask;
@@ -541,7 +540,7 @@ static void participant_add_wr_lease_locked (struct participant * pp, const stru
/* if inserted lease is new shortest lease */
if (minl_prev != minl_new)
{
- nn_etime_t texp = add_duration_to_etime (now_et (), minl_new->tdur);
+ ddsrt_etime_t texp = ddsrt_etime_add_duration (ddsrt_time_elapsed (), minl_new->tdur);
struct lease *lnew = lease_new (texp, minl_new->tdur, minl_new->entity);
if (minl_prev == NULL)
{
@@ -571,7 +570,7 @@ static void participant_remove_wr_lease_locked (struct participant * pp, struct
{
dds_duration_t trem = minl->tdur - wr->lease->tdur;
assert (trem >= 0);
- nn_etime_t texp = add_duration_to_etime (now_et(), trem);
+ ddsrt_etime_t texp = ddsrt_etime_add_duration (ddsrt_time_elapsed(), trem);
struct lease *lnew = lease_new (texp, minl->tdur, minl->entity);
participant_replace_minl (pp, lnew);
lease_register (lnew);
@@ -594,7 +593,7 @@ dds_return_t new_participant_guid (const ddsi_guid_t *ppguid, struct ddsi_domain
/* privileged participant MUST have builtin readers and writers */
assert (!(flags & RTPS_PF_PRIVILEGED_PP) || (flags & (RTPS_PF_NO_BUILTIN_READERS | RTPS_PF_NO_BUILTIN_WRITERS)) == 0);
- prune_deleted_participant_guids (gv->deleted_participants, now_mt ());
+ prune_deleted_participant_guids (gv->deleted_participants, ddsrt_time_monotonic ());
/* FIXME: FULL LOCKING AROUND NEW_XXX FUNCTIONS, JUST SO EXISTENCE TESTS ARE PRECISE */
@@ -630,7 +629,7 @@ dds_return_t new_participant_guid (const ddsi_guid_t *ppguid, struct ddsi_domain
pp = ddsrt_malloc (sizeof (*pp));
- entity_common_init (&pp->e, gv, ppguid, "", EK_PARTICIPANT, now (), NN_VENDORID_ECLIPSE, ((flags & RTPS_PF_ONLY_LOCAL) != 0));
+ entity_common_init (&pp->e, gv, ppguid, "", EK_PARTICIPANT, ddsrt_time_wallclock (), NN_VENDORID_ECLIPSE, ((flags & RTPS_PF_ONLY_LOCAL) != 0));
pp->user_refc = 1;
pp->builtin_refc = 0;
pp->builtins_deleted = 0;
@@ -790,7 +789,7 @@ dds_return_t new_participant_guid (const ddsi_guid_t *ppguid, struct ddsi_domain
trigger_recv_threads (gv);
}
- builtintopic_write (gv->builtin_topic_interface, &pp->e, now(), true);
+ builtintopic_write (gv->builtin_topic_interface, &pp->e, ddsrt_time_wallclock(), true);
/* SPDP periodic broadcast uses the retransmit path, so the initial
publication must be done differently. Must be later than making
@@ -806,12 +805,12 @@ dds_return_t new_participant_guid (const ddsi_guid_t *ppguid, struct ddsi_domain
fire before the calls return. If the initial sample wasn't
accepted, all is lost, but we continue nonetheless, even though
the participant won't be able to discover or be discovered. */
- pp->spdp_xevent = qxev_spdp (gv->xevents, add_duration_to_mtime (now_mt (), DDS_MSECS (100)), &pp->e.guid, NULL);
+ pp->spdp_xevent = qxev_spdp (gv->xevents, ddsrt_mtime_add_duration (ddsrt_time_monotonic (), DDS_MSECS (100)), &pp->e.guid, NULL);
}
{
- nn_mtime_t tsched;
- tsched = (pp->lease_duration == DDS_INFINITY) ? NN_MTIME_NEVER : (nn_mtime_t){0};
+ ddsrt_mtime_t tsched;
+ tsched = (pp->lease_duration == DDS_INFINITY) ? DDSRT_MTIME_NEVER : (ddsrt_mtime_t){0};
pp->pmd_update_xevent = qxev_pmd_update (gv->xevents, tsched, &pp->e.guid);
}
return 0;
@@ -833,7 +832,7 @@ dds_return_t new_participant (ddsi_guid_t *p_ppguid, struct ddsi_domaingv *gv, u
void update_participant_plist (struct participant *pp, const ddsi_plist_t *plist)
{
ddsrt_mutex_lock (&pp->e.lock);
- if (update_qos_locked (&pp->e, &pp->plist->qos, &plist->qos, now ()))
+ if (update_qos_locked (&pp->e, &pp->plist->qos, &plist->qos, ddsrt_time_wallclock ()))
spdp_write (pp);
ddsrt_mutex_unlock (&pp->e.lock);
}
@@ -1016,7 +1015,7 @@ dds_return_t delete_participant (struct ddsi_domaingv *gv, const struct ddsi_gui
GVLOGDISC ("delete_participant("PGUIDFMT")\n", PGUID (*ppguid));
if ((pp = entidx_lookup_participant_guid (gv->entity_index, ppguid)) == NULL)
return DDS_RETCODE_BAD_PARAMETER;
- builtintopic_write (gv->builtin_topic_interface, &pp->e, now(), false);
+ builtintopic_write (gv->builtin_topic_interface, &pp->e, ddsrt_time_wallclock(), false);
remember_deleted_participant_guid (gv->deleted_participants, &pp->e.guid);
entidx_remove_participant_guid (gv->entity_index, pp);
gcreq_participant (pp);
@@ -1864,7 +1863,7 @@ static void writer_add_connection (struct writer *wr, struct proxy_reader *prd)
m->next_acknack = DDSI_COUNT_MIN;
m->next_nackfrag = DDSI_COUNT_MIN;
nn_lat_estim_init (&m->hb_to_ack_latency);
- m->hb_to_ack_latency_tlastlog = now ();
+ m->hb_to_ack_latency_tlastlog = ddsrt_time_wallclock ();
m->t_acknack_accepted.v = 0;
ddsrt_mutex_lock (&wr->e.lock);
@@ -1909,7 +1908,7 @@ static void writer_add_connection (struct writer *wr, struct proxy_reader *prd)
if (wr->heartbeat_xevent)
{
const int64_t delta = DDS_MSECS (1);
- const nn_mtime_t tnext = add_duration_to_mtime (now_mt (), delta);
+ const ddsrt_mtime_t tnext = ddsrt_mtime_add_duration (ddsrt_time_monotonic (), delta);
ddsrt_mutex_lock (&wr->e.lock);
/* To make sure that we keep sending heartbeats at a higher rate
at the start of this discovery, reset the hbs_since_last_write
@@ -2097,7 +2096,7 @@ static void reader_add_local_connection (struct reader *rd, struct writer *wr, c
}
}
-static void proxy_writer_add_connection (struct proxy_writer *pwr, struct reader *rd, nn_mtime_t tnow, nn_count_t init_count)
+static void proxy_writer_add_connection (struct proxy_writer *pwr, struct reader *rd, ddsrt_mtime_t tnow, nn_count_t init_count)
{
struct pwr_rd_match *m = ddsrt_malloc (sizeof (*m));
ddsrt_avl_ipath_t path;
@@ -2116,7 +2115,7 @@ static void proxy_writer_add_connection (struct proxy_writer *pwr, struct reader
ELOGDISC (pwr, " proxy_writer_add_connection(pwr "PGUIDFMT" rd "PGUIDFMT")",
PGUID (pwr->e.guid), PGUID (rd->e.guid));
m->rd_guid = rd->e.guid;
- m->tcreate = now_mt ();
+ m->tcreate = ddsrt_time_monotonic ();
/* We track the last heartbeat count value per reader--proxy-writer
pair, so that we can correctly handle directed heartbeats. The
@@ -2191,7 +2190,7 @@ static void proxy_writer_add_connection (struct proxy_writer *pwr, struct reader
hopefully it won't make that much of a difference in practice.) */
if (rd->reliable)
{
- m->acknack_xevent = qxev_acknack (pwr->evq, add_duration_to_mtime (tnow, pwr->e.gv->config.preemptive_ack_delay), &pwr->e.guid, &rd->e.guid);
+ m->acknack_xevent = qxev_acknack (pwr->evq, ddsrt_mtime_add_duration (tnow, pwr->e.gv->config.preemptive_ack_delay), &pwr->e.guid, &rd->e.guid);
m->u.not_in_sync.reorder =
nn_reorder_new (&pwr->e.gv->logconfig, NN_REORDER_MODE_NORMAL, pwr->e.gv->config.secondary_reorder_maxsamples, pwr->e.gv->config.late_ack_mode);
pwr->n_reliable_readers++;
@@ -2336,7 +2335,7 @@ static bool topickind_qos_match_p_lock (struct entity_common *rd, const dds_qos_
return ret;
}
-static void connect_writer_with_proxy_reader (struct writer *wr, struct proxy_reader *prd, nn_mtime_t tnow)
+static void connect_writer_with_proxy_reader (struct writer *wr, struct proxy_reader *prd, ddsrt_mtime_t tnow)
{
const int isb0 = (is_builtin_entityid (wr->e.guid.entityid, NN_VENDORID_ECLIPSE) != 0);
const int isb1 = (is_builtin_entityid (prd->e.guid.entityid, prd->c.vendor) != 0);
@@ -2355,7 +2354,7 @@ static void connect_writer_with_proxy_reader (struct writer *wr, struct proxy_re
writer_add_connection (wr, prd);
}
-static void connect_proxy_writer_with_reader (struct proxy_writer *pwr, struct reader *rd, nn_mtime_t tnow)
+static void connect_proxy_writer_with_reader (struct proxy_writer *pwr, struct reader *rd, ddsrt_mtime_t tnow)
{
const int isb0 = (is_builtin_entityid (pwr->e.guid.entityid, pwr->c.vendor) != 0);
const int isb1 = (is_builtin_entityid (rd->e.guid.entityid, NN_VENDORID_ECLIPSE) != 0);
@@ -2410,7 +2409,7 @@ static bool ignore_local_p (const ddsi_guid_t *guid1, const ddsi_guid_t *guid2,
return false;
}
-static void connect_writer_with_reader (struct writer *wr, struct reader *rd, nn_mtime_t tnow)
+static void connect_writer_with_reader (struct writer *wr, struct reader *rd, ddsrt_mtime_t tnow)
{
dds_qos_policy_id_t reason;
struct alive_state alive_state;
@@ -2438,7 +2437,7 @@ static void connect_writer_with_reader (struct writer *wr, struct reader *rd, nn
reader_update_notify_wr_alive_state (rd, wr, &alive_state);
}
-static void connect_writer_with_proxy_reader_wrapper (struct entity_common *vwr, struct entity_common *vprd, nn_mtime_t tnow)
+static void connect_writer_with_proxy_reader_wrapper (struct entity_common *vwr, struct entity_common *vprd, ddsrt_mtime_t tnow)
{
struct writer *wr = (struct writer *) vwr;
struct proxy_reader *prd = (struct proxy_reader *) vprd;
@@ -2448,7 +2447,7 @@ static void connect_writer_with_proxy_reader_wrapper (struct entity_common *vwr,
connect_writer_with_proxy_reader (wr, prd, tnow);
}
-static void connect_proxy_writer_with_reader_wrapper (struct entity_common *vpwr, struct entity_common *vrd, nn_mtime_t tnow)
+static void connect_proxy_writer_with_reader_wrapper (struct entity_common *vpwr, struct entity_common *vrd, ddsrt_mtime_t tnow)
{
struct proxy_writer *pwr = (struct proxy_writer *) vpwr;
struct reader *rd = (struct reader *) vrd;
@@ -2458,7 +2457,7 @@ static void connect_proxy_writer_with_reader_wrapper (struct entity_common *vpwr
connect_proxy_writer_with_reader (pwr, rd, tnow);
}
-static void connect_writer_with_reader_wrapper (struct entity_common *vwr, struct entity_common *vrd, nn_mtime_t tnow)
+static void connect_writer_with_reader_wrapper (struct entity_common *vwr, struct entity_common *vrd, ddsrt_mtime_t tnow)
{
struct writer *wr = (struct writer *) vwr;
struct reader *rd = (struct reader *) vrd;
@@ -2486,7 +2485,7 @@ static enum entity_kind generic_do_match_mkind (enum entity_kind kind, bool loca
return EK_WRITER;
}
-static void generic_do_match_connect (struct entity_common *e, struct entity_common *em, nn_mtime_t tnow, bool local)
+static void generic_do_match_connect (struct entity_common *e, struct entity_common *em, ddsrt_mtime_t tnow, bool local)
{
switch (e->kind)
{
@@ -2534,7 +2533,7 @@ static const char *entity_topic_name (const struct entity_common *e)
return "";
}
-static void generic_do_match (struct entity_common *e, nn_mtime_t tnow, bool local)
+static void generic_do_match (struct entity_common *e, ddsrt_mtime_t tnow, bool local)
{
static const struct { const char *full; const char *full_us; const char *abbrev; } kindstr[] = {
[EK_WRITER] = { "writer", "writer", "wr" },
@@ -2600,32 +2599,32 @@ static void generic_do_match (struct entity_common *e, nn_mtime_t tnow, bool loc
}
}
-static void match_writer_with_proxy_readers (struct writer *wr, nn_mtime_t tnow)
+static void match_writer_with_proxy_readers (struct writer *wr, ddsrt_mtime_t tnow)
{
generic_do_match (&wr->e, tnow, false);
}
-static void match_writer_with_local_readers (struct writer *wr, nn_mtime_t tnow)
+static void match_writer_with_local_readers (struct writer *wr, ddsrt_mtime_t tnow)
{
generic_do_match (&wr->e, tnow, true);
}
-static void match_reader_with_proxy_writers (struct reader *rd, nn_mtime_t tnow)
+static void match_reader_with_proxy_writers (struct reader *rd, ddsrt_mtime_t tnow)
{
generic_do_match (&rd->e, tnow, false);
}
-static void match_reader_with_local_writers (struct reader *rd, nn_mtime_t tnow)
+static void match_reader_with_local_writers (struct reader *rd, ddsrt_mtime_t tnow)
{
generic_do_match (&rd->e, tnow, true);
}
-static void match_proxy_writer_with_readers (struct proxy_writer *pwr, nn_mtime_t tnow)
+static void match_proxy_writer_with_readers (struct proxy_writer *pwr, ddsrt_mtime_t tnow)
{
generic_do_match (&pwr->e, tnow, false);
}
-static void match_proxy_reader_with_writers (struct proxy_reader *prd, nn_mtime_t tnow)
+static void match_proxy_reader_with_writers (struct proxy_reader *prd, ddsrt_mtime_t tnow)
{
generic_do_match(&prd->e, tnow, false);
}
@@ -2660,7 +2659,7 @@ static void new_reader_writer_common (const struct ddsrt_log_cfg *logcfg, const
static void endpoint_common_init (struct entity_common *e, struct endpoint_common *c, struct ddsi_domaingv *gv, enum entity_kind kind, const struct ddsi_guid *guid, const struct ddsi_guid *group_guid, struct participant *pp, bool onlylocal)
{
- entity_common_init (e, gv, guid, NULL, kind, now (), NN_VENDORID_ECLIPSE, pp->e.onlylocal || onlylocal);
+ entity_common_init (e, gv, guid, NULL, kind, ddsrt_time_wallclock (), NN_VENDORID_ECLIPSE, pp->e.onlylocal || onlylocal);
c->pp = ref_participant (pp, &e->guid);
if (group_guid)
c->group_guid = *group_guid;
@@ -2861,7 +2860,7 @@ void writer_set_retransmitting (struct writer *wr)
void writer_clear_retransmitting (struct writer *wr)
{
wr->retransmitting = 0;
- wr->t_whc_high_upd = wr->t_rexmit_end = now_et();
+ wr->t_whc_high_upd = wr->t_rexmit_end = ddsrt_time_elapsed();
ddsrt_cond_broadcast (&wr->throttle_cond);
}
@@ -2924,7 +2923,7 @@ void writer_set_alive_may_unlock (struct writer *wr, bool notify)
if (wr->xqos->liveliness.kind == DDS_LIVELINESS_MANUAL_BY_PARTICIPANT)
participant_add_wr_lease_locked (wr->c.pp, wr);
else if (wr->xqos->liveliness.kind == DDS_LIVELINESS_MANUAL_BY_TOPIC)
- lease_set_expiry (wr->lease, add_duration_to_etime (now_et (), wr->lease->tdur));
+ lease_set_expiry (wr->lease, ddsrt_etime_add_duration (ddsrt_time_elapsed (), wr->lease->tdur));
}
ddsrt_mutex_unlock (&wr->c.pp->e.lock);
@@ -3092,7 +3091,7 @@ static void new_writer_guid_common_init (struct writer *wr, const struct ddsi_se
scheduled, and this can only change by writing data, which won't
happen until after it becomes visible. */
if (wr->reliable)
- wr->heartbeat_xevent = qxev_heartbeat (wr->evq, NN_MTIME_NEVER, &wr->e.guid);
+ wr->heartbeat_xevent = qxev_heartbeat (wr->evq, DDSRT_MTIME_NEVER, &wr->e.guid);
else
wr->heartbeat_xevent = NULL;
@@ -3133,7 +3132,7 @@ static void new_writer_guid_common_init (struct writer *wr, const struct ddsi_se
static dds_return_t new_writer_guid (struct writer **wr_out, const struct ddsi_guid *guid, const struct ddsi_guid *group_guid, struct participant *pp, const struct ddsi_sertopic *topic, const struct dds_qos *xqos, struct whc *whc, status_cb_t status_cb, void *status_entity)
{
struct writer *wr;
- nn_mtime_t tnow = now_mt ();
+ ddsrt_mtime_t tnow = ddsrt_time_monotonic ();
assert (is_writer_entityid (guid->entityid));
assert (entidx_lookup_writer_guid (pp->e.gv->entity_index, guid) == NULL);
@@ -3159,7 +3158,7 @@ static dds_return_t new_writer_guid (struct writer **wr_out, const struct ddsi_g
the other. */
ddsrt_mutex_lock (&wr->e.lock);
entidx_insert_writer_guid (pp->e.gv->entity_index, wr);
- builtintopic_write (wr->e.gv->builtin_topic_interface, &wr->e, now(), true);
+ builtintopic_write (wr->e.gv->builtin_topic_interface, &wr->e, ddsrt_time_wallclock(), true);
ddsrt_mutex_unlock (&wr->e.lock);
/* once it exists, match it with proxy writers and broadcast
@@ -3184,11 +3183,11 @@ static dds_return_t new_writer_guid (struct writer **wr_out, const struct ddsi_g
ddsrt_mutex_unlock (&pp->e.lock);
/* Trigger pmd update */
- (void) resched_xevent_if_earlier (pp->pmd_update_xevent, now_mt ());
+ (void) resched_xevent_if_earlier (pp->pmd_update_xevent, ddsrt_time_monotonic ());
}
else
{
- nn_etime_t texpire = add_duration_to_etime (now_et (), wr->lease_duration->ldur);
+ ddsrt_etime_t texpire = ddsrt_etime_add_duration (ddsrt_time_elapsed (), wr->lease_duration->ldur);
wr->lease = lease_new (texpire, wr->lease_duration->ldur, &wr->e);
if (wr->xqos->liveliness.kind == DDS_LIVELINESS_MANUAL_BY_PARTICIPANT)
{
@@ -3233,7 +3232,7 @@ struct local_orphan_writer *new_local_orphan_writer (struct ddsi_domaingv *gv, d
ddsi_guid_t guid;
struct local_orphan_writer *lowr;
struct writer *wr;
- nn_mtime_t tnow = now_mt ();
+ ddsrt_mtime_t tnow = ddsrt_time_monotonic ();
GVLOGDISC ("new_local_orphan_writer(%s/%s)\n", topic->name, topic->type_name);
lowr = ddsrt_malloc (sizeof (*lowr));
@@ -3241,12 +3240,12 @@ struct local_orphan_writer *new_local_orphan_writer (struct ddsi_domaingv *gv, d
memset (&guid.prefix, 0, sizeof (guid.prefix));
guid.entityid = entityid;
- entity_common_init (&wr->e, gv, &guid, NULL, EK_WRITER, now (), NN_VENDORID_ECLIPSE, true);
+ entity_common_init (&wr->e, gv, &guid, NULL, EK_WRITER, ddsrt_time_wallclock (), NN_VENDORID_ECLIPSE, true);
wr->c.pp = NULL;
memset (&wr->c.group_guid, 0, sizeof (wr->c.group_guid));
new_writer_guid_common_init (wr, topic, xqos, whc, 0, NULL);
entidx_insert_writer_guid (gv->entity_index, wr);
- builtintopic_write (gv->builtin_topic_interface, &wr->e, now(), true);
+ builtintopic_write (gv->builtin_topic_interface, &wr->e, ddsrt_time_wallclock(), true);
match_writer_with_local_readers (wr, tnow);
return lowr;
}
@@ -3254,7 +3253,7 @@ struct local_orphan_writer *new_local_orphan_writer (struct ddsi_domaingv *gv, d
void update_writer_qos (struct writer *wr, const dds_qos_t *xqos)
{
ddsrt_mutex_lock (&wr->e.lock);
- if (update_qos_locked (&wr->e, wr->xqos, xqos, now ()))
+ if (update_qos_locked (&wr->e, wr->xqos, xqos, ddsrt_time_wallclock ()))
sedp_write_writer (wr);
ddsrt_mutex_unlock (&wr->e.lock);
}
@@ -3271,7 +3270,7 @@ static void gc_delete_writer (struct gcreq *gcreq)
if (wr->heartbeat_xevent)
{
- wr->hbcontrol.tsched = NN_MTIME_NEVER;
+ wr->hbcontrol.tsched = DDSRT_MTIME_NEVER;
delete_xevent (wr->heartbeat_xevent);
}
@@ -3388,7 +3387,7 @@ dds_return_t delete_writer_nolinger_locked (struct writer *wr)
{
ELOGDISC (wr, "delete_writer_nolinger(guid "PGUIDFMT") ...\n", PGUID (wr->e.guid));
ASSERT_MUTEX_HELD (&wr->e.lock);
- builtintopic_write (wr->e.gv->builtin_topic_interface, &wr->e, now(), false);
+ builtintopic_write (wr->e.gv->builtin_topic_interface, &wr->e, ddsrt_time_wallclock(), false);
local_reader_ary_setinvalid (&wr->rdary);
entidx_remove_writer_guid (wr->e.gv->entity_index, wr);
writer_set_state (wr, WRST_DELETING);
@@ -3399,7 +3398,7 @@ dds_return_t delete_writer_nolinger_locked (struct writer *wr)
ddsrt_mutex_lock (&wr->c.pp->e.lock);
ddsrt_fibheap_delete (&ldur_fhdef, &wr->c.pp->ldur_auto_wr, wr->lease_duration);
ddsrt_mutex_unlock (&wr->c.pp->e.lock);
- resched_xevent_if_earlier (wr->c.pp->pmd_update_xevent, now_mt ());
+ resched_xevent_if_earlier (wr->c.pp->pmd_update_xevent, ddsrt_time_monotonic ());
}
else
{
@@ -3468,12 +3467,12 @@ dds_return_t delete_writer (struct ddsi_domaingv *gv, const struct ddsi_guid *gu
}
else
{
- nn_mtime_t tsched;
+ ddsrt_mtime_t tsched;
int32_t tsec, tusec;
writer_set_state (wr, WRST_LINGERING);
ddsrt_mutex_unlock (&wr->e.lock);
- tsched = add_duration_to_mtime (now_mt (), wr->e.gv->config.writer_linger_duration);
- mtime_to_sec_usec (&tsec, &tusec, tsched);
+ tsched = ddsrt_mtime_add_duration (ddsrt_time_monotonic (), wr->e.gv->config.writer_linger_duration);
+ ddsrt_mtime_to_sec_usec (&tsec, &tusec, tsched);
GVLOGDISC ("delete_writer(guid "PGUIDFMT") - unack'ed samples, will delete when ack'd or at t = %"PRId32".%06"PRId32"\n",
PGUID (*guid), tsec, tusec);
qxev_delete_writer (gv->xevents, tsched, &wr->e.guid);
@@ -3604,7 +3603,7 @@ static dds_return_t new_reader_guid
/* see new_writer_guid for commenets */
struct reader *rd;
- nn_mtime_t tnow = now_mt ();
+ ddsrt_mtime_t tnow = ddsrt_time_monotonic ();
assert (!is_writer_entityid (guid->entityid));
assert (entidx_lookup_reader_guid (pp->e.gv->entity_index, guid) == NULL);
@@ -3715,7 +3714,7 @@ static dds_return_t new_reader_guid
ddsrt_mutex_lock (&rd->e.lock);
entidx_insert_reader_guid (pp->e.gv->entity_index, rd);
- builtintopic_write (pp->e.gv->builtin_topic_interface, &rd->e, now(), true);
+ builtintopic_write (pp->e.gv->builtin_topic_interface, &rd->e, ddsrt_time_wallclock(), true);
ddsrt_mutex_unlock (&rd->e.lock);
match_reader_with_proxy_writers (rd, tnow);
@@ -3816,7 +3815,7 @@ dds_return_t delete_reader (struct ddsi_domaingv *gv, const struct ddsi_guid *gu
return DDS_RETCODE_BAD_PARAMETER;
}
GVLOGDISC ("delete_reader_guid(guid "PGUIDFMT") ...\n", PGUID (*guid));
- builtintopic_write (rd->e.gv->builtin_topic_interface, &rd->e, now(), false);
+ builtintopic_write (rd->e.gv->builtin_topic_interface, &rd->e, ddsrt_time_wallclock(), false);
entidx_remove_reader_guid (gv->entity_index, rd);
gcreq_reader (rd);
return 0;
@@ -3825,7 +3824,7 @@ dds_return_t delete_reader (struct ddsi_domaingv *gv, const struct ddsi_guid *gu
void update_reader_qos (struct reader *rd, const dds_qos_t *xqos)
{
ddsrt_mutex_lock (&rd->e.lock);
- if (update_qos_locked (&rd->e, rd->xqos, xqos, now ()))
+ if (update_qos_locked (&rd->e, rd->xqos, xqos, ddsrt_time_wallclock ()))
sedp_write_reader (rd);
ddsrt_mutex_unlock (&rd->e.lock);
}
@@ -3858,7 +3857,7 @@ void proxy_participant_reassign_lease (struct proxy_participant *proxypp, struct
{
dds_duration_t trem = minl->tdur - proxypp->lease->tdur;
assert (trem >= 0);
- nn_etime_t texp = add_duration_to_etime (now_et(), trem);
+ ddsrt_etime_t texp = ddsrt_etime_add_duration (ddsrt_time_elapsed(), trem);
struct lease *lnew = lease_new (texp, minl->tdur, minl->entity);
proxy_participant_replace_minl (proxypp, false, lnew);
lease_register (lnew);
@@ -3908,7 +3907,7 @@ static void proxy_participant_add_pwr_lease_locked (struct proxy_participant * p
/* if inserted lease is new shortest lease */
if (proxypp->owns_lease && minl_prev != minl_new)
{
- nn_etime_t texp = add_duration_to_etime (now_et (), minl_new->tdur);
+ ddsrt_etime_t texp = ddsrt_etime_add_duration (ddsrt_time_elapsed (), minl_new->tdur);
struct lease *lnew = lease_new (texp, minl_new->tdur, minl_new->entity);
if (minl_prev == NULL)
{
@@ -3942,7 +3941,7 @@ static void proxy_participant_remove_pwr_lease_locked (struct proxy_participant
{
dds_duration_t trem = minl->tdur - pwr->lease->tdur;
assert (trem >= 0);
- nn_etime_t texp = add_duration_to_etime (now_et(), trem);
+ ddsrt_etime_t texp = ddsrt_etime_add_duration (ddsrt_time_elapsed(), trem);
struct lease *lnew = lease_new (texp, minl->tdur, minl->entity);
proxy_participant_replace_minl (proxypp, manbypp, lnew);
lease_register (lnew);
@@ -3954,7 +3953,7 @@ static void proxy_participant_remove_pwr_lease_locked (struct proxy_participant
}
}
-void new_proxy_participant (struct ddsi_domaingv *gv, const struct ddsi_guid *ppguid, uint32_t bes, const struct ddsi_guid *privileged_pp_guid, struct addrset *as_default, struct addrset *as_meta, const ddsi_plist_t *plist, dds_duration_t tlease_dur, nn_vendorid_t vendor, unsigned custom_flags, nn_wctime_t timestamp, seqno_t seq)
+void new_proxy_participant (struct ddsi_domaingv *gv, const struct ddsi_guid *ppguid, uint32_t bes, const struct ddsi_guid *privileged_pp_guid, struct addrset *as_default, struct addrset *as_meta, const ddsi_plist_t *plist, dds_duration_t tlease_dur, nn_vendorid_t vendor, unsigned custom_flags, ddsrt_wctime_t timestamp, seqno_t seq)
{
/* No locking => iff all participants use unique guids, and sedp
runs on a single thread, it can't go wrong. FIXME, maybe? The
@@ -3965,7 +3964,7 @@ void new_proxy_participant (struct ddsi_domaingv *gv, const struct ddsi_guid *pp
assert (entidx_lookup_proxy_participant_guid (gv->entity_index, ppguid) == NULL);
assert (privileged_pp_guid == NULL || privileged_pp_guid->entityid.u == NN_ENTITYID_PARTICIPANT);
- prune_deleted_participant_guids (gv->deleted_participants, now_mt ());
+ prune_deleted_participant_guids (gv->deleted_participants, ddsrt_time_monotonic ());
proxypp = ddsrt_malloc (sizeof (*proxypp));
@@ -4018,7 +4017,7 @@ void new_proxy_participant (struct ddsi_domaingv *gv, const struct ddsi_guid *pp
no further triggers for deleting it. Instead, we take tlease_dur == NEVER as a special value meaning a
lease that doesn't expire now and that has a "reasonable" lease duration. That way the lease renewal in
the data path is fine, and we only need to do something special in SEDP handling. */
- nn_etime_t texp = add_duration_to_etime (now_et(), tlease_dur);
+ ddsrt_etime_t texp = ddsrt_etime_add_duration (ddsrt_time_elapsed(), tlease_dur);
dds_duration_t dur = (tlease_dur == DDS_INFINITY) ? gv->config.lease_duration : tlease_dur;
proxypp->lease = lease_new (texp, dur, &proxypp->e);
proxypp->owns_lease = 1;
@@ -4139,7 +4138,7 @@ void new_proxy_participant (struct ddsi_domaingv *gv, const struct ddsi_guid *pp
ddsrt_mutex_unlock (&proxypp->e.lock);
}
-int update_proxy_participant_plist_locked (struct proxy_participant *proxypp, seqno_t seq, const struct ddsi_plist *datap, nn_wctime_t timestamp)
+int update_proxy_participant_plist_locked (struct proxy_participant *proxypp, seqno_t seq, const struct ddsi_plist *datap, ddsrt_wctime_t timestamp)
{
if (seq > proxypp->seq)
{
@@ -4160,7 +4159,7 @@ int update_proxy_participant_plist_locked (struct proxy_participant *proxypp, se
return 0;
}
-int update_proxy_participant_plist (struct proxy_participant *proxypp, seqno_t seq, const struct ddsi_plist *datap, nn_wctime_t timestamp)
+int update_proxy_participant_plist (struct proxy_participant *proxypp, seqno_t seq, const struct ddsi_plist *datap, ddsrt_wctime_t timestamp)
{
ddsrt_mutex_lock (&proxypp->e.lock);
update_proxy_participant_plist_locked (proxypp, seq, datap, timestamp);
@@ -4194,7 +4193,7 @@ static int ref_proxy_participant (struct proxy_participant *proxypp, struct prox
static void unref_proxy_participant (struct proxy_participant *proxypp, struct proxy_endpoint_common *c)
{
uint32_t refc;
- const nn_wctime_t tnow = now();
+ const ddsrt_wctime_t tnow = ddsrt_time_wallclock();
ddsrt_mutex_lock (&proxypp->e.lock);
refc = --proxypp->refc;
@@ -4269,7 +4268,7 @@ static struct entity_common *entity_common_from_proxy_endpoint_common (const str
return (struct entity_common *) ((char *) c - offsetof (struct proxy_writer, c));
}
-static void delete_or_detach_dependent_pp (struct proxy_participant *p, struct proxy_participant *proxypp, nn_wctime_t timestamp, int isimplicit)
+static void delete_or_detach_dependent_pp (struct proxy_participant *p, struct proxy_participant *proxypp, ddsrt_wctime_t timestamp, int isimplicit)
{
ddsrt_mutex_lock (&p->e.lock);
if (memcmp (&p->privileged_pp_guid, &proxypp->e.guid, sizeof (proxypp->e.guid)) != 0)
@@ -4286,7 +4285,7 @@ static void delete_or_detach_dependent_pp (struct proxy_participant *p, struct p
}
else
{
- nn_etime_t texp = add_duration_to_etime (now_et(), p->e.gv->config.ds_grace_period);
+ ddsrt_etime_t texp = ddsrt_etime_add_duration (ddsrt_time_elapsed(), p->e.gv->config.ds_grace_period);
/* Clear dependency (but don't touch entity id, which must be 0x1c1) and set the lease ticking */
ELOGDISC (p, PGUIDFMT" detach-from-DS "PGUIDFMT"\n", PGUID(p->e.guid), PGUID(proxypp->e.guid));
memset (&p->privileged_pp_guid.prefix, 0, sizeof (p->privileged_pp_guid.prefix));
@@ -4296,7 +4295,7 @@ static void delete_or_detach_dependent_pp (struct proxy_participant *p, struct p
}
}
-static void delete_ppt (struct proxy_participant *proxypp, nn_wctime_t timestamp, int isimplicit)
+static void delete_ppt (struct proxy_participant *proxypp, ddsrt_wctime_t timestamp, int isimplicit)
{
ddsi_entityid_t *eps;
ddsi_guid_t ep_guid;
@@ -4351,7 +4350,7 @@ static void delete_ppt (struct proxy_participant *proxypp, nn_wctime_t timestamp
typedef struct proxy_purge_data {
struct proxy_participant *proxypp;
const nn_locator_t *loc;
- nn_wctime_t timestamp;
+ ddsrt_wctime_t timestamp;
} *proxy_purge_data_t;
static void purge_helper (const nn_locator_t *n, void * varg)
@@ -4371,7 +4370,7 @@ void purge_proxy_participants (struct ddsi_domaingv *gv, const nn_locator_t *loc
thread_state_awake_fixed_domain (ts1);
data.loc = loc;
- data.timestamp = now();
+ data.timestamp = ddsrt_time_wallclock();
entidx_enum_proxy_participant_init (&est, gv->entity_index);
while ((data.proxypp = entidx_enum_proxy_participant_next (&est)) != NULL)
addrset_forall (data.proxypp->as_meta, purge_helper, &data);
@@ -4384,7 +4383,7 @@ void purge_proxy_participants (struct ddsi_domaingv *gv, const nn_locator_t *loc
thread_state_asleep (ts1);
}
-int delete_proxy_participant_by_guid (struct ddsi_domaingv *gv, const struct ddsi_guid *guid, nn_wctime_t timestamp, int isimplicit)
+int delete_proxy_participant_by_guid (struct ddsi_domaingv *gv, const struct ddsi_guid *guid, ddsrt_wctime_t timestamp, int isimplicit)
{
struct proxy_participant *ppt;
@@ -4421,7 +4420,7 @@ uint64_t get_entity_instance_id (const struct ddsi_domaingv *gv, const struct dd
/* PROXY-ENDPOINT --------------------------------------------------- */
-static int proxy_endpoint_common_init (struct entity_common *e, struct proxy_endpoint_common *c, enum entity_kind kind, const struct ddsi_guid *guid, nn_wctime_t tcreate, seqno_t seq, struct proxy_participant *proxypp, struct addrset *as, const ddsi_plist_t *plist)
+static int proxy_endpoint_common_init (struct entity_common *e, struct proxy_endpoint_common *c, enum entity_kind kind, const struct ddsi_guid *guid, ddsrt_wctime_t tcreate, seqno_t seq, struct proxy_participant *proxypp, struct addrset *as, const ddsi_plist_t *plist)
{
const char *name;
int ret;
@@ -4466,12 +4465,12 @@ static void proxy_endpoint_common_fini (struct entity_common *e, struct proxy_en
/* PROXY-WRITER ----------------------------------------------------- */
-int new_proxy_writer (struct ddsi_domaingv *gv, const struct ddsi_guid *ppguid, const struct ddsi_guid *guid, struct addrset *as, const ddsi_plist_t *plist, struct nn_dqueue *dqueue, struct xeventq *evq, nn_wctime_t timestamp, seqno_t seq)
+int new_proxy_writer (struct ddsi_domaingv *gv, const struct ddsi_guid *ppguid, const struct ddsi_guid *guid, struct addrset *as, const ddsi_plist_t *plist, struct nn_dqueue *dqueue, struct xeventq *evq, ddsrt_wctime_t timestamp, seqno_t seq)
{
struct proxy_participant *proxypp;
struct proxy_writer *pwr;
int isreliable;
- nn_mtime_t tnow = now_mt ();
+ ddsrt_mtime_t tnow = ddsrt_time_monotonic ();
int ret;
assert (is_writer_entityid (guid->entityid));
@@ -4524,7 +4523,7 @@ int new_proxy_writer (struct ddsi_domaingv *gv, const struct ddsi_guid *ppguid,
assert (pwr->c.xqos->present & QP_LIVELINESS);
if (pwr->c.xqos->liveliness.lease_duration != DDS_INFINITY)
{
- nn_etime_t texpire = add_duration_to_etime (now_et (), pwr->c.xqos->liveliness.lease_duration);
+ ddsrt_etime_t texpire = ddsrt_etime_add_duration (ddsrt_time_elapsed (), pwr->c.xqos->liveliness.lease_duration);
pwr->lease = lease_new (texpire, pwr->c.xqos->liveliness.lease_duration, &pwr->e);
if (pwr->c.xqos->liveliness.kind != DDS_LIVELINESS_MANUAL_BY_TOPIC)
{
@@ -4573,7 +4572,7 @@ int new_proxy_writer (struct ddsi_domaingv *gv, const struct ddsi_guid *ppguid,
return 0;
}
-void update_proxy_writer (struct proxy_writer *pwr, seqno_t seq, struct addrset *as, const struct dds_qos *xqos, nn_wctime_t timestamp)
+void update_proxy_writer (struct proxy_writer *pwr, seqno_t seq, struct addrset *as, const struct dds_qos *xqos, ddsrt_wctime_t timestamp)
{
struct reader * rd;
struct pwr_rd_match * m;
@@ -4610,7 +4609,7 @@ void update_proxy_writer (struct proxy_writer *pwr, seqno_t seq, struct addrset
ddsrt_mutex_unlock (&pwr->e.lock);
}
-void update_proxy_reader (struct proxy_reader *prd, seqno_t seq, struct addrset *as, const struct dds_qos *xqos, nn_wctime_t timestamp)
+void update_proxy_reader (struct proxy_reader *prd, seqno_t seq, struct addrset *as, const struct dds_qos *xqos, ddsrt_wctime_t timestamp)
{
struct prd_wr_match * m;
ddsi_guid_t wrguid;
@@ -4692,7 +4691,7 @@ static void gc_delete_proxy_writer (struct gcreq *gcreq)
/* First stage in deleting the proxy writer. In this function the pwr and its member pointers
will remain valid. The real cleaning-up is done async in gc_delete_proxy_writer. */
-int delete_proxy_writer (struct ddsi_domaingv *gv, const struct ddsi_guid *guid, nn_wctime_t timestamp, int isimplicit)
+int delete_proxy_writer (struct ddsi_domaingv *gv, const struct ddsi_guid *guid, ddsrt_wctime_t timestamp, int isimplicit)
{
struct proxy_writer *pwr;
DDSRT_UNUSED_ARG (isimplicit);
@@ -4766,7 +4765,7 @@ void proxy_writer_set_alive_may_unlock (struct proxy_writer *pwr, bool notify)
if (pwr->c.xqos->liveliness.kind != DDS_LIVELINESS_MANUAL_BY_TOPIC)
proxy_participant_add_pwr_lease_locked (pwr->c.proxypp, pwr);
else
- lease_set_expiry (pwr->lease, add_duration_to_etime (now_et (), pwr->lease->tdur));
+ lease_set_expiry (pwr->lease, ddsrt_etime_add_duration (ddsrt_time_elapsed (), pwr->lease->tdur));
}
ddsrt_mutex_unlock (&pwr->c.proxypp->e.lock);
@@ -4800,7 +4799,7 @@ int proxy_writer_set_notalive (struct proxy_writer *pwr, bool notify)
/* PROXY-READER ----------------------------------------------------- */
-int new_proxy_reader (struct ddsi_domaingv *gv, const struct ddsi_guid *ppguid, const struct ddsi_guid *guid, struct addrset *as, const ddsi_plist_t *plist, nn_wctime_t timestamp, seqno_t seq
+int new_proxy_reader (struct ddsi_domaingv *gv, const struct ddsi_guid *ppguid, const struct ddsi_guid *guid, struct addrset *as, const ddsi_plist_t *plist, ddsrt_wctime_t timestamp, seqno_t seq
#ifdef DDSI_INCLUDE_SSM
, int favours_ssm
#endif
@@ -4808,7 +4807,7 @@ int new_proxy_reader (struct ddsi_domaingv *gv, const struct ddsi_guid *ppguid,
{
struct proxy_participant *proxypp;
struct proxy_reader *prd;
- nn_mtime_t tnow = now_mt ();
+ ddsrt_mtime_t tnow = ddsrt_time_monotonic ();
int ret;
assert (!is_writer_entityid (guid->entityid));
@@ -4911,7 +4910,7 @@ static void gc_delete_proxy_reader (struct gcreq *gcreq)
ddsrt_free (prd);
}
-int delete_proxy_reader (struct ddsi_domaingv *gv, const struct ddsi_guid *guid, nn_wctime_t timestamp, int isimplicit)
+int delete_proxy_reader (struct ddsi_domaingv *gv, const struct ddsi_guid *guid, ddsrt_wctime_t timestamp, int isimplicit)
{
struct proxy_reader *prd;
(void)isimplicit;
diff --git a/src/core/ddsi/src/q_gc.c b/src/core/ddsi/src/q_gc.c
index 8d205b5..4c29ee2 100644
--- a/src/core/ddsi/src/q_gc.c
+++ b/src/core/ddsi/src/q_gc.c
@@ -19,7 +19,6 @@
#include "dds/ddsi/q_gc.h"
#include "dds/ddsi/q_log.h"
#include "dds/ddsi/q_config.h"
-#include "dds/ddsi/q_time.h"
#include "dds/ddsi/q_thread.h"
#include "dds/ddsi/ddsi_entity_index.h"
#include "dds/ddsi/q_unused.h"
@@ -89,8 +88,8 @@ static int threads_vtime_check (uint32_t *nivs, struct idx_vtime *ivs)
static uint32_t gcreq_queue_thread (struct gcreq_queue *q)
{
struct thread_state1 * const ts1 = lookup_thread_state ();
- nn_mtime_t next_thread_cputime = { 0 };
- nn_mtime_t t_trigger_recv_threads = { 0 };
+ ddsrt_mtime_t next_thread_cputime = { 0 };
+ ddsrt_mtime_t t_trigger_recv_threads = { 0 };
int64_t shortsleep = DDS_MSECS (1);
int64_t delay = DDS_MSECS (1); /* force evaluation after startup */
struct gcreq *gcreq = NULL;
@@ -105,7 +104,7 @@ static uint32_t gcreq_queue_thread (struct gcreq_queue *q)
groups. Do rate-limit it a bit. */
if (q->gv->deaf)
{
- nn_mtime_t tnow_mt = now_mt ();
+ ddsrt_mtime_t tnow_mt = ddsrt_time_monotonic ();
if (tnow_mt.v > t_trigger_recv_threads.v)
{
trigger_recv_threads (q->gv);
@@ -149,7 +148,7 @@ static uint32_t gcreq_queue_thread (struct gcreq_queue *q)
burden on the system than having a separate thread or adding it
to the workload of the data handling threads. */
thread_state_awake_fixed_domain (ts1);
- delay = check_and_handle_lease_expiration (q->gv, now_et ());
+ delay = check_and_handle_lease_expiration (q->gv, ddsrt_time_elapsed ());
thread_state_asleep (ts1);
if (gcreq)
diff --git a/src/core/ddsi/src/q_init.c b/src/core/ddsi/src/q_init.c
index 13173eb..226d75d 100644
--- a/src/core/ddsi/src/q_init.c
+++ b/src/core/ddsi/src/q_init.c
@@ -728,13 +728,13 @@ struct wait_for_receive_threads_helper_arg {
unsigned count;
};
-static void wait_for_receive_threads_helper (struct xevent *xev, void *varg, nn_mtime_t tnow)
+static void wait_for_receive_threads_helper (struct xevent *xev, void *varg, ddsrt_mtime_t tnow)
{
struct wait_for_receive_threads_helper_arg * const arg = varg;
if (arg->count++ == arg->gv->config.recv_thread_stop_maxretries)
abort ();
trigger_recv_threads (arg->gv);
- (void) resched_xevent_if_earlier (xev, add_duration_to_mtime (tnow, DDS_SECS (1)));
+ (void) resched_xevent_if_earlier (xev, ddsrt_mtime_add_duration (tnow, DDS_SECS (1)));
}
static void wait_for_receive_threads (struct ddsi_domaingv *gv)
@@ -743,7 +743,7 @@ static void wait_for_receive_threads (struct ddsi_domaingv *gv)
struct wait_for_receive_threads_helper_arg cbarg;
cbarg.gv = gv;
cbarg.count = 0;
- if ((trigev = qxev_callback (gv->xevents, add_duration_to_mtime (now_mt (), DDS_SECS (1)), wait_for_receive_threads_helper, &cbarg)) == NULL)
+ if ((trigev = qxev_callback (gv->xevents, ddsrt_mtime_add_duration (ddsrt_time_monotonic (), DDS_SECS (1)), wait_for_receive_threads_helper, &cbarg)) == NULL)
{
/* retrying is to deal a packet geting lost because the socket buffer is full or because the
macOS firewall (and perhaps others) likes to ask if the process is allowed to receive data,
@@ -924,7 +924,7 @@ static uint32_t ddsi_sertopic_hash_wrap (const void *tp)
return ddsi_sertopic_hash (tp);
}
-static void reset_deaf_mute (struct xevent *xev, void *varg, UNUSED_ARG (nn_mtime_t tnow))
+static void reset_deaf_mute (struct xevent *xev, void *varg, UNUSED_ARG (ddsrt_mtime_t tnow))
{
struct ddsi_domaingv *gv = varg;
gv->deaf = 0;
@@ -940,7 +940,7 @@ void ddsi_set_deafmute (struct ddsi_domaingv *gv, bool deaf, bool mute, int64_t
GVLOGDISC (" DEAFMUTE set [deaf, mute]=[%d, %d]", gv->deaf, gv->mute);
if (reset_after < DDS_INFINITY)
{
- nn_mtime_t when = add_duration_to_mtime (now_mt (), reset_after);
+ ddsrt_mtime_t when = ddsrt_mtime_add_duration (ddsrt_time_monotonic (), reset_after);
GVTRACE (" reset after %"PRId64".%09u ns", reset_after / DDS_NSECS_IN_SEC, (unsigned) (reset_after % DDS_NSECS_IN_SEC));
qxev_callback (gv->xevents, when, reset_deaf_mute, gv);
}
@@ -952,9 +952,9 @@ int rtps_init (struct ddsi_domaingv *gv)
uint32_t port_disc_uc = 0;
uint32_t port_data_uc = 0;
bool mc_available = true;
- nn_mtime_t reset_deaf_mute_time = NN_MTIME_NEVER;
+ ddsrt_mtime_t reset_deaf_mute_time = DDSRT_MTIME_NEVER;
- gv->tstart = now (); /* wall clock time, used in logs */
+ gv->tstart = ddsrt_time_wallclock (); /* wall clock time, used in logs */
ddsi_plist_init_tables ();
@@ -982,7 +982,7 @@ int rtps_init (struct ddsi_domaingv *gv)
if (gv->deaf || gv->mute)
{
GVLOG (DDS_LC_CONFIG | DDS_LC_DISCOVERY, "DEAFMUTE initial deaf=%d mute=%d reset after %"PRId64"d ns\n", gv->deaf, gv->mute, gv->config.initial_deaf_mute_reset);
- reset_deaf_mute_time = add_duration_to_mtime (now_mt (), gv->config.initial_deaf_mute_reset);
+ reset_deaf_mute_time = ddsrt_mtime_add_duration (ddsrt_time_monotonic (), gv->config.initial_deaf_mute_reset);
}
/* Initialize thread pool */
@@ -1640,7 +1640,7 @@ void rtps_stop (struct ddsi_domaingv *gv)
{
struct entidx_enum_proxy_participant est;
struct proxy_participant *proxypp;
- const nn_wctime_t tnow = now();
+ const ddsrt_wctime_t tnow = ddsrt_time_wallclock();
/* Clean up proxy readers, proxy writers and proxy
participants. Deleting a proxy participants deletes all its
readers and writers automatically */
diff --git a/src/core/ddsi/src/q_lease.c b/src/core/ddsi/src/q_lease.c
index 0469a46..a7a40c5 100644
--- a/src/core/ddsi/src/q_lease.c
+++ b/src/core/ddsi/src/q_lease.c
@@ -76,7 +76,7 @@ void lease_management_term (struct ddsi_domaingv *gv)
ddsrt_mutex_destroy (&gv->leaseheap_lock);
}
-struct lease *lease_new (nn_etime_t texpire, dds_duration_t tdur, struct entity_common *e)
+struct lease *lease_new (ddsrt_etime_t texpire, dds_duration_t tdur, struct entity_common *e)
{
struct lease *l;
if ((l = ddsrt_malloc (sizeof (*l))) == NULL)
@@ -96,7 +96,7 @@ struct lease *lease_new (nn_etime_t texpire, dds_duration_t tdur, struct entity_
*/
struct lease *lease_clone (const struct lease *l)
{
- nn_etime_t texp;
+ ddsrt_etime_t texp;
dds_duration_t tdur;
texp.v = (int64_t) ddsrt_atomic_ld64 (&l->tend);
tdur = l->tdur;
@@ -144,7 +144,7 @@ void lease_free (struct lease *l)
ddsrt_free (l);
}
-static void trace_lease_renew (const struct lease *l, const char *tag, nn_etime_t tend_new)
+static void trace_lease_renew (const struct lease *l, const char *tag, ddsrt_etime_t tend_new)
{
struct ddsi_domaingv const * gv = l->entity->gv;
if (gv->logconfig.c.mask & DDS_LC_TRACE)
@@ -155,14 +155,14 @@ static void trace_lease_renew (const struct lease *l, const char *tag, nn_etime_
GVTRACE (":%"PRIx32, l->entity->guid.entityid.u);
else
GVTRACE (""PGUIDFMT"", PGUID (l->entity->guid));
- etime_to_sec_usec (&tsec, &tusec, tend_new);
+ ddsrt_etime_to_sec_usec (&tsec, &tusec, tend_new);
GVTRACE (" %"PRId32".%06"PRId32")", tsec, tusec);
}
}
-void lease_renew (struct lease *l, nn_etime_t tnowE)
+void lease_renew (struct lease *l, ddsrt_etime_t tnowE)
{
- nn_etime_t tend_new = add_duration_to_etime (tnowE, l->tdur);
+ ddsrt_etime_t tend_new = ddsrt_etime_add_duration (tnowE, l->tdur);
/* do not touch tend if moving forward or if already expired */
int64_t tend;
@@ -179,7 +179,7 @@ void lease_renew (struct lease *l, nn_etime_t tnowE)
trace_lease_renew (l, "", tend_new);
}
-void lease_set_expiry (struct lease *l, nn_etime_t when)
+void lease_set_expiry (struct lease *l, ddsrt_etime_t when)
{
struct ddsi_domaingv * const gv = l->entity->gv;
bool trigger = false;
@@ -212,7 +212,7 @@ void lease_set_expiry (struct lease *l, nn_etime_t when)
force_lease_check (gv->gcreq_queue);
}
-int64_t check_and_handle_lease_expiration (struct ddsi_domaingv *gv, nn_etime_t tnowE)
+int64_t check_and_handle_lease_expiration (struct ddsi_domaingv *gv, ddsrt_etime_t tnowE)
{
struct lease *l;
int64_t delay;
@@ -273,7 +273,7 @@ int64_t check_and_handle_lease_expiration (struct ddsi_domaingv *gv, nn_etime_t
entidx_lookup_proxy_participant_guid (gv->entity_index, &proxypp->privileged_pp_guid) != NULL)
{
GVLOGDISC ("but postponing because privileged pp "PGUIDFMT" is still live\n", PGUID (proxypp->privileged_pp_guid));
- l->tsched = add_duration_to_etime (tnowE, DDS_MSECS (200));
+ l->tsched = ddsrt_etime_add_duration (tnowE, DDS_MSECS (200));
ddsrt_fibheap_insert (&lease_fhdef, &gv->leaseheap, l);
continue;
}
@@ -285,7 +285,7 @@ int64_t check_and_handle_lease_expiration (struct ddsi_domaingv *gv, nn_etime_t
switch (k)
{
case EK_PROXY_PARTICIPANT:
- delete_proxy_participant_by_guid (gv, &g, now(), 1);
+ delete_proxy_participant_by_guid (gv, &g, ddsrt_time_wallclock(), 1);
break;
case EK_PROXY_WRITER:
proxy_writer_set_notalive ((struct proxy_writer *) l->entity, true);
diff --git a/src/core/ddsi/src/q_pcap.c b/src/core/ddsi/src/q_pcap.c
index 42b2824..601c96d 100644
--- a/src/core/ddsi/src/q_pcap.c
+++ b/src/core/ddsi/src/q_pcap.c
@@ -14,7 +14,6 @@
#include "dds/ddsrt/endian.h"
#include "dds/ddsi/q_log.h"
-#include "dds/ddsi/q_time.h"
#include "dds/ddsi/q_config.h"
#include "dds/ddsi/ddsi_domaingv.h"
#include "dds/ddsi/q_bswap.h"
@@ -127,7 +126,7 @@ static uint16_t calc_ipv4_checksum (const uint16_t *x)
return (uint16_t) ~s;
}
-void write_pcap_received (struct ddsi_domaingv *gv, nn_wctime_t tstamp, const struct sockaddr_storage *src, const struct sockaddr_storage *dst, unsigned char *buf, size_t sz)
+void write_pcap_received (struct ddsi_domaingv *gv, ddsrt_wctime_t tstamp, const struct sockaddr_storage *src, const struct sockaddr_storage *dst, unsigned char *buf, size_t sz)
{
if (gv->config.transport_selector == TRANS_UDP)
{
@@ -140,7 +139,7 @@ void write_pcap_received (struct ddsi_domaingv *gv, nn_wctime_t tstamp, const st
size_t sz_ud = sz + UDP_HDR_SIZE;
size_t sz_iud = sz_ud + IPV4_HDR_SIZE;
ddsrt_mutex_lock (&gv->pcap_lock);
- wctime_to_sec_usec (&pcap_hdr.ts_sec, &pcap_hdr.ts_usec, tstamp);
+ ddsrt_wctime_to_sec_usec (&pcap_hdr.ts_sec, &pcap_hdr.ts_usec, tstamp);
pcap_hdr.incl_len = pcap_hdr.orig_len = (uint32_t) sz_iud;
(void) fwrite (&pcap_hdr, sizeof (pcap_hdr), 1, gv->pcap_fp);
u.ipv4_hdr = ipv4_hdr_template;
@@ -160,7 +159,7 @@ void write_pcap_received (struct ddsi_domaingv *gv, nn_wctime_t tstamp, const st
}
}
-void write_pcap_sent (struct ddsi_domaingv *gv, nn_wctime_t tstamp, const struct sockaddr_storage *src, const ddsrt_msghdr_t *hdr, size_t sz)
+void write_pcap_sent (struct ddsi_domaingv *gv, ddsrt_wctime_t tstamp, const struct sockaddr_storage *src, const ddsrt_msghdr_t *hdr, size_t sz)
{
if (gv->config.transport_selector == TRANS_UDP)
{
@@ -173,7 +172,7 @@ void write_pcap_sent (struct ddsi_domaingv *gv, nn_wctime_t tstamp, const struct
size_t sz_ud = sz + UDP_HDR_SIZE;
size_t sz_iud = sz_ud + IPV4_HDR_SIZE;
ddsrt_mutex_lock (&gv->pcap_lock);
- wctime_to_sec_usec (&pcap_hdr.ts_sec, &pcap_hdr.ts_usec, tstamp);
+ ddsrt_wctime_to_sec_usec (&pcap_hdr.ts_sec, &pcap_hdr.ts_usec, tstamp);
pcap_hdr.incl_len = pcap_hdr.orig_len = (uint32_t) sz_iud;
(void) fwrite (&pcap_hdr, sizeof (pcap_hdr), 1, gv->pcap_fp);
u.ipv4_hdr = ipv4_hdr_template;
diff --git a/src/core/ddsi/src/q_qosmatch.c b/src/core/ddsi/src/q_qosmatch.c
index 7c951e1..b20468f 100644
--- a/src/core/ddsi/src/q_qosmatch.c
+++ b/src/core/ddsi/src/q_qosmatch.c
@@ -12,7 +12,6 @@
#include
#include
-#include "dds/ddsi/q_time.h"
#include "dds/ddsi/ddsi_xqos.h"
#include "dds/ddsi/q_misc.h"
#include "dds/ddsi/q_qosmatch.h"
diff --git a/src/core/ddsi/src/q_radmin.c b/src/core/ddsi/src/q_radmin.c
index e269b35..c224919 100644
--- a/src/core/ddsi/src/q_radmin.c
+++ b/src/core/ddsi/src/q_radmin.c
@@ -2427,7 +2427,7 @@ static uint32_t dqueue_thread (struct nn_dqueue *q)
{
struct thread_state1 * const ts1 = lookup_thread_state ();
struct ddsi_domaingv const * const gv = ddsrt_atomic_ldvoidp (&ts1->gv);
- nn_mtime_t next_thread_cputime = { 0 };
+ ddsrt_mtime_t next_thread_cputime = { 0 };
int keepgoing = 1;
ddsi_guid_t rdguid, *prdguid = NULL;
uint32_t rdguid_count = 0;
diff --git a/src/core/ddsi/src/q_receive.c b/src/core/ddsi/src/q_receive.c
index 54e5d7b..17e9654 100644
--- a/src/core/ddsi/src/q_receive.c
+++ b/src/core/ddsi/src/q_receive.c
@@ -205,7 +205,7 @@ static int valid_InfoTS (InfoTS_t *msg, size_t size, int byteswap)
msg->time.seconds = ddsrt_bswap4 (msg->time.seconds);
msg->time.fraction = ddsrt_bswap4u (msg->time.fraction);
}
- return valid_ddsi_timestamp (msg->time);
+ return ddsi_is_valid_timestamp (msg->time);
}
}
@@ -585,7 +585,7 @@ static int acknack_is_nack (const AckNack_t *msg)
return x != 0;
}
-static int accept_ack_or_hb_w_timeout (nn_count_t new_count, nn_count_t *exp_count, nn_etime_t tnow, nn_etime_t *t_last_accepted, int force_accept)
+static int accept_ack_or_hb_w_timeout (nn_count_t new_count, nn_count_t *exp_count, ddsrt_etime_t tnow, ddsrt_etime_t *t_last_accepted, int force_accept)
{
/* AckNacks and Heartbeats with a sequence number (called "count"
for some reason) equal to or less than the highest one received
@@ -613,7 +613,7 @@ static int accept_ack_or_hb_w_timeout (nn_count_t new_count, nn_count_t *exp_cou
return 1;
}
-static int handle_AckNack (struct receiver_state *rst, nn_etime_t tnow, const AckNack_t *msg, nn_wctime_t timestamp)
+static int handle_AckNack (struct receiver_state *rst, ddsrt_etime_t tnow, const AckNack_t *msg, ddsrt_wctime_t timestamp)
{
struct proxy_reader *prd;
struct wr_prd_match *rn;
@@ -712,7 +712,7 @@ static int handle_AckNack (struct receiver_state *rst, nn_etime_t tnow, const Ac
moment. */
if (rst->gv->config.meas_hb_to_ack_latency && timestamp.v)
{
- nn_wctime_t tstamp_now = now ();
+ ddsrt_wctime_t tstamp_now = ddsrt_time_wallclock ();
nn_lat_estim_update (&rn->hb_to_ack_latency, tstamp_now.v - timestamp.v);
if ((rst->gv->logconfig.c.mask & DDS_LC_TRACE) && tstamp_now.v > rn->hb_to_ack_latency_tlastlog.v + DDS_SECS (10))
{
@@ -860,7 +860,7 @@ static int handle_AckNack (struct receiver_state *rst, nn_etime_t tnow, const Ac
if (rst->gv->config.retransmit_merging != REXMIT_MERGE_NEVER && rn->assumed_in_sync)
{
/* send retransmit to all receivers, but skip if recently done */
- nn_mtime_t tstamp = now_mt ();
+ ddsrt_mtime_t tstamp = ddsrt_time_monotonic ();
if (tstamp.v > sample.last_rexmit_ts.v + rst->gv->config.retransmit_merging_period)
{
RSTTRACE (" RX%"PRId64, seqbase + i);
@@ -968,7 +968,7 @@ static int handle_AckNack (struct receiver_state *rst, nn_etime_t tnow, const Ac
gradually lowering rate. If we just got a request for a
retransmit, and there is more to be retransmitted, surely the
rate should be kept up for now */
- writer_hbcontrol_note_asyncwrite (wr, now_mt ());
+ writer_hbcontrol_note_asyncwrite (wr, ddsrt_time_monotonic ());
}
/* If "final" flag not set, we must respond with a heartbeat. Do it
now if we haven't done so already */
@@ -1033,9 +1033,9 @@ struct handle_Heartbeat_helper_arg {
struct receiver_state *rst;
const Heartbeat_t *msg;
struct proxy_writer *pwr;
- nn_wctime_t timestamp;
- nn_etime_t tnow;
- nn_mtime_t tnow_mt;
+ ddsrt_wctime_t timestamp;
+ ddsrt_etime_t tnow;
+ ddsrt_mtime_t tnow_mt;
};
static void handle_Heartbeat_helper (struct pwr_rd_match * const wn, struct handle_Heartbeat_helper_arg * const arg)
@@ -1072,7 +1072,7 @@ static void handle_Heartbeat_helper (struct pwr_rd_match * const wn, struct hand
once, regardless of which readers care about it. */
if (wn->acknack_xevent)
{
- nn_mtime_t tsched = NN_MTIME_NEVER;
+ ddsrt_mtime_t tsched = DDSRT_MTIME_NEVER;
if (pwr->last_seq > refseq)
{
RSTTRACE ("/NAK");
@@ -1096,7 +1096,7 @@ static void handle_Heartbeat_helper (struct pwr_rd_match * const wn, struct hand
}
}
-static int handle_Heartbeat (struct receiver_state *rst, nn_etime_t tnow, struct nn_rmsg *rmsg, const Heartbeat_t *msg, nn_wctime_t timestamp)
+static int handle_Heartbeat (struct receiver_state *rst, ddsrt_etime_t tnow, struct nn_rmsg *rmsg, const Heartbeat_t *msg, ddsrt_wctime_t timestamp)
{
/* We now cheat: and process the heartbeat for _all_ readers,
always, regardless of the destination address in the Heartbeat
@@ -1243,7 +1243,7 @@ static int handle_Heartbeat (struct receiver_state *rst, nn_etime_t tnow, struct
arg.pwr = pwr;
arg.timestamp = timestamp;
arg.tnow = tnow;
- arg.tnow_mt = now_mt ();
+ arg.tnow_mt = ddsrt_time_monotonic ();
handle_forall_destinations (&dst, pwr, (ddsrt_avl_walk_t) handle_Heartbeat_helper, &arg);
RSTTRACE (")");
@@ -1251,7 +1251,7 @@ static int handle_Heartbeat (struct receiver_state *rst, nn_etime_t tnow, struct
return 1;
}
-static int handle_HeartbeatFrag (struct receiver_state *rst, UNUSED_ARG(nn_etime_t tnow), const HeartbeatFrag_t *msg)
+static int handle_HeartbeatFrag (struct receiver_state *rst, UNUSED_ARG(ddsrt_etime_t tnow), const HeartbeatFrag_t *msg)
{
const seqno_t seq = fromSN (msg->writerSN);
const nn_fragment_number_t fragnum = msg->lastFragmentNum - 1; /* we do 0-based */
@@ -1353,7 +1353,7 @@ static int handle_HeartbeatFrag (struct receiver_state *rst, UNUSED_ARG(nn_etime
samples we no longer care about) */
int64_t delay = rst->gv->config.nack_delay;
RSTTRACE ("/nackfrag");
- (void) resched_xevent_if_earlier (m->acknack_xevent, add_duration_to_mtime (now_mt(), delay));
+ (void) resched_xevent_if_earlier (m->acknack_xevent, ddsrt_mtime_add_duration (ddsrt_time_monotonic(), delay));
}
}
}
@@ -1362,7 +1362,7 @@ static int handle_HeartbeatFrag (struct receiver_state *rst, UNUSED_ARG(nn_etime
return 1;
}
-static int handle_NackFrag (struct receiver_state *rst, nn_etime_t tnow, const NackFrag_t *msg)
+static int handle_NackFrag (struct receiver_state *rst, ddsrt_etime_t tnow, const NackFrag_t *msg)
{
struct proxy_reader *prd;
struct wr_prd_match *rn;
@@ -1475,7 +1475,7 @@ static int handle_NackFrag (struct receiver_state *rst, nn_etime_t tnow, const N
struct whc_state whcst;
whc_get_state(wr->whc, &whcst);
force_heartbeat_to_peer (wr, &whcst, prd, 1);
- writer_hbcontrol_note_asyncwrite (wr, now_mt ());
+ writer_hbcontrol_note_asyncwrite (wr, ddsrt_time_monotonic ());
}
out:
@@ -1515,17 +1515,17 @@ static int handle_InfoSRC (struct receiver_state *rst, const InfoSRC_t *msg)
return 1;
}
-static int handle_InfoTS (const struct receiver_state *rst, const InfoTS_t *msg, nn_wctime_t *timestamp)
+static int handle_InfoTS (const struct receiver_state *rst, const InfoTS_t *msg, ddsrt_wctime_t *timestamp)
{
RSTTRACE ("INFOTS(");
if (msg->smhdr.flags & INFOTS_INVALIDATE_FLAG)
{
- *timestamp = NN_WCTIME_INVALID;
+ *timestamp = DDSRT_WCTIME_INVALID;
RSTTRACE ("invalidate");
}
else
{
- *timestamp = nn_wctime_from_ddsi_time (msg->time);
+ *timestamp = ddsi_wctime_from_ddsi_time (msg->time);
if (rst->gv->logconfig.c.mask & DDS_LC_TRACE)
RSTTRACE ("%d.%09d", (int) (timestamp->v / 1000000000), (int) (timestamp->v % 1000000000));
}
@@ -1597,7 +1597,7 @@ static int handle_one_gap (struct proxy_writer *pwr, struct pwr_rd_match *wn, se
return gap_was_valuable;
}
-static int handle_Gap (struct receiver_state *rst, nn_etime_t tnow, struct nn_rmsg *rmsg, const Gap_t *msg)
+static int handle_Gap (struct receiver_state *rst, ddsrt_etime_t tnow, struct nn_rmsg *rmsg, const Gap_t *msg)
{
/* Option 1: Process the Gap for the proxy writer and all
out-of-sync readers: what do I care which reader is being
@@ -1722,7 +1722,7 @@ static int handle_Gap (struct receiver_state *rst, nn_etime_t tnow, struct nn_rm
return 1;
}
-static struct ddsi_serdata *get_serdata (struct ddsi_sertopic const * const topic, const struct nn_rdata *fragchain, uint32_t sz, int justkey, unsigned statusinfo, nn_wctime_t tstamp)
+static struct ddsi_serdata *get_serdata (struct ddsi_sertopic const * const topic, const struct nn_rdata *fragchain, uint32_t sz, int justkey, unsigned statusinfo, ddsrt_wctime_t tstamp)
{
struct ddsi_serdata *sd = ddsi_serdata_from_ser (topic, justkey ? SDK_KEY : SDK_DATA, fragchain, sz);
if (sd)
@@ -1739,7 +1739,7 @@ struct remote_sourceinfo {
const ddsi_plist_t *qos;
const struct nn_rdata *fragchain;
unsigned statusinfo;
- nn_wctime_t tstamp;
+ ddsrt_wctime_t tstamp;
};
static struct ddsi_serdata *remote_make_sample (struct ddsi_tkmap_instance **tk, struct ddsi_domaingv *gv, struct ddsi_sertopic const * const topic, void *vsourceinfo)
@@ -1751,7 +1751,7 @@ static struct ddsi_serdata *remote_make_sample (struct ddsi_tkmap_instance **tk,
const struct nn_rdata * __restrict fragchain = si->fragchain;
const uint32_t statusinfo = si->statusinfo;
const unsigned char data_smhdr_flags = si->data_smhdr_flags;
- const nn_wctime_t tstamp = si->tstamp;
+ const ddsrt_wctime_t tstamp = si->tstamp;
const ddsi_plist_t * __restrict qos = si->qos;
const char *failmsg = NULL;
struct ddsi_serdata *sample = NULL;
@@ -1984,7 +1984,7 @@ static int deliver_user_data (const struct nn_rsample_info *sampleinfo, const st
}
/* FIXME: should it be 0, local wall clock time or INVALID? */
- const nn_wctime_t tstamp = (sampleinfo->timestamp.v != NN_WCTIME_INVALID.v) ? sampleinfo->timestamp : ((nn_wctime_t) {0});
+ const ddsrt_wctime_t tstamp = (sampleinfo->timestamp.v != DDSRT_WCTIME_INVALID.v) ? sampleinfo->timestamp : ((ddsrt_wctime_t) {0});
struct ddsi_writer_info wrinfo;
ddsi_make_writer_info (&wrinfo, &pwr->e, pwr->c.xqos, statusinfo);
@@ -2052,7 +2052,7 @@ static void clean_defrag (struct proxy_writer *pwr)
nn_defrag_notegap (pwr->defrag, 1, seq);
}
-static void handle_regular (struct receiver_state *rst, nn_etime_t tnow, struct nn_rmsg *rmsg, const Data_DataFrag_common_t *msg, const struct nn_rsample_info *sampleinfo,
+static void handle_regular (struct receiver_state *rst, ddsrt_etime_t tnow, struct nn_rmsg *rmsg, const Data_DataFrag_common_t *msg, const struct nn_rsample_info *sampleinfo,
uint32_t fragnum, struct nn_rdata *rdata, struct nn_dqueue **deferred_wakeup, bool renew_manbypp_lease)
{
struct proxy_writer *pwr;
@@ -2320,7 +2320,7 @@ static void drop_oversize (struct receiver_state *rst, struct nn_rmsg *rmsg, con
}
}
-static int handle_Data (struct receiver_state *rst, nn_etime_t tnow, struct nn_rmsg *rmsg, const Data_t *msg, size_t size, struct nn_rsample_info *sampleinfo, unsigned char *datap, struct nn_dqueue **deferred_wakeup)
+static int handle_Data (struct receiver_state *rst, ddsrt_etime_t tnow, struct nn_rmsg *rmsg, const Data_t *msg, size_t size, struct nn_rsample_info *sampleinfo, unsigned char *datap, struct nn_dqueue **deferred_wakeup)
{
RSTTRACE ("DATA("PGUIDFMT" -> "PGUIDFMT" #%"PRId64,
PGUIDPREFIX (rst->src_guid_prefix), msg->x.writerId.u,
@@ -2372,7 +2372,7 @@ static int handle_Data (struct receiver_state *rst, nn_etime_t tnow, struct nn_r
return 1;
}
-static int handle_DataFrag (struct receiver_state *rst, nn_etime_t tnow, struct nn_rmsg *rmsg, const DataFrag_t *msg, size_t size, struct nn_rsample_info *sampleinfo, unsigned char *datap, struct nn_dqueue **deferred_wakeup)
+static int handle_DataFrag (struct receiver_state *rst, ddsrt_etime_t tnow, struct nn_rmsg *rmsg, const DataFrag_t *msg, size_t size, struct nn_rsample_info *sampleinfo, unsigned char *datap, struct nn_dqueue **deferred_wakeup)
{
RSTTRACE ("DATAFRAG("PGUIDFMT" -> "PGUIDFMT" #%"PRId64"/[%u..%u]",
PGUIDPREFIX (rst->src_guid_prefix), msg->x.writerId.u,
@@ -2586,8 +2586,8 @@ static int handle_submsg_sequence
struct ddsi_domaingv *gv,
ddsi_tran_conn_t conn,
const nn_locator_t *srcloc,
- nn_wctime_t tnowWC,
- nn_etime_t tnowE,
+ ddsrt_wctime_t tnowWC,
+ ddsrt_etime_t tnowE,
const ddsi_guid_prefix_t * const src_prefix,
const ddsi_guid_prefix_t * const dst_prefix,
unsigned char * const msg /* NOT const - we may byteswap it */,
@@ -2601,7 +2601,7 @@ static int handle_submsg_sequence
Header_t * hdr = (Header_t *) msg;
struct receiver_state *rst;
int rst_live, ts_for_latmeas;
- nn_wctime_t timestamp;
+ ddsrt_wctime_t timestamp;
size_t submsg_size = 0;
unsigned char * end = msg + len;
struct nn_dqueue *deferred_wakeup = NULL;
@@ -2632,7 +2632,7 @@ static int handle_submsg_sequence
rst->gv = gv;
rst_live = 0;
ts_for_latmeas = 0;
- timestamp = NN_WCTIME_INVALID;
+ timestamp = DDSRT_WCTIME_INVALID;
assert (thread_is_asleep ());
thread_state_awake_fixed_domain (ts1);
@@ -2687,14 +2687,14 @@ static int handle_submsg_sequence
state = "parse:acknack";
if (!valid_AckNack (rst, &sm->acknack, submsg_size, byteswap))
goto malformed;
- handle_AckNack (rst, tnowE, &sm->acknack, ts_for_latmeas ? timestamp : NN_WCTIME_INVALID);
+ handle_AckNack (rst, tnowE, &sm->acknack, ts_for_latmeas ? timestamp : DDSRT_WCTIME_INVALID);
ts_for_latmeas = 0;
break;
case SMID_HEARTBEAT:
state = "parse:heartbeat";
if (!valid_Heartbeat (&sm->heartbeat, submsg_size, byteswap))
goto malformed;
- handle_Heartbeat (rst, tnowE, rmsg, &sm->heartbeat, ts_for_latmeas ? timestamp : NN_WCTIME_INVALID);
+ handle_Heartbeat (rst, tnowE, rmsg, &sm->heartbeat, ts_for_latmeas ? timestamp : DDSRT_WCTIME_INVALID);
ts_for_latmeas = 0;
break;
case SMID_GAP:
@@ -2975,7 +2975,7 @@ static bool do_packet (struct thread_state1 * const ts1, struct ddsi_domaingv *g
PGUIDPREFIX (hdr->guid_prefix), hdr->vendorid.id[0], hdr->vendorid.id[1], (unsigned long) sz, addrstr);
}
- handle_submsg_sequence (ts1, gv, conn, &srcloc, now (), now_et (), &hdr->guid_prefix, guidprefix, buff, (size_t) sz, buff + RTPS_MESSAGE_HEADER_SIZE, rmsg);
+ handle_submsg_sequence (ts1, gv, conn, &srcloc, ddsrt_time_wallclock (), ddsrt_time_elapsed (), &hdr->guid_prefix, guidprefix, buff, (size_t) sz, buff + RTPS_MESSAGE_HEADER_SIZE, rmsg);
}
}
nn_rmsg_commit (rmsg);
@@ -3174,7 +3174,7 @@ uint32_t recv_thread (void *vrecv_thread_arg)
struct ddsi_domaingv * const gv = recv_thread_arg->gv;
struct nn_rbufpool *rbpool = recv_thread_arg->rbpool;
os_sockWaitset waitset = recv_thread_arg->mode == RTM_MANY ? recv_thread_arg->u.many.ws : NULL;
- nn_mtime_t next_thread_cputime = { 0 };
+ ddsrt_mtime_t next_thread_cputime = { 0 };
nn_rbufpool_setowner (rbpool, ddsrt_thread_self ());
if (waitset == NULL)
diff --git a/src/core/ddsi/src/q_time.c b/src/core/ddsi/src/q_time.c
deleted file mode 100644
index d25dd02..0000000
--- a/src/core/ddsi/src/q_time.c
+++ /dev/null
@@ -1,185 +0,0 @@
-/*
- * Copyright(c) 2006 to 2018 ADLINK Technology Limited and others
- *
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v. 2.0 which is available at
- * http://www.eclipse.org/legal/epl-2.0, or the Eclipse Distribution License
- * v. 1.0 which is available at
- * http://www.eclipse.org/org/documents/edl-v10.php.
- *
- * SPDX-License-Identifier: EPL-2.0 OR BSD-3-Clause
- */
-#include
-
-#include "dds/ddsrt/time.h"
-#include "dds/ddsi/q_time.h"
-
-nn_wctime_t now (void)
-{
- /* This function uses the wall clock.
- * This clock is not affected by time spent in suspend mode.
- * This clock is affected when the real time system clock jumps
- * forwards/backwards */
- nn_wctime_t t;
- t.v = dds_time();
- return t;
-}
-
-nn_mtime_t now_mt (void)
-{
- /* This function uses the monotonic clock.
- * This clock stops while the system is in suspend mode.
- * This clock is not affected by any jumps of the realtime clock. */
- nn_mtime_t t;
- t.v = ddsrt_time_monotonic();
- return t;
-}
-
-nn_etime_t now_et (void)
-{
- /* This function uses the elapsed clock.
- * This clock is not affected by any jumps of the realtime clock.
- * This clock does NOT stop when the system is in suspend mode.
- * This clock stops when the system is shut down, and starts when the system is restarted.
- * When restarted, there are no assumptions about the initial value of clock. */
- nn_etime_t t;
- t.v = ddsrt_time_elapsed();
- return t;
-}
-
-static void time_to_sec_usec (int32_t * __restrict sec, int32_t * __restrict usec, int64_t t)
-{
- *sec = (int32_t) (t / DDS_NSECS_IN_SEC);
- *usec = (int32_t) (t % DDS_NSECS_IN_SEC) / 1000;
-}
-
-void mtime_to_sec_usec (int32_t * __restrict sec, int32_t * __restrict usec, nn_mtime_t t)
-{
- time_to_sec_usec (sec, usec, t.v);
-}
-
-void wctime_to_sec_usec (int32_t * __restrict sec, int32_t * __restrict usec, nn_wctime_t t)
-{
- time_to_sec_usec (sec, usec, t.v);
-}
-
-void etime_to_sec_usec (int32_t * __restrict sec, int32_t * __restrict usec, nn_etime_t t)
-{
- time_to_sec_usec (sec, usec, t.v);
-}
-
-
-nn_mtime_t mtime_round_up (nn_mtime_t t, int64_t round)
-{
- /* This function rounds up t to the nearest next multiple of round.
- t is nanoseconds, round is milliseconds. Avoid functions from
- maths libraries to keep code portable */
- assert (t.v >= 0 && round >= 0);
- if (round == 0 || t.v == DDS_INFINITY)
- {
- return t;
- }
- else
- {
- int64_t remainder = t.v % round;
- if (remainder == 0)
- {
- return t;
- }
- else
- {
- nn_mtime_t u;
- u.v = t.v + round - remainder;
- return u;
- }
- }
-}
-
-static int64_t add_duration_to_time (int64_t t, int64_t d)
-{
- uint64_t sum;
- assert (t >= 0 && d >= 0);
- sum = (uint64_t)t + (uint64_t)d;
- return sum >= DDS_NEVER ? DDS_NEVER : (int64_t)sum;
-}
-
-nn_mtime_t add_duration_to_mtime (nn_mtime_t t, int64_t d)
-{
- /* assumed DDS_NEVER <=> MAX_INT64 */
- nn_mtime_t u;
- u.v = add_duration_to_time (t.v, d);
- return u;
-}
-
-nn_wctime_t add_duration_to_wctime (nn_wctime_t t, int64_t d)
-{
- /* assumed DDS_NEVER <=> MAX_INT64 */
- nn_wctime_t u;
- u.v = add_duration_to_time (t.v, d);
- return u;
-}
-
-nn_etime_t add_duration_to_etime (nn_etime_t t, int64_t d)
-{
- /* assumed DDS_NEVER <=> MAX_INT64 */
- nn_etime_t u;
- u.v = add_duration_to_time (t.v, d);
- return u;
-}
-
-int valid_ddsi_timestamp (ddsi_time_t t)
-{
- return t.seconds != DDSI_TIME_INVALID.seconds && t.fraction != DDSI_TIME_INVALID.fraction;
-}
-
-static ddsi_time_t nn_to_ddsi_time (int64_t t)
-{
- if (t == DDS_NEVER)
- return DDSI_TIME_INFINITE;
- else
- {
- /* ceiling(ns * 2^32/10^9) -- can't change the ceiling to round-to-nearest
- because that would break backwards compatibility, but round-to-nearest
- of the inverse is correctly rounded anyway, so it shouldn't ever matter. */
- ddsi_time_t x;
- int ns = (int) (t % DDS_NSECS_IN_SEC);
- x.seconds = (int) (t / DDS_NSECS_IN_SEC);
- x.fraction = (unsigned) (((DDS_NSECS_IN_SEC-1) + ((int64_t) ns << 32)) / DDS_NSECS_IN_SEC);
- return x;
- }
-}
-
-ddsi_time_t nn_wctime_to_ddsi_time (nn_wctime_t t)
-{
- return nn_to_ddsi_time (t.v);
-}
-
-static int64_t nn_from_ddsi_time (ddsi_time_t x)
-{
- if (x.seconds == DDSI_TIME_INFINITE.seconds && x.fraction == DDSI_TIME_INFINITE.fraction)
- return DDS_NEVER;
- else
- {
- /* Round-to-nearest conversion of DDSI time fraction to nanoseconds */
- int ns = (int) (((int64_t) 2147483648u + (int64_t) x.fraction * DDS_NSECS_IN_SEC) >> 32);
- return x.seconds * DDS_NSECS_IN_SEC + ns;
- }
-}
-
-nn_wctime_t nn_wctime_from_ddsi_time (ddsi_time_t x)
-{
- nn_wctime_t t;
- t.v = nn_from_ddsi_time (x);
- return t;
-}
-
-ddsi_duration_t nn_to_ddsi_duration (int64_t x)
-{
- return nn_to_ddsi_time (x);
-}
-
-int64_t nn_from_ddsi_duration (ddsi_duration_t x)
-{
- return nn_from_ddsi_time (x);
-}
-
diff --git a/src/core/ddsi/src/q_transmit.c b/src/core/ddsi/src/q_transmit.c
index 79cb661..8cd0508 100644
--- a/src/core/ddsi/src/q_transmit.c
+++ b/src/core/ddsi/src/q_transmit.c
@@ -25,7 +25,6 @@
#include "dds/ddsi/q_misc.h"
#include "dds/ddsi/q_thread.h"
#include "dds/ddsi/q_xevent.h"
-#include "dds/ddsi/q_time.h"
#include "dds/ddsi/q_config.h"
#include "dds/ddsi/ddsi_domaingv.h"
#include "dds/ddsi/q_transmit.h"
@@ -58,12 +57,12 @@ void writer_hbcontrol_init (struct hbcontrol *hbc)
hbc->t_of_last_write.v = 0;
hbc->t_of_last_hb.v = 0;
hbc->t_of_last_ackhb.v = 0;
- hbc->tsched = NN_MTIME_NEVER;
+ hbc->tsched = DDSRT_MTIME_NEVER;
hbc->hbs_since_last_write = 0;
hbc->last_packetid = 0;
}
-static void writer_hbcontrol_note_hb (struct writer *wr, nn_mtime_t tnow, int ansreq)
+static void writer_hbcontrol_note_hb (struct writer *wr, ddsrt_mtime_t tnow, int ansreq)
{
struct hbcontrol * const hbc = &wr->hbcontrol;
@@ -77,7 +76,7 @@ static void writer_hbcontrol_note_hb (struct writer *wr, nn_mtime_t tnow, int an
hbc->hbs_since_last_write++;
}
-int64_t writer_hbcontrol_intv (const struct writer *wr, const struct whc_state *whcst, UNUSED_ARG (nn_mtime_t tnow))
+int64_t writer_hbcontrol_intv (const struct writer *wr, const struct whc_state *whcst, UNUSED_ARG (ddsrt_mtime_t tnow))
{
struct ddsi_domaingv const * const gv = wr->e.gv;
struct hbcontrol const * const hbc = &wr->hbcontrol;
@@ -103,11 +102,11 @@ int64_t writer_hbcontrol_intv (const struct writer *wr, const struct whc_state *
return ret;
}
-void writer_hbcontrol_note_asyncwrite (struct writer *wr, nn_mtime_t tnow)
+void writer_hbcontrol_note_asyncwrite (struct writer *wr, ddsrt_mtime_t tnow)
{
struct ddsi_domaingv const * const gv = wr->e.gv;
struct hbcontrol * const hbc = &wr->hbcontrol;
- nn_mtime_t tnext;
+ ddsrt_mtime_t tnext;
/* Reset number of heartbeats since last write: that means the
heartbeat rate will go back up to the default */
@@ -126,13 +125,13 @@ void writer_hbcontrol_note_asyncwrite (struct writer *wr, nn_mtime_t tnow)
}
}
-int writer_hbcontrol_must_send (const struct writer *wr, const struct whc_state *whcst, nn_mtime_t tnow /* monotonic */)
+int writer_hbcontrol_must_send (const struct writer *wr, const struct whc_state *whcst, ddsrt_mtime_t tnow /* monotonic */)
{
struct hbcontrol const * const hbc = &wr->hbcontrol;
return (tnow.v >= hbc->t_of_last_hb.v + writer_hbcontrol_intv (wr, whcst, tnow));
}
-struct nn_xmsg *writer_hbcontrol_create_heartbeat (struct writer *wr, const struct whc_state *whcst, nn_mtime_t tnow, int hbansreq, int issync)
+struct nn_xmsg *writer_hbcontrol_create_heartbeat (struct writer *wr, const struct whc_state *whcst, ddsrt_mtime_t tnow, int hbansreq, int issync)
{
struct ddsi_domaingv const * const gv = wr->e.gv;
struct nn_xmsg *msg;
@@ -224,7 +223,7 @@ struct nn_xmsg *writer_hbcontrol_create_heartbeat (struct writer *wr, const stru
return msg;
}
-static int writer_hbcontrol_ack_required_generic (const struct writer *wr, const struct whc_state *whcst, nn_mtime_t tlast, nn_mtime_t tnow, int piggyback)
+static int writer_hbcontrol_ack_required_generic (const struct writer *wr, const struct whc_state *whcst, ddsrt_mtime_t tlast, ddsrt_mtime_t tnow, int piggyback)
{
struct ddsi_domaingv const * const gv = wr->e.gv;
struct hbcontrol const * const hbc = &wr->hbcontrol;
@@ -260,17 +259,17 @@ static int writer_hbcontrol_ack_required_generic (const struct writer *wr, const
return 0;
}
-int writer_hbcontrol_ack_required (const struct writer *wr, const struct whc_state *whcst, nn_mtime_t tnow)
+int writer_hbcontrol_ack_required (const struct writer *wr, const struct whc_state *whcst, ddsrt_mtime_t tnow)
{
struct hbcontrol const * const hbc = &wr->hbcontrol;
return writer_hbcontrol_ack_required_generic (wr, whcst, hbc->t_of_last_write, tnow, 0);
}
-struct nn_xmsg *writer_hbcontrol_piggyback (struct writer *wr, const struct whc_state *whcst, nn_mtime_t tnow, uint32_t packetid, int *hbansreq)
+struct nn_xmsg *writer_hbcontrol_piggyback (struct writer *wr, const struct whc_state *whcst, ddsrt_mtime_t tnow, uint32_t packetid, int *hbansreq)
{
struct hbcontrol * const hbc = &wr->hbcontrol;
uint32_t last_packetid;
- nn_mtime_t tlast;
+ ddsrt_mtime_t tlast;
struct nn_xmsg *msg;
tlast = hbc->t_of_last_write;
@@ -332,7 +331,7 @@ void add_Heartbeat (struct nn_xmsg *msg, struct writer *wr, const struct whc_sta
{
/* If configured to measure heartbeat-to-ack latency, we must add
a timestamp. No big deal if it fails. */
- nn_xmsg_add_timestamp (msg, now ());
+ nn_xmsg_add_timestamp (msg, ddsrt_time_wallclock ());
}
hb = nn_xmsg_append (msg, &sm_marker, sizeof (Heartbeat_t));
@@ -687,9 +686,9 @@ dds_return_t write_hb_liveliness (struct ddsi_domaingv * const gv, struct ddsi_g
}
if (wr->xqos->liveliness.kind == DDS_LIVELINESS_MANUAL_BY_PARTICIPANT && ((lease = ddsrt_atomic_ldvoidp (&wr->c.pp->minl_man)) != NULL))
- lease_renew (lease, now_et());
+ lease_renew (lease, ddsrt_time_elapsed());
else if (wr->xqos->liveliness.kind == DDS_LIVELINESS_MANUAL_BY_TOPIC && wr->lease != NULL)
- lease_renew (wr->lease, now_et());
+ lease_renew (wr->lease, ddsrt_time_elapsed());
if ((msg = nn_xmsg_new (gv->xmsgpool, &wr->e.guid.prefix, sizeof (InfoTS_t) + sizeof (Heartbeat_t), NN_XMSG_KIND_CONTROL)) == NULL)
return DDS_RETCODE_OUT_OF_RESOURCES;
@@ -920,13 +919,13 @@ static int insert_sample_in_whc (struct writer *wr, seqno_t seq, struct ddsi_pli
if ((wr->reliable && have_reliable_subs (wr)) || wr_deadline || wr->handle_as_transient_local)
{
- nn_mtime_t exp = NN_MTIME_NEVER;
+ ddsrt_mtime_t exp = DDSRT_MTIME_NEVER;
#ifdef DDSI_INCLUDE_LIFESPAN
/* Don't set expiry for samples with flags unregister or dispose, because these are required
* for sample lifecycle and should always be delivered to the reader so that is can clean up
* its history cache. */
if (wr->xqos->lifespan.duration != DDS_INFINITY && (serdata->statusinfo & (NN_STATUSINFO_UNREGISTER | NN_STATUSINFO_DISPOSE)) == 0)
- exp = add_duration_to_mtime(serdata->twrite, wr->xqos->lifespan.duration);
+ exp = ddsrt_mtime_add_duration(serdata->twrite, wr->xqos->lifespan.duration);
#endif
res = ((insres = whc_insert (wr->whc, writer_max_drop_seq (wr), seq, exp, plist, serdata, tk)) < 0) ? insres : 1;
@@ -999,8 +998,8 @@ static dds_return_t throttle_writer (struct thread_state1 * const ts1, struct nn
writer. */
struct ddsi_domaingv const * const gv = wr->e.gv;
dds_return_t result = DDS_RETCODE_OK;
- nn_mtime_t tnow = now_mt ();
- const nn_mtime_t abstimeout = add_duration_to_mtime (tnow, wr->xqos->reliability.max_blocking_time);
+ ddsrt_mtime_t tnow = ddsrt_time_monotonic ();
+ const ddsrt_mtime_t abstimeout = ddsrt_mtime_add_duration (tnow, wr->xqos->reliability.max_blocking_time);
struct whc_state whcst;
whc_get_state (wr->whc, &whcst);
@@ -1036,7 +1035,7 @@ static dds_return_t throttle_writer (struct thread_state1 * const ts1, struct nn
while (ddsrt_atomic_ld32 (&gv->rtps_keepgoing) && !writer_may_continue (wr, &whcst))
{
int64_t reltimeout;
- tnow = now_mt ();
+ tnow = ddsrt_time_monotonic ();
reltimeout = abstimeout.v - tnow.v;
result = DDS_RETCODE_TIMEOUT;
if (reltimeout > 0)
@@ -1071,8 +1070,8 @@ static int maybe_grow_whc (struct writer *wr)
struct ddsi_domaingv const * const gv = wr->e.gv;
if (!wr->retransmitting && gv->config.whc_adaptive && wr->whc_high < gv->config.whc_highwater_mark)
{
- nn_etime_t tnow = now_et();
- nn_etime_t tgrow = add_duration_to_etime (wr->t_whc_high_upd, DDS_MSECS (10));
+ ddsrt_etime_t tnow = ddsrt_time_elapsed();
+ ddsrt_etime_t tgrow = ddsrt_etime_add_duration (wr->t_whc_high_upd, DDS_MSECS (10));
if (tnow.v >= tgrow.v)
{
uint32_t m = (gv->config.whc_highwater_mark - wr->whc_high) / 32;
@@ -1089,7 +1088,7 @@ static int write_sample_eot (struct thread_state1 * const ts1, struct nn_xpack *
struct ddsi_domaingv const * const gv = wr->e.gv;
int r;
seqno_t seq;
- nn_mtime_t tnow;
+ ddsrt_mtime_t tnow;
struct lease *lease;
/* If GC not allowed, we must be sure to never block when writing. That is only the case for (true, aggressive) KEEP_LAST writers, and also only if there is no limit to how much unacknowledged data the WHC may contain. */
@@ -1113,9 +1112,9 @@ static int write_sample_eot (struct thread_state1 * const ts1, struct nn_xpack *
}
if (wr->xqos->liveliness.kind == DDS_LIVELINESS_MANUAL_BY_PARTICIPANT && ((lease = ddsrt_atomic_ldvoidp (&wr->c.pp->minl_man)) != NULL))
- lease_renew (lease, now_et());
+ lease_renew (lease, ddsrt_time_elapsed());
else if (wr->xqos->liveliness.kind == DDS_LIVELINESS_MANUAL_BY_TOPIC && wr->lease != NULL)
- lease_renew (wr->lease, now_et());
+ lease_renew (wr->lease, ddsrt_time_elapsed());
ddsrt_mutex_lock (&wr->e.lock);
@@ -1162,7 +1161,7 @@ static int write_sample_eot (struct thread_state1 * const ts1, struct nn_xpack *
}
/* Always use the current monotonic time */
- tnow = now_mt ();
+ tnow = ddsrt_time_monotonic ();
serdata->twrite = tnow;
seq = ++wr->seq;
diff --git a/src/core/ddsi/src/q_whc.c b/src/core/ddsi/src/q_whc.c
index 457045d..7cc86fd 100644
--- a/src/core/ddsi/src/q_whc.c
+++ b/src/core/ddsi/src/q_whc.c
@@ -10,7 +10,6 @@
* SPDX-License-Identifier: EPL-2.0 OR BSD-3-Clause
*/
#include "dds/ddsi/q_rtps.h"
-#include "dds/ddsi/q_time.h"
#include "dds/ddsi/q_whc.h"
extern inline seqno_t whc_next_seq (const struct whc *whc, seqno_t seq);
@@ -21,7 +20,7 @@ extern inline void whc_return_sample (struct whc *whc, struct whc_borrowed_sampl
extern inline void whc_sample_iter_init (const struct whc *whc, struct whc_sample_iter *it);
extern inline bool whc_sample_iter_borrow_next (struct whc_sample_iter *it, struct whc_borrowed_sample *sample);
extern inline void whc_free (struct whc *whc);
-extern int whc_insert (struct whc *whc, seqno_t max_drop_seq, seqno_t seq, nn_mtime_t exp, struct ddsi_plist *plist, struct ddsi_serdata *serdata, struct ddsi_tkmap_instance *tk);
+extern int whc_insert (struct whc *whc, seqno_t max_drop_seq, seqno_t seq, ddsrt_mtime_t exp, struct ddsi_plist *plist, struct ddsi_serdata *serdata, struct ddsi_tkmap_instance *tk);
extern unsigned whc_downgrade_to_volatile (struct whc *whc, struct whc_state *st);
extern unsigned whc_remove_acked_messages (struct whc *whc, seqno_t max_drop_seq, struct whc_state *whcst, struct whc_node **deferred_free_list);
extern void whc_free_deferred_free_list (struct whc *whc, struct whc_node *deferred_free_list);
diff --git a/src/core/ddsi/src/q_xevent.c b/src/core/ddsi/src/q_xevent.c
index 4fa7554..54bdb22 100644
--- a/src/core/ddsi/src/q_xevent.c
+++ b/src/core/ddsi/src/q_xevent.c
@@ -19,7 +19,6 @@
#include "dds/ddsrt/avl.h"
#include "dds/ddsrt/fibheap.h"
-#include "dds/ddsi/q_time.h"
#include "dds/ddsi/q_log.h"
#include "dds/ddsi/q_addrset.h"
#include "dds/ddsi/q_xmsg.h"
@@ -66,7 +65,7 @@ struct xevent
{
ddsrt_fibheap_node_t heapnode;
struct xeventq *evq;
- nn_mtime_t tsched;
+ ddsrt_mtime_t tsched;
enum xeventkind kind;
union {
struct {
@@ -92,7 +91,7 @@ struct xevent
ddsi_guid_t guid;
} delete_writer;
struct {
- void (*cb) (struct xevent *ev, void *arg, nn_mtime_t tnow);
+ void (*cb) (struct xevent *ev, void *arg, ddsrt_mtime_t tnow);
void *arg;
bool executing;
} callback;
@@ -152,7 +151,7 @@ struct xeventq {
};
static uint32_t xevent_thread (struct xeventq *xevq);
-static nn_mtime_t earliest_in_xeventq (struct xeventq *evq);
+static ddsrt_mtime_t earliest_in_xeventq (struct xeventq *evq);
static int msg_xevents_cmp (const void *a, const void *b);
static int compare_xevent_tsched (const void *va, const void *vb);
static void handle_nontimed_xevent (struct xevent_nt *xev, struct nn_xpack *xp);
@@ -360,7 +359,7 @@ void delete_xevent_callback (struct xevent *ev)
free_xevent (evq, ev);
}
-int resched_xevent_if_earlier (struct xevent *ev, nn_mtime_t tsched)
+int resched_xevent_if_earlier (struct xevent *ev, ddsrt_mtime_t tsched)
{
struct xeventq *evq = ev->evq;
int is_resched;
@@ -376,7 +375,7 @@ int resched_xevent_if_earlier (struct xevent *ev, nn_mtime_t tsched)
is_resched = 0;
else
{
- nn_mtime_t tbefore = earliest_in_xeventq (evq);
+ ddsrt_mtime_t tbefore = earliest_in_xeventq (evq);
if (ev->tsched.v != DDS_NEVER)
{
ev->tsched = tsched;
@@ -395,7 +394,25 @@ int resched_xevent_if_earlier (struct xevent *ev, nn_mtime_t tsched)
return is_resched;
}
-static struct xevent *qxev_common (struct xeventq *evq, nn_mtime_t tsched, enum xeventkind kind)
+static ddsrt_mtime_t mtime_round_up (ddsrt_mtime_t t, int64_t round)
+{
+ /* This function rounds up t to the nearest next multiple of round.
+ t is nanoseconds, round is milliseconds. Avoid functions from
+ maths libraries to keep code portable */
+ assert (t.v >= 0 && round >= 0);
+ if (round == 0 || t.v == DDS_INFINITY)
+ return t;
+ else
+ {
+ int64_t remainder = t.v % round;
+ if (remainder == 0)
+ return t;
+ else
+ return (ddsrt_mtime_t) { t.v + round - remainder };
+ }
+}
+
+static struct xevent *qxev_common (struct xeventq *evq, ddsrt_mtime_t tsched, enum xeventkind kind)
{
/* qxev_common is the route by which all timed xevents are
created. */
@@ -407,7 +424,7 @@ static struct xevent *qxev_common (struct xeventq *evq, nn_mtime_t tsched, enum
/* round up the scheduled time if required */
if (tsched.v != DDS_NEVER && evq->gv->config.schedule_time_rounding != 0)
{
- nn_mtime_t tsched_rounded = mtime_round_up (tsched, evq->gv->config.schedule_time_rounding);
+ ddsrt_mtime_t tsched_rounded = mtime_round_up (tsched, evq->gv->config.schedule_time_rounding);
EVQTRACE ("rounded event scheduled for %"PRId64" to %"PRId64"\n", tsched.v, tsched_rounded.v);
tsched = tsched_rounded;
}
@@ -427,11 +444,11 @@ static struct xevent_nt *qxev_common_nt (struct xeventq *evq, enum xeventkind_nt
return ev;
}
-static nn_mtime_t earliest_in_xeventq (struct xeventq *evq)
+static ddsrt_mtime_t earliest_in_xeventq (struct xeventq *evq)
{
struct xevent *min;
ASSERT_MUTEX_HELD (&evq->lock);
- return ((min = ddsrt_fibheap_min (&evq_xevents_fhdef, &evq->xevents)) != NULL) ? min->tsched : NN_MTIME_NEVER;
+ return ((min = ddsrt_fibheap_min (&evq_xevents_fhdef, &evq->xevents)) != NULL) ? min->tsched : DDSRT_MTIME_NEVER;
}
static void qxev_insert (struct xevent *ev)
@@ -442,7 +459,7 @@ static void qxev_insert (struct xevent *ev)
ASSERT_MUTEX_HELD (&evq->lock);
if (ev->tsched.v != DDS_NEVER)
{
- nn_mtime_t tbefore = earliest_in_xeventq (evq);
+ ddsrt_mtime_t tbefore = earliest_in_xeventq (evq);
ddsrt_fibheap_insert (&evq_xevents_fhdef, &evq->xevents, ev);
if (ev->tsched.v < tbefore.v)
ddsrt_cond_broadcast (&evq->cond);
@@ -584,12 +601,12 @@ static void handle_xevk_entityid (struct nn_xpack *xp, struct xevent_nt *ev)
nn_xpack_addmsg (xp, ev->u.entityid.msg, 0);
}
-static void handle_xevk_heartbeat (struct nn_xpack *xp, struct xevent *ev, nn_mtime_t tnow /* monotonic */)
+static void handle_xevk_heartbeat (struct nn_xpack *xp, struct xevent *ev, ddsrt_mtime_t tnow /* monotonic */)
{
struct ddsi_domaingv const * const gv = ev->evq->gv;
struct nn_xmsg *msg;
struct writer *wr;
- nn_mtime_t t_next;
+ ddsrt_mtime_t t_next;
int hbansreq = 0;
struct whc_state whcst;
@@ -846,7 +863,7 @@ static void add_AckNack (struct nn_xmsg *msg, struct proxy_writer *pwr, struct p
ETRACE (pwr, "\n");
}
-static void handle_xevk_acknack (UNUSED_ARG (struct nn_xpack *xp), struct xevent *ev, nn_mtime_t tnow)
+static void handle_xevk_acknack (UNUSED_ARG (struct nn_xpack *xp), struct xevent *ev, ddsrt_mtime_t tnow)
{
/* FIXME: ought to keep track of which NACKs are being generated in
response to a Heartbeat. There is no point in having multiple
@@ -901,7 +918,7 @@ static void handle_xevk_acknack (UNUSED_ARG (struct nn_xpack *xp), struct xevent
HEARTBEAT, I've seen too many cases of not sending an NACK
because the writing side got confused ... Better to recover
eventually. */
- (void) resched_xevent_if_earlier (ev, add_duration_to_mtime (tnow, gv->config.auto_resched_nack_delay));
+ (void) resched_xevent_if_earlier (ev, ddsrt_mtime_add_duration (tnow, gv->config.auto_resched_nack_delay));
}
GVTRACE ("send acknack(rd "PGUIDFMT" -> pwr "PGUIDFMT")\n",
PGUID (ev->u.acknack.rd_guid), PGUID (ev->u.acknack.pwr_guid));
@@ -927,7 +944,7 @@ static void handle_xevk_acknack (UNUSED_ARG (struct nn_xpack *xp), struct xevent
intv = 5;
else
intv = 10;
- (void) resched_xevent_if_earlier (ev, add_duration_to_mtime (tnow, intv * DDS_NSECS_IN_SEC));
+ (void) resched_xevent_if_earlier (ev, ddsrt_mtime_add_duration (tnow, intv * DDS_NSECS_IN_SEC));
}
ddsrt_mutex_unlock (&pwr->e.lock);
@@ -940,7 +957,7 @@ static void handle_xevk_acknack (UNUSED_ARG (struct nn_xpack *xp), struct xevent
outofmem:
/* What to do if out of memory? Crash or burn? */
ddsrt_mutex_unlock (&pwr->e.lock);
- (void) resched_xevent_if_earlier (ev, add_duration_to_mtime (tnow, DDS_MSECS (100)));
+ (void) resched_xevent_if_earlier (ev, ddsrt_mtime_add_duration (tnow, DDS_MSECS (100)));
}
static bool resend_spdp_sample_by_guid_key (struct writer *wr, const ddsi_guid_t *guid, struct proxy_reader *prd)
@@ -981,7 +998,7 @@ static bool resend_spdp_sample_by_guid_key (struct writer *wr, const ddsi_guid_t
return sample_found;
}
-static void handle_xevk_spdp (UNUSED_ARG (struct nn_xpack *xp), struct xevent *ev, nn_mtime_t tnow)
+static void handle_xevk_spdp (UNUSED_ARG (struct nn_xpack *xp), struct xevent *ev, ddsrt_mtime_t tnow)
{
/* Like the writer pointer in the heartbeat event, the participant pointer in the spdp event is assumed valid. */
struct ddsi_domaingv *gv = ev->evq->gv;
@@ -1060,7 +1077,7 @@ static void handle_xevk_spdp (UNUSED_ARG (struct nn_xpack *xp), struct xevent *e
delete_xevent (ev);
else
{
- nn_mtime_t tnext = add_duration_to_mtime (tnow, DDS_SECS (1));
+ ddsrt_mtime_t tnext = ddsrt_mtime_add_duration (tnow, DDS_SECS (1));
GVTRACE ("xmit spdp "PGUIDFMT" to %"PRIx32":%"PRIx32":%"PRIx32":%x (resched %gs)\n",
PGUID (pp->e.guid),
PGUIDPREFIX (ev->u.spdp.dest_proxypp_guid_prefix), NN_ENTITYID_SPDP_BUILTIN_PARTICIPANT_READER,
@@ -1075,7 +1092,7 @@ static void handle_xevk_spdp (UNUSED_ARG (struct nn_xpack *xp), struct xevent *e
but never wait longer than spdp_interval */
const dds_duration_t mindelta = DDS_MSECS (10);
const dds_duration_t ldur = pp->lease_duration;
- nn_mtime_t tnext;
+ ddsrt_mtime_t tnext;
int64_t intv;
if (ldur < 5 * mindelta / 4)
@@ -1087,7 +1104,7 @@ static void handle_xevk_spdp (UNUSED_ARG (struct nn_xpack *xp), struct xevent *e
if (intv > gv->config.spdp_interval)
intv = gv->config.spdp_interval;
- tnext = add_duration_to_mtime (tnow, intv);
+ tnext = ddsrt_mtime_add_duration (tnow, intv);
GVTRACE ("xmit spdp "PGUIDFMT" to %"PRIx32":%"PRIx32":%"PRIx32":%x (resched %gs)\n",
PGUID (pp->e.guid),
PGUIDPREFIX (ev->u.spdp.dest_proxypp_guid_prefix), NN_ENTITYID_SPDP_BUILTIN_PARTICIPANT_READER,
@@ -1096,12 +1113,12 @@ static void handle_xevk_spdp (UNUSED_ARG (struct nn_xpack *xp), struct xevent *e
}
}
-static void handle_xevk_pmd_update (struct thread_state1 * const ts1, struct nn_xpack *xp, struct xevent *ev, nn_mtime_t tnow)
+static void handle_xevk_pmd_update (struct thread_state1 * const ts1, struct nn_xpack *xp, struct xevent *ev, ddsrt_mtime_t tnow)
{
struct ddsi_domaingv * const gv = ev->evq->gv;
struct participant *pp;
dds_duration_t intv;
- nn_mtime_t tnext;
+ ddsrt_mtime_t tnext;
if ((pp = entidx_lookup_participant_guid (gv->entity_index, &ev->u.pmd_update.pp_guid)) == NULL)
{
@@ -1130,7 +1147,7 @@ static void handle_xevk_pmd_update (struct thread_state1 * const ts1, struct nn_
(void) resched_xevent_if_earlier (ev, tnext);
}
-static void handle_xevk_delete_writer (UNUSED_ARG (struct nn_xpack *xp), struct xevent *ev, UNUSED_ARG (nn_mtime_t tnow))
+static void handle_xevk_delete_writer (UNUSED_ARG (struct nn_xpack *xp), struct xevent *ev, UNUSED_ARG (ddsrt_mtime_t tnow))
{
/* don't worry if the writer is already gone by the time we get here. */
struct ddsi_domaingv * const gv = ev->evq->gv;
@@ -1139,7 +1156,7 @@ static void handle_xevk_delete_writer (UNUSED_ARG (struct nn_xpack *xp), struct
delete_xevent (ev);
}
-static void handle_individual_xevent (struct thread_state1 * const ts1, struct xevent *xev, struct nn_xpack *xp, nn_mtime_t tnow)
+static void handle_individual_xevent (struct thread_state1 * const ts1, struct xevent *xev, struct nn_xpack *xp, ddsrt_mtime_t tnow)
{
struct xeventq *xevq = xev->evq;
/* We relinquish the lock while processing the event, but require it
@@ -1200,7 +1217,7 @@ static void handle_individual_xevent_nt (struct xevent_nt *xev, struct nn_xpack
ddsrt_free (xev);
}
-static void handle_timed_xevent (struct thread_state1 * const ts1, struct xevent *xev, struct nn_xpack *xp, nn_mtime_t tnow /* monotonic */)
+static void handle_timed_xevent (struct thread_state1 * const ts1, struct xevent *xev, struct nn_xpack *xp, ddsrt_mtime_t tnow /* monotonic */)
{
/* This function handles the individual xevent irrespective of
whether it is a "timed" or "non-timed" xevent */
@@ -1228,7 +1245,7 @@ static void handle_nontimed_xevent (struct xevent_nt *xev, struct nn_xpack *xp)
ASSERT_MUTEX_HELD (&xevq->lock);
}
-static void handle_xevents (struct thread_state1 * const ts1, struct xeventq *xevq, struct nn_xpack *xp, nn_mtime_t tnow /* monotonic */)
+static void handle_xevents (struct thread_state1 * const ts1, struct xeventq *xevq, struct nn_xpack *xp, ddsrt_mtime_t tnow /* monotonic */)
{
int xeventsToProcess = 1;
@@ -1265,7 +1282,7 @@ static void handle_xevents (struct thread_state1 * const ts1, struct xeventq *xe
/* Limited-bandwidth channels means events can take a LONG time
to process. So read the clock more often. */
- tnow = now_mt ();
+ tnow = ddsrt_time_monotonic ();
}
if (!non_timed_xmit_list_is_empty (xevq))
@@ -1273,7 +1290,7 @@ static void handle_xevents (struct thread_state1 * const ts1, struct xeventq *xe
struct xevent_nt *xev = getnext_from_non_timed_xmit_list (xevq);
thread_state_awake_to_awake_no_nest (ts1);
handle_nontimed_xevent (xev, xp);
- tnow = now_mt ();
+ tnow = ddsrt_time_monotonic ();
}
else
{
@@ -1288,14 +1305,14 @@ static uint32_t xevent_thread (struct xeventq * xevq)
{
struct thread_state1 * const ts1 = lookup_thread_state ();
struct nn_xpack *xp;
- nn_mtime_t next_thread_cputime = { 0 };
+ ddsrt_mtime_t next_thread_cputime = { 0 };
xp = nn_xpack_new (xevq->tev_conn, xevq->auxiliary_bandwidth_limit, xevq->gv->config.xpack_send_async);
ddsrt_mutex_lock (&xevq->lock);
while (!xevq->terminate)
{
- nn_mtime_t tnow = now_mt ();
+ ddsrt_mtime_t tnow = ddsrt_time_monotonic ();
LOG_THREAD_CPUTIME (&xevq->gv->logconfig, next_thread_cputime);
@@ -1313,7 +1330,7 @@ static uint32_t xevent_thread (struct xeventq * xevq)
}
else
{
- nn_mtime_t twakeup = earliest_in_xeventq (xevq);
+ ddsrt_mtime_t twakeup = earliest_in_xeventq (xevq);
if (twakeup.v == DDS_NEVER)
{
/* no scheduled events nor any non-timed events */
@@ -1325,7 +1342,7 @@ static uint32_t xevent_thread (struct xeventq * xevq)
don't want to sleep much longer than we have to. With
os_condTimedWait requiring a relative time, we don't have
much choice but to read the clock now */
- tnow = now_mt ();
+ tnow = ddsrt_time_monotonic ();
if (twakeup.v > tnow.v)
{
twakeup.v -= tnow.v; /* ddsrt_cond_waitfor: relative timeout */
@@ -1453,7 +1470,7 @@ int qxev_msg_rexmit_wrlock_held (struct xeventq *evq, struct nn_xmsg *msg, int f
}
}
-struct xevent *qxev_heartbeat (struct xeventq *evq, nn_mtime_t tsched, const ddsi_guid_t *wr_guid)
+struct xevent *qxev_heartbeat (struct xeventq *evq, ddsrt_mtime_t tsched, const ddsi_guid_t *wr_guid)
{
/* Event _must_ be deleted before enough of the writer is freed to
cause trouble. Currently used exclusively for
@@ -1468,7 +1485,7 @@ struct xevent *qxev_heartbeat (struct xeventq *evq, nn_mtime_t tsched, const dds
return ev;
}
-struct xevent *qxev_acknack (struct xeventq *evq, nn_mtime_t tsched, const ddsi_guid_t *pwr_guid, const ddsi_guid_t *rd_guid)
+struct xevent *qxev_acknack (struct xeventq *evq, ddsrt_mtime_t tsched, const ddsi_guid_t *pwr_guid, const ddsi_guid_t *rd_guid)
{
struct xevent *ev;
assert(evq);
@@ -1481,7 +1498,7 @@ struct xevent *qxev_acknack (struct xeventq *evq, nn_mtime_t tsched, const ddsi_
return ev;
}
-struct xevent *qxev_spdp (struct xeventq *evq, nn_mtime_t tsched, const ddsi_guid_t *pp_guid, const ddsi_guid_t *dest_proxypp_guid)
+struct xevent *qxev_spdp (struct xeventq *evq, ddsrt_mtime_t tsched, const ddsi_guid_t *pp_guid, const ddsi_guid_t *dest_proxypp_guid)
{
struct xevent *ev;
ddsrt_mutex_lock (&evq->lock);
@@ -1499,7 +1516,7 @@ struct xevent *qxev_spdp (struct xeventq *evq, nn_mtime_t tsched, const ddsi_gui
return ev;
}
-struct xevent *qxev_pmd_update (struct xeventq *evq, nn_mtime_t tsched, const ddsi_guid_t *pp_guid)
+struct xevent *qxev_pmd_update (struct xeventq *evq, ddsrt_mtime_t tsched, const ddsi_guid_t *pp_guid)
{
struct xevent *ev;
ddsrt_mutex_lock (&evq->lock);
@@ -1510,7 +1527,7 @@ struct xevent *qxev_pmd_update (struct xeventq *evq, nn_mtime_t tsched, const dd
return ev;
}
-struct xevent *qxev_delete_writer (struct xeventq *evq, nn_mtime_t tsched, const ddsi_guid_t *guid)
+struct xevent *qxev_delete_writer (struct xeventq *evq, ddsrt_mtime_t tsched, const ddsi_guid_t *guid)
{
struct xevent *ev;
ddsrt_mutex_lock (&evq->lock);
@@ -1521,7 +1538,7 @@ struct xevent *qxev_delete_writer (struct xeventq *evq, nn_mtime_t tsched, const
return ev;
}
-struct xevent *qxev_callback (struct xeventq *evq, nn_mtime_t tsched, void (*cb) (struct xevent *ev, void *arg, nn_mtime_t tnow), void *arg)
+struct xevent *qxev_callback (struct xeventq *evq, ddsrt_mtime_t tsched, void (*cb) (struct xevent *ev, void *arg, ddsrt_mtime_t tnow), void *arg)
{
struct xevent *ev;
ddsrt_mutex_lock (&evq->lock);
diff --git a/src/core/ddsi/src/q_xmsg.c b/src/core/ddsi/src/q_xmsg.c
index ef76893..c897550 100644
--- a/src/core/ddsi/src/q_xmsg.c
+++ b/src/core/ddsi/src/q_xmsg.c
@@ -538,14 +538,14 @@ void nn_xmsg_shrink (struct nn_xmsg *m, struct nn_xmsg_marker marker, size_t sz)
m->sz = marker.offset + sz;
}
-void nn_xmsg_add_timestamp (struct nn_xmsg *m, nn_wctime_t t)
+void nn_xmsg_add_timestamp (struct nn_xmsg *m, ddsrt_wctime_t t)
{
InfoTimestamp_t * ts;
struct nn_xmsg_marker sm;
ts = (InfoTimestamp_t*) nn_xmsg_append (m, &sm, sizeof (InfoTimestamp_t));
nn_xmsg_submsg_init (m, sm, SMID_INFO_TS);
- ts->time = nn_wctime_to_ddsi_time (t);
+ ts->time = ddsi_wctime_to_ddsi_time (t);
nn_xmsg_submsg_setnext (m, sm);
}
diff --git a/src/core/xtests/rhc_torture/rhc_torture.c b/src/core/xtests/rhc_torture/rhc_torture.c
index b662b7a..fe9dc53 100644
--- a/src/core/xtests/rhc_torture/rhc_torture.c
+++ b/src/core/xtests/rhc_torture/rhc_torture.c
@@ -108,9 +108,9 @@ static struct ddsi_serdata *mkkeysample (int32_t keyval, unsigned statusinfo)
}
#if defined(DDSI_INCLUDE_LIFESPAN) || defined (DDSI_INCLUDE_DEADLINE_MISSED)
-static nn_mtime_t rand_texp ()
+static ddsrt_mtime_t rand_texp ()
{
- nn_mtime_t ret = now_mt();
+ ddsrt_mtime_t ret = ddsrt_time_monotonic();
ret.v -= DDS_MSECS(500) + (int64_t) (ddsrt_prng_random (&prng) % DDS_MSECS(1500));
return ret;
}
@@ -158,7 +158,7 @@ static uint64_t store (struct ddsi_tkmap *tkmap, struct dds_rhc *rhc, struct pro
if (lifespan_expiry && (sd->statusinfo & (NN_STATUSINFO_UNREGISTER | NN_STATUSINFO_DISPOSE)) == 0)
pwr_info.lifespan_exp = rand_texp();
else
- pwr_info.lifespan_exp = NN_MTIME_NEVER;
+ pwr_info.lifespan_exp = DDSRT_MTIME_NEVER;
#endif
dds_rhc_store (rhc, &pwr_info, sd, tk);
ddsi_tkmap_instance_unref (tkmap, tk);
@@ -831,7 +831,7 @@ static void test_conditions (dds_entity_t pp, dds_entity_t tp, const int count,
wr_info.iid = wr[which]->e.iid;
wr_info.ownership_strength = wr[which]->c.xqos->ownership_strength.value;
#ifdef DDSI_INCLUDE_LIFESPAN
- wr_info.lifespan_exp = NN_MTIME_NEVER;
+ wr_info.lifespan_exp = DDSRT_MTIME_NEVER;
#endif
for (size_t k = 0; k < nrd; k++)
dds_rhc_unregister_wr (rhc[k], &wr_info);
@@ -962,7 +962,7 @@ int main (int argc, char **argv)
wr0_info.iid = wr0->e.iid;
wr0_info.ownership_strength = wr0->c.xqos->ownership_strength.value;
#ifdef DDSI_INCLUDE_LIFESPAN
- wr0_info.lifespan_exp = NN_MTIME_NEVER;
+ wr0_info.lifespan_exp = DDSRT_MTIME_NEVER;
#endif
dds_rhc_unregister_wr (rhc, &wr0_info);
thread_state_asleep (lookup_thread_state ());
diff --git a/src/ddsrt/include/dds/ddsrt/time.h b/src/ddsrt/include/dds/ddsrt/time.h
index 61992f8..224862e 100644
--- a/src/ddsrt/include/dds/ddsrt/time.h
+++ b/src/ddsrt/include/dds/ddsrt/time.h
@@ -21,6 +21,7 @@
#define DDS_TIME_H
#include
+#include
#include "dds/export.h"
#include "dds/ddsrt/types.h"
@@ -69,6 +70,23 @@ typedef int64_t dds_duration_t;
#define DDS_USECS(n) ((n) * DDS_NSECS_IN_USEC)
/** @}*/
+typedef struct {
+ dds_time_t v;
+} ddsrt_mtime_t;
+
+typedef struct {
+ dds_time_t v;
+} ddsrt_wctime_t;
+
+typedef struct {
+ dds_time_t v;
+} ddsrt_etime_t;
+
+#define DDSRT_MTIME_NEVER ((ddsrt_mtime_t) { DDS_NEVER })
+#define DDSRT_WCTIME_NEVER ((ddsrt_wctime_t) { DDS_NEVER })
+#define DDSRT_ETIME_NEVER ((ddsrt_etime_t) { DDS_NEVER })
+#define DDSRT_WCTIME_INVALID ((ddsrt_wctime_t) { INT64_MIN })
+
/**
* @brief Get the current time in nanoseconds since the UNIX Epoch.
*
@@ -86,6 +104,14 @@ DDS_EXPORT dds_time_t dds_time(void);
*/
DDS_EXPORT void dds_sleepfor (dds_duration_t reltime);
+/**
+ * @brief Get the current time in nanoseconds since the UNIX Epoch. Identical
+ * to (ddsrt_wctime_t){dds_time()}
+ *
+ * @returns Curren time.
+ */
+DDS_EXPORT ddsrt_wctime_t ddsrt_time_wallclock(void);
+
/**
* @brief Get high resolution, monotonic time.
*
@@ -99,7 +125,7 @@ DDS_EXPORT void dds_sleepfor (dds_duration_t reltime);
*
* @returns Monotonic time if available, otherwise real time.
*/
-DDS_EXPORT dds_time_t ddsrt_time_monotonic(void);
+DDS_EXPORT ddsrt_mtime_t ddsrt_time_monotonic(void);
/**
* @brief Get high resolution, elapsed (and thus monotonic) time since some
@@ -113,7 +139,7 @@ DDS_EXPORT dds_time_t ddsrt_time_monotonic(void);
*
* @returns Elapsed time if available, otherwise return monotonic time.
*/
-DDS_EXPORT dds_time_t ddsrt_time_elapsed(void);
+DDS_EXPORT ddsrt_etime_t ddsrt_time_elapsed(void);
/**
* @brief Convert time into a human readable string in RFC 3339 format.
@@ -135,6 +161,131 @@ DDS_EXPORT dds_time_t ddsrt_time_elapsed(void);
DDS_EXPORT size_t ddsrt_ctime(dds_time_t abstime, char *str, size_t size);
+/**
+ * @brief Calculate a time given an offset time and a duration.
+ *
+ * Negative time can become positive by adding a large enough duration, of
+ * course a positive time can become negative given a large enough negative
+ * duration.
+ *
+ * @param[in] abstime Timestamp in nanoseconds since UNIX Epoch.
+ * @param[in] reltime Relative time in nanoseconds.
+ *
+ * @returns A timestamp in nanoseconds since UNIX Epoch.
+ */
+inline dds_time_t ddsrt_time_add_duration(dds_time_t abstime, dds_duration_t reltime)
+{
+ assert(abstime >= 0);
+ assert(reltime >= 0);
+ return (reltime >= DDS_NEVER - abstime ? DDS_NEVER : abstime + reltime);
+}
+
+/**
+ * @brief Calculate a monotonic time given an offset time and a duration.
+ *
+ * Negative time can become positive by adding a large enough duration, of
+ * course a positive time can become negative given a large enough negative
+ * duration.
+ *
+ * @param[in] abstime Timestamp in nanoseconds since UNIX Epoch.
+ * @param[in] reltime Relative time in nanoseconds.
+ *
+ * @returns A timestamp in nanoseconds since UNIX Epoch.
+ */
+inline ddsrt_mtime_t ddsrt_mtime_add_duration(ddsrt_mtime_t abstime, dds_duration_t reltime) {
+ return (ddsrt_mtime_t) { ddsrt_time_add_duration (abstime.v, reltime) };
+}
+
+/**
+ * @brief Calculate a wall-clock time given an offset time and a duration.
+ *
+ * Negative time can become positive by adding a large enough duration, of
+ * course a positive time can become negative given a large enough negative
+ * duration.
+ *
+ * @param[in] abstime Timestamp in nanoseconds since UNIX Epoch.
+ * @param[in] reltime Relative time in nanoseconds.
+ *
+ * @returns A timestamp in nanoseconds since UNIX Epoch.
+ */
+inline ddsrt_wctime_t ddsrt_wctime_add_duration(ddsrt_wctime_t abstime, dds_duration_t reltime) {
+ return (ddsrt_wctime_t) { ddsrt_time_add_duration (abstime.v, reltime) };
+}
+
+/**
+ * @brief Calculate an elapsed time given an offset time and a duration.
+ *
+ * Negative time can become positive by adding a large enough duration, of
+ * course a positive time can become negative given a large enough negative
+ * duration.
+ *
+ * @param[in] abstime Timestamp in nanoseconds since UNIX Epoch.
+ * @param[in] reltime Relative time in nanoseconds.
+ *
+ * @returns A timestamp in nanoseconds since UNIX Epoch.
+ */
+inline ddsrt_etime_t ddsrt_etime_add_duration(ddsrt_etime_t abstime, dds_duration_t reltime) {
+ return (ddsrt_etime_t) { ddsrt_time_add_duration (abstime.v, reltime) };
+}
+
+#if _WIN32
+/**
+ * @brief Convert a relative time to microseconds rounding up.
+ *
+ * @param[in] reltime Relative time to convert.
+ *
+ * @returns INFINITE if @reltime was @DDS_INIFINITY, relative time converted to
+ * microseconds otherwise.
+ */
+inline DWORD
+ddsrt_duration_to_msecs_ceil(dds_duration_t reltime)
+{
+ if (reltime == DDS_INFINITY) {
+ return INFINITE;
+ } else if (reltime > 0) {
+ assert(INFINITE < (DDS_INFINITY / DDS_NSECS_IN_MSEC));
+ dds_duration_t max_nsecs = (INFINITE - 1) * DDS_NSECS_IN_MSEC;
+
+ if (reltime < (max_nsecs - (DDS_NSECS_IN_MSEC - 1))) {
+ reltime += (DDS_NSECS_IN_MSEC - 1);
+ } else {
+ reltime = max_nsecs;
+ }
+
+ return (DWORD)(reltime / DDS_NSECS_IN_MSEC);
+ }
+
+ return 0;
+}
+#endif
+
+/**
+ * @brief Convert monotonic time seconds & microseconds
+ *
+ * @param[in] t Monotonic time to convert
+ * @param[out] sec Seconds part
+ * @param[out] usec Microseconds part
+ */
+DDS_EXPORT void ddsrt_mtime_to_sec_usec (int32_t * __restrict sec, int32_t * __restrict usec, ddsrt_mtime_t t);
+
+/**
+ * @brief Convert wall-clock time seconds & microseconds
+ *
+ * @param[in] t Wall-clock time to convert
+ * @param[out] sec Seconds part
+ * @param[out] usec Microseconds part
+ */
+DDS_EXPORT void ddsrt_wctime_to_sec_usec (int32_t * __restrict sec, int32_t * __restrict usec, ddsrt_wctime_t t);
+
+/**
+ * @brief Convert elapsed time seconds & microseconds
+ *
+ * @param[in] t Elasped time to convert
+ * @param[out] sec Seconds part
+ * @param[out] usec Microseconds part
+ */
+DDS_EXPORT void ddsrt_etime_to_sec_usec (int32_t * __restrict sec, int32_t * __restrict usec, ddsrt_etime_t t);
+
#if defined(__cplusplus)
}
#endif
diff --git a/src/ddsrt/src/process/windows/process.c b/src/ddsrt/src/process/windows/process.c
index 65c5125..8fd942b 100644
--- a/src/ddsrt/src/process/windows/process.c
+++ b/src/ddsrt/src/process/windows/process.c
@@ -18,7 +18,6 @@
#include "dds/ddsrt/string.h"
#include "dds/ddsrt/atomics.h"
#include "dds/ddsrt/process.h"
-#include "dds/ddsrt/timeconv.h"
ddsrt_pid_t
diff --git a/src/ddsrt/src/sync/freertos/sync.c b/src/ddsrt/src/sync/freertos/sync.c
index f38b0c2..2f024ee 100644
--- a/src/ddsrt/src/sync/freertos/sync.c
+++ b/src/ddsrt/src/sync/freertos/sync.c
@@ -19,7 +19,7 @@
#include "dds/ddsrt/heap.h"
#include "dds/ddsrt/log.h"
#include "dds/ddsrt/sync.h"
-#include "dds/ddsrt/timeconv.h"
+#include "dds/ddsrt/time.h"
void ddsrt_mutex_init(ddsrt_mutex_t *mutex)
{
diff --git a/src/ddsrt/src/sync/posix/sync.c b/src/ddsrt/src/sync/posix/sync.c
index ff03c52..a7f92e8 100644
--- a/src/ddsrt/src/sync/posix/sync.c
+++ b/src/ddsrt/src/sync/posix/sync.c
@@ -18,7 +18,7 @@
#include
#include "dds/ddsrt/sync.h"
-#include "dds/ddsrt/timeconv.h"
+#include "dds/ddsrt/time.h"
void ddsrt_mutex_init (ddsrt_mutex_t *mutex)
{
diff --git a/src/ddsrt/src/sync/solaris2.6/sync.c b/src/ddsrt/src/sync/solaris2.6/sync.c
index 884f597..a3731bd 100644
--- a/src/ddsrt/src/sync/solaris2.6/sync.c
+++ b/src/ddsrt/src/sync/solaris2.6/sync.c
@@ -18,7 +18,7 @@
#include
#include "dds/ddsrt/sync.h"
-#include "dds/ddsrt/timeconv.h"
+#include "dds/ddsrt/time.h"
void ddsrt_mutex_init (ddsrt_mutex_t *mutex)
{
diff --git a/src/ddsrt/src/sync/windows/sync.c b/src/ddsrt/src/sync/windows/sync.c
index b069239..4657f91 100644
--- a/src/ddsrt/src/sync/windows/sync.c
+++ b/src/ddsrt/src/sync/windows/sync.c
@@ -13,7 +13,7 @@
#include
#include "dds/ddsrt/sync.h"
-#include "dds/ddsrt/timeconv.h"
+#include "dds/ddsrt/time.h"
void ddsrt_mutex_init(ddsrt_mutex_t *mutex)
{
diff --git a/src/ddsrt/src/time.c b/src/ddsrt/src/time.c
index 8dfa587..f5043df 100644
--- a/src/ddsrt/src/time.c
+++ b/src/ddsrt/src/time.c
@@ -12,11 +12,14 @@
#include
#include
-#include "dds/ddsrt/timeconv.h"
+#include "dds/ddsrt/time.h"
#include "dds/ddsrt/string.h"
+#include "dds/ddsrt/static_assert.h"
-extern inline dds_time_t
-ddsrt_time_add_duration(dds_time_t abstime, dds_duration_t reltime);
+extern inline dds_time_t ddsrt_time_add_duration(dds_time_t abstime, dds_duration_t reltime);
+extern inline ddsrt_mtime_t ddsrt_mtime_add_duration(ddsrt_mtime_t abstime, dds_duration_t reltime);
+extern inline ddsrt_wctime_t ddsrt_wctime_add_duration(ddsrt_wctime_t abstime, dds_duration_t reltime);
+extern inline ddsrt_etime_t ddsrt_etime_add_duration(ddsrt_etime_t abstime, dds_duration_t reltime);
#if !_WIN32 && !DDSRT_WITH_FREERTOS
#include
@@ -71,3 +74,23 @@ ddsrt_ctime(dds_time_t n, char *str, size_t size)
return ddsrt_strlcpy(str, buf, size);
}
+static void time_to_sec_usec (int32_t * __restrict sec, int32_t * __restrict usec, int64_t t)
+{
+ *sec = (int32_t) (t / DDS_NSECS_IN_SEC);
+ *usec = (int32_t) (t % DDS_NSECS_IN_SEC) / 1000;
+}
+
+void ddsrt_mtime_to_sec_usec (int32_t * __restrict sec, int32_t * __restrict usec, ddsrt_mtime_t t)
+{
+ time_to_sec_usec (sec, usec, t.v);
+}
+
+void ddsrt_wctime_to_sec_usec (int32_t * __restrict sec, int32_t * __restrict usec, ddsrt_wctime_t t)
+{
+ time_to_sec_usec (sec, usec, t.v);
+}
+
+void ddsrt_etime_to_sec_usec (int32_t * __restrict sec, int32_t * __restrict usec, ddsrt_etime_t t)
+{
+ time_to_sec_usec (sec, usec, t.v);
+}
diff --git a/src/ddsrt/src/time/darwin/time.c b/src/ddsrt/src/time/darwin/time.c
index eda70f9..9e4c894 100644
--- a/src/ddsrt/src/time/darwin/time.c
+++ b/src/ddsrt/src/time/darwin/time.c
@@ -32,10 +32,15 @@ dds_time_t dds_time(void)
#endif
}
-dds_time_t ddsrt_time_monotonic(void)
+ddsrt_wctime_t ddsrt_time_wallclock(void)
+{
+ return (ddsrt_wctime_t) { dds_time () };
+}
+
+ddsrt_mtime_t ddsrt_time_monotonic(void)
{
#if defined MAC_OS_X_VERSION_10_12 && MAC_OS_X_VERSION_MIN_REQUIRED >= MAC_OS_X_VERSION_10_12
- return (int64_t) clock_gettime_nsec_np (CLOCK_UPTIME_RAW);
+ return (ddsrt_mtime_t) { (int64_t) clock_gettime_nsec_np (CLOCK_UPTIME_RAW) };
#else
static mach_timebase_info_data_t timeInfo;
uint64_t mt;
@@ -57,16 +62,17 @@ dds_time_t ddsrt_time_monotonic(void)
(void)mach_timebase_info(&timeInfo);
}
- return (dds_time_t)(mt * timeInfo.numer / timeInfo.denom);
+ return (ddsrt_mtime_t) { mt * timeInfo.numer / timeInfo.denom };
#endif
}
-dds_time_t ddsrt_time_elapsed(void)
+ddsrt_etime_t ddsrt_time_elapsed(void)
{
#if defined MAC_OS_X_VERSION_10_12 && MAC_OS_X_VERSION_MIN_REQUIRED >= MAC_OS_X_VERSION_10_12
- return (int64_t) clock_gettime_nsec_np (CLOCK_MONOTONIC_RAW);
+ return (ddsrt_etime_t) { (int64_t) clock_gettime_nsec_np (CLOCK_MONOTONIC_RAW) };
#else
/* Elapsed time clock not (yet) supported on this platform. */
- return ddsrt_time_monotonic();
+ dds_mtime_t mt = ddsrt_time_monotonic();
+ return (ddsrt_etime_t) { mt.v };
#endif
}
diff --git a/src/ddsrt/src/time/freertos/time.c b/src/ddsrt/src/time/freertos/time.c
index 39ee345..438ca0a 100644
--- a/src/ddsrt/src/time/freertos/time.c
+++ b/src/ddsrt/src/time/freertos/time.c
@@ -33,15 +33,20 @@ dds_time_t dds_time(void)
#define NSECS_PER_TICK (DDS_NSECS_IN_SEC / configTICK_RATE_HZ)
-dds_time_t ddsrt_time_monotonic (void)
+ddsrt_wctime_t ddsrt_time_wallclock (void)
{
- return (xTaskGetTickCount() * NSECS_PER_TICK);
+ return (ddsrt_wctime_t) { dds_time() };
}
-dds_time_t ddsrt_time_elapsed (void)
+ddsrt_mtime_t ddsrt_time_monotonic (void)
+{
+ return (ddsrt_mtime_t) { xTaskGetTickCount() * NSECS_PER_TICK };
+}
+
+ddsrt_etime_t ddsrt_time_elapsed (void)
{
/* Elapsed time clock not (yet) supported on this platform. */
- return ddsrt_time_monotonic ();
+ return (ddsrt_etime_t) { xTaskGetTickCount() * NSECS_PER_TICK };
}
void dds_sleepfor (dds_duration_t reltime)
diff --git a/src/ddsrt/src/time/include/dds/ddsrt/timeconv.h b/src/ddsrt/src/time/include/dds/ddsrt/timeconv.h
index 7ee22d3..8b5efbc 100644
--- a/src/ddsrt/src/time/include/dds/ddsrt/timeconv.h
+++ b/src/ddsrt/src/time/include/dds/ddsrt/timeconv.h
@@ -15,54 +15,3 @@
#include "dds/ddsrt/misc.h"
#include "dds/ddsrt/time.h"
-/**
- * @brief Calculate a time given an offset time and a duration.
- *
- * Negative time can become positive by adding a large enough duration, of
- * course a positive time can become negative given a large enough negative
- * duration.
- *
- * @param[in] abstime Timestamp in nanoseconds since UNIX Epoch.
- * @param[in] reltime Relative time in nanoseconds.
- *
- * @returns A timestamp in nanoseconds since UNIX Epoch.
- */
-inline dds_time_t
-ddsrt_time_add_duration(dds_time_t abstime, dds_duration_t reltime)
-{
- assert(abstime >= 0);
- assert(reltime >= 0);
-
- return (reltime >= DDS_NEVER - abstime ? DDS_NEVER : abstime + reltime);
-}
-
-#if _WIN32
-/**
- * @brief Convert a relative time to microseconds rounding up.
- *
- * @param[in] reltime Relative time to convert.
- *
- * @returns INFINITE if @reltime was @DDS_INIFINITY, relative time converted to
- * microseconds otherwise.
- */
-inline DWORD
-ddsrt_duration_to_msecs_ceil(dds_duration_t reltime)
-{
- if (reltime == DDS_INFINITY) {
- return INFINITE;
- } else if (reltime > 0) {
- assert(INFINITE < (DDS_INFINITY / DDS_NSECS_IN_MSEC));
- dds_duration_t max_nsecs = (INFINITE - 1) * DDS_NSECS_IN_MSEC;
-
- if (reltime < (max_nsecs - (DDS_NSECS_IN_MSEC - 1))) {
- reltime += (DDS_NSECS_IN_MSEC - 1);
- } else {
- reltime = max_nsecs;
- }
-
- return (DWORD)(reltime / DDS_NSECS_IN_MSEC);
- }
-
- return 0;
-}
-#endif
diff --git a/src/ddsrt/src/time/posix/time.c b/src/ddsrt/src/time/posix/time.c
index cfc98f5..9ac2ff5 100644
--- a/src/ddsrt/src/time/posix/time.c
+++ b/src/ddsrt/src/time/posix/time.c
@@ -21,21 +21,28 @@
dds_time_t dds_time(void)
{
struct timespec ts;
-
(void)clock_gettime(CLOCK_REALTIME, &ts);
return (ts.tv_sec * DDS_NSECS_IN_SEC) + ts.tv_nsec;
}
-dds_time_t ddsrt_time_monotonic(void)
+ddsrt_wctime_t ddsrt_time_wallclock(void)
{
struct timespec ts;
-
- (void)clock_gettime(CLOCK_MONOTONIC, &ts);
- return (ts.tv_sec * DDS_NSECS_IN_SEC) + ts.tv_nsec;
+ (void)clock_gettime(CLOCK_REALTIME, &ts);
+ return (ddsrt_wctime_t) { (ts.tv_sec * DDS_NSECS_IN_SEC) + ts.tv_nsec };
}
-dds_time_t ddsrt_time_elapsed(void)
+ddsrt_mtime_t ddsrt_time_monotonic(void)
+{
+ struct timespec ts;
+ (void)clock_gettime(CLOCK_MONOTONIC, &ts);
+ return (ddsrt_mtime_t) { (ts.tv_sec * DDS_NSECS_IN_SEC) + ts.tv_nsec };
+}
+
+ddsrt_etime_t ddsrt_time_elapsed(void)
{
/* Elapsed time clock not worth the bother for now. */
- return ddsrt_time_monotonic();
+ struct timespec ts;
+ (void)clock_gettime(CLOCK_MONOTONIC, &ts);
+ return (ddsrt_etime_t) { (ts.tv_sec * DDS_NSECS_IN_SEC) + ts.tv_nsec };
}
diff --git a/src/ddsrt/src/time/solaris2.6/time.c b/src/ddsrt/src/time/solaris2.6/time.c
index 0c5fb7c..46f98db 100644
--- a/src/ddsrt/src/time/solaris2.6/time.c
+++ b/src/ddsrt/src/time/solaris2.6/time.c
@@ -26,13 +26,17 @@ dds_time_t dds_time(void)
return (ts.tv_sec * DDS_NSECS_IN_SEC) + ts.tv_nsec;
}
-dds_time_t ddsrt_time_monotonic(void)
+ddsrt_wctime_t ddsrt_time_wallclock(void)
{
- return gethrtime ();
+ return (ddsrt_wctime_t) { dds_time() };
}
-dds_time_t ddsrt_time_elapsed(void)
+ddsrt_mtime_t ddsrt_time_monotonic(void)
{
- /* Elapsed time clock not worth the bother for now. */
- return ddsrt_time_monotonic();
+ return (ddsrt_mtime_t) { gethrtime () };
+}
+
+ddsrt_etime_t ddsrt_time_elapsed(void)
+{
+ return (ddsrt_etime_t) { gethrtime () };
}
diff --git a/src/ddsrt/src/time/windows/time.c b/src/ddsrt/src/time/windows/time.c
index e4c9c87..04262dd 100644
--- a/src/ddsrt/src/time/windows/time.c
+++ b/src/ddsrt/src/time/windows/time.c
@@ -13,7 +13,7 @@
#include
#include
-#include "dds/ddsrt/timeconv.h"
+#include "dds/ddsrt/time.h"
extern inline DWORD
ddsrt_duration_to_msecs_ceil(dds_duration_t reltime);
@@ -100,16 +100,21 @@ void ddsrt_time_fini(void)
#endif
}
-dds_time_t ddsrt_time_monotonic(void)
+ddsrt_wctime_t ddsrt_time_wallclock(void)
+{
+ return (ddsrt_wctime_t) { dds_time() } ;
+}
+
+ddsrt_mtime_t ddsrt_time_monotonic(void)
{
ULONGLONG ubit;
(void)QueryUnbiasedInterruptTime(&ubit); /* 100ns ticks */
- return (dds_time_t)(ubit * 100);
+ return (ddsrt_mtime_t) { ubit * 100 };
}
-dds_time_t ddsrt_time_elapsed(void)
+ddsrt_etime_t ddsrt_time_elapsed(void)
{
LARGE_INTEGER qpc;
static LONGLONG qpc_freq; /* Counts per nanosecond. */
@@ -152,7 +157,7 @@ dds_time_t ddsrt_time_elapsed(void)
* the time progression to actual time progression. */
QueryPerformanceCounter(&qpc);
- return (dds_time_t)(qpc.QuadPart * qpc_freq);
+ return (ddsrt_etime_t) { qpc.QuadPart * qpc_freq };
}
void dds_sleepfor(dds_duration_t reltime)
diff --git a/src/ddsrt/tests/hopscotch.c b/src/ddsrt/tests/hopscotch.c
index fdb0f0c..aab275f 100644
--- a/src/ddsrt/tests/hopscotch.c
+++ b/src/ddsrt/tests/hopscotch.c
@@ -167,7 +167,7 @@ CU_Theory ((const struct ops *ops, bool random, adj_fun_t adj, const char *adjna
void *h = ops->new ();
uint32_t i, nk = 0;
uint64_t nn = 0;
- dds_time_t t0, t1;
+ ddsrt_mtime_t t0, t1;
t0 = ddsrt_time_monotonic ();
for (uint32_t iter = 0; iter < MAX_ITERS; iter++)
{
@@ -205,5 +205,5 @@ CU_Theory ((const struct ops *ops, bool random, adj_fun_t adj, const char *adjna
}
t1 = ddsrt_time_monotonic ();
ops->free (h);
- printf (" %"PRIu64" %.0f ns/cycle\n", nn, (double) (t1 - t0) / (double) nn);
+ printf (" %"PRIu64" %.0f ns/cycle\n", nn, (double) (t1.v - t0.v) / (double) nn);
}
From 89001a0f6abbbf36445189a62609545ee67141b7 Mon Sep 17 00:00:00 2001
From: Erik Boasson
Date: Tue, 10 Mar 2020 10:25:51 +0100
Subject: [PATCH 25/30] Remove unused PrismTech/Adlink-specials
Signed-off-by: Erik Boasson
---
src/core/ddsi/include/dds/ddsi/ddsi_plist.h | 5 -----
src/core/ddsi/include/dds/ddsi/q_entity.h | 1 -
src/core/ddsi/include/dds/ddsi/q_protocol.h | 8 --------
src/core/ddsi/include/dds/ddsi/q_radmin.h | 3 ---
src/core/ddsi/include/dds/ddsi/q_rtps.h | 2 --
src/core/ddsi/src/ddsi_plist.c | 1 -
src/core/ddsi/src/q_ddsi_discovery.c | 2 +-
src/core/ddsi/src/q_entity.c | 9 +++------
src/core/ddsi/src/q_receive.c | 7 ++-----
src/core/ddsi/src/q_xmsg.c | 2 --
10 files changed, 6 insertions(+), 34 deletions(-)
diff --git a/src/core/ddsi/include/dds/ddsi/ddsi_plist.h b/src/core/ddsi/include/dds/ddsi/ddsi_plist.h
index 2db8914..06ad610 100644
--- a/src/core/ddsi/include/dds/ddsi/ddsi_plist.h
+++ b/src/core/ddsi/include/dds/ddsi/ddsi_plist.h
@@ -112,11 +112,6 @@ typedef struct nn_prismtech_participant_version_info
char *internals;
} nn_prismtech_participant_version_info_t;
-typedef struct nn_prismtech_eotgroup_tid {
- ddsi_entityid_t writer_entityid;
- uint32_t transactionId;
-} nn_prismtech_eotgroup_tid_t;
-
typedef struct ddsi_plist {
uint64_t present;
uint64_t aliased;
diff --git a/src/core/ddsi/include/dds/ddsi/q_entity.h b/src/core/ddsi/include/dds/ddsi/q_entity.h
index ab017c3..82f2fea 100644
--- a/src/core/ddsi/include/dds/ddsi/q_entity.h
+++ b/src/core/ddsi/include/dds/ddsi/q_entity.h
@@ -332,7 +332,6 @@ struct proxy_participant
uint32_t refc; /* number of proxy endpoints (both user & built-in; not groups, they don't have a life of their own) */
nn_vendorid_t vendor; /* vendor code from discovery */
unsigned bes; /* built-in endpoint set */
- unsigned prismtech_bes; /* prismtech-specific extension of built-in endpoints set */
ddsi_guid_t privileged_pp_guid; /* if this PP depends on another PP for its SEDP writing */
struct ddsi_plist *plist; /* settings/QoS for this participant */
ddsrt_atomic_voidp_t minl_auto; /* lease object for shortest automatic liveliness pwr's lease (includes this proxypp's lease) */
diff --git a/src/core/ddsi/include/dds/ddsi/q_protocol.h b/src/core/ddsi/include/dds/ddsi/q_protocol.h
index 1bae50a..9ba0fc5 100644
--- a/src/core/ddsi/include/dds/ddsi/q_protocol.h
+++ b/src/core/ddsi/include/dds/ddsi/q_protocol.h
@@ -150,7 +150,6 @@ typedef enum SubmessageKind {
SMID_DATA = 0x15,
SMID_DATA_FRAG = 0x16,
/* vendor-specific sub messages (0x80 .. 0xff) */
- SMID_PT_INFO_CONTAINER = 0x80,
SMID_PT_MSG_LEN = 0x81,
SMID_PT_ENTITY_ID = 0x82
} SubmessageKind_t;
@@ -291,12 +290,6 @@ DDSRT_WARNING_MSVC_ON(4200)
#define NACKFRAG_SIZE(numbits) (offsetof (NackFrag_t, bits) + NN_FRAGMENT_NUMBER_SET_BITS_SIZE (numbits) + 4)
#define NACKFRAG_SIZE_MAX NACKFRAG_SIZE (256u)
-typedef struct PT_InfoContainer {
- SubmessageHeader_t smhdr;
- uint32_t id;
-} PT_InfoContainer_t;
-#define PTINFO_ID_ENCRYPT (0x01u)
-
typedef union Submessage {
SubmessageHeader_t smhdr;
AckNack_t acknack;
@@ -309,7 +302,6 @@ typedef union Submessage {
HeartbeatFrag_t heartbeatfrag;
Gap_t gap;
NackFrag_t nackfrag;
- PT_InfoContainer_t pt_infocontainer;
} Submessage_t;
DDSRT_WARNING_MSVC_OFF(4200)
diff --git a/src/core/ddsi/include/dds/ddsi/q_radmin.h b/src/core/ddsi/include/dds/ddsi/q_radmin.h
index af5e3d0..5d2d713 100644
--- a/src/core/ddsi/include/dds/ddsi/q_radmin.h
+++ b/src/core/ddsi/include/dds/ddsi/q_radmin.h
@@ -123,7 +123,6 @@ struct nn_rsample_info {
ddsrt_wctime_t timestamp;
ddsrt_wctime_t reception_timestamp; /* OpenSplice extension -- but we get it essentially for free, so why not? */
unsigned statusinfo: 2; /* just the two defined bits from the status info */
- unsigned pt_wr_info_zoff: 16; /* PrismTech writer info offset */
unsigned bswap: 1; /* so we can extract well formatted writer info quicker */
unsigned complex_qos: 1; /* includes QoS other than keyhash, 2-bit statusinfo, PT writer info */
};
@@ -156,8 +155,6 @@ struct nn_rdata {
#define NN_ZOFF_TO_OFF(zoff) ((unsigned) (zoff))
#define NN_OFF_TO_ZOFF(off) ((unsigned short) (off))
#endif
-#define NN_SAMPLEINFO_HAS_WRINFO(rsi) ((rsi)->pt_wr_info_zoff != NN_OFF_TO_ZOFF (0))
-#define NN_SAMPLEINFO_WRINFO_OFF(rsi) NN_ZOFF_TO_OFF ((rsi)->pt_wr_info_zoff)
#define NN_RDATA_PAYLOAD_OFF(rdata) NN_ZOFF_TO_OFF ((rdata)->payload_zoff)
#define NN_RDATA_SUBMSG_OFF(rdata) NN_ZOFF_TO_OFF ((rdata)->submsg_zoff)
diff --git a/src/core/ddsi/include/dds/ddsi/q_rtps.h b/src/core/ddsi/include/dds/ddsi/q_rtps.h
index 384a15e..47dc332 100644
--- a/src/core/ddsi/include/dds/ddsi/q_rtps.h
+++ b/src/core/ddsi/include/dds/ddsi/q_rtps.h
@@ -54,8 +54,6 @@ typedef int64_t seqno_t;
#define NN_ENTITYID_KIND_WRITER_NO_KEY 0x03
#define NN_ENTITYID_KIND_READER_NO_KEY 0x04
#define NN_ENTITYID_KIND_READER_WITH_KEY 0x07
-#define NN_ENTITYID_KIND_PRISMTECH_SUBSCRIBER 0x0a /* source = VENDOR */
-#define NN_ENTITYID_KIND_PRISMTECH_PUBLISHER 0x0b /* source = VENDOR */
#define NN_ENTITYID_ALLOCSTEP 0x100
struct cfgst;
diff --git a/src/core/ddsi/src/ddsi_plist.c b/src/core/ddsi/src/ddsi_plist.c
index ffa7f44..b12321a 100644
--- a/src/core/ddsi/src/ddsi_plist.c
+++ b/src/core/ddsi/src/ddsi_plist.c
@@ -2686,7 +2686,6 @@ unsigned char *ddsi_plist_quickscan (struct nn_rsample_info *dest, const struct
const unsigned char *pl;
(void)rmsg;
dest->statusinfo = 0;
- dest->pt_wr_info_zoff = NN_OFF_TO_ZOFF (0);
dest->complex_qos = 0;
switch (src->encoding)
{
diff --git a/src/core/ddsi/src/q_ddsi_discovery.c b/src/core/ddsi/src/q_ddsi_discovery.c
index 8c6f331..cbcbcd2 100644
--- a/src/core/ddsi/src/q_ddsi_discovery.c
+++ b/src/core/ddsi/src/q_ddsi_discovery.c
@@ -320,7 +320,7 @@ int spdp_write (struct participant *pp)
ETRACE (pp, "spdp_write("PGUIDFMT") - internals: %s\n", PGUID (pp->e.guid), ps.prismtech_participant_version_info.internals);
}
- /* Participant QoS's insofar as they are set, different from the default, and mapped to the SPDP data, rather than to the PrismTech-specific CMParticipant endpoint. Currently, that means just USER_DATA. */
+ /* Participant QoS's insofar as they are set, different from the default. Currently, that means just USER_DATA. */
qosdiff = ddsi_xqos_delta (&pp->plist->qos, &pp->e.gv->default_plist_pp.qos, QP_USER_DATA);
if (pp->e.gv->config.explicitly_publish_qos_set_to_default)
qosdiff |= ~QP_UNRECOGNIZED_INCOMPATIBLE_MASK;
diff --git a/src/core/ddsi/src/q_entity.c b/src/core/ddsi/src/q_entity.c
index 3cb3ee7..a4652b6 100644
--- a/src/core/ddsi/src/q_entity.c
+++ b/src/core/ddsi/src/q_entity.c
@@ -4063,12 +4063,10 @@ void new_proxy_participant (struct ddsi_domaingv *gv, const struct ddsi_guid *pp
/* Add proxy endpoints based on the advertised (& possibly augmented
...) built-in endpoint set. */
{
-#define PT_TE(ap_, a_, bp_, b_) { 0, NN_##ap_##BUILTIN_ENDPOINT_##a_, NN_ENTITYID_##bp_##_BUILTIN_##b_ }
-#define TE(ap_, a_, bp_, b_) { NN_##ap_##BUILTIN_ENDPOINT_##a_, 0, NN_ENTITYID_##bp_##_BUILTIN_##b_ }
-#define LTE(a_, bp_, b_) { NN_##BUILTIN_ENDPOINT_##a_, 0, NN_ENTITYID_##bp_##_BUILTIN_##b_ }
+#define TE(ap_, a_, bp_, b_) { NN_##ap_##BUILTIN_ENDPOINT_##a_, NN_ENTITYID_##bp_##_BUILTIN_##b_ }
+#define LTE(a_, bp_, b_) { NN_##BUILTIN_ENDPOINT_##a_, NN_ENTITYID_##bp_##_BUILTIN_##b_ }
static const struct bestab {
unsigned besflag;
- unsigned prismtech_besflag;
unsigned entityid;
} bestab[] = {
#if 0
@@ -4086,7 +4084,6 @@ void new_proxy_participant (struct ddsi_domaingv *gv, const struct ddsi_guid *pp
TE (DISC_, TOPIC_ANNOUNCER, SEDP, TOPIC_WRITER),
TE (DISC_, TOPIC_DETECTOR, SEDP, TOPIC_READER)
};
-#undef PT_TE
#undef TE
#undef LTE
ddsi_plist_t plist_rd, plist_wr;
@@ -4101,7 +4098,7 @@ void new_proxy_participant (struct ddsi_domaingv *gv, const struct ddsi_guid *pp
for (i = 0; i < (int) (sizeof (bestab) / sizeof (*bestab)); i++)
{
const struct bestab *te = &bestab[i];
- if ((proxypp->bes & te->besflag) || (proxypp->prismtech_bes & te->prismtech_besflag))
+ if (proxypp->bes & te->besflag)
{
ddsi_guid_t guid1;
guid1.prefix = proxypp->e.guid.prefix;
diff --git a/src/core/ddsi/src/q_receive.c b/src/core/ddsi/src/q_receive.c
index 17e9654..098a565 100644
--- a/src/core/ddsi/src/q_receive.c
+++ b/src/core/ddsi/src/q_receive.c
@@ -283,7 +283,7 @@ static void set_sampleinfo_proxy_writer (struct nn_rsample_info *sampleinfo, dds
static int valid_Data (const struct receiver_state *rst, struct nn_rmsg *rmsg, Data_t *msg, size_t size, int byteswap, struct nn_rsample_info *sampleinfo, unsigned char **payloadp)
{
- /* on success: sampleinfo->{seq,rst,statusinfo,pt_wr_info_zoff,bswap,complex_qos} all set */
+ /* on success: sampleinfo->{seq,rst,statusinfo,bswap,complex_qos} all set */
ddsi_guid_t pwr_guid;
unsigned char *ptr;
@@ -320,7 +320,6 @@ static int valid_Data (const struct receiver_state *rst, struct nn_rmsg *rmsg, D
*payloadp = NULL;
sampleinfo->size = 0; /* size is full payload size, no payload & unfragmented => size = 0 */
sampleinfo->statusinfo = 0;
- sampleinfo->pt_wr_info_zoff = NN_OFF_TO_ZOFF (0);
sampleinfo->complex_qos = 0;
return 1;
}
@@ -349,7 +348,6 @@ static int valid_Data (const struct receiver_state *rst, struct nn_rmsg *rmsg, D
else
{
sampleinfo->statusinfo = 0;
- sampleinfo->pt_wr_info_zoff = NN_OFF_TO_ZOFF (0);
sampleinfo->complex_qos = 0;
}
@@ -393,7 +391,7 @@ static int valid_Data (const struct receiver_state *rst, struct nn_rmsg *rmsg, D
static int valid_DataFrag (const struct receiver_state *rst, struct nn_rmsg *rmsg, DataFrag_t *msg, size_t size, int byteswap, struct nn_rsample_info *sampleinfo, unsigned char **payloadp)
{
- /* on success: sampleinfo->{rst,statusinfo,pt_wr_info_zoff,bswap,complex_qos} all set */
+ /* on success: sampleinfo->{rst,statusinfo,bswap,complex_qos} all set */
uint32_t payloadsz;
ddsi_guid_t pwr_guid;
unsigned char *ptr;
@@ -471,7 +469,6 @@ static int valid_DataFrag (const struct receiver_state *rst, struct nn_rmsg *rms
else
{
sampleinfo->statusinfo = 0;
- sampleinfo->pt_wr_info_zoff = NN_OFF_TO_ZOFF (0);
sampleinfo->complex_qos = 0;
}
diff --git a/src/core/ddsi/src/q_xmsg.c b/src/core/ddsi/src/q_xmsg.c
index c897550..08ce49e 100644
--- a/src/core/ddsi/src/q_xmsg.c
+++ b/src/core/ddsi/src/q_xmsg.c
@@ -377,7 +377,6 @@ static int submsg_is_compatible (const struct nn_xmsg *msg, SubmessageKind_t smk
case SMID_ACKNACK: case SMID_HEARTBEAT:
case SMID_GAP: case SMID_NACK_FRAG:
case SMID_HEARTBEAT_FRAG:
- case SMID_PT_INFO_CONTAINER:
case SMID_PT_MSG_LEN:
case SMID_PT_ENTITY_ID:
/* normal control stuff is ok */
@@ -411,7 +410,6 @@ static int submsg_is_compatible (const struct nn_xmsg *msg, SubmessageKind_t smk
case SMID_GAP:
case SMID_NACK_FRAG:
case SMID_HEARTBEAT_FRAG:
- case SMID_PT_INFO_CONTAINER:
case SMID_PT_MSG_LEN:
case SMID_PT_ENTITY_ID:
/* anything else is strictly verboten */
From 59459b9b8bcd4e03ad4b4455696a1192b72d5d91 Mon Sep 17 00:00:00 2001
From: Erik Boasson
Date: Tue, 10 Mar 2020 10:43:57 +0100
Subject: [PATCH 26/30] Change PrismTech references to Adlink
Signed-off-by: Erik Boasson
---
src/core/ddsc/src/dds__qos.h | 10 ++--
src/core/ddsc/src/dds_qos.c | 8 +--
src/core/ddsc/src/dds_topic.c | 4 +-
src/core/ddsi/include/dds/ddsi/ddsi_plist.h | 26 ++++-----
src/core/ddsi/include/dds/ddsi/ddsi_vendor.h | 30 +++++-----
src/core/ddsi/include/dds/ddsi/ddsi_xqos.h | 12 ++--
src/core/ddsi/include/dds/ddsi/q_entity.h | 2 +-
src/core/ddsi/include/dds/ddsi/q_protocol.h | 55 +++++++++----------
src/core/ddsi/include/dds/ddsi/q_xmsg.h | 2 +-
src/core/ddsi/src/ddsi_plist.c | 58 ++++++++++----------
src/core/ddsi/src/ddsi_vendor.c | 4 +-
src/core/ddsi/src/q_ddsi_discovery.c | 54 +++++++++---------
src/core/ddsi/src/q_entity.c | 12 ++--
src/core/ddsi/src/q_receive.c | 8 +--
src/core/ddsi/src/q_xmsg.c | 12 ++--
src/mpt/tests/qos/procs/rw.c | 4 +-
src/tools/decode-trace | 2 +-
17 files changed, 151 insertions(+), 152 deletions(-)
diff --git a/src/core/ddsc/src/dds__qos.h b/src/core/ddsc/src/dds__qos.h
index 99a26a6..ef9553d 100644
--- a/src/core/ddsc/src/dds__qos.h
+++ b/src/core/ddsc/src/dds__qos.h
@@ -25,29 +25,29 @@ extern "C" {
QP_DESTINATION_ORDER | QP_HISTORY | QP_RESOURCE_LIMITS)
#define DDS_PARTICIPANT_QOS_MASK \
- (QP_USER_DATA | QP_PRISMTECH_ENTITY_FACTORY | QP_CYCLONE_IGNORELOCAL)
+ (QP_USER_DATA | QP_ADLINK_ENTITY_FACTORY | QP_CYCLONE_IGNORELOCAL)
#define DDS_PUBLISHER_QOS_MASK \
(QP_PARTITION | QP_PRESENTATION | QP_GROUP_DATA | \
- QP_PRISMTECH_ENTITY_FACTORY | QP_CYCLONE_IGNORELOCAL)
+ QP_ADLINK_ENTITY_FACTORY | QP_CYCLONE_IGNORELOCAL)
#define DDS_READER_QOS_MASK \
(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_RESOURCE_LIMITS | QP_ADLINK_READER_DATA_LIFECYCLE | \
QP_CYCLONE_IGNORELOCAL)
#define DDS_SUBSCRIBER_QOS_MASK \
(QP_PARTITION | QP_PRESENTATION | QP_GROUP_DATA | \
- QP_PRISMTECH_ENTITY_FACTORY | QP_CYCLONE_IGNORELOCAL)
+ QP_ADLINK_ENTITY_FACTORY | QP_CYCLONE_IGNORELOCAL)
#define DDS_WRITER_QOS_MASK \
(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_RESOURCE_LIMITS | QP_ADLINK_WRITER_DATA_LIFECYCLE | \
QP_CYCLONE_IGNORELOCAL)
#if defined (__cplusplus)
diff --git a/src/core/ddsc/src/dds_qos.c b/src/core/ddsc/src/dds_qos.c
index f3fb576..b53fa7e 100644
--- a/src/core/ddsc/src/dds_qos.c
+++ b/src/core/ddsc/src/dds_qos.c
@@ -302,7 +302,7 @@ void dds_qset_writer_data_lifecycle (dds_qos_t * __restrict qos, bool autodispos
if (qos == NULL)
return;
qos->writer_data_lifecycle.autodispose_unregistered_instances = autodispose;
- qos->present |= QP_PRISMTECH_WRITER_DATA_LIFECYCLE;
+ qos->present |= QP_ADLINK_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)
@@ -311,7 +311,7 @@ void dds_qset_reader_data_lifecycle (dds_qos_t * __restrict qos, dds_duration_t
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;
+ qos->present |= QP_ADLINK_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)
@@ -520,7 +520,7 @@ bool dds_qget_destination_order (const dds_qos_t * __restrict qos, dds_destinati
bool dds_qget_writer_data_lifecycle (const dds_qos_t * __restrict qos, bool *autodispose)
{
- if (qos == NULL || !(qos->present & QP_PRISMTECH_WRITER_DATA_LIFECYCLE))
+ if (qos == NULL || !(qos->present & QP_ADLINK_WRITER_DATA_LIFECYCLE))
return false;
if (autodispose)
*autodispose = qos->writer_data_lifecycle.autodispose_unregistered_instances;
@@ -529,7 +529,7 @@ bool dds_qget_writer_data_lifecycle (const dds_qos_t * __restrict qos, bool *aut
bool dds_qget_reader_data_lifecycle (const dds_qos_t * __restrict qos, dds_duration_t *autopurge_nowriter_samples_delay, dds_duration_t *autopurge_disposed_samples_delay)
{
- if (qos == NULL || !(qos->present & QP_PRISMTECH_READER_DATA_LIFECYCLE))
+ if (qos == NULL || !(qos->present & QP_ADLINK_READER_DATA_LIFECYCLE))
return false;
if (autopurge_nowriter_samples_delay)
*autopurge_nowriter_samples_delay = qos->reader_data_lifecycle.autopurge_nowriter_samples_delay;
diff --git a/src/core/ddsc/src/dds_topic.c b/src/core/ddsc/src/dds_topic.c
index 913a8a4..ff177b8 100644
--- a/src/core/ddsc/src/dds_topic.c
+++ b/src/core/ddsc/src/dds_topic.c
@@ -434,11 +434,11 @@ dds_entity_t dds_create_topic (dds_entity_t participant, const dds_topic_descrip
if (desc->m_meta)
{
plist.type_description = dds_string_dup (desc->m_meta);
- plist.present |= PP_PRISMTECH_TYPE_DESCRIPTION;
+ plist.present |= PP_ADLINK_TYPE_DESCRIPTION;
}
if (desc->m_nkeys)
{
- plist.qos.present |= QP_PRISMTECH_SUBSCRIPTION_KEYS;
+ plist.qos.present |= QP_ADLINK_SUBSCRIPTION_KEYS;
plist.qos.subscription_keys.use_key_list = 1;
plist.qos.subscription_keys.key_list.n = desc->m_nkeys;
plist.qos.subscription_keys.key_list.strs = dds_alloc (desc->m_nkeys * sizeof (char*));
diff --git a/src/core/ddsi/include/dds/ddsi/ddsi_plist.h b/src/core/ddsi/include/dds/ddsi/ddsi_plist.h
index 06ad610..f027865 100644
--- a/src/core/ddsi/include/dds/ddsi/ddsi_plist.h
+++ b/src/core/ddsi/include/dds/ddsi/ddsi_plist.h
@@ -45,8 +45,8 @@ extern "C" {
#define PP_STATUSINFO ((uint64_t)1 << 22)
#define PP_ORIGINAL_WRITER_INFO ((uint64_t)1 << 23)
#define PP_ENDPOINT_GUID ((uint64_t)1 << 24)
-#define PP_PRISMTECH_PARTICIPANT_VERSION_INFO ((uint64_t)1 << 26)
-#define PP_PRISMTECH_TYPE_DESCRIPTION ((uint64_t)1 << 27)
+#define PP_ADLINK_PARTICIPANT_VERSION_INFO ((uint64_t)1 << 26)
+#define PP_ADLINK_TYPE_DESCRIPTION ((uint64_t)1 << 27)
#define PP_COHERENT_SET ((uint64_t)1 << 28)
#ifdef DDSI_INCLUDE_SSM
#define PP_READER_FAVOURS_SSM ((uint64_t)1 << 29)
@@ -61,15 +61,15 @@ extern "C" {
PID_UNRECOGNIZED_INCOMPATIBLE_FLAG set (see DDSI 2.1 9.6.2.2.1) */
#define PP_INCOMPATIBLE ((uint64_t)1 << 63)
-#define NN_PRISMTECH_PARTICIPANT_VERSION_INFO_FIXED_CDRSIZE (24)
+#define NN_ADLINK_PARTICIPANT_VERSION_INFO_FIXED_CDRSIZE (24)
-#define NN_PRISMTECH_FL_KERNEL_SEQUENCE_NUMBER (1u << 0)
-#define NN_PRISMTECH_FL_DISCOVERY_INCLUDES_GID (1u << 1)
-#define NN_PRISMTECH_FL_PTBES_FIXED_0 (1u << 2)
-#define NN_PRISMTECH_FL_DDSI2_PARTICIPANT_FLAG (1u << 3)
-#define NN_PRISMTECH_FL_PARTICIPANT_IS_DDSI2 (1u << 4)
-#define NN_PRISMTECH_FL_MINIMAL_BES_MODE (1u << 5)
-#define NN_PRISMTECH_FL_SUPPORTS_STATUSINFOX (1u << 5)
+#define NN_ADLINK_FL_KERNEL_SEQUENCE_NUMBER (1u << 0)
+#define NN_ADLINK_FL_DISCOVERY_INCLUDES_GID (1u << 1)
+#define NN_ADLINK_FL_PTBES_FIXED_0 (1u << 2)
+#define NN_ADLINK_FL_DDSI2_PARTICIPANT_FLAG (1u << 3)
+#define NN_ADLINK_FL_PARTICIPANT_IS_DDSI2 (1u << 4)
+#define NN_ADLINK_FL_MINIMAL_BES_MODE (1u << 5)
+#define NN_ADLINK_FL_SUPPORTS_STATUSINFOX (1u << 5)
/* SUPPORTS_STATUSINFOX: when set, also means any combination of
write/unregister/dispose supported */
@@ -104,13 +104,13 @@ typedef struct nn_reader_favours_ssm {
} nn_reader_favours_ssm_t;
#endif
-typedef struct nn_prismtech_participant_version_info
+typedef struct nn_adlink_participant_version_info
{
uint32_t version;
uint32_t flags;
uint32_t unused[3];
char *internals;
-} nn_prismtech_participant_version_info_t;
+} nn_adlink_participant_version_info_t;
typedef struct ddsi_plist {
uint64_t present;
@@ -144,7 +144,7 @@ typedef struct ddsi_plist {
char *entity_name;
nn_keyhash_t keyhash;
uint32_t statusinfo;
- nn_prismtech_participant_version_info_t prismtech_participant_version_info;
+ nn_adlink_participant_version_info_t adlink_participant_version_info;
char *type_description;
nn_sequence_number_t coherent_set_seqno;
#ifdef DDSI_INCLUDE_SSM
diff --git a/src/core/ddsi/include/dds/ddsi/ddsi_vendor.h b/src/core/ddsi/include/dds/ddsi/ddsi_vendor.h
index 7a5af9a..604f6b6 100644
--- a/src/core/ddsi/include/dds/ddsi/ddsi_vendor.h
+++ b/src/core/ddsi/include/dds/ddsi/ddsi_vendor.h
@@ -22,7 +22,7 @@ typedef struct {
/* All existing vendor codes have the major part equal to 1 (and this will probably be true for a long, long time) */
#define NN_VENDORID_MINOR_RTI 0x01
-#define NN_VENDORID_MINOR_PRISMTECH_OSPL 0x02
+#define NN_VENDORID_MINOR_ADLINK_OSPL 0x02
#define NN_VENDORID_MINOR_OCI 0x03
#define NN_VENDORID_MINOR_MILSOFT 0x04
#define NN_VENDORID_MINOR_KONGSBERG 0x05
@@ -31,13 +31,13 @@ typedef struct {
#define NN_VENDORID_MINOR_ICOUP 0x08
#define NN_VENDORID_MINOR_ETRI 0x09
#define NN_VENDORID_MINOR_RTI_MICRO 0x0a
-#define NN_VENDORID_MINOR_PRISMTECH_JAVA 0x0b
-#define NN_VENDORID_MINOR_PRISMTECH_GATEWAY 0x0c
-#define NN_VENDORID_MINOR_PRISMTECH_LITE 0x0d
+#define NN_VENDORID_MINOR_ADLINK_JAVA 0x0b
+#define NN_VENDORID_MINOR_ADLINK_GATEWAY 0x0c
+#define NN_VENDORID_MINOR_ADLINK_LITE 0x0d
#define NN_VENDORID_MINOR_TECHNICOLOR 0x0e
#define NN_VENDORID_MINOR_EPROSIMA 0x0f
#define NN_VENDORID_MINOR_ECLIPSE 0x10
-#define NN_VENDORID_MINOR_PRISMTECH_CLOUD 0x20
+#define NN_VENDORID_MINOR_ADLINK_CLOUD 0x20
#if defined(_WIN32) && defined(__cplusplus)
#define NN_VENDORID(vendor) {{ 0x01, NN_VENDORID_MINOR_##vendor }}
@@ -63,7 +63,7 @@ inline bool vendor_is_rti (nn_vendorid_t vendor) {
return vendor_equals (vendor, NN_VENDORID (RTI));
}
inline bool vendor_is_opensplice (nn_vendorid_t vendor) {
- return vendor_equals (vendor, NN_VENDORID (PRISMTECH_OSPL));
+ return vendor_equals (vendor, NN_VENDORID (ADLINK_OSPL));
}
inline bool vendor_is_twinoaks (nn_vendorid_t vendor) {
return vendor_equals (vendor, NN_VENDORID (TWINOAKS));
@@ -72,20 +72,20 @@ inline bool vendor_is_eprosima (nn_vendorid_t vendor) {
return vendor_equals (vendor, NN_VENDORID (EPROSIMA));
}
inline bool vendor_is_cloud (nn_vendorid_t vendor) {
- return vendor_equals (vendor, NN_VENDORID (PRISMTECH_CLOUD));
+ return vendor_equals (vendor, NN_VENDORID (ADLINK_CLOUD));
}
inline bool vendor_is_eclipse_or_opensplice (nn_vendorid_t vendor) {
return vendor_is_eclipse (vendor) | vendor_is_opensplice (vendor);
}
-inline bool vendor_is_prismtech (nn_vendorid_t vendor) {
- return (vendor_equals (vendor, NN_VENDORID (PRISMTECH_OSPL)) ||
- vendor_equals (vendor, NN_VENDORID (PRISMTECH_LITE)) ||
- vendor_equals (vendor, NN_VENDORID (PRISMTECH_GATEWAY)) ||
- vendor_equals (vendor, NN_VENDORID (PRISMTECH_JAVA)) ||
- vendor_equals (vendor, NN_VENDORID (PRISMTECH_CLOUD)));
+inline bool vendor_is_adlink (nn_vendorid_t vendor) {
+ return (vendor_equals (vendor, NN_VENDORID (ADLINK_OSPL)) ||
+ vendor_equals (vendor, NN_VENDORID (ADLINK_LITE)) ||
+ vendor_equals (vendor, NN_VENDORID (ADLINK_GATEWAY)) ||
+ vendor_equals (vendor, NN_VENDORID (ADLINK_JAVA)) ||
+ vendor_equals (vendor, NN_VENDORID (ADLINK_CLOUD)));
}
-inline bool vendor_is_eclipse_or_prismtech (nn_vendorid_t vendor) {
- return vendor_is_eclipse (vendor) || vendor_is_prismtech (vendor);
+inline bool vendor_is_eclipse_or_adlink (nn_vendorid_t vendor) {
+ return vendor_is_eclipse (vendor) || vendor_is_adlink (vendor);
}
#if defined (__cplusplus)
diff --git a/src/core/ddsi/include/dds/ddsi/ddsi_xqos.h b/src/core/ddsi/include/dds/ddsi/ddsi_xqos.h
index 039f5c7..9161a70 100644
--- a/src/core/ddsi/include/dds/ddsi/ddsi_xqos.h
+++ b/src/core/ddsi/include/dds/ddsi/ddsi_xqos.h
@@ -241,11 +241,11 @@ typedef struct dds_ignorelocal_qospolicy {
#define QP_OWNERSHIP ((uint64_t)1 << 18)
#define QP_OWNERSHIP_STRENGTH ((uint64_t)1 << 19)
#define QP_TIME_BASED_FILTER ((uint64_t)1 << 20)
-#define QP_PRISMTECH_WRITER_DATA_LIFECYCLE ((uint64_t)1 << 21)
-#define QP_PRISMTECH_READER_DATA_LIFECYCLE ((uint64_t)1 << 22)
-#define QP_PRISMTECH_READER_LIFESPAN ((uint64_t)1 << 24)
-#define QP_PRISMTECH_SUBSCRIPTION_KEYS ((uint64_t)1 << 25)
-#define QP_PRISMTECH_ENTITY_FACTORY ((uint64_t)1 << 27)
+#define QP_ADLINK_WRITER_DATA_LIFECYCLE ((uint64_t)1 << 21)
+#define QP_ADLINK_READER_DATA_LIFECYCLE ((uint64_t)1 << 22)
+#define QP_ADLINK_READER_LIFESPAN ((uint64_t)1 << 24)
+#define QP_ADLINK_SUBSCRIPTION_KEYS ((uint64_t)1 << 25)
+#define QP_ADLINK_ENTITY_FACTORY ((uint64_t)1 << 27)
#define QP_CYCLONE_IGNORELOCAL ((uint64_t)1 << 30)
#define QP_PROPERTY_LIST ((uint64_t)1 << 31)
@@ -254,7 +254,7 @@ typedef struct dds_ignorelocal_qospolicy {
matches. Same for topic and type. Relaxed qos matching is a bit of
a weird one, but it affects matching, so ... */
#define QP_RXO_MASK (QP_DURABILITY | QP_PRESENTATION | QP_DEADLINE | QP_LATENCY_BUDGET | QP_OWNERSHIP | QP_LIVELINESS | QP_RELIABILITY | QP_DESTINATION_ORDER)
-#define QP_CHANGEABLE_MASK (QP_USER_DATA | QP_TOPIC_DATA | QP_GROUP_DATA | QP_DEADLINE | QP_LATENCY_BUDGET | QP_OWNERSHIP_STRENGTH | QP_TIME_BASED_FILTER | QP_PARTITION | QP_TRANSPORT_PRIORITY | QP_LIFESPAN | QP_PRISMTECH_ENTITY_FACTORY | QP_PRISMTECH_WRITER_DATA_LIFECYCLE | QP_PRISMTECH_READER_DATA_LIFECYCLE)
+#define QP_CHANGEABLE_MASK (QP_USER_DATA | QP_TOPIC_DATA | QP_GROUP_DATA | QP_DEADLINE | QP_LATENCY_BUDGET | QP_OWNERSHIP_STRENGTH | QP_TIME_BASED_FILTER | QP_PARTITION | QP_TRANSPORT_PRIORITY | QP_LIFESPAN | QP_ADLINK_ENTITY_FACTORY | QP_ADLINK_WRITER_DATA_LIFECYCLE | QP_ADLINK_READER_DATA_LIFECYCLE)
#define QP_UNRECOGNIZED_INCOMPATIBLE_MASK ((uint64_t) 0)
/* readers & writers have an extended qos, hence why it is a separate
diff --git a/src/core/ddsi/include/dds/ddsi/q_entity.h b/src/core/ddsi/include/dds/ddsi/q_entity.h
index 82f2fea..956c908 100644
--- a/src/core/ddsi/include/dds/ddsi/q_entity.h
+++ b/src/core/ddsi/include/dds/ddsi/q_entity.h
@@ -638,7 +638,7 @@ int writer_set_notalive (struct writer *wr, bool notify);
XX --
*/
-/* Set this custom flag when using nn_prismtech_writer_info_t iso nn_prismtech_writer_info_old_t */
+/* Set this custom flag when using nn_adlink_writer_info_t iso nn_adlink_writer_info_old_t */
#define CF_INC_KERNEL_SEQUENCE_NUMBERS (1 << 0)
/* Set when this proxy participant is created implicitly and has to be deleted upon disappearance
of its last endpoint. FIXME: Currently there is a potential race with adding a new endpoint
diff --git a/src/core/ddsi/include/dds/ddsi/q_protocol.h b/src/core/ddsi/include/dds/ddsi/q_protocol.h
index 9ba0fc5..4556ee1 100644
--- a/src/core/ddsi/include/dds/ddsi/q_protocol.h
+++ b/src/core/ddsi/include/dds/ddsi/q_protocol.h
@@ -89,7 +89,7 @@ typedef struct {
#define NN_DISC_BUILTIN_ENDPOINT_TOPIC_ANNOUNCER (1u << 12)
#define NN_DISC_BUILTIN_ENDPOINT_TOPIC_DETECTOR (1u << 13)
-/* PrismTech extensions: */
+/* Adlink extensions: */
#define NN_DISC_BUILTIN_ENDPOINT_CM_PARTICIPANT_WRITER (1u << 0)
#define NN_DISC_BUILTIN_ENDPOINT_CM_PARTICIPANT_READER (1u << 1)
#define NN_DISC_BUILTIN_ENDPOINT_CM_PUBLISHER_WRITER (1u << 2)
@@ -150,8 +150,8 @@ typedef enum SubmessageKind {
SMID_DATA = 0x15,
SMID_DATA_FRAG = 0x16,
/* vendor-specific sub messages (0x80 .. 0xff) */
- SMID_PT_MSG_LEN = 0x81,
- SMID_PT_ENTITY_ID = 0x82
+ SMID_ADLINK_MSG_LEN = 0x81,
+ SMID_ADLINK_ENTITY_ID = 0x82
} SubmessageKind_t;
typedef struct InfoTimestamp {
@@ -379,7 +379,7 @@ DDSRT_WARNING_MSVC_ON(4200)
#define PID_COHERENT_SET 0x56u
#define PID_DIRECTED_WRITE 0x57u
#define PID_ORIGINAL_WRITER_INFO 0x61u
-#define PID_ENDPOINT_GUID 0x5au /* !SPEC <=> PRISMTECH_ENDPOINT_GUID */
+#define PID_ENDPOINT_GUID 0x5au /* !SPEC <=> ADLINK_ENDPOINT_GUID */
/* Security related PID values. */
#define PID_IDENTITY_TOKEN 0x1001u
@@ -404,43 +404,42 @@ DDSRT_WARNING_MSVC_ON(4200)
#define PID_RECV_QUEUE_SIZE 0x18u
#define PID_RELIABILITY_OFFERED 0x19u
-#define PID_PRISMTECH_BUILTIN_ENDPOINT_SET (PID_VENDORSPECIFIC_FLAG | 0x0u)
+#define PID_ADLINK_BUILTIN_ENDPOINT_SET (PID_VENDORSPECIFIC_FLAG | 0x0u)
/* parameter ids for READER_DATA_LIFECYCLE & WRITER_DATA_LIFECYCLE are
undefined, but let's publish them anyway */
-#define PID_PRISMTECH_READER_DATA_LIFECYCLE (PID_VENDORSPECIFIC_FLAG | 0x2u)
-#define PID_PRISMTECH_WRITER_DATA_LIFECYCLE (PID_VENDORSPECIFIC_FLAG | 0x3u)
+#define PID_ADLINK_READER_DATA_LIFECYCLE (PID_VENDORSPECIFIC_FLAG | 0x2u)
+#define PID_ADLINK_WRITER_DATA_LIFECYCLE (PID_VENDORSPECIFIC_FLAG | 0x3u)
/* ENDPOINT_GUID is formally undefined, so in strictly conforming
mode, we use our own */
-#define PID_PRISMTECH_ENDPOINT_GUID (PID_VENDORSPECIFIC_FLAG | 0x4u)
+#define PID_ADLINK_ENDPOINT_GUID (PID_VENDORSPECIFIC_FLAG | 0x4u)
-#define PID_PRISMTECH_SYNCHRONOUS_ENDPOINT (PID_VENDORSPECIFIC_FLAG | 0x5u)
+#define PID_ADLINK_SYNCHRONOUS_ENDPOINT (PID_VENDORSPECIFIC_FLAG | 0x5u)
/* Relaxed QoS matching readers/writers are best ignored by
implementations that don't understand them. This also covers "old"
DDSI2's, although they may emit an error. */
-#define PID_PRISMTECH_RELAXED_QOS_MATCHING (PID_VENDORSPECIFIC_FLAG | PID_UNRECOGNIZED_INCOMPATIBLE_FLAG | 0x6u)
+#define PID_ADLINK_RELAXED_QOS_MATCHING (PID_VENDORSPECIFIC_FLAG | PID_UNRECOGNIZED_INCOMPATIBLE_FLAG | 0x6u)
-#define PID_PRISMTECH_PARTICIPANT_VERSION_INFO (PID_VENDORSPECIFIC_FLAG | 0x7u)
+#define PID_ADLINK_PARTICIPANT_VERSION_INFO (PID_VENDORSPECIFIC_FLAG | 0x7u)
-/* See CMTopics protocol.doc (2013-12-09) */
-#define PID_PRISMTECH_NODE_NAME (PID_VENDORSPECIFIC_FLAG | 0x8u)
-#define PID_PRISMTECH_EXEC_NAME (PID_VENDORSPECIFIC_FLAG | 0x9u)
-#define PID_PRISMTECH_PROCESS_ID (PID_VENDORSPECIFIC_FLAG | 0xau)
-#define PID_PRISMTECH_SERVICE_TYPE (PID_VENDORSPECIFIC_FLAG | 0xbu)
-#define PID_PRISMTECH_ENTITY_FACTORY (PID_VENDORSPECIFIC_FLAG | 0xcu)
-#define PID_PRISMTECH_WATCHDOG_SCHEDULING (PID_VENDORSPECIFIC_FLAG | 0xdu)
-#define PID_PRISMTECH_LISTENER_SCHEDULING (PID_VENDORSPECIFIC_FLAG | 0xeu)
-#define PID_PRISMTECH_SUBSCRIPTION_KEYS (PID_VENDORSPECIFIC_FLAG | 0xfu)
-#define PID_PRISMTECH_READER_LIFESPAN (PID_VENDORSPECIFIC_FLAG | 0x10u)
-#define PID_PRISMTECH_TYPE_DESCRIPTION (PID_VENDORSPECIFIC_FLAG | 0x12u)
-#define PID_PRISMTECH_LAN (PID_VENDORSPECIFIC_FLAG | 0x13u)
-#define PID_PRISMTECH_ENDPOINT_GID (PID_VENDORSPECIFIC_FLAG | 0x14u)
-#define PID_PRISMTECH_GROUP_GID (PID_VENDORSPECIFIC_FLAG | 0x15u)
-#define PID_PRISMTECH_EOTINFO (PID_VENDORSPECIFIC_FLAG | 0x16u)
-#define PID_PRISMTECH_PART_CERT_NAME (PID_VENDORSPECIFIC_FLAG | 0x17u);
-#define PID_PRISMTECH_LAN_CERT_NAME (PID_VENDORSPECIFIC_FLAG | 0x18u);
+#define PID_ADLINK_NODE_NAME (PID_VENDORSPECIFIC_FLAG | 0x8u)
+#define PID_ADLINK_EXEC_NAME (PID_VENDORSPECIFIC_FLAG | 0x9u)
+#define PID_ADLINK_PROCESS_ID (PID_VENDORSPECIFIC_FLAG | 0xau)
+#define PID_ADLINK_SERVICE_TYPE (PID_VENDORSPECIFIC_FLAG | 0xbu)
+#define PID_ADLINK_ENTITY_FACTORY (PID_VENDORSPECIFIC_FLAG | 0xcu)
+#define PID_ADLINK_WATCHDOG_SCHEDULING (PID_VENDORSPECIFIC_FLAG | 0xdu)
+#define PID_ADLINK_LISTENER_SCHEDULING (PID_VENDORSPECIFIC_FLAG | 0xeu)
+#define PID_ADLINK_SUBSCRIPTION_KEYS (PID_VENDORSPECIFIC_FLAG | 0xfu)
+#define PID_ADLINK_READER_LIFESPAN (PID_VENDORSPECIFIC_FLAG | 0x10u)
+#define PID_ADLINK_TYPE_DESCRIPTION (PID_VENDORSPECIFIC_FLAG | 0x12u)
+#define PID_ADLINK_LAN (PID_VENDORSPECIFIC_FLAG | 0x13u)
+#define PID_ADLINK_ENDPOINT_GID (PID_VENDORSPECIFIC_FLAG | 0x14u)
+#define PID_ADLINK_GROUP_GID (PID_VENDORSPECIFIC_FLAG | 0x15u)
+#define PID_ADLINK_EOTINFO (PID_VENDORSPECIFIC_FLAG | 0x16u)
+#define PID_ADLINK_PART_CERT_NAME (PID_VENDORSPECIFIC_FLAG | 0x17u);
+#define PID_ADLINK_LAN_CERT_NAME (PID_VENDORSPECIFIC_FLAG | 0x18u);
#if defined (__cplusplus)
}
diff --git a/src/core/ddsi/include/dds/ddsi/q_xmsg.h b/src/core/ddsi/include/dds/ddsi/q_xmsg.h
index b002e67..af2b937 100644
--- a/src/core/ddsi/include/dds/ddsi/q_xmsg.h
+++ b/src/core/ddsi/include/dds/ddsi/q_xmsg.h
@@ -27,7 +27,7 @@ struct addrset;
struct proxy_reader;
struct proxy_writer;
-struct nn_prismtech_participant_version_info;
+struct nn_adlink_participant_version_info;
struct nn_xmsgpool;
struct nn_xmsg_data;
struct nn_xmsg;
diff --git a/src/core/ddsi/src/ddsi_plist.c b/src/core/ddsi/src/ddsi_plist.c
index b12321a..a4e21b4 100644
--- a/src/core/ddsi/src/ddsi_plist.c
+++ b/src/core/ddsi/src/ddsi_plist.c
@@ -1449,28 +1449,28 @@ static const struct piddesc piddesc_omg[] = {
/* Understood parameters for Eclipse Foundation (Cyclone DDS) vendor code */
static const struct piddesc piddesc_eclipse[] = {
- QP (PRISMTECH_ENTITY_FACTORY, entity_factory, Xb),
- QP (PRISMTECH_READER_LIFESPAN, reader_lifespan, Xb, XD),
- QP (PRISMTECH_WRITER_DATA_LIFECYCLE, writer_data_lifecycle, Xb),
- QP (PRISMTECH_READER_DATA_LIFECYCLE, reader_data_lifecycle, XDx2),
- QP (PRISMTECH_SUBSCRIPTION_KEYS, subscription_keys, XbCOND, XQ, XS, XSTOP),
+ QP (ADLINK_ENTITY_FACTORY, entity_factory, Xb),
+ QP (ADLINK_READER_LIFESPAN, reader_lifespan, Xb, XD),
+ QP (ADLINK_WRITER_DATA_LIFECYCLE, writer_data_lifecycle, Xb),
+ QP (ADLINK_READER_DATA_LIFECYCLE, reader_data_lifecycle, XDx2),
+ QP (ADLINK_SUBSCRIPTION_KEYS, subscription_keys, XbCOND, XQ, XS, XSTOP),
{ PID_PAD, PDF_QOS, QP_CYCLONE_IGNORELOCAL, "CYCLONE_IGNORELOCAL",
offsetof (struct ddsi_plist, qos.ignorelocal), membersize (struct ddsi_plist, qos.ignorelocal),
{ .desc = { XE2, XSTOP } }, 0 },
- PP (PRISMTECH_PARTICIPANT_VERSION_INFO, prismtech_participant_version_info, Xux5, XS),
- PP (PRISMTECH_TYPE_DESCRIPTION, type_description, XS),
+ PP (ADLINK_PARTICIPANT_VERSION_INFO, adlink_participant_version_info, Xux5, XS),
+ PP (ADLINK_TYPE_DESCRIPTION, type_description, XS),
{ PID_SENTINEL, 0, 0, NULL, 0, 0, { .desc = { XSTOP } }, 0 }
};
-/* Understood parameters for PrismTech vendor code */
-static const struct piddesc piddesc_prismtech[] = {
- QP (PRISMTECH_ENTITY_FACTORY, entity_factory, Xb),
- QP (PRISMTECH_READER_LIFESPAN, reader_lifespan, Xb, XD),
- QP (PRISMTECH_WRITER_DATA_LIFECYCLE, writer_data_lifecycle, Xb),
- QP (PRISMTECH_READER_DATA_LIFECYCLE, reader_data_lifecycle, XDx2),
- QP (PRISMTECH_SUBSCRIPTION_KEYS, subscription_keys, XbCOND, XQ, XS, XSTOP),
- PP (PRISMTECH_PARTICIPANT_VERSION_INFO, prismtech_participant_version_info, Xux5, XS),
- PP (PRISMTECH_TYPE_DESCRIPTION, type_description, XS),
+/* Understood parameters for Adlink vendor code */
+static const struct piddesc piddesc_adlink[] = {
+ QP (ADLINK_ENTITY_FACTORY, entity_factory, Xb),
+ QP (ADLINK_READER_LIFESPAN, reader_lifespan, Xb, XD),
+ QP (ADLINK_WRITER_DATA_LIFECYCLE, writer_data_lifecycle, Xb),
+ QP (ADLINK_READER_DATA_LIFECYCLE, reader_data_lifecycle, XDx2),
+ QP (ADLINK_SUBSCRIPTION_KEYS, subscription_keys, XbCOND, XQ, XS, XSTOP),
+ PP (ADLINK_PARTICIPANT_VERSION_INFO, adlink_participant_version_info, Xux5, XS),
+ PP (ADLINK_TYPE_DESCRIPTION, type_description, XS),
{ PID_SENTINEL, 0, 0, NULL, 0, 0, { .desc = { XSTOP } }, 0 }
};
@@ -1524,7 +1524,7 @@ static const struct piddesc *piddesc_omg_index[115];
static const struct piddesc *piddesc_omg_index[114];
#endif
static const struct piddesc *piddesc_eclipse_index[19];
-static const struct piddesc *piddesc_prismtech_index[19];
+static const struct piddesc *piddesc_adlink_index[19];
#define INDEX_ANY(vendorid_, tab_) [vendorid_] = { \
.index_max = sizeof (piddesc_##tab_##_index) / sizeof (piddesc_##tab_##_index[0]) - 1, \
@@ -1535,11 +1535,11 @@ static const struct piddesc *piddesc_prismtech_index[19];
static const struct piddesc_index piddesc_vendor_index[] = {
INDEX_ANY (0, omg),
INDEX (ECLIPSE, eclipse),
- INDEX (PRISMTECH_OSPL, prismtech),
- INDEX (PRISMTECH_JAVA, prismtech),
- INDEX (PRISMTECH_LITE, prismtech),
- INDEX (PRISMTECH_GATEWAY, prismtech),
- INDEX (PRISMTECH_CLOUD, prismtech)
+ INDEX (ADLINK_OSPL, adlink),
+ INDEX (ADLINK_JAVA, adlink),
+ INDEX (ADLINK_LITE, adlink),
+ INDEX (ADLINK_GATEWAY, adlink),
+ INDEX (ADLINK_CLOUD, adlink)
};
#undef INDEX
@@ -2781,7 +2781,7 @@ void ddsi_plist_init_default_participant (ddsi_plist_t *plist)
{
ddsi_plist_init_empty (plist);
- plist->qos.present |= QP_PRISMTECH_ENTITY_FACTORY;
+ plist->qos.present |= QP_ADLINK_ENTITY_FACTORY;
plist->qos.entity_factory.autoenable_created_entities = 0;
plist->qos.present |= QP_USER_DATA;
@@ -2864,15 +2864,15 @@ void ddsi_xqos_init_default_reader (dds_qos_t *xqos)
xqos->present |= QP_TIME_BASED_FILTER;
xqos->time_based_filter.minimum_separation = 0;
- xqos->present |= QP_PRISMTECH_READER_DATA_LIFECYCLE;
+ xqos->present |= QP_ADLINK_READER_DATA_LIFECYCLE;
xqos->reader_data_lifecycle.autopurge_nowriter_samples_delay = DDS_INFINITY;
xqos->reader_data_lifecycle.autopurge_disposed_samples_delay = DDS_INFINITY;
- xqos->present |= QP_PRISMTECH_READER_LIFESPAN;
+ xqos->present |= QP_ADLINK_READER_LIFESPAN;
xqos->reader_lifespan.use_lifespan = 0;
xqos->reader_lifespan.duration = DDS_INFINITY;
- xqos->present |= QP_PRISMTECH_SUBSCRIPTION_KEYS;
+ xqos->present |= QP_ADLINK_SUBSCRIPTION_KEYS;
xqos->subscription_keys.use_key_list = 0;
xqos->subscription_keys.key_list.n = 0;
xqos->subscription_keys.key_list.strs = NULL;
@@ -2903,7 +2903,7 @@ void ddsi_xqos_init_default_writer (dds_qos_t *xqos)
xqos->present |= QP_LIFESPAN;
xqos->lifespan.duration = DDS_INFINITY;
- xqos->present |= QP_PRISMTECH_WRITER_DATA_LIFECYCLE;
+ xqos->present |= QP_ADLINK_WRITER_DATA_LIFECYCLE;
xqos->writer_data_lifecycle.autodispose_unregistered_instances = 1;
}
@@ -2935,7 +2935,7 @@ void ddsi_xqos_init_default_topic (dds_qos_t *xqos)
xqos->present |= QP_LIFESPAN;
xqos->lifespan.duration = DDS_INFINITY;
- xqos->present |= QP_PRISMTECH_SUBSCRIPTION_KEYS;
+ xqos->present |= QP_ADLINK_SUBSCRIPTION_KEYS;
xqos->subscription_keys.use_key_list = 0;
xqos->subscription_keys.key_list.n = 0;
xqos->subscription_keys.key_list.strs = NULL;
@@ -2949,7 +2949,7 @@ static void ddsi_xqos_init_default_publisher_subscriber (dds_qos_t *xqos)
xqos->group_data.length = 0;
xqos->group_data.value = NULL;
- xqos->present |= QP_PRISMTECH_ENTITY_FACTORY;
+ xqos->present |= QP_ADLINK_ENTITY_FACTORY;
xqos->entity_factory.autoenable_created_entities = 1;
xqos->present |= QP_PARTITION;
diff --git a/src/core/ddsi/src/ddsi_vendor.c b/src/core/ddsi/src/ddsi_vendor.c
index 6d1dfaf..a662b09 100644
--- a/src/core/ddsi/src/ddsi_vendor.c
+++ b/src/core/ddsi/src/ddsi_vendor.c
@@ -17,9 +17,9 @@ extern inline bool vendor_equals (nn_vendorid_t a, nn_vendorid_t b);
extern inline bool vendor_is_rti (nn_vendorid_t vendor);
extern inline bool vendor_is_twinoaks (nn_vendorid_t vendor);
extern inline bool vendor_is_eprosima (nn_vendorid_t vendor);
-extern inline bool vendor_is_prismtech (nn_vendorid_t vendor);
+extern inline bool vendor_is_adlink (nn_vendorid_t vendor);
extern inline bool vendor_is_opensplice (nn_vendorid_t vendor);
extern inline bool vendor_is_cloud (nn_vendorid_t vendor);
extern inline bool vendor_is_eclipse (nn_vendorid_t vendor);
extern inline bool vendor_is_eclipse_or_opensplice (nn_vendorid_t vendor);
-extern inline bool vendor_is_eclipse_or_prismtech (nn_vendorid_t vendor);
+extern inline bool vendor_is_eclipse_or_adlink (nn_vendorid_t vendor);
diff --git a/src/core/ddsi/src/q_ddsi_discovery.c b/src/core/ddsi/src/q_ddsi_discovery.c
index cbcbcd2..67a8d62 100644
--- a/src/core/ddsi/src/q_ddsi_discovery.c
+++ b/src/core/ddsi/src/q_ddsi_discovery.c
@@ -296,28 +296,28 @@ int spdp_write (struct participant *pp)
}
ps.participant_lease_duration = pp->lease_duration;
- /* Add PrismTech specific version information */
+ /* Add Adlink specific version information */
{
- ps.present |= PP_PRISMTECH_PARTICIPANT_VERSION_INFO;
- memset (&ps.prismtech_participant_version_info, 0, sizeof (ps.prismtech_participant_version_info));
- ps.prismtech_participant_version_info.version = 0;
- ps.prismtech_participant_version_info.flags =
- NN_PRISMTECH_FL_DDSI2_PARTICIPANT_FLAG |
- NN_PRISMTECH_FL_PTBES_FIXED_0 |
- NN_PRISMTECH_FL_SUPPORTS_STATUSINFOX;
+ ps.present |= PP_ADLINK_PARTICIPANT_VERSION_INFO;
+ memset (&ps.adlink_participant_version_info, 0, sizeof (ps.adlink_participant_version_info));
+ ps.adlink_participant_version_info.version = 0;
+ ps.adlink_participant_version_info.flags =
+ NN_ADLINK_FL_DDSI2_PARTICIPANT_FLAG |
+ NN_ADLINK_FL_PTBES_FIXED_0 |
+ NN_ADLINK_FL_SUPPORTS_STATUSINFOX;
if (pp->e.gv->config.besmode == BESMODE_MINIMAL)
- ps.prismtech_participant_version_info.flags |= NN_PRISMTECH_FL_MINIMAL_BES_MODE;
+ ps.adlink_participant_version_info.flags |= NN_ADLINK_FL_MINIMAL_BES_MODE;
ddsrt_mutex_lock (&pp->e.gv->privileged_pp_lock);
if (pp->is_ddsi2_pp)
- ps.prismtech_participant_version_info.flags |= NN_PRISMTECH_FL_PARTICIPANT_IS_DDSI2;
+ ps.adlink_participant_version_info.flags |= NN_ADLINK_FL_PARTICIPANT_IS_DDSI2;
ddsrt_mutex_unlock (&pp->e.gv->privileged_pp_lock);
if (ddsrt_gethostname(node, sizeof(node)-1) < 0)
(void) ddsrt_strlcpy (node, "unknown", sizeof (node));
size = strlen(node) + strlen(DDS_VERSION) + strlen(DDS_HOST_NAME) + strlen(DDS_TARGET_NAME) + 4; /* + ///'\0' */
- ps.prismtech_participant_version_info.internals = ddsrt_malloc(size);
- (void) snprintf(ps.prismtech_participant_version_info.internals, size, "%s/%s/%s/%s", node, DDS_VERSION, DDS_HOST_NAME, DDS_TARGET_NAME);
- ETRACE (pp, "spdp_write("PGUIDFMT") - internals: %s\n", PGUID (pp->e.guid), ps.prismtech_participant_version_info.internals);
+ ps.adlink_participant_version_info.internals = ddsrt_malloc(size);
+ (void) snprintf(ps.adlink_participant_version_info.internals, size, "%s/%s/%s/%s", node, DDS_VERSION, DDS_HOST_NAME, DDS_TARGET_NAME);
+ ETRACE (pp, "spdp_write("PGUIDFMT") - internals: %s\n", PGUID (pp->e.guid), ps.adlink_participant_version_info.internals);
}
/* Participant QoS's insofar as they are set, different from the default. Currently, that means just USER_DATA. */
@@ -631,21 +631,21 @@ static int handle_SPDP_alive (const struct receiver_state *rst, seqno_t seq, dds
lease_duration = DDS_SECS (100);
}
- if (datap->present & PP_PRISMTECH_PARTICIPANT_VERSION_INFO) {
- if (datap->prismtech_participant_version_info.flags & NN_PRISMTECH_FL_KERNEL_SEQUENCE_NUMBER)
+ if (datap->present & PP_ADLINK_PARTICIPANT_VERSION_INFO) {
+ if (datap->adlink_participant_version_info.flags & NN_ADLINK_FL_KERNEL_SEQUENCE_NUMBER)
custom_flags |= CF_INC_KERNEL_SEQUENCE_NUMBERS;
- if ((datap->prismtech_participant_version_info.flags & NN_PRISMTECH_FL_DDSI2_PARTICIPANT_FLAG) &&
- (datap->prismtech_participant_version_info.flags & NN_PRISMTECH_FL_PARTICIPANT_IS_DDSI2))
+ if ((datap->adlink_participant_version_info.flags & NN_ADLINK_FL_DDSI2_PARTICIPANT_FLAG) &&
+ (datap->adlink_participant_version_info.flags & NN_ADLINK_FL_PARTICIPANT_IS_DDSI2))
custom_flags |= CF_PARTICIPANT_IS_DDSI2;
GVLOGDISC (" (0x%08x-0x%08x-0x%08x-0x%08x-0x%08x %s)",
- datap->prismtech_participant_version_info.version,
- datap->prismtech_participant_version_info.flags,
- datap->prismtech_participant_version_info.unused[0],
- datap->prismtech_participant_version_info.unused[1],
- datap->prismtech_participant_version_info.unused[2],
- datap->prismtech_participant_version_info.internals);
+ datap->adlink_participant_version_info.version,
+ datap->adlink_participant_version_info.flags,
+ datap->adlink_participant_version_info.unused[0],
+ datap->adlink_participant_version_info.unused[1],
+ datap->adlink_participant_version_info.unused[2],
+ datap->adlink_participant_version_info.internals);
}
/* If any of the SEDP announcer are missing AND the guid prefix of
@@ -1114,12 +1114,12 @@ static struct proxy_participant *implicitly_create_proxypp (struct ddsi_domaingv
as_meta = ref_addrset(privpp->as_meta);
/* copy just what we need */
tmp_plist = *privpp->plist;
- tmp_plist.present = PP_PARTICIPANT_GUID | PP_PRISMTECH_PARTICIPANT_VERSION_INFO;
+ tmp_plist.present = PP_PARTICIPANT_GUID | PP_ADLINK_PARTICIPANT_VERSION_INFO;
tmp_plist.participant_guid = *ppguid;
ddsi_plist_mergein_missing (&pp_plist, &tmp_plist, ~(uint64_t)0, ~(uint64_t)0);
ddsrt_mutex_unlock (&privpp->e.lock);
- pp_plist.prismtech_participant_version_info.flags &= ~NN_PRISMTECH_FL_PARTICIPANT_IS_DDSI2;
+ pp_plist.adlink_participant_version_info.flags &= ~NN_ADLINK_FL_PARTICIPANT_IS_DDSI2;
new_proxy_participant (gv, ppguid, 0, &privguid, as_default, as_meta, &pp_plist, DDS_INFINITY, vendorid, CF_IMPLICITLY_CREATED_PROXYPP | CF_PROXYPP_NO_SPDP, timestamp, seq);
}
}
@@ -1179,7 +1179,7 @@ static void handle_SEDP_alive (const struct receiver_state *rst, seqno_t seq, dd
is_writer = is_writer_entityid (datap->endpoint_guid.entityid);
if (!is_writer)
ddsi_xqos_mergein_missing (xqos, &gv->default_xqos_rd, ~(uint64_t)0);
- else if (vendor_is_eclipse_or_prismtech(vendorid))
+ else if (vendor_is_eclipse_or_adlink(vendorid))
ddsi_xqos_mergein_missing (xqos, &gv->default_xqos_wr, ~(uint64_t)0);
else
ddsi_xqos_mergein_missing (xqos, &gv->default_xqos_wr_nad, ~(uint64_t)0);
@@ -1273,7 +1273,7 @@ static void handle_SEDP_alive (const struct receiver_state *rst, seqno_t seq, dd
ddsi_xqos_log (DDS_LC_DISCOVERY, &gv->logconfig, xqos);
GVLOGDISC ("}\n");
- if ((datap->endpoint_guid.entityid.u & NN_ENTITYID_SOURCE_MASK) == NN_ENTITYID_SOURCE_VENDOR && !vendor_is_eclipse_or_prismtech (vendorid))
+ if ((datap->endpoint_guid.entityid.u & NN_ENTITYID_SOURCE_MASK) == NN_ENTITYID_SOURCE_VENDOR && !vendor_is_eclipse_or_adlink (vendorid))
{
GVLOGDISC ("ignoring vendor-specific endpoint "PGUIDFMT"\n", PGUID (datap->endpoint_guid));
}
diff --git a/src/core/ddsi/src/q_entity.c b/src/core/ddsi/src/q_entity.c
index a4652b6..6917574 100644
--- a/src/core/ddsi/src/q_entity.c
+++ b/src/core/ddsi/src/q_entity.c
@@ -176,7 +176,7 @@ int is_builtin_entityid (ddsi_entityid_t id, nn_vendorid_t vendorid)
return 1;
else if ((id.u & NN_ENTITYID_SOURCE_MASK) != NN_ENTITYID_SOURCE_VENDOR)
return 0;
- else if (!vendor_is_eclipse_or_prismtech (vendorid))
+ else if (!vendor_is_eclipse_or_adlink (vendorid))
return 0;
else
{
@@ -3981,14 +3981,14 @@ void new_proxy_participant (struct ddsi_domaingv *gv, const struct ddsi_guid *pp
memset (&proxypp->privileged_pp_guid.prefix, 0, sizeof (proxypp->privileged_pp_guid.prefix));
proxypp->privileged_pp_guid.entityid.u = NN_ENTITYID_PARTICIPANT;
}
- if ((plist->present & PP_PRISMTECH_PARTICIPANT_VERSION_INFO) &&
- (plist->prismtech_participant_version_info.flags & NN_PRISMTECH_FL_DDSI2_PARTICIPANT_FLAG) &&
- (plist->prismtech_participant_version_info.flags & NN_PRISMTECH_FL_PARTICIPANT_IS_DDSI2))
+ if ((plist->present & PP_ADLINK_PARTICIPANT_VERSION_INFO) &&
+ (plist->adlink_participant_version_info.flags & NN_ADLINK_FL_DDSI2_PARTICIPANT_FLAG) &&
+ (plist->adlink_participant_version_info.flags & NN_ADLINK_FL_PARTICIPANT_IS_DDSI2))
proxypp->is_ddsi2_pp = 1;
else
proxypp->is_ddsi2_pp = 0;
- if ((plist->present & PP_PRISMTECH_PARTICIPANT_VERSION_INFO) &&
- (plist->prismtech_participant_version_info.flags & NN_PRISMTECH_FL_MINIMAL_BES_MODE))
+ if ((plist->present & PP_ADLINK_PARTICIPANT_VERSION_INFO) &&
+ (plist->adlink_participant_version_info.flags & NN_ADLINK_FL_MINIMAL_BES_MODE))
proxypp->minimal_bes_mode = 1;
else
proxypp->minimal_bes_mode = 0;
diff --git a/src/core/ddsi/src/q_receive.c b/src/core/ddsi/src/q_receive.c
index 098a565..2f209e1 100644
--- a/src/core/ddsi/src/q_receive.c
+++ b/src/core/ddsi/src/q_receive.c
@@ -1775,7 +1775,7 @@ static struct ddsi_serdata *remote_make_sample (struct ddsi_tkmap_instance **tk,
else if (sampleinfo->size)
{
/* dispose or unregister with included serialized key or data
- (data is a PrismTech extension) -- i.e., dispose or unregister
+ (data is a Adlink extension) -- i.e., dispose or unregister
as one would expect to receive */
if (data_smhdr_flags & DATA_FLAG_KEYFLAG)
{
@@ -2787,7 +2787,7 @@ static int handle_submsg_sequence
ts_for_latmeas = 0;
}
break;
- case SMID_PT_MSG_LEN:
+ case SMID_ADLINK_MSG_LEN:
{
#if 0
state = "parse:msg_len";
@@ -2795,7 +2795,7 @@ static int handle_submsg_sequence
GVTRACE ("MSG_LEN(%"PRIu32")", ((MsgLen_t*) sm)->length);
break;
}
- case SMID_PT_ENTITY_ID:
+ case SMID_ADLINK_ENTITY_ID:
{
#if 0
state = "parse:entity_id";
@@ -2921,7 +2921,7 @@ static bool do_packet (struct thread_state1 * const ts1, struct ddsi_domaingv *g
ml->length = ddsrt_bswap4u (ml->length);
}
- if (ml->smhdr.submessageId != SMID_PT_MSG_LEN)
+ if (ml->smhdr.submessageId != SMID_ADLINK_MSG_LEN)
{
malformed_packet_received_nosubmsg (gv, buff, sz, "header", hdr->vendorid);
sz = -1;
diff --git a/src/core/ddsi/src/q_xmsg.c b/src/core/ddsi/src/q_xmsg.c
index 08ce49e..7bc9993 100644
--- a/src/core/ddsi/src/q_xmsg.c
+++ b/src/core/ddsi/src/q_xmsg.c
@@ -377,8 +377,8 @@ static int submsg_is_compatible (const struct nn_xmsg *msg, SubmessageKind_t smk
case SMID_ACKNACK: case SMID_HEARTBEAT:
case SMID_GAP: case SMID_NACK_FRAG:
case SMID_HEARTBEAT_FRAG:
- case SMID_PT_MSG_LEN:
- case SMID_PT_ENTITY_ID:
+ case SMID_ADLINK_MSG_LEN:
+ case SMID_ADLINK_ENTITY_ID:
/* normal control stuff is ok */
return 1;
case SMID_DATA: case SMID_DATA_FRAG:
@@ -410,8 +410,8 @@ static int submsg_is_compatible (const struct nn_xmsg *msg, SubmessageKind_t smk
case SMID_GAP:
case SMID_NACK_FRAG:
case SMID_HEARTBEAT_FRAG:
- case SMID_PT_MSG_LEN:
- case SMID_PT_ENTITY_ID:
+ case SMID_ADLINK_MSG_LEN:
+ case SMID_ADLINK_ENTITY_ID:
/* anything else is strictly verboten */
return 0;
}
@@ -553,7 +553,7 @@ void nn_xmsg_add_entityid (struct nn_xmsg * m)
struct nn_xmsg_marker sm;
eid = (EntityId_t*) nn_xmsg_append (m, &sm, sizeof (EntityId_t));
- nn_xmsg_submsg_init (m, sm, SMID_PT_ENTITY_ID);
+ nn_xmsg_submsg_init (m, sm, SMID_ADLINK_ENTITY_ID);
eid->entityid.u = NN_ENTITYID_PARTICIPANT;
nn_xmsg_submsg_setnext (m, sm);
}
@@ -982,7 +982,7 @@ struct nn_xpack * nn_xpack_new (ddsi_tran_conn_t conn, uint32_t bw_limit, bool a
/* MSG_LEN first sub message for stream based connections */
- xp->msg_len.smhdr.submessageId = SMID_PT_MSG_LEN;
+ xp->msg_len.smhdr.submessageId = SMID_ADLINK_MSG_LEN;
xp->msg_len.smhdr.flags = (DDSRT_ENDIAN == DDSRT_LITTLE_ENDIAN ? SMFLAG_ENDIANNESS : 0);
xp->msg_len.smhdr.octetsToNextHeader = 4;
diff --git a/src/mpt/tests/qos/procs/rw.c b/src/mpt/tests/qos/procs/rw.c
index 14889cf..747302a 100644
--- a/src/mpt/tests/qos/procs/rw.c
+++ b/src/mpt/tests/qos/procs/rw.c
@@ -155,7 +155,7 @@ static bool pubsub_qos_eq_h (const dds_qos_t *a, dds_entity_t ent)
static uint64_t reader_qos_delta (const dds_qos_t *a, const dds_qos_t *b)
{
- return ddsi_xqos_delta (a, b, QP_USER_DATA | QP_TOPIC_DATA | QP_GROUP_DATA | QP_DURABILITY | QP_HISTORY | QP_RESOURCE_LIMITS | QP_PRESENTATION | QP_DEADLINE | QP_LATENCY_BUDGET | QP_OWNERSHIP | QP_LIVELINESS | QP_TIME_BASED_FILTER | QP_PARTITION | QP_RELIABILITY | QP_DESTINATION_ORDER | QP_PRISMTECH_READER_DATA_LIFECYCLE);
+ return ddsi_xqos_delta (a, b, QP_USER_DATA | QP_TOPIC_DATA | QP_GROUP_DATA | QP_DURABILITY | QP_HISTORY | QP_RESOURCE_LIMITS | QP_PRESENTATION | QP_DEADLINE | QP_LATENCY_BUDGET | QP_OWNERSHIP | QP_LIVELINESS | QP_TIME_BASED_FILTER | QP_PARTITION | QP_RELIABILITY | QP_DESTINATION_ORDER | QP_ADLINK_READER_DATA_LIFECYCLE);
}
static bool reader_qos_eq_h (const dds_qos_t *a, dds_entity_t ent)
@@ -177,7 +177,7 @@ static bool reader_qos_eq_h (const dds_qos_t *a, dds_entity_t ent)
static uint64_t writer_qos_delta (const dds_qos_t *a, const dds_qos_t *b)
{
- return ddsi_xqos_delta (a, b, QP_USER_DATA | QP_TOPIC_DATA | QP_GROUP_DATA | QP_DURABILITY | QP_HISTORY | QP_RESOURCE_LIMITS | QP_PRESENTATION | QP_LIFESPAN | QP_DEADLINE | QP_LATENCY_BUDGET | QP_OWNERSHIP | QP_OWNERSHIP_STRENGTH | QP_LIVELINESS | QP_PARTITION | QP_RELIABILITY | QP_DESTINATION_ORDER | QP_PRISMTECH_WRITER_DATA_LIFECYCLE);
+ return ddsi_xqos_delta (a, b, QP_USER_DATA | QP_TOPIC_DATA | QP_GROUP_DATA | QP_DURABILITY | QP_HISTORY | QP_RESOURCE_LIMITS | QP_PRESENTATION | QP_LIFESPAN | QP_DEADLINE | QP_LATENCY_BUDGET | QP_OWNERSHIP | QP_OWNERSHIP_STRENGTH | QP_LIVELINESS | QP_PARTITION | QP_RELIABILITY | QP_DESTINATION_ORDER | QP_ADLINK_WRITER_DATA_LIFECYCLE);
}
static bool writer_qos_eq_h (const dds_qos_t *a, dds_entity_t ent)
diff --git a/src/tools/decode-trace b/src/tools/decode-trace
index 82ada68..98a639c 100755
--- a/src/tools/decode-trace
+++ b/src/tools/decode-trace
@@ -324,7 +324,7 @@ while(<>) {
my $userdata = $_;
if ($userdata =~ s/.*QOS=\{.*?user_data=//) {
$userdata =~ s/\}$//;
- $userdata =~ s/,(?:prismtech_)?entity_factory=\d$//;
+ $userdata =~ s/,(?:(?:prismtech|adlink)_)?entity_factory=\d$//;
$userdata = " userdata:$userdata";
} else {
$userdata = "";
From 4df38f5bf9de41c0691c7336df3782d5e40e09f9 Mon Sep 17 00:00:00 2001
From: Erik Boasson
Date: Tue, 10 Mar 2020 12:59:20 +0100
Subject: [PATCH 27/30] Move all socket creation stuff to transport code
Signed-off-by: Erik Boasson
---
src/core/ddsi/CMakeLists.txt | 4 +-
.../ddsi/include/dds/ddsi/ddsi_domaingv.h | 2 +-
.../dds/ddsi/{q_nwif.h => ddsi_ownip.h} | 8 +-
src/core/ddsi/src/ddsi_ipaddr.c | 1 -
src/core/ddsi/src/ddsi_ownip.c | 304 ++++++++
src/core/ddsi/src/ddsi_raweth.c | 1 -
src/core/ddsi/src/ddsi_tcp.c | 249 ++++---
src/core/ddsi/src/ddsi_udp.c | 333 +++++++--
src/core/ddsi/src/q_config.c | 1 -
src/core/ddsi/src/q_init.c | 2 +-
src/core/ddsi/src/q_nwif.c | 687 ------------------
11 files changed, 758 insertions(+), 834 deletions(-)
rename src/core/ddsi/include/dds/ddsi/{q_nwif.h => ddsi_ownip.h} (78%)
create mode 100644 src/core/ddsi/src/ddsi_ownip.c
delete mode 100644 src/core/ddsi/src/q_nwif.c
diff --git a/src/core/ddsi/CMakeLists.txt b/src/core/ddsi/CMakeLists.txt
index af84a9b..60d91dd 100644
--- a/src/core/ddsi/CMakeLists.txt
+++ b/src/core/ddsi/CMakeLists.txt
@@ -35,6 +35,7 @@ PREPEND(srcs_ddsi "${CMAKE_CURRENT_LIST_DIR}/src"
ddsi_plist.c
ddsi_cdrstream.c
ddsi_time.c
+ ddsi_ownip.c
q_addrset.c
q_bitset_inlines.c
q_bswap.c
@@ -47,7 +48,6 @@ PREPEND(srcs_ddsi "${CMAKE_CURRENT_LIST_DIR}/src"
q_lat_estim.c
q_lease.c
q_misc.c
- q_nwif.c
q_pcap.c
q_qosmatch.c
q_radmin.c
@@ -100,6 +100,7 @@ PREPEND(hdrs_private_ddsi "${CMAKE_CURRENT_LIST_DIR}/include/dds/ddsi"
ddsi_xqos.h
ddsi_cdrstream.h
ddsi_time.h
+ ddsi_ownip.h
q_addrset.h
q_bitset.h
q_bswap.h
@@ -115,7 +116,6 @@ PREPEND(hdrs_private_ddsi "${CMAKE_CURRENT_LIST_DIR}/include/dds/ddsi"
q_lease.h
q_log.h
q_misc.h
- q_nwif.h
q_pcap.h
q_protocol.h
q_qosmatch.h
diff --git a/src/core/ddsi/include/dds/ddsi/ddsi_domaingv.h b/src/core/ddsi/include/dds/ddsi/ddsi_domaingv.h
index 27c9d3a..4c96ef1 100644
--- a/src/core/ddsi/include/dds/ddsi/ddsi_domaingv.h
+++ b/src/core/ddsi/include/dds/ddsi/ddsi_domaingv.h
@@ -21,8 +21,8 @@
#include "dds/ddsrt/fibheap.h"
#include "dds/ddsi/ddsi_plist.h"
+#include "dds/ddsi/ddsi_ownip.h"
#include "dds/ddsi/q_protocol.h"
-#include "dds/ddsi/q_nwif.h"
#include "dds/ddsi/q_sockwaitset.h"
#include "dds/ddsi/q_config.h"
diff --git a/src/core/ddsi/include/dds/ddsi/q_nwif.h b/src/core/ddsi/include/dds/ddsi/ddsi_ownip.h
similarity index 78%
rename from src/core/ddsi/include/dds/ddsi/q_nwif.h
rename to src/core/ddsi/include/dds/ddsi/ddsi_ownip.h
index 12f232e..caf6a2d 100644
--- a/src/core/ddsi/include/dds/ddsi/q_nwif.h
+++ b/src/core/ddsi/include/dds/ddsi/ddsi_ownip.h
@@ -9,8 +9,8 @@
*
* SPDX-License-Identifier: EPL-2.0 OR BSD-3-Clause
*/
-#ifndef Q_NWIF_H
-#define Q_NWIF_H
+#ifndef DDSI_OWNIP_H
+#define DDSI_OWNIP_H
#include
@@ -35,12 +35,10 @@ struct nn_interface {
char *name;
};
-int make_socket (ddsrt_socket_t *socket, uint16_t port, bool stream, bool reuse_addr, bool bind_to_any, const struct ddsi_domaingv *gv);
int find_own_ip (struct ddsi_domaingv *gv, const char *requested_address);
-uint32_t locator_to_hopefully_unique_uint32 (const nn_locator_t *src);
#if defined (__cplusplus)
}
#endif
-#endif /* Q_NWIF_H */
+#endif /* DDSI_OWNIP_H */
diff --git a/src/core/ddsi/src/ddsi_ipaddr.c b/src/core/ddsi/src/ddsi_ipaddr.c
index a68021e..b6c6b71 100644
--- a/src/core/ddsi/src/ddsi_ipaddr.c
+++ b/src/core/ddsi/src/ddsi_ipaddr.c
@@ -17,7 +17,6 @@
#include "dds/ddsrt/log.h"
#include "dds/ddsrt/sockets.h"
#include "dds/ddsi/ddsi_ipaddr.h"
-#include "dds/ddsi/q_nwif.h"
#include "dds/ddsi/q_config.h"
#include "dds/ddsi/ddsi_domaingv.h"
diff --git a/src/core/ddsi/src/ddsi_ownip.c b/src/core/ddsi/src/ddsi_ownip.c
new file mode 100644
index 0000000..d53fe85
--- /dev/null
+++ b/src/core/ddsi/src/ddsi_ownip.c
@@ -0,0 +1,304 @@
+/*
+ * Copyright(c) 2006 to 2018 ADLINK Technology Limited and others
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v. 2.0 which is available at
+ * http://www.eclipse.org/legal/epl-2.0, or the Eclipse Distribution License
+ * v. 1.0 which is available at
+ * http://www.eclipse.org/org/documents/edl-v10.php.
+ *
+ * SPDX-License-Identifier: EPL-2.0 OR BSD-3-Clause
+ */
+#include
+#include
+#include
+#include
+#include
+
+#include "dds/ddsrt/ifaddrs.h"
+#include "dds/ddsrt/heap.h"
+#include "dds/ddsrt/md5.h"
+#include "dds/ddsrt/string.h"
+#include "dds/ddsrt/sockets.h"
+
+#include "dds/ddsi/q_log.h"
+#include "dds/ddsi/ddsi_ownip.h"
+
+#include "dds/ddsi/ddsi_domaingv.h"
+#include "dds/ddsi/q_config.h"
+#include "dds/ddsi/q_unused.h"
+#include "dds/ddsi/q_misc.h"
+#include "dds/ddsi/q_addrset.h" /* unspec locator */
+#include "dds/ddsi/q_feature_check.h"
+#include "dds/ddsi/ddsi_ipaddr.h"
+#include "dds/ddsrt/avl.h"
+
+static int multicast_override(const char *ifname, const struct config *config)
+{
+ char *copy = ddsrt_strdup (config->assumeMulticastCapable), *cursor = copy, *tok;
+ int match = 0;
+ if (copy != NULL)
+ {
+ while ((tok = ddsrt_strsep (&cursor, ",")) != NULL)
+ {
+ if (ddsi2_patmatch (tok, ifname))
+ match = 1;
+ }
+ }
+ ddsrt_free (copy);
+ return match;
+}
+
+#ifdef __linux
+/* FIMXE: HACK HACK */
+#include
+#endif
+
+int find_own_ip (struct ddsi_domaingv *gv, const char *requested_address)
+{
+ const char *sep = " ";
+ char last_if_name[80] = "";
+ int quality = -1;
+ int i;
+ ddsrt_ifaddrs_t *ifa, *ifa_root = NULL;
+ int maxq_list[MAX_INTERFACES];
+ int maxq_count = 0;
+ size_t maxq_strlen = 0;
+ int selected_idx = -1;
+ char addrbuf[DDSI_LOCSTRLEN];
+
+ GVLOG (DDS_LC_CONFIG, "interfaces:");
+
+ {
+ int ret;
+ ret = ddsi_enumerate_interfaces(gv->m_factory, gv->config.transport_selector, &ifa_root);
+ if (ret < 0) {
+ GVERROR ("ddsi_enumerate_interfaces(%s): %d\n", gv->m_factory->m_typename, ret);
+ return 0;
+ }
+ }
+
+ gv->n_interfaces = 0;
+ last_if_name[0] = 0;
+ for (ifa = ifa_root; ifa != NULL; ifa = ifa->next)
+ {
+ char if_name[sizeof (last_if_name)];
+ int q = 0;
+
+ (void) ddsrt_strlcpy(if_name, ifa->name, sizeof(if_name));
+
+ if (strcmp (if_name, last_if_name))
+ GVLOG (DDS_LC_CONFIG, "%s%s", sep, if_name);
+ (void) ddsrt_strlcpy(last_if_name, if_name, sizeof(last_if_name));
+
+ /* interface must be up */
+ if ((ifa->flags & IFF_UP) == 0) {
+ GVLOG (DDS_LC_CONFIG, " (interface down)");
+ continue;
+ } else if (ddsrt_sockaddr_isunspecified(ifa->addr)) {
+ GVLOG (DDS_LC_CONFIG, " (address unspecified)");
+ continue;
+ }
+
+ switch (ifa->type)
+ {
+ case DDSRT_IFTYPE_WIFI:
+ DDS_LOG(DDS_LC_CONFIG, " wireless");
+ break;
+ case DDSRT_IFTYPE_WIRED:
+ DDS_LOG(DDS_LC_CONFIG, " wired");
+ break;
+ case DDSRT_IFTYPE_UNKNOWN:
+ break;
+ }
+
+#if defined(__linux) && !LWIP_SOCKET
+ if (ifa->addr->sa_family == AF_PACKET)
+ {
+ /* FIXME: weirdo warning warranted */
+ nn_locator_t *l = &gv->interfaces[gv->n_interfaces].loc;
+ l->kind = NN_LOCATOR_KIND_RAWETH;
+ l->port = NN_LOCATOR_PORT_INVALID;
+ memset(l->address, 0, 10);
+ memcpy(l->address + 10, ((struct sockaddr_ll *)ifa->addr)->sll_addr, 6);
+ }
+ else
+#endif
+ {
+ ddsi_ipaddr_to_loc(gv->m_factory, &gv->interfaces[gv->n_interfaces].loc, ifa->addr, gv->m_factory->m_kind);
+ }
+ ddsi_locator_to_string_no_port(addrbuf, sizeof(addrbuf), &gv->interfaces[gv->n_interfaces].loc);
+ GVLOG (DDS_LC_CONFIG, " %s(", addrbuf);
+
+ if (!(ifa->flags & IFF_MULTICAST) && multicast_override (if_name, &gv->config))
+ {
+ GVLOG (DDS_LC_CONFIG, "assume-mc:");
+ ifa->flags |= IFF_MULTICAST;
+ }
+
+ if (ifa->flags & IFF_LOOPBACK)
+ {
+ /* Loopback device has the lowest priority of every interface
+ available, because the other interfaces at least in principle
+ allow communicating with other machines. */
+ q += 0;
+#if DDSRT_HAVE_IPV6
+ if (!(ifa->addr->sa_family == AF_INET6 && IN6_IS_ADDR_LINKLOCAL (&((struct sockaddr_in6 *)ifa->addr)->sin6_addr)))
+ q += 1;
+#endif
+ }
+ else
+ {
+#if DDSRT_HAVE_IPV6
+ /* We accept link-local IPv6 addresses, but an interface with a
+ link-local address will end up lower in the ordering than one
+ with a global address. When forced to use a link-local
+ address, we restrict ourselves to operating on that one
+ interface only and assume any advertised (incoming) link-local
+ address belongs to that interface. FIXME: this is wrong, and
+ should be changed to tag addresses with the interface over
+ which it was received. But that means proper multi-homing
+ support and has quite an impact in various places, not least of
+ which is the abstraction layer. */
+ if (!(ifa->addr->sa_family == AF_INET6 && IN6_IS_ADDR_LINKLOCAL (&((struct sockaddr_in6 *)ifa->addr)->sin6_addr)))
+ q += 5;
+#endif
+
+ /* We strongly prefer a multicast capable interface, if that's
+ not available anything that's not point-to-point, or else we
+ hope IP routing will take care of the issues. */
+ if (ifa->flags & IFF_MULTICAST)
+ q += 4;
+ else if (!(ifa->flags & IFF_POINTOPOINT))
+ q += 3;
+ else
+ q += 2;
+ }
+
+ GVLOG (DDS_LC_CONFIG, "q%d)", q);
+ if (q == quality) {
+ maxq_list[maxq_count] = gv->n_interfaces;
+ maxq_strlen += 2 + strlen (if_name);
+ maxq_count++;
+ } else if (q > quality) {
+ maxq_list[0] = gv->n_interfaces;
+ maxq_strlen += 2 + strlen (if_name);
+ maxq_count = 1;
+ quality = q;
+ }
+
+ if (ifa->addr->sa_family == AF_INET && ifa->netmask)
+ {
+ ddsi_ipaddr_to_loc(gv->m_factory, &gv->interfaces[gv->n_interfaces].netmask, ifa->netmask, gv->m_factory->m_kind);
+ }
+ else
+ {
+ gv->interfaces[gv->n_interfaces].netmask.kind = gv->m_factory->m_kind;
+ gv->interfaces[gv->n_interfaces].netmask.port = NN_LOCATOR_PORT_INVALID;
+ memset(&gv->interfaces[gv->n_interfaces].netmask.address, 0, sizeof(gv->interfaces[gv->n_interfaces].netmask.address));
+ }
+ gv->interfaces[gv->n_interfaces].mc_capable = ((ifa->flags & IFF_MULTICAST) != 0);
+ gv->interfaces[gv->n_interfaces].mc_flaky = ((ifa->type == DDSRT_IFTYPE_WIFI) != 0);
+ gv->interfaces[gv->n_interfaces].point_to_point = ((ifa->flags & IFF_POINTOPOINT) != 0);
+ gv->interfaces[gv->n_interfaces].if_index = ifa->index;
+ gv->interfaces[gv->n_interfaces].name = ddsrt_strdup (if_name);
+ gv->n_interfaces++;
+ }
+ GVLOG (DDS_LC_CONFIG, "\n");
+ ddsrt_freeifaddrs (ifa_root);
+
+ if (requested_address == NULL)
+ {
+ if (maxq_count > 1)
+ {
+ const int idx = maxq_list[0];
+ char *names;
+ int p;
+ ddsi_locator_to_string_no_port (addrbuf, sizeof(addrbuf), &gv->interfaces[idx].loc);
+ names = ddsrt_malloc (maxq_strlen + 1);
+ p = 0;
+ for (i = 0; i < maxq_count && (size_t) p < maxq_strlen; i++)
+ p += snprintf (names + p, maxq_strlen - (size_t) p, ", %s", gv->interfaces[maxq_list[i]].name);
+ GVWARNING ("using network interface %s (%s) selected arbitrarily from: %s\n",
+ gv->interfaces[idx].name, addrbuf, names + 2);
+ ddsrt_free (names);
+ }
+
+ if (maxq_count > 0)
+ selected_idx = maxq_list[0];
+ else
+ GVERROR ("failed to determine default own IP address\n");
+ }
+ else
+ {
+ nn_locator_t req;
+ /* Presumably an interface name */
+ for (i = 0; i < gv->n_interfaces; i++)
+ {
+ if (strcmp (gv->interfaces[i].name, gv->config.networkAddressString) == 0)
+ break;
+ }
+ if (i < gv->n_interfaces)
+ ; /* got a match */
+ else if (ddsi_locator_from_string(gv, &req, gv->config.networkAddressString, gv->m_factory) != AFSR_OK)
+ ; /* not good, i = gv->n_interfaces, so error handling will kick in */
+ else
+ {
+ /* Try an exact match on the address */
+ for (i = 0; i < gv->n_interfaces; i++)
+ if (compare_locators(&gv->interfaces[i].loc, &req) == 0)
+ break;
+ if (i == gv->n_interfaces && req.kind == NN_LOCATOR_KIND_UDPv4)
+ {
+ /* Try matching on network portion only, where the network
+ portion is based on the netmask of the interface under
+ consideration */
+ for (i = 0; i < gv->n_interfaces; i++)
+ {
+ uint32_t req1, ip1, nm1;
+ memcpy (&req1, req.address + 12, sizeof (req1));
+ memcpy (&ip1, gv->interfaces[i].loc.address + 12, sizeof (ip1));
+ memcpy (&nm1, gv->interfaces[i].netmask.address + 12, sizeof (nm1));
+
+ /* If the host portion of the requested address is non-zero,
+ skip this interface */
+ if (req1 & ~nm1)
+ continue;
+
+ if ((req1 & nm1) == (ip1 & nm1))
+ break;
+ }
+ }
+ }
+
+ if (i < gv->n_interfaces)
+ selected_idx = i;
+ else
+ GVERROR ("%s: does not match an available interface\n", gv->config.networkAddressString);
+ }
+
+ if (selected_idx < 0)
+ return 0;
+ else
+ {
+ gv->ownloc = gv->interfaces[selected_idx].loc;
+ gv->selected_interface = selected_idx;
+ gv->interfaceNo = gv->interfaces[selected_idx].if_index;
+#if DDSRT_HAVE_IPV6
+ if (gv->extloc.kind == NN_LOCATOR_KIND_TCPv6 || gv->extloc.kind == NN_LOCATOR_KIND_UDPv6)
+ {
+ struct sockaddr_in6 addr;
+ memcpy(&addr.sin6_addr, gv->ownloc.address, sizeof(addr.sin6_addr));
+ gv->ipv6_link_local = IN6_IS_ADDR_LINKLOCAL (&addr.sin6_addr) != 0;
+ }
+ else
+ {
+ gv->ipv6_link_local = 0;
+ }
+#endif
+ GVLOG (DDS_LC_CONFIG, "selected interface: %s (index %u)\n",
+ gv->interfaces[selected_idx].name, gv->interfaceNo);
+
+ return 1;
+ }
+}
diff --git a/src/core/ddsi/src/ddsi_raweth.c b/src/core/ddsi/src/ddsi_raweth.c
index 6e0bca2..7237e4a 100644
--- a/src/core/ddsi/src/ddsi_raweth.c
+++ b/src/core/ddsi/src/ddsi_raweth.c
@@ -13,7 +13,6 @@
#include "dds/ddsi/ddsi_raweth.h"
#include "dds/ddsi/ddsi_ipaddr.h"
#include "dds/ddsi/ddsi_mcgroup.h"
-#include "dds/ddsi/q_nwif.h"
#include "dds/ddsi/q_config.h"
#include "dds/ddsi/q_log.h"
#include "dds/ddsi/q_pcap.h"
diff --git a/src/core/ddsi/src/ddsi_tcp.c b/src/core/ddsi/src/ddsi_tcp.c
index 5a87fd1..5cf5b62 100644
--- a/src/core/ddsi/src/ddsi_tcp.c
+++ b/src/core/ddsi/src/ddsi_tcp.c
@@ -21,7 +21,6 @@
#include "dds/ddsi/ddsi_tcp.h"
#include "dds/ddsi/ddsi_ipaddr.h"
#include "dds/ddsrt/avl.h"
-#include "dds/ddsi/q_nwif.h"
#include "dds/ddsi/q_config.h"
#include "dds/ddsi/q_log.h"
#include "dds/ddsi/q_entity.h"
@@ -165,12 +164,94 @@ static void ddsi_tcp_sock_free (const struct ddsrt_log_cfg *logcfg, ddsrt_socket
}
}
-static void ddsi_tcp_sock_new (ddsrt_socket_t *sock, unsigned short port, const struct ddsi_domaingv *gv)
+static dds_return_t ddsi_tcp_sock_new (struct ddsi_tran_factory_tcp * const fact, ddsrt_socket_t *sock, uint16_t port)
{
- if (make_socket (sock, port, true, true, true, gv) != 0)
+ struct ddsi_domaingv * const gv = fact->fact.gv;
+ const int one = 1;
+ dds_return_t rc;
+
{
- *sock = DDSRT_INVALID_SOCKET;
+ int af = AF_UNSPEC;
+ switch (fact->fact.m_kind)
+ {
+ case NN_LOCATOR_KIND_TCPv4:
+ af = AF_INET;
+ break;
+#if DDSRT_HAVE_IPV6
+ case NN_LOCATOR_KIND_TCPv6:
+ af = AF_INET6;
+ break;
+#endif
+ default:
+ DDS_FATAL ("ddsi_tcp_sock_new: unsupported kind %"PRId32"\n", fact->fact.m_kind);
+ }
+ assert (af != AF_UNSPEC);
+ if ((rc = ddsrt_socket (sock, af, SOCK_STREAM, 0)) != DDS_RETCODE_OK)
+ {
+ GVERROR ("ddsi_tcp_sock_new: failed to create socket: %s\n", dds_strretcode (rc));
+ goto fail;
+ }
}
+
+ /* REUSEADDR if we're binding to a port number */
+ if (port && (rc = ddsrt_setsockopt (*sock, SOL_SOCKET, SO_REUSEADDR, (char *) &one, sizeof (one))) != DDS_RETCODE_OK)
+ {
+ GVERROR ("ddsi_tcp_sock_new: failed to enable address reuse: %s\n", dds_strretcode (rc));
+ goto fail_w_socket;
+ }
+
+ {
+ union {
+ struct sockaddr_storage x;
+ struct sockaddr_in a4;
+ struct sockaddr_in6 a6;
+ } socketname;
+ memset (&socketname.x, 0, sizeof (socketname.x));
+ switch (fact->fact.m_kind)
+ {
+ case NN_LOCATOR_KIND_TCPv4:
+ socketname.a4.sin_family = AF_INET;
+ socketname.a4.sin_addr.s_addr = htonl (INADDR_ANY);
+ socketname.a4.sin_port = htons (port);
+ break;
+#if DDSRT_HAVE_IPV6
+ case NN_LOCATOR_KIND_TCPv6:
+ socketname.a4.sin_family = AF_INET6;
+ socketname.a6.sin6_addr = ddsrt_in6addr_any;
+ socketname.a6.sin6_port = htons (port);
+ break;
+#endif
+ default:
+ DDS_FATAL ("ddsi_tcp_sock_new: unsupported kind %"PRId32"\n", fact->fact.m_kind);
+ }
+ if ((rc = ddsrt_bind (*sock, (struct sockaddr *) &socketname, ddsrt_sockaddr_get_size ((struct sockaddr *) &socketname))) != DDS_RETCODE_OK)
+ {
+ GVERROR ("ddsi_tcp_sock_new: failed to bind to ANY:%"PRIu16": %s\n", port, dds_strretcode (rc));
+ goto fail_w_socket;
+ }
+ }
+
+#ifdef SO_NOSIGPIPE
+ if (ddsrt_setsockopt (*sock, SOL_SOCKET, SO_NOSIGPIPE, (char *) &one, sizeof (one)) != DDS_RETCODE_OK)
+ {
+ GVERROR ("ddsi_tcp_sock_new: failed to set NOSIGPIPE: %s\n", dds_strretcode (rc));
+ goto fail_w_socket;
+ }
+#endif
+#ifdef TCP_NODELAY
+ if (gv->config.tcp_nodelay && (rc = ddsrt_setsockopt (*sock, IPPROTO_TCP, TCP_NODELAY, (char*) &one, sizeof (one))) != DDS_RETCODE_OK)
+ {
+ GVERROR ("ddsi_tcp_sock_new: failed to set NODELAY: %s\n", dds_strretcode (rc));
+ goto fail_w_socket;
+ }
+#endif
+ return DDS_RETCODE_OK;
+
+fail_w_socket:
+ ddsrt_close (*sock);
+fail:
+ *sock = DDSRT_INVALID_SOCKET;
+ return rc;
}
static void ddsi_tcp_node_free (void * ptr)
@@ -187,16 +268,12 @@ static void ddsi_tcp_conn_connect (ddsi_tcp_conn_t conn, const ddsrt_msghdr_t *
ddsrt_socket_t sock;
dds_return_t ret;
- ddsi_tcp_sock_new (&sock, 0, conn->m_base.m_base.gv);
- if (sock != DDSRT_INVALID_SOCKET)
+ if (ddsi_tcp_sock_new (fact, &sock, 0) == DDS_RETCODE_OK)
{
/* Attempt to connect, expected that may fail */
-
- do
- {
+ do {
ret = ddsrt_connect(sock, msg->msg_name, msg->msg_namelen);
- }
- while (ret == DDS_RETCODE_INTERRUPTED);
+ } while (ret == DDS_RETCODE_INTERRUPTED);
if (ret != DDS_RETCODE_OK)
{
@@ -855,48 +932,45 @@ static ddsi_tcp_conn_t ddsi_tcp_new_conn (struct ddsi_tran_factory_tcp *fact, dd
static ddsi_tran_listener_t ddsi_tcp_create_listener (ddsi_tran_factory_t fact, uint32_t port, const struct ddsi_tran_qos *qos)
{
- char buff[DDSI_LOCSTRLEN];
- ddsrt_socket_t sock;
- struct sockaddr_storage addr;
- socklen_t addrlen = sizeof (addr);
- ddsi_tcp_listener_t tl = NULL;
struct ddsi_tran_factory_tcp * const fact_tcp = (struct ddsi_tran_factory_tcp *) fact;
+ struct ddsi_domaingv * const gv = fact_tcp->fact.gv;
+ ddsrt_socket_t sock;
(void) qos;
- ddsi_tcp_sock_new (&sock, (unsigned short) port, fact->gv);
+ if (ddsi_tcp_sock_new (fact_tcp, &sock, (unsigned short) port) != DDS_RETCODE_OK)
+ return NULL;
- if (sock != DDSRT_INVALID_SOCKET)
+ dds_return_t ret;
+ ddsi_tcp_listener_t tl = (ddsi_tcp_listener_t) ddsrt_malloc (sizeof (*tl));
+ memset (tl, 0, sizeof (*tl));
+
+ tl->m_sock = sock;
+
+ tl->m_base.m_base.gv = fact->gv;
+ tl->m_base.m_listen_fn = ddsi_tcp_listen;
+ tl->m_base.m_accept_fn = ddsi_tcp_accept;
+ tl->m_base.m_factory = fact;
+
+ tl->m_base.m_base.m_port = get_socket_port (&fact->gv->logconfig, sock);
+ tl->m_base.m_base.m_trantype = DDSI_TRAN_LISTENER;
+ tl->m_base.m_base.m_handle_fn = ddsi_tcp_listener_handle;
+ tl->m_base.m_locator_fn = ddsi_tcp_locator;
+
+ struct sockaddr_storage addr;
+ socklen_t addrlen = sizeof (addr);
+ if ((ret = ddsrt_getsockname (sock, (struct sockaddr *) &addr, &addrlen)) != DDS_RETCODE_OK)
{
- dds_return_t ret;
- tl = (ddsi_tcp_listener_t) ddsrt_malloc (sizeof (*tl));
- memset (tl, 0, sizeof (*tl));
-
- tl->m_sock = sock;
-
- tl->m_base.m_base.gv = fact->gv;
- tl->m_base.m_listen_fn = ddsi_tcp_listen;
- tl->m_base.m_accept_fn = ddsi_tcp_accept;
- tl->m_base.m_factory = fact;
-
- tl->m_base.m_base.m_port = get_socket_port (&fact->gv->logconfig, sock);
- tl->m_base.m_base.m_trantype = DDSI_TRAN_LISTENER;
- tl->m_base.m_base.m_handle_fn = ddsi_tcp_listener_handle;
- tl->m_base.m_locator_fn = ddsi_tcp_locator;
-
- ret = ddsrt_getsockname(sock, (struct sockaddr *)&addr, &addrlen);
- if (ret != DDS_RETCODE_OK) {
- DDS_CERROR (&fact->gv->logconfig, "ddsi_tcp_create_listener: ddsrt_getsockname returned %"PRId32"\n", ret);
- ddsi_tcp_sock_free(&fact->gv->logconfig, sock, NULL);
- ddsrt_free(tl);
- return NULL;
- }
-
- sockaddr_to_string_with_port(fact_tcp, buff, sizeof(buff), (struct sockaddr *)&addr);
- DDS_CLOG (DDS_LC_TCP, &fact->gv->logconfig, "tcp create listener socket %"PRIdSOCK" on %s\n", sock, buff);
+ GVERROR ("ddsi_tcp_create_listener: ddsrt_getsockname returned %"PRId32"\n", ret);
+ ddsi_tcp_sock_free (&fact->gv->logconfig, sock, NULL);
+ ddsrt_free (tl);
+ return NULL;
}
- return tl ? &tl->m_base : NULL;
+ char buff[DDSI_LOCSTRLEN];
+ sockaddr_to_string_with_port (fact_tcp, buff, sizeof (buff), (struct sockaddr *) &addr);
+ GVLOG (DDS_LC_TCP, "tcp create listener socket %"PRIdSOCK" on %s\n", sock, buff);
+ return &tl->m_base;
}
static void ddsi_tcp_conn_delete (ddsi_tcp_conn_t conn)
@@ -948,55 +1022,56 @@ static void ddsi_tcp_release_conn (ddsi_tran_conn_t conn)
static void ddsi_tcp_unblock_listener (ddsi_tran_listener_t listener)
{
+ struct ddsi_tran_factory_tcp * const fact_tcp = (struct ddsi_tran_factory_tcp *) listener->m_factory;
+ struct ddsi_domaingv * const gv = fact_tcp->fact.gv;
ddsi_tcp_listener_t tl = (ddsi_tcp_listener_t) listener;
ddsrt_socket_t sock;
dds_return_t ret;
/* Connect to own listener socket to wake listener from blocking 'accept()' */
- ddsi_tcp_sock_new (&sock, 0, listener->m_base.gv);
- if (sock != DDSRT_INVALID_SOCKET)
- {
- struct sockaddr_storage addr;
- socklen_t addrlen = sizeof (addr);
+ if (ddsi_tcp_sock_new (fact_tcp, &sock, 0) != DDS_RETCODE_OK)
+ goto fail;
- ret = ddsrt_getsockname(tl->m_sock, (struct sockaddr *)&addr, &addrlen);
- if (ret != DDS_RETCODE_OK) {
- DDS_CWARNING (&listener->m_base.gv->logconfig, "tcp failed to get listener address error %"PRId32"\n", ret);
- } else {
- switch (addr.ss_family) {
- case AF_INET:
- {
- struct sockaddr_in *socketname = (struct sockaddr_in*)&addr;
- if (socketname->sin_addr.s_addr == htonl (INADDR_ANY)) {
- socketname->sin_addr.s_addr = htonl (INADDR_LOOPBACK);
- }
- }
- break;
-#if DDSRT_HAVE_IPV6
- case AF_INET6:
- {
- struct sockaddr_in6 *socketname = (struct sockaddr_in6*)&addr;
- if (memcmp(&socketname->sin6_addr, &ddsrt_in6addr_any, sizeof(socketname->sin6_addr)) == 0) {
- socketname->sin6_addr = ddsrt_in6addr_loopback;
- }
- }
- break;
-#endif
- }
- do
- {
- ret = ddsrt_connect(sock, (struct sockaddr *)&addr, ddsrt_sockaddr_get_size((struct sockaddr *)&addr));
- } while (ret == DDS_RETCODE_INTERRUPTED);
- if (ret != DDS_RETCODE_OK)
- {
- struct ddsi_tran_factory_tcp * const fact = (struct ddsi_tran_factory_tcp *) listener->m_factory;
- char buff[DDSI_LOCSTRLEN];
- sockaddr_to_string_with_port(fact, buff, sizeof(buff), (struct sockaddr *)&addr);
- DDS_CWARNING (&listener->m_base.gv->logconfig, "tcp failed to connect to own listener (%s) error %"PRId32"\n", buff, ret);
- }
- }
- ddsi_tcp_sock_free (&listener->m_base.gv->logconfig, sock, NULL);
+ struct sockaddr_storage addr;
+ socklen_t addrlen = sizeof (addr);
+ if ((ret = ddsrt_getsockname (tl->m_sock, (struct sockaddr *) &addr, &addrlen)) != DDS_RETCODE_OK)
+ {
+ GVWARNING ("tcp failed to get listener address error %"PRId32"\n", ret);
+ goto fail_w_socket;
}
+ switch (addr.ss_family)
+ {
+ case AF_INET: {
+ struct sockaddr_in *socketname = (struct sockaddr_in *) &addr;
+ if (socketname->sin_addr.s_addr == htonl (INADDR_ANY))
+ socketname->sin_addr.s_addr = htonl (INADDR_LOOPBACK);
+ break;
+ }
+#if DDSRT_HAVE_IPV6
+ case AF_INET6: {
+ struct sockaddr_in6 *socketname = (struct sockaddr_in6 *) &addr;
+ if (memcmp (&socketname->sin6_addr, &ddsrt_in6addr_any, sizeof (socketname->sin6_addr)) == 0)
+ socketname->sin6_addr = ddsrt_in6addr_loopback;
+ break;
+ }
+#endif
+ }
+
+ do {
+ ret = ddsrt_connect (sock, (struct sockaddr *) &addr, ddsrt_sockaddr_get_size ((struct sockaddr *) &addr));
+ } while (ret == DDS_RETCODE_INTERRUPTED);
+ if (ret != DDS_RETCODE_OK)
+ {
+ struct ddsi_tran_factory_tcp * const fact = (struct ddsi_tran_factory_tcp *) listener->m_factory;
+ char buff[DDSI_LOCSTRLEN];
+ sockaddr_to_string_with_port (fact, buff, sizeof (buff), (struct sockaddr *) &addr);
+ GVWARNING ("tcp failed to connect to own listener (%s) error %"PRId32"\n", buff, ret);
+ }
+
+fail_w_socket:
+ ddsi_tcp_sock_free (&listener->m_base.gv->logconfig, sock, NULL);
+fail:
+ return;
}
static void ddsi_tcp_release_listener (ddsi_tran_listener_t listener)
diff --git a/src/core/ddsi/src/ddsi_udp.c b/src/core/ddsi/src/ddsi_udp.c
index d30d319..382f029 100644
--- a/src/core/ddsi/src/ddsi_udp.c
+++ b/src/core/ddsi/src/ddsi_udp.c
@@ -21,7 +21,6 @@
#include "dds/ddsi/ddsi_udp.h"
#include "dds/ddsi/ddsi_ipaddr.h"
#include "dds/ddsi/ddsi_mcgroup.h"
-#include "dds/ddsi/q_nwif.h"
#include "dds/ddsi/q_config.h"
#include "dds/ddsi/q_log.h"
#include "dds/ddsi/q_pcap.h"
@@ -202,28 +201,189 @@ static int ddsi_udp_conn_locator (ddsi_tran_factory_t fact, ddsi_tran_base_t bas
return ret;
}
-static unsigned short get_socket_port (const struct ddsrt_log_cfg *logcfg, ddsrt_socket_t socket)
+static uint16_t get_socket_port (struct ddsi_domaingv * const gv, ddsrt_socket_t sock)
{
dds_return_t ret;
struct sockaddr_storage addr;
socklen_t addrlen = sizeof (addr);
- ret = ddsrt_getsockname (socket, (struct sockaddr *)&addr, &addrlen);
+ ret = ddsrt_getsockname (sock, (struct sockaddr *)&addr, &addrlen);
if (ret != DDS_RETCODE_OK)
{
- DDS_CERROR (logcfg, "ddsi_udp_get_socket_port: getsockname returned %"PRId32"\n", ret);
+ GVERROR ("ddsi_udp_get_socket_port: getsockname returned %"PRId32"\n", ret);
return 0;
}
- return ddsrt_sockaddr_get_port((struct sockaddr *)&addr);
+ return ddsrt_sockaddr_get_port ((struct sockaddr *)&addr);
+}
+
+static dds_return_t set_dont_route (struct ddsi_domaingv * const gv, ddsrt_socket_t socket, bool ipv6)
+{
+ dds_return_t rc;
+#if DDSRT_HAVE_IPV6
+ if (ipv6)
+ {
+ const unsigned ipv6Flag = 1;
+ if ((rc = ddsrt_setsockopt (socket, IPPROTO_IPV6, IPV6_UNICAST_HOPS, &ipv6Flag, sizeof (ipv6Flag))) != DDS_RETCODE_OK)
+ GVERROR ("ddsi_udp_create_conn: set IPV6_UNICAST_HOPS = 1 failed: %s\n", dds_strretcode (rc));
+ return rc;
+ }
+#endif
+ const int one = 1;
+ if ((rc = ddsrt_setsockopt (socket, SOL_SOCKET, SO_DONTROUTE, (char *) &one, sizeof (one))) != DDS_RETCODE_OK)
+ GVERROR ("ddsi_udp_create_conn: set SO_DONTROUTE = 1 failed: %s\n", dds_strretcode (rc));
+ return rc;
+}
+
+static dds_return_t set_rcvbuf (struct ddsi_domaingv * const gv, ddsrt_socket_t sock, const struct config_maybe_uint32 *min_size)
+{
+ uint32_t ReceiveBufferSize;
+ socklen_t optlen = (socklen_t) sizeof (ReceiveBufferSize);
+ uint32_t socket_min_rcvbuf_size;
+ dds_return_t rc;
+
+ if (min_size->isdefault)
+ socket_min_rcvbuf_size = 1048576;
+ else
+ socket_min_rcvbuf_size = min_size->value;
+ rc = ddsrt_getsockopt (sock, SOL_SOCKET, SO_RCVBUF, (char *) &ReceiveBufferSize, &optlen);
+ if (rc == DDS_RETCODE_BAD_PARAMETER)
+ {
+ /* not all stacks support getting/setting RCVBUF */
+ GVLOG (DDS_LC_CONFIG, "cannot retrieve socket receive buffer size\n");
+ return DDS_RETCODE_OK;
+ }
+
+ if (rc != DDS_RETCODE_OK)
+ {
+ GVERROR ("ddsi_udp_create_conn: get SO_RCVBUF failed: %s\n", dds_strretcode (rc));
+ goto fail;
+ }
+
+ if (ReceiveBufferSize < socket_min_rcvbuf_size)
+ {
+ /* make sure the receive buffersize is at least the minimum required */
+ ReceiveBufferSize = socket_min_rcvbuf_size;
+ (void) ddsrt_setsockopt (sock, SOL_SOCKET, SO_RCVBUF, (const char *) &ReceiveBufferSize, sizeof (ReceiveBufferSize));
+
+ /* We don't check the return code from setsockopt, because some O/Ss tend
+ to silently cap the buffer size. The only way to make sure is to read
+ the option value back and check it is now set correctly. */
+ if ((rc = ddsrt_getsockopt (sock, SOL_SOCKET, SO_RCVBUF, (char *) &ReceiveBufferSize, &optlen)) != DDS_RETCODE_OK)
+ {
+ GVERROR ("ddsi_udp_create_conn: get SO_RCVBUF failed: %s\n", dds_strretcode (rc));
+ goto fail;
+ }
+
+ if (ReceiveBufferSize >= socket_min_rcvbuf_size)
+ GVLOG (DDS_LC_CONFIG, "socket receive buffer size set to %"PRIu32" bytes\n", ReceiveBufferSize);
+ else
+ GVLOG (min_size->isdefault ? DDS_LC_CONFIG : DDS_LC_ERROR,
+ "failed to increase socket receive buffer size to %"PRIu32" bytes, continuing with %"PRIu32" bytes\n",
+ socket_min_rcvbuf_size, ReceiveBufferSize);
+ }
+
+fail:
+ return rc;
+}
+
+static dds_return_t set_sndbuf (struct ddsi_domaingv * const gv, ddsrt_socket_t sock, uint32_t min_size)
+{
+ unsigned SendBufferSize;
+ socklen_t optlen = (socklen_t) sizeof(SendBufferSize);
+ dds_return_t rc;
+
+ rc = ddsrt_getsockopt(sock, SOL_SOCKET, SO_SNDBUF,(char *)&SendBufferSize, &optlen);
+ if (rc == DDS_RETCODE_BAD_PARAMETER)
+ {
+ /* not all stacks support getting/setting SNDBUF */
+ GVLOG (DDS_LC_CONFIG, "cannot retrieve socket send buffer size\n");
+ return DDS_RETCODE_OK;
+ }
+
+ if (rc != DDS_RETCODE_OK)
+ {
+ GVERROR ("ddsi_udp_create_conn: get SO_SNDBUF failed: %s\n", dds_strretcode (rc));
+ goto fail;
+ }
+
+ if (SendBufferSize < min_size)
+ {
+ /* make sure the send buffersize is at least the minimum required */
+ SendBufferSize = min_size;
+ if ((rc = ddsrt_setsockopt (sock, SOL_SOCKET, SO_SNDBUF, (const char *) &SendBufferSize, sizeof (SendBufferSize))) != DDS_RETCODE_OK)
+ {
+ GVERROR ("ddsi_udp_create_conn: set SO_SNDBUF failed: %s\n", dds_strretcode (rc));
+ goto fail;
+ }
+ }
+
+fail:
+ return rc;
+}
+
+static dds_return_t set_mc_options_transmit_ipv6 (struct ddsi_domaingv * const gv, ddsrt_socket_t sock)
+{
+#if DDSRT_HAVE_IPV6
+ const unsigned interfaceNo = gv->interfaceNo;
+ const unsigned ttl = (unsigned) gv->config.multicast_ttl;
+ const unsigned loop = (unsigned) !!gv->config.enableMulticastLoopback;
+ dds_return_t rc;
+ if ((rc = ddsrt_setsockopt (sock, IPPROTO_IPV6, IPV6_MULTICAST_IF, &interfaceNo, sizeof (interfaceNo))) != DDS_RETCODE_OK)
+ GVERROR ("ddsi_udp_create_conn: set IPV6_MULTICAST_IF failed: %s\n", dds_strretcode (rc));
+ else if ((rc = ddsrt_setsockopt (sock, IPPROTO_IPV6, IPV6_MULTICAST_HOPS, (char *) &ttl, sizeof (ttl))) != DDS_RETCODE_OK)
+ GVERROR ("ddsi_udp_create_conn: set IPV6_MULTICAST_HOPS failed: %s\n", dds_strretcode (rc));
+ else if ((rc = ddsrt_setsockopt (sock, IPPROTO_IPV6, IPV6_MULTICAST_LOOP, &loop, sizeof (loop))) != DDS_RETCODE_OK)
+ GVERROR ("ddsi_udp_create_conn: set IPV6_MULTICAST_LOOP failed: %s\n", dds_strretcode (rc));
+ return rc;
+#else
+ (void) gv; (void) sock;
+ return DDS_RETCODE_ERROR;
+#endif
+}
+
+static dds_return_t set_mc_options_transmit_ipv4_if (struct ddsi_domaingv * const gv, ddsrt_socket_t sock)
+{
+#if (defined(__linux) || defined(__APPLE__)) && !LWIP_SOCKET
+ if (gv->config.use_multicast_if_mreqn)
+ {
+ struct ip_mreqn mreqn;
+ memset (&mreqn, 0, sizeof (mreqn));
+ /* looks like imr_multiaddr is not relevant, not sure about imr_address */
+ mreqn.imr_multiaddr.s_addr = htonl (INADDR_ANY);
+ if (gv->config.use_multicast_if_mreqn > 1)
+ memcpy (&mreqn.imr_address.s_addr, gv->ownloc.address + 12, 4);
+ else
+ mreqn.imr_address.s_addr = htonl (INADDR_ANY);
+ mreqn.imr_ifindex = (int) gv->interfaceNo;
+ return ddsrt_setsockopt (sock, IPPROTO_IP, IP_MULTICAST_IF, &mreqn, sizeof (mreqn));
+ }
+#endif
+ return ddsrt_setsockopt (sock, IPPROTO_IP, IP_MULTICAST_IF, gv->ownloc.address + 12, 4);
+}
+
+static dds_return_t set_mc_options_transmit_ipv4 (struct ddsi_domaingv * const gv, ddsrt_socket_t sock)
+{
+ const unsigned char ttl = (unsigned char) gv->config.multicast_ttl;
+ const unsigned char loop = (unsigned char) !!gv->config.enableMulticastLoopback;
+ dds_return_t rc;
+ if ((rc = set_mc_options_transmit_ipv4_if (gv, sock)) != DDS_RETCODE_OK)
+ GVERROR ("ddsi_udp_create_conn: set IP_MULTICAST_IF failed: %s\n", dds_strretcode (rc));
+ else if ((rc = ddsrt_setsockopt (sock, IPPROTO_IP, IP_MULTICAST_TTL, (char *) &ttl, sizeof (ttl))) != DDS_RETCODE_OK)
+ GVERROR ("ddsi_udp_create_conn: set IP_MULTICAST_TTL failed: %s\n", dds_strretcode (rc));
+ else if ((rc = ddsrt_setsockopt (sock, IPPROTO_IP, IP_MULTICAST_LOOP, &loop, sizeof (loop))) != DDS_RETCODE_OK)
+ GVERROR ("ddsi_udp_create_conn: set IP_MULTICAST_LOOP failed: %s\n", dds_strretcode (rc));
+ return rc;
}
static ddsi_tran_conn_t ddsi_udp_create_conn (ddsi_tran_factory_t fact, uint32_t port, const ddsi_tran_qos_t *qos)
{
- int ret;
+ struct ddsi_domaingv * const gv = fact->gv;
+ const int one = 1;
+
+ dds_return_t rc;
ddsrt_socket_t sock;
- ddsi_udp_conn_t uc = NULL;
- bool reuse_addr = false, bind_to_any = false;
+ bool reuse_addr = false, bind_to_any = false, ipv6 = false;
const char *purpose_str = NULL;
switch (qos->m_purpose)
@@ -246,57 +406,134 @@ static ddsi_tran_conn_t ddsi_udp_create_conn (ddsi_tran_factory_t fact, uint32_t
}
assert (purpose_str != NULL);
- /* If port is zero, need to create dynamic port */
-
- ret = make_socket (&sock, (unsigned short) port, false, reuse_addr, bind_to_any, fact->gv);
-
- if (ret == 0)
{
- uc = (ddsi_udp_conn_t) ddsrt_malloc (sizeof (*uc));
- memset (uc, 0, sizeof (*uc));
-
- uc->m_sock = sock;
- uc->m_diffserv = qos->m_diffserv;
-#if defined _WIN32 && !defined WINCE
- uc->m_sockEvent = WSACreateEvent();
- WSAEventSelect(uc->m_sock, uc->m_sockEvent, FD_WRITE);
+ int af = AF_UNSPEC;
+ switch (fact->m_kind)
+ {
+ case NN_LOCATOR_KIND_UDPv4:
+ af = AF_INET;
+ break;
+#if DDSRT_HAVE_IPV6
+ case NN_LOCATOR_KIND_UDPv6:
+ af = AF_INET6;
+ ipv6 = true;
+ break;
#endif
+ default:
+ DDS_FATAL ("ddsi_udp_create_conn: unsupported kind %"PRId32"\n", fact->m_kind);
+ }
+ assert (af != AF_UNSPEC);
+ if ((rc = ddsrt_socket (&sock, af, SOCK_DGRAM, 0)) != DDS_RETCODE_OK)
+ {
+ GVERROR ("ddsi_udp_create_conn: failed to create socket: %s\n", dds_strretcode (rc));
+ goto fail;
+ }
+ }
- ddsi_factory_conn_init (fact, &uc->m_base);
- uc->m_base.m_base.m_port = get_socket_port (&fact->gv->logconfig, sock);
- uc->m_base.m_base.m_trantype = DDSI_TRAN_CONN;
- uc->m_base.m_base.m_multicast = (qos->m_purpose == DDSI_TRAN_QOS_RECV_MC);
- uc->m_base.m_base.m_handle_fn = ddsi_udp_conn_handle;
+ if (reuse_addr && (rc = ddsrt_setsockopt (sock, SOL_SOCKET, SO_REUSEADDR, (char *) &one, sizeof (one))) != DDS_RETCODE_OK)
+ {
+ GVERROR ("ddsi_udp_create_conn: failed to enable address reuse: %s\n", dds_strretcode (rc));
+ if (rc != DDS_RETCODE_BAD_PARAMETER)
+ {
+ /* There must at some point have been an implementation that refused to do SO_REUSEADDR, but I
+ don't know which */
+ goto fail_w_socket;
+ }
+ }
- uc->m_base.m_read_fn = ddsi_udp_conn_read;
- uc->m_base.m_write_fn = ddsi_udp_conn_write;
- uc->m_base.m_disable_multiplexing_fn = ddsi_udp_disable_multiplexing;
- uc->m_base.m_locator_fn = ddsi_udp_conn_locator;
+ if ((rc = set_rcvbuf (gv, sock, &gv->config.socket_min_rcvbuf_size)) != DDS_RETCODE_OK)
+ goto fail_w_socket;
+ if ((rc = set_sndbuf (gv, sock, gv->config.socket_min_sndbuf_size)) != DDS_RETCODE_OK)
+ goto fail_w_socket;
+ if (gv->config.dontRoute && (rc = set_dont_route (gv, sock, ipv6)) != DDS_RETCODE_OK)
+ goto fail_w_socket;
+
+ {
+ union {
+ struct sockaddr_storage x;
+ struct sockaddr_in a4;
+ struct sockaddr_in6 a6;
+ } socketname;
+ nn_locator_t ownloc_w_port = gv->ownloc;
+ assert (ownloc_w_port.port == NN_LOCATOR_PORT_INVALID);
+ if (port) {
+ /* PORT_INVALID maps to 0 in ipaddr_from_loc */
+ ownloc_w_port.port = port;
+ }
+ ddsi_ipaddr_from_loc (&socketname.x, &ownloc_w_port);
+ if (bind_to_any)
+ {
+ switch (fact->m_kind)
+ {
+ case NN_LOCATOR_KIND_UDPv4:
+ socketname.a4.sin_addr.s_addr = htonl (INADDR_ANY);
+ break;
+#if DDSRT_HAVE_IPV6
+ case NN_LOCATOR_KIND_UDPv6:
+ socketname.a6.sin6_addr = ddsrt_in6addr_any;
+ break;
+#endif
+ default:
+ DDS_FATAL ("ddsi_udp_create_conn: unsupported kind %"PRId32"\n", fact->m_kind);
+ }
+ }
+ if ((rc = ddsrt_bind (sock, (struct sockaddr *) &socketname, ddsrt_sockaddr_get_size ((struct sockaddr *) &socketname))) != DDS_RETCODE_OK)
+ {
+ char buf[DDSI_LOCATORSTRLEN];
+ if (bind_to_any)
+ snprintf (buf, sizeof (buf), "ANY:%"PRIu32, port);
+ else
+ ddsi_locator_to_string (buf, sizeof (buf), &ownloc_w_port);
+ GVERROR ("ddsi_udp_create_conn: failed to bind to %s: %s\n", buf, dds_strretcode (rc));
+ goto fail_w_socket;
+ }
+ }
+
+ rc = ipv6 ? set_mc_options_transmit_ipv6 (gv, sock) : set_mc_options_transmit_ipv4 (gv, sock);
+ if (rc != DDS_RETCODE_OK)
+ goto fail_w_socket;
- DDS_CTRACE (&fact->gv->logconfig,
- "ddsi_udp_create_conn %s socket %"PRIdSOCK" port %"PRIu32"\n",
- purpose_str,
- uc->m_sock,
- uc->m_base.m_base.m_port);
#ifdef DDSI_INCLUDE_NETWORK_CHANNELS
- if ((uc->m_diffserv != 0) && (fact->m_kind == NN_LOCATOR_KIND_UDPv4))
- {
- dds_return_t rc;
- rc = ddsrt_setsockopt(sock, IPPROTO_IP, IP_TOS, (char *)&uc->m_diffserv, sizeof(uc->m_diffserv));
- if (rc != DDS_RETCODE_OK)
- DDS_CERROR (fact->gv->logconfig, "ddsi_udp_create_conn: set diffserv retcode %"PRId32"\n", rc);
- }
-#endif
- }
- else
+ if ((qos->m_diffserv != 0) && (fact->m_kind == NN_LOCATOR_KIND_UDPv4))
{
- if (fact->gv->config.participantIndex != PARTICIPANT_INDEX_AUTO)
+ if ((rc = ddsrt_setsockopt (sock, IPPROTO_IP, IP_TOS, (char *) &qos->m_diffserv, sizeof (qos->m_diffserv))) != DDS_RETCODE_OK)
{
- DDS_CERROR (&fact->gv->logconfig, "UDP make_socket failed for %s port %"PRIu32"\n", purpose_str, port);
+ GVERROR ("ddsi_udp_create_conn: set diffserv retcode %"PRId32"\n", rc);
+ goto fail_w_socket;
}
}
+#endif
- return uc ? &uc->m_base : NULL;
+ ddsi_udp_conn_t uc = (ddsi_udp_conn_t) ddsrt_malloc (sizeof (*uc));
+ memset (uc, 0, sizeof (*uc));
+
+ uc->m_sock = sock;
+ uc->m_diffserv = qos->m_diffserv;
+#if defined _WIN32 && !defined WINCE
+ uc->m_sockEvent = WSACreateEvent();
+ WSAEventSelect(uc->m_sock, uc->m_sockEvent, FD_WRITE);
+#endif
+
+ ddsi_factory_conn_init (fact, &uc->m_base);
+ uc->m_base.m_base.m_port = get_socket_port (gv, sock);
+ uc->m_base.m_base.m_trantype = DDSI_TRAN_CONN;
+ uc->m_base.m_base.m_multicast = (qos->m_purpose == DDSI_TRAN_QOS_RECV_MC);
+ uc->m_base.m_base.m_handle_fn = ddsi_udp_conn_handle;
+
+ uc->m_base.m_read_fn = ddsi_udp_conn_read;
+ uc->m_base.m_write_fn = ddsi_udp_conn_write;
+ uc->m_base.m_disable_multiplexing_fn = ddsi_udp_disable_multiplexing;
+ uc->m_base.m_locator_fn = ddsi_udp_conn_locator;
+
+ GVTRACE ("ddsi_udp_create_conn %s socket %"PRIdSOCK" port %"PRIu32"\n", purpose_str, uc->m_sock, uc->m_base.m_base.m_port);
+ return &uc->m_base;
+
+fail_w_socket:
+ ddsrt_close (sock);
+fail:
+ if (fact->gv->config.participantIndex != PARTICIPANT_INDEX_AUTO)
+ GVERROR ("ddsi_udp_create_conn: failed for %s port %"PRIu32"\n", purpose_str, port);
+ return NULL;
}
static int joinleave_asm_mcgroup (ddsrt_socket_t socket, int join, const nn_locator_t *mcloc, const struct nn_interface *interf)
diff --git a/src/core/ddsi/src/q_config.c b/src/core/ddsi/src/q_config.c
index c8d0e40..7165bbe 100644
--- a/src/core/ddsi/src/q_config.c
+++ b/src/core/ddsi/src/q_config.c
@@ -30,7 +30,6 @@
#include "dds/ddsi/q_unused.h"
#include "dds/ddsi/q_misc.h"
#include "dds/ddsi/q_addrset.h"
-#include "dds/ddsi/q_nwif.h"
#include "dds/ddsrt/xmlparser.h"
diff --git a/src/core/ddsi/src/q_init.c b/src/core/ddsi/src/q_init.c
index 226d75d..1a1a0cb 100644
--- a/src/core/ddsi/src/q_init.c
+++ b/src/core/ddsi/src/q_init.c
@@ -41,7 +41,7 @@
#include "dds/ddsi/q_lease.h"
#include "dds/ddsi/q_gc.h"
#include "dds/ddsi/q_entity.h"
-#include "dds/ddsi/q_nwif.h"
+#include "dds/ddsi/ddsi_ownip.h"
#include "dds/ddsi/ddsi_domaingv.h"
#include "dds/ddsi/q_xmsg.h"
#include "dds/ddsi/q_receive.h"
diff --git a/src/core/ddsi/src/q_nwif.c b/src/core/ddsi/src/q_nwif.c
deleted file mode 100644
index 9bbbb5c..0000000
--- a/src/core/ddsi/src/q_nwif.c
+++ /dev/null
@@ -1,687 +0,0 @@
-/*
- * Copyright(c) 2006 to 2018 ADLINK Technology Limited and others
- *
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v. 2.0 which is available at
- * http://www.eclipse.org/legal/epl-2.0, or the Eclipse Distribution License
- * v. 1.0 which is available at
- * http://www.eclipse.org/org/documents/edl-v10.php.
- *
- * SPDX-License-Identifier: EPL-2.0 OR BSD-3-Clause
- */
-#include
-#include
-#include
-#include
-#include
-
-#include "dds/ddsrt/ifaddrs.h"
-#include "dds/ddsrt/heap.h"
-#include "dds/ddsrt/md5.h"
-#include "dds/ddsrt/string.h"
-#include "dds/ddsrt/sockets.h"
-
-#include "dds/ddsi/q_log.h"
-#include "dds/ddsi/q_nwif.h"
-
-#include "dds/ddsi/ddsi_domaingv.h"
-#include "dds/ddsi/q_config.h"
-#include "dds/ddsi/q_unused.h"
-#include "dds/ddsi/q_misc.h"
-#include "dds/ddsi/q_addrset.h" /* unspec locator */
-#include "dds/ddsi/q_feature_check.h"
-#include "dds/ddsi/ddsi_ipaddr.h"
-#include "dds/ddsrt/avl.h"
-
-static void print_sockerror (const struct ddsrt_log_cfg *logcfg, const char *msg)
-{
- DDS_CERROR (logcfg, "SOCKET %s\n", msg);
-}
-
-uint32_t locator_to_hopefully_unique_uint32 (const nn_locator_t *src)
-{
- uint32_t id = 0;
- if (src->kind == NN_LOCATOR_KIND_UDPv4 || src->kind == NN_LOCATOR_KIND_TCPv4)
- memcpy (&id, src->address + 12, sizeof (id));
- else
- {
-#if DDSRT_HAVE_IPV6
- ddsrt_md5_state_t st;
- ddsrt_md5_byte_t digest[16];
- ddsrt_md5_init (&st);
- ddsrt_md5_append (&st, (const ddsrt_md5_byte_t *) ((const struct sockaddr_in6 *) src)->sin6_addr.s6_addr, 16);
- ddsrt_md5_finish (&st, digest);
- memcpy (&id, digest, sizeof (id));
-#else
- DDS_FATAL ("IPv6 unavailable\n");
-#endif
- }
- return id;
-}
-
-#ifdef DDSI_INCLUDE_NETWORK_CHANNELS
-void set_socket_diffserv (const struct ddsrt_log_cfg *logcfg, ddsrt_socket_t sock, int diffserv)
-{
- if (ddsrt_setsockopt (sock, IPPROTO_IP, IP_TOS, (char*) &diffserv, sizeof (diffserv)) != DDS_RETCODE_OK)
- {
- print_sockerror (logcfg, "IP_TOS");
- }
-}
-#endif
-
-#ifdef SO_NOSIGPIPE
-static void set_socket_nosigpipe (const struct ddsrt_log_cfg *logcfg, ddsrt_socket_t sock)
-{
- int val = 1;
- if (ddsrt_setsockopt (sock, SOL_SOCKET, SO_NOSIGPIPE, (char*) &val, sizeof (val)) != DDS_RETCODE_OK)
- {
- print_sockerror (logcfg, "SO_NOSIGPIPE");
- }
-}
-#endif
-
-#ifdef TCP_NODELAY
-static void set_socket_nodelay (const struct ddsrt_log_cfg *logcfg, ddsrt_socket_t sock)
-{
- int val = 1;
- if (ddsrt_setsockopt (sock, IPPROTO_TCP, TCP_NODELAY, (char*) &val, sizeof (val)) != DDS_RETCODE_OK)
- {
- print_sockerror (logcfg, "TCP_NODELAY");
- }
-}
-#endif
-
-static int set_rcvbuf (const struct ddsrt_log_cfg *logcfg, ddsrt_socket_t socket, const struct config_maybe_uint32 *min_size)
-{
- uint32_t ReceiveBufferSize;
- socklen_t optlen = (socklen_t) sizeof (ReceiveBufferSize);
- uint32_t socket_min_rcvbuf_size;
- dds_return_t rc;
- if (min_size->isdefault)
- socket_min_rcvbuf_size = 1048576;
- else
- socket_min_rcvbuf_size = min_size->value;
- rc = ddsrt_getsockopt(
- socket, SOL_SOCKET, SO_RCVBUF, (char *) &ReceiveBufferSize, &optlen);
- /* TCP/IP stack may not support SO_RCVBUF. */
- if (rc == DDS_RETCODE_BAD_PARAMETER) {
- DDS_CLOG (DDS_LC_CONFIG, logcfg, "cannot retrieve socket receive buffer size\n");
- return 0;
- } else if (rc != DDS_RETCODE_OK) {
- print_sockerror (logcfg, "get SO_RCVBUF");
- return -2;
- }
- if (ReceiveBufferSize < socket_min_rcvbuf_size)
- {
- /* make sure the receive buffersize is at least the minimum required */
- ReceiveBufferSize = socket_min_rcvbuf_size;
- (void) ddsrt_setsockopt (socket, SOL_SOCKET, SO_RCVBUF, (const char *) &ReceiveBufferSize, sizeof (ReceiveBufferSize));
-
- /* We don't check the return code from setsockopt, because some O/Ss tend
- to silently cap the buffer size. The only way to make sure is to read
- the option value back and check it is now set correctly. */
- if (ddsrt_getsockopt (socket, SOL_SOCKET, SO_RCVBUF, (char *) &ReceiveBufferSize, &optlen) != DDS_RETCODE_OK)
- {
- print_sockerror (logcfg, "get SO_RCVBUF");
- return -2;
- }
- if (ReceiveBufferSize < socket_min_rcvbuf_size)
- {
- /* NN_ERROR does more than just DDS_ERROR(), hence the duplication */
- DDS_CLOG (min_size->isdefault ? DDS_LC_CONFIG : DDS_LC_ERROR, logcfg,
- "failed to increase socket receive buffer size to %"PRIu32" bytes, continuing with %"PRIu32" bytes\n",
- socket_min_rcvbuf_size, ReceiveBufferSize);
- }
- else
- {
- DDS_CLOG (DDS_LC_CONFIG, logcfg, "socket receive buffer size set to %"PRIu32" bytes\n", ReceiveBufferSize);
- }
- }
- return 0;
-}
-
-static int set_sndbuf (const struct ddsrt_log_cfg *logcfg, ddsrt_socket_t socket, uint32_t min_size)
-{
- unsigned SendBufferSize;
- socklen_t optlen = (socklen_t) sizeof(SendBufferSize);
- dds_return_t rc;
- rc = ddsrt_getsockopt(
- socket, SOL_SOCKET, SO_SNDBUF,(char *)&SendBufferSize, &optlen);
- if (rc == DDS_RETCODE_BAD_PARAMETER) {
- DDS_CLOG (DDS_LC_CONFIG, logcfg, "cannot retrieve socket send buffer size\n");
- return 0;
- } else if (rc != DDS_RETCODE_OK) {
- print_sockerror (logcfg, "get SO_SNDBUF");
- return -2;
- }
- if (SendBufferSize < min_size )
- {
- /* make sure the send buffersize is at least the minimum required */
- SendBufferSize = min_size;
- if (ddsrt_setsockopt (socket, SOL_SOCKET, SO_SNDBUF, (const char *)&SendBufferSize, sizeof (SendBufferSize)) != DDS_RETCODE_OK)
- {
- print_sockerror (logcfg, "SO_SNDBUF");
- return -2;
- }
- }
- return 0;
-}
-
-static int maybe_set_dont_route (const struct ddsrt_log_cfg *logcfg, ddsrt_socket_t socket, const struct config *config)
-{
- if (config->dontRoute)
- {
-#if DDSRT_HAVE_IPV6
- if (config->transport_selector == TRANS_TCP6 || config->transport_selector == TRANS_UDP6)
- {
- unsigned ipv6Flag = 1;
- if (ddsrt_setsockopt (socket, IPPROTO_IPV6, IPV6_UNICAST_HOPS, &ipv6Flag, sizeof (ipv6Flag)) != DDS_RETCODE_OK)
- {
- print_sockerror (logcfg, "IPV6_UNICAST_HOPS");
- return -2;
- }
- }
- else
-#endif
- if (config->transport_selector == TRANS_TCP || config->transport_selector == TRANS_UDP)
- {
- int one = 1;
- if (ddsrt_setsockopt (socket, SOL_SOCKET, SO_DONTROUTE, (char *) &one, sizeof (one)) != DDS_RETCODE_OK)
- {
- print_sockerror (logcfg, "SO_DONTROUTE");
- return -2;
- }
- }
- }
- return 0;
-}
-
-static int set_reuse_options (const struct ddsrt_log_cfg *logcfg, ddsrt_socket_t socket)
-{
- /* Set REUSEADDR (if available on platform) for
- multicast sockets, leave unicast sockets alone. */
- int one = 1;
- dds_return_t rc = ddsrt_setsockopt (
- socket, SOL_SOCKET, SO_REUSEADDR, (char *) &one, sizeof (one));
- if (rc == DDS_RETCODE_BAD_PARAMETER) {
- DDS_CLOG (DDS_LC_CONFIG, logcfg, "cannot enable address reuse on socket\n");
- return 0;
- } else if (rc != DDS_RETCODE_OK) {
- print_sockerror (logcfg, "SO_REUSEADDR");
- return -2;
- }
-
- return 0;
-}
-
-static int bind_socket (ddsrt_socket_t socket, unsigned short port, bool bind_to_any, const struct ddsi_domaingv *gv)
-{
- dds_return_t rc = DDS_RETCODE_ERROR;
-
-#if DDSRT_HAVE_IPV6
- if (gv->config.transport_selector == TRANS_TCP6 || gv->config.transport_selector == TRANS_UDP6)
- {
- union {
- struct sockaddr_storage x;
- struct sockaddr_in6 a;
- } socketname;
- ddsi_ipaddr_from_loc (&socketname.x, &gv->ownloc);
- if (bind_to_any)
- socketname.a.sin6_addr = ddsrt_in6addr_any;
- socketname.a.sin6_port = htons (port);
- if (IN6_IS_ADDR_LINKLOCAL (&socketname.a.sin6_addr)) {
- socketname.a.sin6_scope_id = gv->interfaceNo;
- }
- rc = ddsrt_bind (socket, (struct sockaddr *) &socketname.a, sizeof (socketname.a));
- }
- else
-#endif
- if (gv->config.transport_selector == TRANS_TCP || gv->config.transport_selector == TRANS_UDP)
- {
- union {
- struct sockaddr_storage x;
- struct sockaddr_in a;
- } socketname;
- ddsi_ipaddr_from_loc (&socketname.x, &gv->ownloc);
- if (bind_to_any)
- socketname.a.sin_addr.s_addr = htonl (INADDR_ANY);
- socketname.a.sin_port = htons (port);
- rc = ddsrt_bind (socket, (struct sockaddr *) &socketname.a, sizeof (socketname.a));
- }
- if (rc != DDS_RETCODE_OK && rc != DDS_RETCODE_PRECONDITION_NOT_MET)
- {
- print_sockerror (&gv->logconfig, "bind");
- }
- return (rc == DDS_RETCODE_OK) ? 0 : -1;
-}
-
-#if DDSRT_HAVE_IPV6
-static int set_mc_options_transmit_ipv6 (ddsrt_socket_t socket, const struct ddsi_domaingv *gv)
-{
- unsigned interfaceNo = gv->interfaceNo;
- unsigned ttl = (unsigned) gv->config.multicast_ttl;
- unsigned loop;
- if (ddsrt_setsockopt (socket, IPPROTO_IPV6, IPV6_MULTICAST_IF, &interfaceNo, sizeof (interfaceNo)) != DDS_RETCODE_OK)
- {
- print_sockerror (&gv->logconfig, "IPV6_MULTICAST_IF");
- return -2;
- }
- if (ddsrt_setsockopt (socket, IPPROTO_IPV6, IPV6_MULTICAST_HOPS, (char *) &ttl, sizeof (ttl)) != DDS_RETCODE_OK)
- {
- print_sockerror (&gv->logconfig, "IPV6_MULTICAST_HOPS");
- return -2;
- }
- loop = (unsigned) !!gv->config.enableMulticastLoopback;
- if (ddsrt_setsockopt (socket, IPPROTO_IPV6, IPV6_MULTICAST_LOOP, &loop, sizeof (loop)) != DDS_RETCODE_OK)
- {
- print_sockerror (&gv->logconfig, "IPV6_MULTICAST_LOOP");
- return -2;
- }
- return 0;
-}
-#endif
-
-static int set_mc_options_transmit_ipv4 (ddsrt_socket_t socket, const struct ddsi_domaingv *gv)
-{
- unsigned char ttl = (unsigned char) gv->config.multicast_ttl;
- unsigned char loop;
- dds_return_t ret;
-
-#if (defined(__linux) || defined(__APPLE__)) && !LWIP_SOCKET
- if (gv->config.use_multicast_if_mreqn)
- {
- struct ip_mreqn mreqn;
- memset (&mreqn, 0, sizeof (mreqn));
- /* looks like imr_multiaddr is not relevant, not sure about imr_address */
- mreqn.imr_multiaddr.s_addr = htonl (INADDR_ANY);
- if (gv->config.use_multicast_if_mreqn > 1)
- memcpy (&mreqn.imr_address.s_addr, gv->ownloc.address + 12, 4);
- else
- mreqn.imr_address.s_addr = htonl (INADDR_ANY);
- mreqn.imr_ifindex = (int) gv->interfaceNo;
- ret = ddsrt_setsockopt (socket, IPPROTO_IP, IP_MULTICAST_IF, &mreqn, sizeof (mreqn));
- }
- else
-#endif
- {
- ret = ddsrt_setsockopt (socket, IPPROTO_IP, IP_MULTICAST_IF, gv->ownloc.address + 12, 4);
- }
- if (ret != DDS_RETCODE_OK)
- {
- print_sockerror (&gv->logconfig, "IP_MULTICAST_IF");
- return -2;
- }
- if (ddsrt_setsockopt (socket, IPPROTO_IP, IP_MULTICAST_TTL, (char *) &ttl, sizeof (ttl)) != DDS_RETCODE_OK)
- {
- print_sockerror (&gv->logconfig, "IP_MULICAST_TTL");
- return -2;
- }
- loop = (unsigned char) gv->config.enableMulticastLoopback;
-
- if (ddsrt_setsockopt (socket, IPPROTO_IP, IP_MULTICAST_LOOP, &loop, sizeof (loop)) != DDS_RETCODE_OK)
- {
- print_sockerror (&gv->logconfig, "IP_MULTICAST_LOOP");
- return -2;
- }
- return 0;
-}
-
-static int set_mc_options_transmit (ddsrt_socket_t socket, const struct ddsi_domaingv *gv)
-{
-#if DDSRT_HAVE_IPV6
- if (gv->config.transport_selector == TRANS_TCP6 || gv->config.transport_selector == TRANS_UDP6)
- {
- return set_mc_options_transmit_ipv6 (socket, gv);
- }
- else
-#endif
- if (gv->config.transport_selector == TRANS_TCP || gv->config.transport_selector == TRANS_UDP)
- {
- return set_mc_options_transmit_ipv4 (socket, gv);
- }
- else
- {
- return -2;
- }
-}
-
-int make_socket (ddsrt_socket_t *sock, uint16_t port, bool stream, bool reuse_addr, bool bind_to_any, const struct ddsi_domaingv *gv)
-{
- /* FIXME: this stuff has to move to the transports */
- int rc = -2;
- dds_return_t ret;
-
-#if DDSRT_HAVE_IPV6
- if (gv->config.transport_selector == TRANS_TCP6 || gv->config.transport_selector == TRANS_UDP6)
- {
- ret = ddsrt_socket(sock, AF_INET6, stream ? SOCK_STREAM : SOCK_DGRAM, 0);
- }
- else
-#endif
- if (gv->config.transport_selector == TRANS_TCP || gv->config.transport_selector == TRANS_UDP)
- {
- ret = ddsrt_socket(sock, AF_INET, stream ? SOCK_STREAM : SOCK_DGRAM, 0);
- }
- else
- {
- return -2;
- }
-
- if (ret != DDS_RETCODE_OK)
- {
- print_sockerror (&gv->logconfig, "socket");
- return rc;
- }
-
- if (port && reuse_addr && ((rc = set_reuse_options (&gv->logconfig, *sock)) < 0))
- {
- goto fail;
- }
-
- if ((rc = set_rcvbuf (&gv->logconfig, *sock, &gv->config.socket_min_rcvbuf_size) < 0) ||
- (rc = set_sndbuf (&gv->logconfig, *sock, gv->config.socket_min_sndbuf_size) < 0) ||
- ((rc = maybe_set_dont_route (&gv->logconfig, *sock, &gv->config)) < 0) ||
- ((rc = bind_socket (*sock, port, bind_to_any, gv)) < 0))
- {
- goto fail;
- }
-
- if (! stream)
- {
- if ((rc = set_mc_options_transmit (*sock, gv)) < 0)
- {
- goto fail;
- }
- }
-
- if (stream)
- {
-#ifdef SO_NOSIGPIPE
- set_socket_nosigpipe (&gv->logconfig, *sock);
-#endif
-#ifdef TCP_NODELAY
- if (gv->config.tcp_nodelay)
- {
- set_socket_nodelay (&gv->logconfig, *sock);
- }
-#endif
- }
-
- return 0;
-
-fail:
-
- ddsrt_close(*sock);
- *sock = DDSRT_INVALID_SOCKET;
- return rc;
-}
-
-static int multicast_override(const char *ifname, const struct config *config)
-{
- char *copy = ddsrt_strdup (config->assumeMulticastCapable), *cursor = copy, *tok;
- int match = 0;
- if (copy != NULL)
- {
- while ((tok = ddsrt_strsep (&cursor, ",")) != NULL)
- {
- if (ddsi2_patmatch (tok, ifname))
- match = 1;
- }
- }
- ddsrt_free (copy);
- return match;
-}
-
-#ifdef __linux
-/* FIMXE: HACK HACK */
-#include
-#endif
-
-int find_own_ip (struct ddsi_domaingv *gv, const char *requested_address)
-{
- const char *sep = " ";
- char last_if_name[80] = "";
- int quality = -1;
- int i;
- ddsrt_ifaddrs_t *ifa, *ifa_root = NULL;
- int maxq_list[MAX_INTERFACES];
- int maxq_count = 0;
- size_t maxq_strlen = 0;
- int selected_idx = -1;
- char addrbuf[DDSI_LOCSTRLEN];
-
- GVLOG (DDS_LC_CONFIG, "interfaces:");
-
- {
- int ret;
- ret = ddsi_enumerate_interfaces(gv->m_factory, gv->config.transport_selector, &ifa_root);
- if (ret < 0) {
- GVERROR ("ddsi_enumerate_interfaces(%s): %d\n", gv->m_factory->m_typename, ret);
- return 0;
- }
- }
-
- gv->n_interfaces = 0;
- last_if_name[0] = 0;
- for (ifa = ifa_root; ifa != NULL; ifa = ifa->next)
- {
- char if_name[sizeof (last_if_name)];
- int q = 0;
-
- (void) ddsrt_strlcpy(if_name, ifa->name, sizeof(if_name));
-
- if (strcmp (if_name, last_if_name))
- GVLOG (DDS_LC_CONFIG, "%s%s", sep, if_name);
- (void) ddsrt_strlcpy(last_if_name, if_name, sizeof(last_if_name));
-
- /* interface must be up */
- if ((ifa->flags & IFF_UP) == 0) {
- GVLOG (DDS_LC_CONFIG, " (interface down)");
- continue;
- } else if (ddsrt_sockaddr_isunspecified(ifa->addr)) {
- GVLOG (DDS_LC_CONFIG, " (address unspecified)");
- continue;
- }
-
- switch (ifa->type)
- {
- case DDSRT_IFTYPE_WIFI:
- DDS_LOG(DDS_LC_CONFIG, " wireless");
- break;
- case DDSRT_IFTYPE_WIRED:
- DDS_LOG(DDS_LC_CONFIG, " wired");
- break;
- case DDSRT_IFTYPE_UNKNOWN:
- break;
- }
-
-#if defined(__linux) && !LWIP_SOCKET
- if (ifa->addr->sa_family == AF_PACKET)
- {
- /* FIXME: weirdo warning warranted */
- nn_locator_t *l = &gv->interfaces[gv->n_interfaces].loc;
- l->kind = NN_LOCATOR_KIND_RAWETH;
- l->port = NN_LOCATOR_PORT_INVALID;
- memset(l->address, 0, 10);
- memcpy(l->address + 10, ((struct sockaddr_ll *)ifa->addr)->sll_addr, 6);
- }
- else
-#endif
- {
- ddsi_ipaddr_to_loc(gv->m_factory, &gv->interfaces[gv->n_interfaces].loc, ifa->addr, gv->m_factory->m_kind);
- }
- ddsi_locator_to_string_no_port(addrbuf, sizeof(addrbuf), &gv->interfaces[gv->n_interfaces].loc);
- GVLOG (DDS_LC_CONFIG, " %s(", addrbuf);
-
- if (!(ifa->flags & IFF_MULTICAST) && multicast_override (if_name, &gv->config))
- {
- GVLOG (DDS_LC_CONFIG, "assume-mc:");
- ifa->flags |= IFF_MULTICAST;
- }
-
- if (ifa->flags & IFF_LOOPBACK)
- {
- /* Loopback device has the lowest priority of every interface
- available, because the other interfaces at least in principle
- allow communicating with other machines. */
- q += 0;
-#if DDSRT_HAVE_IPV6
- if (!(ifa->addr->sa_family == AF_INET6 && IN6_IS_ADDR_LINKLOCAL (&((struct sockaddr_in6 *)ifa->addr)->sin6_addr)))
- q += 1;
-#endif
- }
- else
- {
-#if DDSRT_HAVE_IPV6
- /* We accept link-local IPv6 addresses, but an interface with a
- link-local address will end up lower in the ordering than one
- with a global address. When forced to use a link-local
- address, we restrict ourselves to operating on that one
- interface only and assume any advertised (incoming) link-local
- address belongs to that interface. FIXME: this is wrong, and
- should be changed to tag addresses with the interface over
- which it was received. But that means proper multi-homing
- support and has quite an impact in various places, not least of
- which is the abstraction layer. */
- if (!(ifa->addr->sa_family == AF_INET6 && IN6_IS_ADDR_LINKLOCAL (&((struct sockaddr_in6 *)ifa->addr)->sin6_addr)))
- q += 5;
-#endif
-
- /* We strongly prefer a multicast capable interface, if that's
- not available anything that's not point-to-point, or else we
- hope IP routing will take care of the issues. */
- if (ifa->flags & IFF_MULTICAST)
- q += 4;
- else if (!(ifa->flags & IFF_POINTOPOINT))
- q += 3;
- else
- q += 2;
- }
-
- GVLOG (DDS_LC_CONFIG, "q%d)", q);
- if (q == quality) {
- maxq_list[maxq_count] = gv->n_interfaces;
- maxq_strlen += 2 + strlen (if_name);
- maxq_count++;
- } else if (q > quality) {
- maxq_list[0] = gv->n_interfaces;
- maxq_strlen += 2 + strlen (if_name);
- maxq_count = 1;
- quality = q;
- }
-
- if (ifa->addr->sa_family == AF_INET && ifa->netmask)
- {
- ddsi_ipaddr_to_loc(gv->m_factory, &gv->interfaces[gv->n_interfaces].netmask, ifa->netmask, gv->m_factory->m_kind);
- }
- else
- {
- gv->interfaces[gv->n_interfaces].netmask.kind = gv->m_factory->m_kind;
- gv->interfaces[gv->n_interfaces].netmask.port = NN_LOCATOR_PORT_INVALID;
- memset(&gv->interfaces[gv->n_interfaces].netmask.address, 0, sizeof(gv->interfaces[gv->n_interfaces].netmask.address));
- }
- gv->interfaces[gv->n_interfaces].mc_capable = ((ifa->flags & IFF_MULTICAST) != 0);
- gv->interfaces[gv->n_interfaces].mc_flaky = ((ifa->type == DDSRT_IFTYPE_WIFI) != 0);
- gv->interfaces[gv->n_interfaces].point_to_point = ((ifa->flags & IFF_POINTOPOINT) != 0);
- gv->interfaces[gv->n_interfaces].if_index = ifa->index;
- gv->interfaces[gv->n_interfaces].name = ddsrt_strdup (if_name);
- gv->n_interfaces++;
- }
- GVLOG (DDS_LC_CONFIG, "\n");
- ddsrt_freeifaddrs (ifa_root);
-
- if (requested_address == NULL)
- {
- if (maxq_count > 1)
- {
- const int idx = maxq_list[0];
- char *names;
- int p;
- ddsi_locator_to_string_no_port (addrbuf, sizeof(addrbuf), &gv->interfaces[idx].loc);
- names = ddsrt_malloc (maxq_strlen + 1);
- p = 0;
- for (i = 0; i < maxq_count && (size_t) p < maxq_strlen; i++)
- p += snprintf (names + p, maxq_strlen - (size_t) p, ", %s", gv->interfaces[maxq_list[i]].name);
- GVWARNING ("using network interface %s (%s) selected arbitrarily from: %s\n",
- gv->interfaces[idx].name, addrbuf, names + 2);
- ddsrt_free (names);
- }
-
- if (maxq_count > 0)
- selected_idx = maxq_list[0];
- else
- GVERROR ("failed to determine default own IP address\n");
- }
- else
- {
- nn_locator_t req;
- /* Presumably an interface name */
- for (i = 0; i < gv->n_interfaces; i++)
- {
- if (strcmp (gv->interfaces[i].name, gv->config.networkAddressString) == 0)
- break;
- }
- if (i < gv->n_interfaces)
- ; /* got a match */
- else if (ddsi_locator_from_string(gv, &req, gv->config.networkAddressString, gv->m_factory) != AFSR_OK)
- ; /* not good, i = gv->n_interfaces, so error handling will kick in */
- else
- {
- /* Try an exact match on the address */
- for (i = 0; i < gv->n_interfaces; i++)
- if (compare_locators(&gv->interfaces[i].loc, &req) == 0)
- break;
- if (i == gv->n_interfaces && req.kind == NN_LOCATOR_KIND_UDPv4)
- {
- /* Try matching on network portion only, where the network
- portion is based on the netmask of the interface under
- consideration */
- for (i = 0; i < gv->n_interfaces; i++)
- {
- uint32_t req1, ip1, nm1;
- memcpy (&req1, req.address + 12, sizeof (req1));
- memcpy (&ip1, gv->interfaces[i].loc.address + 12, sizeof (ip1));
- memcpy (&nm1, gv->interfaces[i].netmask.address + 12, sizeof (nm1));
-
- /* If the host portion of the requested address is non-zero,
- skip this interface */
- if (req1 & ~nm1)
- continue;
-
- if ((req1 & nm1) == (ip1 & nm1))
- break;
- }
- }
- }
-
- if (i < gv->n_interfaces)
- selected_idx = i;
- else
- GVERROR ("%s: does not match an available interface\n", gv->config.networkAddressString);
- }
-
- if (selected_idx < 0)
- return 0;
- else
- {
- gv->ownloc = gv->interfaces[selected_idx].loc;
- gv->selected_interface = selected_idx;
- gv->interfaceNo = gv->interfaces[selected_idx].if_index;
-#if DDSRT_HAVE_IPV6
- if (gv->extloc.kind == NN_LOCATOR_KIND_TCPv6 || gv->extloc.kind == NN_LOCATOR_KIND_UDPv6)
- {
- struct sockaddr_in6 addr;
- memcpy(&addr.sin6_addr, gv->ownloc.address, sizeof(addr.sin6_addr));
- gv->ipv6_link_local = IN6_IS_ADDR_LINKLOCAL (&addr.sin6_addr) != 0;
- }
- else
- {
- gv->ipv6_link_local = 0;
- }
-#endif
- GVLOG (DDS_LC_CONFIG, "selected interface: %s (index %u)\n",
- gv->interfaces[selected_idx].name, gv->interfaceNo);
-
- return 1;
- }
-}
From 0b9ab170184d32a21825493dc45df1422a142340 Mon Sep 17 00:00:00 2001
From: Erik Boasson
Date: Tue, 10 Mar 2020 15:50:22 +0100
Subject: [PATCH 28/30] Do not set DCPSParticipant listener too early
The participant listener creates a pong writer, setting a publication
matched listener on it. That listener can be invoked immediately and as
it queries the subscriptions reader, it must not be enabled before the
latter reader has been created.
Signed-off-by: Erik Boasson
---
src/tools/ddsperf/ddsperf.c | 15 +++++++++------
1 file changed, 9 insertions(+), 6 deletions(-)
diff --git a/src/tools/ddsperf/ddsperf.c b/src/tools/ddsperf/ddsperf.c
index bed06bd..b6f248e 100644
--- a/src/tools/ddsperf/ddsperf.c
+++ b/src/tools/ddsperf/ddsperf.c
@@ -2051,8 +2051,15 @@ int main (int argc, char *argv[])
has convenience functions for that ...) */
if ((rd_participants = dds_create_reader (dp, DDS_BUILTIN_TOPIC_DCPSPARTICIPANT, NULL, NULL)) < 0)
error2 ("dds_create_reader(participants) failed: %d\n", (int) rd_participants);
- /* set listener later: DATA_AVAILABLE still has the nasty habit of potentially triggering
- before the reader is accessible to the application via its handle */
+ if ((rd_subscriptions = dds_create_reader (dp, DDS_BUILTIN_TOPIC_DCPSSUBSCRIPTION, NULL, NULL)) < 0)
+ error2 ("dds_create_reader(subscriptions) failed: %d\n", (int) rd_subscriptions);
+ if ((rd_publications = dds_create_reader (dp, DDS_BUILTIN_TOPIC_DCPSPUBLICATION, NULL, NULL)) < 0)
+ error2 ("dds_create_reader(publications) failed: %d\n", (int) rd_publications);
+
+ /* Set DATA_AVAILABLE listener on participant later: it has the nasty habit of potentially
+ triggering before the reader is accessible to the application via its handle. Furthermore,
+ upon matching a participant, a new writer is created that gets a publication_matched
+ listener, which in turn depends on rd_subscriptions. */
listener = dds_create_listener (NULL);
dds_lset_data_available (listener, participant_data_listener);
dds_set_listener (rd_participants, listener);
@@ -2060,10 +2067,6 @@ int main (int argc, char *argv[])
/* then there is the matter of data arriving prior to setting the listener ... this state
of affairs is undoubtedly a bug */
participant_data_listener (rd_participants, NULL);
- if ((rd_subscriptions = dds_create_reader (dp, DDS_BUILTIN_TOPIC_DCPSSUBSCRIPTION, NULL, NULL)) < 0)
- error2 ("dds_create_reader(subscriptions) failed: %d\n", (int) rd_subscriptions);
- if ((rd_publications = dds_create_reader (dp, DDS_BUILTIN_TOPIC_DCPSPUBLICATION, NULL, NULL)) < 0)
- error2 ("dds_create_reader(publications) failed: %d\n", (int) rd_publications);
/* stats writer always exists, reader only when we were requested to collect & print stats */
qos = dds_create_qos ();
From e1201e678d7e70b704f16b729e5629fd5b381684 Mon Sep 17 00:00:00 2001
From: Erik Boasson
Date: Fri, 13 Mar 2020 15:14:17 +0100
Subject: [PATCH 29/30] Minor cleanup of UDP, TCP support code
Signed-off-by: Erik Boasson
---
src/core/ddsi/include/dds/ddsi/ddsi_tran.h | 18 +-
src/core/ddsi/include/dds/ddsi/q_pcap.h | 2 +-
src/core/ddsi/src/ddsi_raweth.c | 13 +-
src/core/ddsi/src/ddsi_tcp.c | 364 ++++++++--------
src/core/ddsi/src/ddsi_tran.c | 4 +-
src/core/ddsi/src/ddsi_udp.c | 479 +++++++++++----------
src/core/ddsi/src/q_debmon.c | 3 +-
src/core/ddsi/src/q_entity.c | 24 +-
src/core/ddsi/src/q_init.c | 85 ++--
src/core/ddsi/src/q_pcap.c | 4 +-
10 files changed, 517 insertions(+), 479 deletions(-)
diff --git a/src/core/ddsi/include/dds/ddsi/ddsi_tran.h b/src/core/ddsi/include/dds/ddsi/ddsi_tran.h
index c6ccc8f..f18b2db 100644
--- a/src/core/ddsi/include/dds/ddsi/ddsi_tran.h
+++ b/src/core/ddsi/include/dds/ddsi/ddsi_tran.h
@@ -60,8 +60,8 @@ typedef void (*ddsi_tran_free_fn_t) (ddsi_tran_factory_t);
typedef void (*ddsi_tran_peer_locator_fn_t) (ddsi_tran_conn_t, nn_locator_t *);
typedef void (*ddsi_tran_disable_multiplexing_fn_t) (ddsi_tran_conn_t);
typedef ddsi_tran_conn_t (*ddsi_tran_accept_fn_t) (ddsi_tran_listener_t);
-typedef ddsi_tran_conn_t (*ddsi_tran_create_conn_fn_t) (ddsi_tran_factory_t fact, uint32_t, const struct ddsi_tran_qos *);
-typedef ddsi_tran_listener_t (*ddsi_tran_create_listener_fn_t) (ddsi_tran_factory_t fact, uint32_t port, const struct ddsi_tran_qos *);
+typedef dds_return_t (*ddsi_tran_create_conn_fn_t) (ddsi_tran_conn_t *conn, ddsi_tran_factory_t fact, uint32_t, const struct ddsi_tran_qos *);
+typedef dds_return_t (*ddsi_tran_create_listener_fn_t) (ddsi_tran_listener_t *listener, ddsi_tran_factory_t fact, uint32_t port, const struct ddsi_tran_qos *);
typedef void (*ddsi_tran_release_conn_fn_t) (ddsi_tran_conn_t);
typedef void (*ddsi_tran_close_conn_fn_t) (ddsi_tran_conn_t);
typedef void (*ddsi_tran_unblock_listener_fn_t) (ddsi_tran_listener_t);
@@ -214,15 +214,17 @@ inline bool ddsi_factory_supports (const struct ddsi_tran_factory *factory, int3
inline int ddsi_is_valid_port (ddsi_tran_factory_t factory, uint32_t port) {
return factory->m_is_valid_port_fn (factory, port);
}
-inline ddsi_tran_conn_t ddsi_factory_create_conn (ddsi_tran_factory_t factory, uint32_t port, const struct ddsi_tran_qos *qos) {
+inline dds_return_t ddsi_factory_create_conn (ddsi_tran_conn_t *conn, ddsi_tran_factory_t factory, uint32_t port, const struct ddsi_tran_qos *qos) {
+ *conn = NULL;
if (!ddsi_is_valid_port (factory, port))
- return NULL;
- return factory->m_create_conn_fn (factory, port, qos);
+ return DDS_RETCODE_BAD_PARAMETER;
+ return factory->m_create_conn_fn (conn, factory, port, qos);
}
-inline ddsi_tran_listener_t ddsi_factory_create_listener (ddsi_tran_factory_t factory, uint32_t port, const struct ddsi_tran_qos *qos) {
+inline dds_return_t ddsi_factory_create_listener (ddsi_tran_listener_t *listener, ddsi_tran_factory_t factory, uint32_t port, const struct ddsi_tran_qos *qos) {
+ *listener = NULL;
if (!ddsi_is_valid_port (factory, port))
- return NULL;
- return factory->m_create_listener_fn (factory, port, qos);
+ return DDS_RETCODE_BAD_PARAMETER;
+ return factory->m_create_listener_fn (listener, factory, port, qos);
}
void ddsi_tran_free (ddsi_tran_base_t base);
diff --git a/src/core/ddsi/include/dds/ddsi/q_pcap.h b/src/core/ddsi/include/dds/ddsi/q_pcap.h
index 6ae6d66..f69d3bb 100644
--- a/src/core/ddsi/include/dds/ddsi/q_pcap.h
+++ b/src/core/ddsi/include/dds/ddsi/q_pcap.h
@@ -21,7 +21,7 @@ extern "C" {
struct msghdr;
-FILE * new_pcap_file (const struct ddsrt_log_cfg *logcfg, const char *name);
+FILE * new_pcap_file (struct ddsi_domaingv *gv, const char *name);
void write_pcap_received (struct ddsi_domaingv *gv, ddsrt_wctime_t tstamp, const struct sockaddr_storage *src, const struct sockaddr_storage *dst, unsigned char *buf, size_t sz);
void write_pcap_sent (struct ddsi_domaingv *gv, ddsrt_wctime_t tstamp, const struct sockaddr_storage *src,
diff --git a/src/core/ddsi/src/ddsi_raweth.c b/src/core/ddsi/src/ddsi_raweth.c
index 7237e4a..2dcb957 100644
--- a/src/core/ddsi/src/ddsi_raweth.c
+++ b/src/core/ddsi/src/ddsi_raweth.c
@@ -174,7 +174,7 @@ static int ddsi_raweth_conn_locator (ddsi_tran_factory_t fact, ddsi_tran_base_t
return ret;
}
-static ddsi_tran_conn_t ddsi_raweth_create_conn (ddsi_tran_factory_t fact, uint32_t port, const struct ddsi_tran_qos *qos)
+static dds_return_t ddsi_raweth_create_conn (ddsi_tran_conn_t *conn_out, ddsi_tran_factory_t fact, uint32_t port, const struct ddsi_tran_qos *qos)
{
ddsrt_socket_t sock;
dds_return_t rc;
@@ -187,14 +187,14 @@ static ddsi_tran_conn_t ddsi_raweth_create_conn (ddsi_tran_factory_t fact, uint3
if (port == 0 || port > 65535)
{
DDS_CERROR (&fact->gv->logconfig, "ddsi_raweth_create_conn %s port %u - using port number as ethernet type, %u won't do\n", mcast ? "multicast" : "unicast", port, port);
- return NULL;
+ return DDS_RETCODE_ERROR;
}
rc = ddsrt_socket(&sock, PF_PACKET, SOCK_DGRAM, htons((uint16_t)port));
if (rc != DDS_RETCODE_OK)
{
DDS_CERROR (&fact->gv->logconfig, "ddsi_raweth_create_conn %s port %u failed ... retcode = %d\n", mcast ? "multicast" : "unicast", port, rc);
- return NULL;
+ return DDS_RETCODE_ERROR;
}
memset(&addr, 0, sizeof(addr));
@@ -207,13 +207,13 @@ static ddsi_tran_conn_t ddsi_raweth_create_conn (ddsi_tran_factory_t fact, uint3
{
ddsrt_close(sock);
DDS_CERROR (&fact->gv->logconfig, "ddsi_raweth_create_conn %s bind port %u failed ... retcode = %d\n", mcast ? "multicast" : "unicast", port, rc);
- return NULL;
+ return DDS_RETCODE_ERROR;
}
if ((uc = (ddsi_raweth_conn_t) ddsrt_malloc (sizeof (*uc))) == NULL)
{
ddsrt_close(sock);
- return NULL;
+ return DDS_RETCODE_ERROR;
}
memset (uc, 0, sizeof (*uc));
@@ -230,7 +230,8 @@ static ddsi_tran_conn_t ddsi_raweth_create_conn (ddsi_tran_factory_t fact, uint3
uc->m_base.m_disable_multiplexing_fn = 0;
DDS_CTRACE (&fact->gv->logconfig, "ddsi_raweth_create_conn %s socket %d port %u\n", mcast ? "multicast" : "unicast", uc->m_sock, uc->m_base.m_base.m_port);
- return &uc->m_base;
+ *conn_out = &uc->m_base;
+ return DDS_RETCODE_OK;
}
static int isbroadcast(const nn_locator_t *loc)
diff --git a/src/core/ddsi/src/ddsi_tcp.c b/src/core/ddsi/src/ddsi_tcp.c
index 5cf5b62..de7a7e6 100644
--- a/src/core/ddsi/src/ddsi_tcp.c
+++ b/src/core/ddsi/src/ddsi_tcp.c
@@ -39,9 +39,15 @@
wait set that manages their lifecycle.
*/
+union addr {
+ struct sockaddr a;
+ struct sockaddr_in a4;
+ struct sockaddr_in6 a6;
+};
+
typedef struct ddsi_tcp_conn {
struct ddsi_tran_conn m_base;
- struct sockaddr_storage m_peer_addr;
+ union addr m_peer_addr;
uint32_t m_peer_port;
ddsrt_mutex_t m_mutex;
ddsrt_socket_t m_sock;
@@ -70,8 +76,8 @@ struct ddsi_tran_factory_tcp {
static int ddsi_tcp_cmp_conn (const struct ddsi_tcp_conn *c1, const struct ddsi_tcp_conn *c2)
{
- const struct sockaddr *a1s = (struct sockaddr *)&c1->m_peer_addr;
- const struct sockaddr *a2s = (struct sockaddr *)&c2->m_peer_addr;
+ const struct sockaddr *a1s = &c1->m_peer_addr.a;
+ const struct sockaddr *a2s = &c2->m_peer_addr.a;
if (a1s->sa_family != a2s->sa_family)
return (a1s->sa_family < a2s->sa_family) ? -1 : 1;
else if (c1->m_peer_port != c2->m_peer_port)
@@ -132,114 +138,91 @@ static void ddsi_tcp_cache_dump (void)
}
*/
-static unsigned short get_socket_port (struct ddsrt_log_cfg *logcfg, ddsrt_socket_t socket)
+static uint16_t get_socket_port (struct ddsi_domaingv const * const gv, ddsrt_socket_t socket)
{
- struct sockaddr_storage addr;
+ union addr addr;
socklen_t addrlen = sizeof (addr);
dds_return_t ret;
- ret = ddsrt_getsockname(socket, (struct sockaddr *)&addr, &addrlen);
+ ret = ddsrt_getsockname(socket, &addr.a, &addrlen);
if (ret != DDS_RETCODE_OK) {
- DDS_CERROR (logcfg, "ddsi_tcp_get_socket_port: ddsrt_getsockname retcode %"PRId32"\n", ret);
+ GVERROR ("ddsi_tcp_get_socket_port: ddsrt_getsockname retcode %"PRId32"\n", ret);
return 0;
}
- return ddsrt_sockaddr_get_port((struct sockaddr *)&addr);
+ return ddsrt_sockaddr_get_port (&addr.a);
}
static void ddsi_tcp_conn_set_socket (ddsi_tcp_conn_t conn, ddsrt_socket_t sock)
{
+ struct ddsi_domaingv const * const gv = conn->m_base.m_base.gv;
conn->m_sock = sock;
- conn->m_base.m_base.m_port = (sock == DDSRT_INVALID_SOCKET) ? INVALID_PORT : get_socket_port (&conn->m_base.m_base.gv->logconfig, sock);
+ conn->m_base.m_base.m_port = (sock == DDSRT_INVALID_SOCKET) ? INVALID_PORT : get_socket_port (gv, sock);
}
-static void ddsi_tcp_sock_free (const struct ddsrt_log_cfg *logcfg, ddsrt_socket_t sock, const char *msg)
+static void ddsi_tcp_sock_free (struct ddsi_domaingv const * const gv, ddsrt_socket_t sock, const char *msg)
{
if (sock != DDSRT_INVALID_SOCKET)
{
if (msg)
- {
- DDS_CLOG (DDS_LC_TCP, logcfg, "tcp %s free socket %"PRIdSOCK"\n", msg, sock);
- }
+ GVLOG (DDS_LC_TCP, "tcp %s free socket %"PRIdSOCK"\n", msg, sock);
ddsrt_close (sock);
}
}
static dds_return_t ddsi_tcp_sock_new (struct ddsi_tran_factory_tcp * const fact, ddsrt_socket_t *sock, uint16_t port)
{
- struct ddsi_domaingv * const gv = fact->fact.gv;
+ struct ddsi_domaingv const * const gv = fact->fact.gv;
const int one = 1;
+ union addr socketname;
dds_return_t rc;
+ memset (&socketname, 0, sizeof (socketname));
+ switch (fact->fact.m_kind)
{
- int af = AF_UNSPEC;
- switch (fact->fact.m_kind)
- {
- case NN_LOCATOR_KIND_TCPv4:
- af = AF_INET;
- break;
+ case NN_LOCATOR_KIND_TCPv4:
+ socketname.a4.sin_family = AF_INET;
+ socketname.a4.sin_addr.s_addr = htonl (INADDR_ANY);
+ socketname.a4.sin_port = htons (port);
+ break;
#if DDSRT_HAVE_IPV6
- case NN_LOCATOR_KIND_TCPv6:
- af = AF_INET6;
- break;
+ case NN_LOCATOR_KIND_TCPv6:
+ socketname.a6.sin6_family = AF_INET6;
+ socketname.a6.sin6_addr = ddsrt_in6addr_any;
+ socketname.a6.sin6_port = htons (port);
+ break;
#endif
- default:
- DDS_FATAL ("ddsi_tcp_sock_new: unsupported kind %"PRId32"\n", fact->fact.m_kind);
- }
- assert (af != AF_UNSPEC);
- if ((rc = ddsrt_socket (sock, af, SOCK_STREAM, 0)) != DDS_RETCODE_OK)
- {
- GVERROR ("ddsi_tcp_sock_new: failed to create socket: %s\n", dds_strretcode (rc));
- goto fail;
- }
+ default:
+ DDS_FATAL ("ddsi_tcp_sock_new: unsupported kind %"PRId32"\n", fact->fact.m_kind);
+ }
+ if ((rc = ddsrt_socket (sock, socketname.a.sa_family, SOCK_STREAM, 0)) != DDS_RETCODE_OK)
+ {
+ GVERROR ("ddsi_tcp_sock_new: failed to create socket: %s\n", dds_strretcode (rc));
+ goto fail;
}
/* REUSEADDR if we're binding to a port number */
- if (port && (rc = ddsrt_setsockopt (*sock, SOL_SOCKET, SO_REUSEADDR, (char *) &one, sizeof (one))) != DDS_RETCODE_OK)
+ if (port && (rc = ddsrt_setsockopt (*sock, SOL_SOCKET, SO_REUSEADDR, &one, sizeof (one))) != DDS_RETCODE_OK)
{
GVERROR ("ddsi_tcp_sock_new: failed to enable address reuse: %s\n", dds_strretcode (rc));
goto fail_w_socket;
}
+ if ((rc = ddsrt_bind (*sock, &socketname.a, ddsrt_sockaddr_get_size (&socketname.a))) != DDS_RETCODE_OK)
{
- union {
- struct sockaddr_storage x;
- struct sockaddr_in a4;
- struct sockaddr_in6 a6;
- } socketname;
- memset (&socketname.x, 0, sizeof (socketname.x));
- switch (fact->fact.m_kind)
- {
- case NN_LOCATOR_KIND_TCPv4:
- socketname.a4.sin_family = AF_INET;
- socketname.a4.sin_addr.s_addr = htonl (INADDR_ANY);
- socketname.a4.sin_port = htons (port);
- break;
-#if DDSRT_HAVE_IPV6
- case NN_LOCATOR_KIND_TCPv6:
- socketname.a4.sin_family = AF_INET6;
- socketname.a6.sin6_addr = ddsrt_in6addr_any;
- socketname.a6.sin6_port = htons (port);
- break;
-#endif
- default:
- DDS_FATAL ("ddsi_tcp_sock_new: unsupported kind %"PRId32"\n", fact->fact.m_kind);
- }
- if ((rc = ddsrt_bind (*sock, (struct sockaddr *) &socketname, ddsrt_sockaddr_get_size ((struct sockaddr *) &socketname))) != DDS_RETCODE_OK)
- {
- GVERROR ("ddsi_tcp_sock_new: failed to bind to ANY:%"PRIu16": %s\n", port, dds_strretcode (rc));
- goto fail_w_socket;
- }
+ GVERROR ("ddsi_tcp_sock_new: failed to bind to ANY:%"PRIu16": %s\n", port,
+ (rc == DDS_RETCODE_PRECONDITION_NOT_MET) ? "address in use" : dds_strretcode (rc));
+ goto fail_w_socket;
}
#ifdef SO_NOSIGPIPE
- if (ddsrt_setsockopt (*sock, SOL_SOCKET, SO_NOSIGPIPE, (char *) &one, sizeof (one)) != DDS_RETCODE_OK)
+ if (ddsrt_setsockopt (*sock, SOL_SOCKET, SO_NOSIGPIPE, &one, sizeof (one)) != DDS_RETCODE_OK)
{
GVERROR ("ddsi_tcp_sock_new: failed to set NOSIGPIPE: %s\n", dds_strretcode (rc));
goto fail_w_socket;
}
#endif
#ifdef TCP_NODELAY
- if (gv->config.tcp_nodelay && (rc = ddsrt_setsockopt (*sock, IPPROTO_TCP, TCP_NODELAY, (char*) &one, sizeof (one))) != DDS_RETCODE_OK)
+ if (gv->config.tcp_nodelay && (rc = ddsrt_setsockopt (*sock, IPPROTO_TCP, TCP_NODELAY, &one, sizeof (one))) != DDS_RETCODE_OK)
{
GVERROR ("ddsi_tcp_sock_new: failed to set NODELAY: %s\n", dds_strretcode (rc));
goto fail_w_socket;
@@ -264,52 +247,57 @@ static void ddsi_tcp_node_free (void * ptr)
static void ddsi_tcp_conn_connect (ddsi_tcp_conn_t conn, const ddsrt_msghdr_t * msg)
{
struct ddsi_tran_factory_tcp * const fact = (struct ddsi_tran_factory_tcp *) conn->m_base.m_factory;
+ struct ddsi_domaingv const * const gv = fact->fact.gv;
char buff[DDSI_LOCSTRLEN];
ddsrt_socket_t sock;
dds_return_t ret;
- if (ddsi_tcp_sock_new (fact, &sock, 0) == DDS_RETCODE_OK)
+ if (ddsi_tcp_sock_new (fact, &sock, 0) != DDS_RETCODE_OK)
{
- /* Attempt to connect, expected that may fail */
- do {
- ret = ddsrt_connect(sock, msg->msg_name, msg->msg_namelen);
- } while (ret == DDS_RETCODE_INTERRUPTED);
+ /* error messages are logged by ddsi_tcp_sock_new */
+ return;
+ }
- if (ret != DDS_RETCODE_OK)
- {
- ddsi_tcp_sock_free (&conn->m_base.m_base.gv->logconfig, sock, NULL);
- return;
- }
- ddsi_tcp_conn_set_socket (conn, sock);
+ /* Attempt to connect, expected that may fail */
+ do {
+ ret = ddsrt_connect(sock, msg->msg_name, msg->msg_namelen);
+ } while (ret == DDS_RETCODE_INTERRUPTED);
+ if (ret != DDS_RETCODE_OK)
+ goto fail_w_socket;
+ ddsi_tcp_conn_set_socket (conn, sock);
#ifdef DDSI_INCLUDE_SSL
- if (fact->ddsi_tcp_ssl_plugin.connect)
+ if (fact->ddsi_tcp_ssl_plugin.connect)
+ {
+ conn->m_ssl = (fact->ddsi_tcp_ssl_plugin.connect) (conn->m_base.m_base.gv, sock);
+ if (conn->m_ssl == NULL)
{
- conn->m_ssl = (fact->ddsi_tcp_ssl_plugin.connect) (conn->m_base.m_base.gv, sock);
- if (conn->m_ssl == NULL)
- {
- ddsi_tcp_conn_set_socket (conn, DDSRT_INVALID_SOCKET);
- return;
- }
+ ddsi_tcp_conn_set_socket (conn, DDSRT_INVALID_SOCKET);
+ goto fail_w_socket;
}
+ }
#endif
- sockaddr_to_string_with_port(fact, buff, sizeof(buff), (struct sockaddr *) msg->msg_name);
- DDS_CLOG (DDS_LC_TCP, &conn->m_base.m_base.gv->logconfig, "tcp connect socket %"PRIdSOCK" port %u to %s\n", sock, get_socket_port (&conn->m_base.m_base.gv->logconfig, sock), buff);
+ sockaddr_to_string_with_port(fact, buff, sizeof(buff), (struct sockaddr *) msg->msg_name);
+ GVLOG (DDS_LC_TCP, "tcp connect socket %"PRIdSOCK" port %u to %s\n", sock, get_socket_port (gv, sock), buff);
- /* Also may need to receive on connection so add to waitset */
+ /* Also may need to receive on connection so add to waitset */
- (void)ddsrt_setsocknonblocking(conn->m_sock, true);
+ (void)ddsrt_setsocknonblocking(conn->m_sock, true);
- assert (conn->m_base.m_base.gv->n_recv_threads > 0);
- assert (conn->m_base.m_base.gv->recv_threads[0].arg.mode == RTM_MANY);
- os_sockWaitsetAdd (conn->m_base.m_base.gv->recv_threads[0].arg.u.many.ws, &conn->m_base);
- os_sockWaitsetTrigger (conn->m_base.m_base.gv->recv_threads[0].arg.u.many.ws);
- }
+ assert (conn->m_base.m_base.gv->n_recv_threads > 0);
+ assert (conn->m_base.m_base.gv->recv_threads[0].arg.mode == RTM_MANY);
+ os_sockWaitsetAdd (conn->m_base.m_base.gv->recv_threads[0].arg.u.many.ws, &conn->m_base);
+ os_sockWaitsetTrigger (conn->m_base.m_base.gv->recv_threads[0].arg.u.many.ws);
+ return;
+
+fail_w_socket:
+ ddsi_tcp_sock_free (gv, sock, NULL);
}
static void ddsi_tcp_cache_add (struct ddsi_tran_factory_tcp *fact, ddsi_tcp_conn_t conn, ddsrt_avl_ipath_t * path)
{
+ struct ddsi_domaingv * const gv = fact->fact.gv;
const char * action = "added";
ddsi_tcp_node_t node;
char buff[DDSI_LOCSTRLEN];
@@ -342,13 +330,14 @@ static void ddsi_tcp_cache_add (struct ddsi_tran_factory_tcp *fact, ddsi_tcp_con
}
}
- sockaddr_to_string_with_port(fact, buff, sizeof(buff), (struct sockaddr *)&conn->m_peer_addr);
- DDS_CLOG (DDS_LC_TCP, &fact->fact.gv->logconfig, "tcp cache %s %s socket %"PRIdSOCK" to %s\n", action, conn->m_base.m_server ? "server" : "client", conn->m_sock, buff);
+ sockaddr_to_string_with_port(fact, buff, sizeof(buff), &conn->m_peer_addr.a);
+ GVLOG (DDS_LC_TCP, "tcp cache %s %s socket %"PRIdSOCK" to %s\n", action, conn->m_base.m_server ? "server" : "client", conn->m_sock, buff);
}
static void ddsi_tcp_cache_remove (ddsi_tcp_conn_t conn)
{
struct ddsi_tran_factory_tcp * const fact = (struct ddsi_tran_factory_tcp *) conn->m_base.m_factory;
+ struct ddsi_domaingv * const gv = fact->fact.gv;
char buff[DDSI_LOCSTRLEN];
ddsi_tcp_node_t node;
ddsrt_avl_dpath_t path;
@@ -357,8 +346,8 @@ static void ddsi_tcp_cache_remove (ddsi_tcp_conn_t conn)
node = ddsrt_avl_lookup_dpath (&ddsi_tcp_treedef, &fact->ddsi_tcp_cache_g, conn, &path);
if (node)
{
- sockaddr_to_string_with_port(fact, buff, sizeof(buff), (struct sockaddr *)&conn->m_peer_addr);
- DDS_CLOG (DDS_LC_TCP, &conn->m_base.m_base.gv->logconfig, "tcp cache removed socket %"PRIdSOCK" to %s\n", conn->m_sock, buff);
+ sockaddr_to_string_with_port(fact, buff, sizeof(buff), &conn->m_peer_addr.a);
+ GVLOG (DDS_LC_TCP, "tcp cache removed socket %"PRIdSOCK" to %s\n", conn->m_sock, buff);
ddsrt_avl_delete_dpath (&ddsi_tcp_treedef, &fact->ddsi_tcp_cache_g, node, &path);
ddsi_tcp_node_free (node);
}
@@ -399,7 +388,7 @@ static ddsi_tcp_conn_t ddsi_tcp_cache_find (struct ddsi_tran_factory_tcp *fact,
}
if (ret == NULL)
{
- ret = ddsi_tcp_new_conn (fact, DDSRT_INVALID_SOCKET, false, (struct sockaddr *)&key.m_peer_addr);
+ ret = ddsi_tcp_new_conn (fact, DDSRT_INVALID_SOCKET, false, &key.m_peer_addr.a);
ddsi_tcp_cache_add (fact, ret, &path);
}
ddsrt_mutex_unlock (&fact->ddsi_tcp_cache_lock_g);
@@ -425,7 +414,7 @@ static ssize_t ddsi_tcp_conn_read_ssl (ddsi_tcp_conn_t tcp, void * buf, size_t l
}
#endif
-static bool ddsi_tcp_select (const struct ddsrt_log_cfg *logcfg, ddsrt_socket_t sock, bool read, size_t pos, int64_t timeout)
+static bool ddsi_tcp_select (struct ddsi_domaingv const * const gv, ddsrt_socket_t sock, bool read, size_t pos, int64_t timeout)
{
dds_return_t rc;
fd_set fds;
@@ -443,22 +432,29 @@ static bool ddsi_tcp_select (const struct ddsrt_log_cfg *logcfg, ddsrt_socket_t
DDSRT_WARNING_GNUC_ON(sign-conversion)
#endif
- DDS_CLOG (DDS_LC_TCP, logcfg, "tcp blocked %s: sock %d\n", read ? "read" : "write", (int) sock);
+ GVLOG (DDS_LC_TCP, "tcp blocked %s: sock %d\n", read ? "read" : "write", (int) sock);
do {
rc = ddsrt_select (sock + 1, rdset, wrset, NULL, tval, &ready);
} while (rc == DDS_RETCODE_INTERRUPTED);
if (rc != DDS_RETCODE_OK)
{
- DDS_CWARNING (logcfg, "tcp abandoning %s on blocking socket %d after %"PRIuSIZE" bytes\n", read ? "read" : "write", (int) sock, pos);
+ GVWARNING ("tcp abandoning %s on blocking socket %d after %"PRIuSIZE" bytes\n", read ? "read" : "write", (int) sock, pos);
}
return (ready > 0);
}
+static int32_t addrfam_to_locator_kind (int af)
+{
+ assert (af == AF_INET || af == AF_INET6);
+ return (af == AF_INET) ? NN_LOCATOR_KIND_TCPv4 : NN_LOCATOR_KIND_TCPv6;
+}
+
static ssize_t ddsi_tcp_conn_read (ddsi_tran_conn_t conn, unsigned char *buf, size_t len, bool allow_spurious, nn_locator_t *srcloc)
{
struct ddsi_tran_factory_tcp * const fact = (struct ddsi_tran_factory_tcp *) conn->m_factory;
+ struct ddsi_domaingv const * const gv = fact->fact.gv;
dds_return_t rc;
ddsi_tcp_conn_t tcp = (ddsi_tcp_conn_t) conn;
ssize_t (*rd) (ddsi_tcp_conn_t, void *, size_t, dds_return_t * err) = ddsi_tcp_conn_read_plain;
@@ -482,14 +478,15 @@ static ssize_t ddsi_tcp_conn_read (ddsi_tran_conn_t conn, unsigned char *buf, si
{
if (srcloc)
{
- ddsi_ipaddr_to_loc(&fact->fact, srcloc, (struct sockaddr *)&tcp->m_peer_addr, tcp->m_peer_addr.ss_family == AF_INET ? NN_LOCATOR_KIND_TCPv4 : NN_LOCATOR_KIND_TCPv6);
+ const int32_t kind = addrfam_to_locator_kind (tcp->m_peer_addr.a.sa_family);
+ ddsi_ipaddr_to_loc(&fact->fact, srcloc, &tcp->m_peer_addr.a, kind);
}
return (ssize_t) pos;
}
}
else if (n == 0)
{
- DDS_CLOG (DDS_LC_TCP, &conn->m_base.gv->logconfig, "tcp read: sock %"PRIdSOCK" closed-by-peer\n", tcp->m_sock);
+ GVLOG (DDS_LC_TCP, "tcp read: sock %"PRIdSOCK" closed-by-peer\n", tcp->m_sock);
break;
}
else
@@ -500,13 +497,13 @@ static ssize_t ddsi_tcp_conn_read (ddsi_tran_conn_t conn, unsigned char *buf, si
{
if (allow_spurious && pos == 0)
return 0;
- const int64_t timeout = conn->m_base.gv->config.tcp_read_timeout;
- if (ddsi_tcp_select (&conn->m_base.gv->logconfig, tcp->m_sock, true, pos, timeout) == false)
+ const int64_t timeout = gv->config.tcp_read_timeout;
+ if (ddsi_tcp_select (gv, tcp->m_sock, true, pos, timeout) == false)
break;
}
else
{
- DDS_CLOG (DDS_LC_TCP, &conn->m_base.gv->logconfig, "tcp read: sock %"PRIdSOCK" error %"PRId32"\n", tcp->m_sock, rc);
+ GVLOG (DDS_LC_TCP, "tcp read: sock %"PRIdSOCK" error %"PRId32"\n", tcp->m_sock, rc);
break;
}
}
@@ -542,6 +539,7 @@ static ssize_t ddsi_tcp_block_write (ssize_t (*wr) (ddsi_tcp_conn_t, const void
{
/* Write all bytes of buf even in the presence of signals,
partial writes and blocking (typically write buffer full) */
+ struct ddsi_domaingv const * const gv = conn->m_base.m_base.gv;
dds_return_t rc;
size_t pos = 0;
ssize_t n = -1;
@@ -559,15 +557,15 @@ static ssize_t ddsi_tcp_block_write (ssize_t (*wr) (ddsi_tcp_conn_t, const void
{
if (rc == DDS_RETCODE_TRY_AGAIN)
{
- const int64_t timeout = conn->m_base.m_base.gv->config.tcp_write_timeout;
- if (ddsi_tcp_select (&conn->m_base.m_base.gv->logconfig, conn->m_sock, false, pos, timeout) == false)
+ const int64_t timeout = gv->config.tcp_write_timeout;
+ if (ddsi_tcp_select (gv, conn->m_sock, false, pos, timeout) == false)
{
break;
}
}
else
{
- DDS_CLOG (DDS_LC_TCP, &conn->m_base.m_base.gv->logconfig, "tcp write: sock %"PRIdSOCK" error %"PRId32"\n", conn->m_sock, rc);
+ GVLOG (DDS_LC_TCP, "tcp write: sock %"PRIdSOCK" error %"PRId32"\n", conn->m_sock, rc);
break;
}
}
@@ -594,6 +592,7 @@ static void set_msghdr_iov (ddsrt_msghdr_t *mhdr, ddsrt_iovec_t *iov, size_t iov
static ssize_t ddsi_tcp_conn_write (ddsi_tran_conn_t base, const nn_locator_t *dst, size_t niov, const ddsrt_iovec_t *iov, uint32_t flags)
{
struct ddsi_tran_factory_tcp * const fact = (struct ddsi_tran_factory_tcp *) base->m_factory;
+ struct ddsi_domaingv const * const gv = fact->fact.gv;
#ifdef DDSI_INCLUDE_SSL
char msgbuf[4096]; /* stack buffer for merging smallish writes without requiring allocations */
ddsrt_iovec_t iovec; /* iovec used for msgbuf */
@@ -604,13 +603,16 @@ static ssize_t ddsi_tcp_conn_write (ddsi_tran_conn_t base, const nn_locator_t *d
int piecewise;
bool connect = false;
ddsrt_msghdr_t msg;
- struct sockaddr_storage dstaddr;
+ union {
+ struct sockaddr_storage x;
+ union addr a;
+ } dstaddr;
assert(niov <= INT_MAX);
- ddsi_ipaddr_from_loc(&dstaddr, dst);
+ ddsi_ipaddr_from_loc(&dstaddr.x, dst);
memset(&msg, 0, sizeof(msg));
set_msghdr_iov (&msg, (ddsrt_iovec_t *) iov, niov);
msg.msg_name = &dstaddr;
- msg.msg_namelen = (socklen_t) ddsrt_sockaddr_get_size((struct sockaddr *) &dstaddr);
+ msg.msg_namelen = ddsrt_sockaddr_get_size(&dstaddr.a.a);
#if DDSRT_MSGHDR_FLAGS
msg.msg_flags = (int) flags;
#endif
@@ -643,13 +645,13 @@ static ssize_t ddsi_tcp_conn_write (ddsi_tran_conn_t base, const nn_locator_t *d
if (!connect && ((flags & DDSI_TRAN_ON_CONNECT) != 0))
{
- DDS_CLOG (DDS_LC_TCP, &conn->m_base.m_base.gv->logconfig, "tcp write: sock %"PRIdSOCK" message filtered\n", conn->m_sock);
+ GVLOG (DDS_LC_TCP, "tcp write: sock %"PRIdSOCK" message filtered\n", conn->m_sock);
ddsrt_mutex_unlock (&conn->m_mutex);
return (ssize_t) len;
}
#ifdef DDSI_INCLUDE_SSL
- if (base->m_base.gv->config.ssl_enable)
+ if (gv->config.ssl_enable)
{
/* SSL doesn't have sendmsg, ret = 0 so writing starts at first byte.
Rumor is that it is much better to merge small writes, which do here
@@ -702,11 +704,11 @@ static ssize_t ddsi_tcp_conn_write (ddsi_tran_conn_t base, const nn_locator_t *d
{
case DDS_RETCODE_NO_CONNECTION:
case DDS_RETCODE_ILLEGAL_OPERATION:
- DDS_CLOG (DDS_LC_TCP, &conn->m_base.m_base.gv->logconfig, "tcp write: sock %"PRIdSOCK" DDS_RETCODE_NO_CONNECTION\n", conn->m_sock);
+ GVLOG (DDS_LC_TCP, "tcp write: sock %"PRIdSOCK" DDS_RETCODE_NO_CONNECTION\n", conn->m_sock);
break;
default:
if (! conn->m_base.m_closed && (conn->m_sock != DDSRT_INVALID_SOCKET))
- DDS_CWARNING (&conn->m_base.m_base.gv->logconfig, "tcp write failed on socket %"PRIdSOCK" with errno %"PRId32"\n", conn->m_sock, rc);
+ GVWARNING ("tcp write failed on socket %"PRIdSOCK" with errno %"PRId32"\n", conn->m_sock, rc);
break;
}
}
@@ -715,7 +717,7 @@ static ssize_t ddsi_tcp_conn_write (ddsi_tran_conn_t base, const nn_locator_t *d
{
if (ret == 0)
{
- DDS_CLOG (DDS_LC_TCP, &conn->m_base.m_base.gv->logconfig, "tcp write: sock %"PRIdSOCK" eof\n", conn->m_sock);
+ GVLOG (DDS_LC_TCP, "tcp write: sock %"PRIdSOCK" eof\n", conn->m_sock);
}
piecewise = (ret > 0 && (size_t) ret < len);
}
@@ -783,12 +785,13 @@ static int ddsi_tcp_locator (struct ddsi_tran_factory *fact_cmn, ddsi_tran_base_
return 0;
}
-static ddsi_tran_conn_t ddsi_tcp_create_conn (struct ddsi_tran_factory *fact_cmn, uint32_t port, const struct ddsi_tran_qos *qos)
+static dds_return_t ddsi_tcp_create_conn (ddsi_tran_conn_t *conn_out, struct ddsi_tran_factory *fact_cmn, uint32_t port, const struct ddsi_tran_qos *qos)
{
struct ddsi_tran_factory_tcp * const fact = (struct ddsi_tran_factory_tcp *) fact_cmn;
(void) qos;
(void) port;
- return &fact->ddsi_tcp_conn_client.m_base;
+ *conn_out = &fact->ddsi_tcp_conn_client.m_base;
+ return DDS_RETCODE_OK;
}
static int ddsi_tcp_listen (ddsi_tran_listener_t listener)
@@ -812,10 +815,11 @@ static int ddsi_tcp_listen (ddsi_tran_listener_t listener)
static ddsi_tran_conn_t ddsi_tcp_accept (ddsi_tran_listener_t listener)
{
struct ddsi_tran_factory_tcp * const fact = (struct ddsi_tran_factory_tcp *) listener->m_factory;
+ struct ddsi_domaingv const * const gv = fact->fact.gv;
ddsi_tcp_listener_t tl = (ddsi_tcp_listener_t) listener;
ddsi_tcp_conn_t tcp = NULL;
ddsrt_socket_t sock = DDSRT_INVALID_SOCKET;
- struct sockaddr_storage addr;
+ union addr addr;
socklen_t addrlen = sizeof (addr);
char buff[DDSI_LOCSTRLEN];
dds_return_t rc = DDS_RETCODE_OK;
@@ -839,31 +843,31 @@ static ddsi_tran_conn_t ddsi_tcp_accept (ddsi_tran_listener_t listener)
{
rc = ddsrt_accept(tl->m_sock, NULL, NULL, &sock);
}
- if (!ddsrt_atomic_ld32(&listener->m_base.gv->rtps_keepgoing))
+ if (!ddsrt_atomic_ld32(&gv->rtps_keepgoing))
{
- ddsi_tcp_sock_free (&listener->m_base.gv->logconfig, sock, NULL);
+ ddsi_tcp_sock_free (gv, sock, NULL);
return NULL;
}
} while (rc == DDS_RETCODE_INTERRUPTED || rc == DDS_RETCODE_TRY_AGAIN);
if (sock == DDSRT_INVALID_SOCKET)
{
- (void)ddsrt_getsockname (tl->m_sock, (struct sockaddr *) &addr, &addrlen);
- sockaddr_to_string_with_port(fact, buff, sizeof(buff), (struct sockaddr *)&addr);
- DDS_CLOG ((rc == DDS_RETCODE_OK) ? DDS_LC_ERROR : DDS_LC_FATAL, &listener->m_base.gv->logconfig, "tcp accept failed on socket %"PRIdSOCK" at %s retcode %"PRId32"\n", tl->m_sock, buff, rc);
+ (void)ddsrt_getsockname (tl->m_sock, &addr.a, &addrlen);
+ sockaddr_to_string_with_port(fact, buff, sizeof(buff), &addr.a);
+ GVLOG ((rc == DDS_RETCODE_OK) ? DDS_LC_ERROR : DDS_LC_FATAL, "tcp accept failed on socket %"PRIdSOCK" at %s retcode %"PRId32"\n", tl->m_sock, buff, rc);
}
- else if (getpeername (sock, (struct sockaddr *) &addr, &addrlen) == -1)
+ else if (getpeername (sock, &addr.a, &addrlen) == -1)
{
- DDS_CWARNING (&listener->m_base.gv->logconfig, "tcp accepted new socket %"PRIdSOCK" on socket %"PRIdSOCK" but no peer address, errno %"PRId32"\n", sock, tl->m_sock, rc);
+ GVWARNING ("tcp accepted new socket %"PRIdSOCK" on socket %"PRIdSOCK" but no peer address, errno %"PRId32"\n", sock, tl->m_sock, rc);
ddsrt_close (sock);
}
else
{
- sockaddr_to_string_with_port(fact, buff, sizeof(buff), (struct sockaddr *)&addr);
- DDS_CLOG (DDS_LC_TCP, &listener->m_base.gv->logconfig, "tcp accept new socket %"PRIdSOCK" on socket %"PRIdSOCK" from %s\n", sock, tl->m_sock, buff);
+ sockaddr_to_string_with_port(fact, buff, sizeof(buff), &addr.a);
+ GVLOG (DDS_LC_TCP, "tcp accept new socket %"PRIdSOCK" on socket %"PRIdSOCK" from %s\n", sock, tl->m_sock, buff);
(void)ddsrt_setsocknonblocking (sock, true);
- tcp = ddsi_tcp_new_conn (fact, sock, true, (struct sockaddr *)&addr);
+ tcp = ddsi_tcp_new_conn (fact, sock, true, &addr.a);
#ifdef DDSI_INCLUDE_SSL
tcp->m_ssl = ssl;
#endif
@@ -891,14 +895,20 @@ static ddsrt_socket_t ddsi_tcp_listener_handle (ddsi_tran_base_t base)
caller (supporting call back over NAT).
*/
+static void addr_to_loc (const struct ddsi_tran_factory *fact, nn_locator_t *loc, const union addr *addr)
+{
+ ddsi_ipaddr_to_loc (fact, loc, &addr->a, addrfam_to_locator_kind (addr->a.sa_family));
+}
+
static void ddsi_tcp_conn_peer_locator (ddsi_tran_conn_t conn, nn_locator_t * loc)
{
+ struct ddsi_domaingv const * const gv = conn->m_base.gv;
char buff[DDSI_LOCSTRLEN];
ddsi_tcp_conn_t tc = (ddsi_tcp_conn_t) conn;
assert (tc->m_sock != DDSRT_INVALID_SOCKET);
- ddsi_ipaddr_to_loc (conn->m_factory, loc, (struct sockaddr *)&tc->m_peer_addr, tc->m_peer_addr.ss_family == AF_INET ? NN_LOCATOR_KIND_TCPv4 : NN_LOCATOR_KIND_TCPv6);
+ addr_to_loc (conn->m_factory, loc, &tc->m_peer_addr);
ddsi_locator_to_string(buff, sizeof(buff), loc);
- DDS_CLOG (DDS_LC_TCP, &conn->m_base.gv->logconfig, "(tcp EP:%s)", buff);
+ GVLOG (DDS_LC_TCP, "(tcp EP:%s)", buff);
}
static void ddsi_tcp_base_init (const struct ddsi_tran_factory_tcp *fact, struct ddsi_tran_conn *base)
@@ -915,7 +925,7 @@ static void ddsi_tcp_base_init (const struct ddsi_tran_factory_tcp *fact, struct
static ddsi_tcp_conn_t ddsi_tcp_new_conn (struct ddsi_tran_factory_tcp *fact, ddsrt_socket_t sock, bool server, struct sockaddr * peer)
{
- ddsi_tcp_conn_t conn = (ddsi_tcp_conn_t) ddsrt_malloc (sizeof (*conn));
+ ddsi_tcp_conn_t conn = ddsrt_malloc (sizeof (*conn));
memset (conn, 0, sizeof (*conn));
ddsi_tcp_base_init (fact, &conn->m_base);
@@ -930,19 +940,30 @@ static ddsi_tcp_conn_t ddsi_tcp_new_conn (struct ddsi_tran_factory_tcp *fact, dd
return conn;
}
-static ddsi_tran_listener_t ddsi_tcp_create_listener (ddsi_tran_factory_t fact, uint32_t port, const struct ddsi_tran_qos *qos)
+static dds_return_t ddsi_tcp_create_listener (ddsi_tran_listener_t *listener_out, ddsi_tran_factory_t fact, uint32_t port, const struct ddsi_tran_qos *qos)
{
struct ddsi_tran_factory_tcp * const fact_tcp = (struct ddsi_tran_factory_tcp *) fact;
- struct ddsi_domaingv * const gv = fact_tcp->fact.gv;
+ struct ddsi_domaingv const * const gv = fact_tcp->fact.gv;
ddsrt_socket_t sock;
-
(void) qos;
- if (ddsi_tcp_sock_new (fact_tcp, &sock, (unsigned short) port) != DDS_RETCODE_OK)
- return NULL;
+ if (ddsi_tcp_sock_new (fact_tcp, &sock, (uint16_t) port) != DDS_RETCODE_OK)
+ return DDS_RETCODE_ERROR;
+ char buff[DDSI_LOCSTRLEN];
+ union addr addr;
+ socklen_t addrlen = sizeof (addr);
dds_return_t ret;
- ddsi_tcp_listener_t tl = (ddsi_tcp_listener_t) ddsrt_malloc (sizeof (*tl));
+ if ((ret = ddsrt_getsockname (sock, &addr.a, &addrlen)) != DDS_RETCODE_OK)
+ {
+ GVERROR ("ddsi_tcp_create_listener: ddsrt_getsockname returned %"PRId32"\n", ret);
+ ddsi_tcp_sock_free (gv, sock, NULL);
+ return DDS_RETCODE_ERROR;
+ }
+ sockaddr_to_string_with_port (fact_tcp, buff, sizeof (buff), &addr.a);
+ GVLOG (DDS_LC_TCP, "tcp create listener socket %"PRIdSOCK" on %s\n", sock, buff);
+
+ ddsi_tcp_listener_t tl = ddsrt_malloc (sizeof (*tl));
memset (tl, 0, sizeof (*tl));
tl->m_sock = sock;
@@ -952,33 +973,21 @@ static ddsi_tran_listener_t ddsi_tcp_create_listener (ddsi_tran_factory_t fact,
tl->m_base.m_accept_fn = ddsi_tcp_accept;
tl->m_base.m_factory = fact;
- tl->m_base.m_base.m_port = get_socket_port (&fact->gv->logconfig, sock);
+ tl->m_base.m_base.m_port = get_socket_port (gv, sock);
tl->m_base.m_base.m_trantype = DDSI_TRAN_LISTENER;
tl->m_base.m_base.m_handle_fn = ddsi_tcp_listener_handle;
tl->m_base.m_locator_fn = ddsi_tcp_locator;
-
- struct sockaddr_storage addr;
- socklen_t addrlen = sizeof (addr);
- if ((ret = ddsrt_getsockname (sock, (struct sockaddr *) &addr, &addrlen)) != DDS_RETCODE_OK)
- {
- GVERROR ("ddsi_tcp_create_listener: ddsrt_getsockname returned %"PRId32"\n", ret);
- ddsi_tcp_sock_free (&fact->gv->logconfig, sock, NULL);
- ddsrt_free (tl);
- return NULL;
- }
-
- char buff[DDSI_LOCSTRLEN];
- sockaddr_to_string_with_port (fact_tcp, buff, sizeof (buff), (struct sockaddr *) &addr);
- GVLOG (DDS_LC_TCP, "tcp create listener socket %"PRIdSOCK" on %s\n", sock, buff);
- return &tl->m_base;
+ *listener_out = &tl->m_base;
+ return DDS_RETCODE_OK;
}
static void ddsi_tcp_conn_delete (ddsi_tcp_conn_t conn)
{
struct ddsi_tran_factory_tcp * const fact = (struct ddsi_tran_factory_tcp *) conn->m_base.m_factory;
+ struct ddsi_domaingv const * const gv = fact->fact.gv;
char buff[DDSI_LOCSTRLEN];
- sockaddr_to_string_with_port(fact, buff, sizeof(buff), (struct sockaddr *)&conn->m_peer_addr);
- DDS_CLOG (DDS_LC_TCP, &conn->m_base.m_base.gv->logconfig, "tcp free %s connnection on socket %"PRIdSOCK" to %s\n", conn->m_base.m_server ? "server" : "client", conn->m_sock, buff);
+ sockaddr_to_string_with_port(fact, buff, sizeof(buff), &conn->m_peer_addr.a);
+ GVLOG (DDS_LC_TCP, "tcp free %s connnection on socket %"PRIdSOCK" to %s\n", conn->m_base.m_server ? "server" : "client", conn->m_sock, buff);
#ifdef DDSI_INCLUDE_SSL
if (fact->ddsi_tcp_ssl_plugin.ssl_free)
@@ -988,7 +997,7 @@ static void ddsi_tcp_conn_delete (ddsi_tcp_conn_t conn)
else
#endif
{
- ddsi_tcp_sock_free (&conn->m_base.m_base.gv->logconfig, conn->m_sock, "connection");
+ ddsi_tcp_sock_free (gv, conn->m_sock, "connection");
}
ddsrt_mutex_destroy (&conn->m_mutex);
ddsrt_free (conn);
@@ -997,17 +1006,18 @@ static void ddsi_tcp_conn_delete (ddsi_tcp_conn_t conn)
static void ddsi_tcp_close_conn (ddsi_tran_conn_t tc)
{
struct ddsi_tran_factory_tcp * const fact_tcp = (struct ddsi_tran_factory_tcp *) tc->m_factory;
+ struct ddsi_domaingv * const gv = fact_tcp->fact.gv;
if (tc != &fact_tcp->ddsi_tcp_conn_client.m_base)
{
char buff[DDSI_LOCSTRLEN];
nn_locator_t loc;
ddsi_tcp_conn_t conn = (ddsi_tcp_conn_t) tc;
- sockaddr_to_string_with_port(fact_tcp, buff, sizeof(buff), (struct sockaddr *)&conn->m_peer_addr);
- DDS_CLOG (DDS_LC_TCP, &tc->m_base.gv->logconfig, "tcp close %s connnection on socket %"PRIdSOCK" to %s\n", conn->m_base.m_server ? "server" : "client", conn->m_sock, buff);
+ sockaddr_to_string_with_port(fact_tcp, buff, sizeof(buff), &conn->m_peer_addr.a);
+ GVLOG (DDS_LC_TCP, "tcp close %s connnection on socket %"PRIdSOCK" to %s\n", conn->m_base.m_server ? "server" : "client", conn->m_sock, buff);
(void) shutdown (conn->m_sock, 2);
- ddsi_ipaddr_to_loc(&fact_tcp->fact, &loc, (struct sockaddr *)&conn->m_peer_addr, conn->m_peer_addr.ss_family == AF_INET ? NN_LOCATOR_KIND_TCPv4 : NN_LOCATOR_KIND_TCPv6);
+ ddsi_ipaddr_to_loc(&fact_tcp->fact, &loc, &conn->m_peer_addr.a, addrfam_to_locator_kind(conn->m_peer_addr.a.sa_family));
loc.port = conn->m_peer_port;
- purge_proxy_participants (conn->m_base.m_base.gv, &loc, conn->m_base.m_server);
+ purge_proxy_participants (gv, &loc, conn->m_base.m_server);
}
}
@@ -1023,7 +1033,7 @@ static void ddsi_tcp_release_conn (ddsi_tran_conn_t conn)
static void ddsi_tcp_unblock_listener (ddsi_tran_listener_t listener)
{
struct ddsi_tran_factory_tcp * const fact_tcp = (struct ddsi_tran_factory_tcp *) listener->m_factory;
- struct ddsi_domaingv * const gv = fact_tcp->fact.gv;
+ struct ddsi_domaingv const * const gv = fact_tcp->fact.gv;
ddsi_tcp_listener_t tl = (ddsi_tcp_listener_t) listener;
ddsrt_socket_t sock;
dds_return_t ret;
@@ -1032,44 +1042,40 @@ static void ddsi_tcp_unblock_listener (ddsi_tran_listener_t listener)
if (ddsi_tcp_sock_new (fact_tcp, &sock, 0) != DDS_RETCODE_OK)
goto fail;
- struct sockaddr_storage addr;
+ union addr addr;
socklen_t addrlen = sizeof (addr);
- if ((ret = ddsrt_getsockname (tl->m_sock, (struct sockaddr *) &addr, &addrlen)) != DDS_RETCODE_OK)
+ if ((ret = ddsrt_getsockname (tl->m_sock, &addr.a, &addrlen)) != DDS_RETCODE_OK)
{
GVWARNING ("tcp failed to get listener address error %"PRId32"\n", ret);
goto fail_w_socket;
}
- switch (addr.ss_family)
+ switch (addr.a.sa_family)
{
- case AF_INET: {
- struct sockaddr_in *socketname = (struct sockaddr_in *) &addr;
- if (socketname->sin_addr.s_addr == htonl (INADDR_ANY))
- socketname->sin_addr.s_addr = htonl (INADDR_LOOPBACK);
+ case AF_INET:
+ if (addr.a4.sin_addr.s_addr == htonl (INADDR_ANY))
+ addr.a4.sin_addr.s_addr = htonl (INADDR_LOOPBACK);
break;
- }
#if DDSRT_HAVE_IPV6
- case AF_INET6: {
- struct sockaddr_in6 *socketname = (struct sockaddr_in6 *) &addr;
- if (memcmp (&socketname->sin6_addr, &ddsrt_in6addr_any, sizeof (socketname->sin6_addr)) == 0)
- socketname->sin6_addr = ddsrt_in6addr_loopback;
+ case AF_INET6:
+ if (memcmp (&addr.a6.sin6_addr, &ddsrt_in6addr_any, sizeof (addr.a6.sin6_addr)) == 0)
+ addr.a6.sin6_addr = ddsrt_in6addr_loopback;
break;
- }
#endif
}
do {
- ret = ddsrt_connect (sock, (struct sockaddr *) &addr, ddsrt_sockaddr_get_size ((struct sockaddr *) &addr));
+ ret = ddsrt_connect (sock, &addr.a, ddsrt_sockaddr_get_size (&addr.a));
} while (ret == DDS_RETCODE_INTERRUPTED);
if (ret != DDS_RETCODE_OK)
{
struct ddsi_tran_factory_tcp * const fact = (struct ddsi_tran_factory_tcp *) listener->m_factory;
char buff[DDSI_LOCSTRLEN];
- sockaddr_to_string_with_port (fact, buff, sizeof (buff), (struct sockaddr *) &addr);
+ sockaddr_to_string_with_port (fact, buff, sizeof (buff), &addr.a);
GVWARNING ("tcp failed to connect to own listener (%s) error %"PRId32"\n", buff, ret);
}
fail_w_socket:
- ddsi_tcp_sock_free (&listener->m_base.gv->logconfig, sock, NULL);
+ ddsi_tcp_sock_free (gv, sock, NULL);
fail:
return;
}
@@ -1077,6 +1083,7 @@ fail:
static void ddsi_tcp_release_listener (ddsi_tran_listener_t listener)
{
ddsi_tcp_listener_t tl = (ddsi_tcp_listener_t) listener;
+ struct ddsi_domaingv const * const gv = tl->m_base.m_base.gv;
#ifdef DDSI_INCLUDE_SSL
struct ddsi_tran_factory_tcp * const fact = (struct ddsi_tran_factory_tcp *) listener->m_factory;
if (fact->ddsi_tcp_ssl_plugin.bio_vfree)
@@ -1084,13 +1091,14 @@ static void ddsi_tcp_release_listener (ddsi_tran_listener_t listener)
(fact->ddsi_tcp_ssl_plugin.bio_vfree) (tl->m_bio);
}
#endif
- ddsi_tcp_sock_free (&listener->m_base.gv->logconfig, tl->m_sock, "listener");
+ ddsi_tcp_sock_free (gv, tl->m_sock, "listener");
ddsrt_free (tl);
}
static void ddsi_tcp_release_factory (struct ddsi_tran_factory *fact_cmn)
{
struct ddsi_tran_factory_tcp * const fact = (struct ddsi_tran_factory_tcp *) fact_cmn;
+ struct ddsi_domaingv const * const gv = fact->fact.gv;
ddsrt_avl_free (&ddsi_tcp_treedef, &fact->ddsi_tcp_cache_g, ddsi_tcp_node_free);
ddsrt_mutex_destroy (&fact->ddsi_tcp_cache_lock_g);
#ifdef DDSI_INCLUDE_SSL
@@ -1099,7 +1107,7 @@ static void ddsi_tcp_release_factory (struct ddsi_tran_factory *fact_cmn)
(fact->ddsi_tcp_ssl_plugin.fini) ();
}
#endif
- DDS_CLOG (DDS_LC_CONFIG, &fact_cmn->gv->logconfig, "tcp de-initialized\n");
+ GVLOG (DDS_LC_CONFIG, "tcp de-initialized\n");
ddsrt_free (fact);
}
diff --git a/src/core/ddsi/src/ddsi_tran.c b/src/core/ddsi/src/ddsi_tran.c
index fdf1fcf..afd7c33 100644
--- a/src/core/ddsi/src/ddsi_tran.c
+++ b/src/core/ddsi/src/ddsi_tran.c
@@ -24,13 +24,13 @@
extern inline uint32_t ddsi_conn_type (ddsi_tran_conn_t conn);
extern inline uint32_t ddsi_conn_port (ddsi_tran_conn_t conn);
-extern inline ddsi_tran_listener_t ddsi_factory_create_listener (ddsi_tran_factory_t factory, uint32_t port, const struct ddsi_tran_qos *qos);
+extern inline dds_return_t ddsi_factory_create_listener (ddsi_tran_listener_t *listener, ddsi_tran_factory_t factory, uint32_t port, const struct ddsi_tran_qos *qos);
extern inline bool ddsi_factory_supports (const struct ddsi_tran_factory *factory, int32_t kind);
extern inline int ddsi_is_valid_port (ddsi_tran_factory_t factory, uint32_t port);
extern inline ddsrt_socket_t ddsi_conn_handle (ddsi_tran_conn_t conn);
extern inline int ddsi_conn_locator (ddsi_tran_conn_t conn, nn_locator_t * loc);
extern inline ddsrt_socket_t ddsi_tran_handle (ddsi_tran_base_t base);
-extern inline ddsi_tran_conn_t ddsi_factory_create_conn (ddsi_tran_factory_t factory, uint32_t port, const struct ddsi_tran_qos *qos);
+extern inline dds_return_t ddsi_factory_create_conn (ddsi_tran_conn_t *conn, ddsi_tran_factory_t factory, uint32_t port, const struct ddsi_tran_qos *qos);
extern inline int ddsi_listener_locator (ddsi_tran_listener_t listener, nn_locator_t * loc);
extern inline int ddsi_listener_listen (ddsi_tran_listener_t listener);
extern inline ddsi_tran_conn_t ddsi_listener_accept (ddsi_tran_listener_t listener);
diff --git a/src/core/ddsi/src/ddsi_udp.c b/src/core/ddsi/src/ddsi_udp.c
index 382f029..3410510 100644
--- a/src/core/ddsi/src/ddsi_udp.c
+++ b/src/core/ddsi/src/ddsi_udp.c
@@ -26,6 +26,13 @@
#include "dds/ddsi/q_pcap.h"
#include "dds/ddsi/ddsi_domaingv.h"
+union addr {
+ struct sockaddr_storage x;
+ struct sockaddr a;
+ struct sockaddr_in a4;
+ struct sockaddr_in6 a6;
+};
+
typedef struct ddsi_udp_conn {
struct ddsi_tran_conn m_base;
ddsrt_socket_t m_sock;
@@ -35,20 +42,27 @@ typedef struct ddsi_udp_conn {
int m_diffserv;
} *ddsi_udp_conn_t;
-static ssize_t ddsi_udp_conn_read (ddsi_tran_conn_t conn, unsigned char * buf, size_t len, bool allow_spurious, nn_locator_t *srcloc)
+static void addr_to_loc (const struct ddsi_tran_factory *tran, nn_locator_t *dst, const union addr *src)
{
+ ddsi_ipaddr_to_loc (tran, dst, &src->a, (src->a.sa_family == AF_INET) ? NN_LOCATOR_KIND_UDPv4 : NN_LOCATOR_KIND_UDPv6);
+}
+
+static ssize_t ddsi_udp_conn_read (ddsi_tran_conn_t conn_cmn, unsigned char * buf, size_t len, bool allow_spurious, nn_locator_t *srcloc)
+{
+ ddsi_udp_conn_t conn = (ddsi_udp_conn_t) conn_cmn;
+ struct ddsi_domaingv * const gv = conn->m_base.m_base.gv;
dds_return_t rc;
ssize_t ret = 0;
ddsrt_msghdr_t msghdr;
- struct sockaddr_storage src;
+ union addr src;
ddsrt_iovec_t msg_iov;
socklen_t srclen = (socklen_t) sizeof (src);
(void) allow_spurious;
- msg_iov.iov_base = (void*) buf;
- msg_iov.iov_len = (ddsrt_iov_len_t)len; /* Windows uses unsigned, POSIX (except Linux) int */
+ msg_iov.iov_base = (void *) buf;
+ msg_iov.iov_len = (ddsrt_iov_len_t) len; /* Windows uses unsigned, POSIX (except Linux) int */
- msghdr.msg_name = &src;
+ msghdr.msg_name = &src.x;
msghdr.msg_namelen = srclen;
msghdr.msg_iov = &msg_iov;
msghdr.msg_iovlen = 1;
@@ -61,65 +75,67 @@ static ssize_t ddsi_udp_conn_read (ddsi_tran_conn_t conn, unsigned char * buf, s
#endif
do {
- rc = ddsrt_recvmsg(((ddsi_udp_conn_t) conn)->m_sock, &msghdr, 0, &ret);
+ rc = ddsrt_recvmsg (conn->m_sock, &msghdr, 0, &ret);
} while (rc == DDS_RETCODE_INTERRUPTED);
if (ret > 0)
{
if (srcloc)
- ddsi_ipaddr_to_loc(conn->m_factory, srcloc, (struct sockaddr *)&src, src.ss_family == AF_INET ? NN_LOCATOR_KIND_UDPv4 : NN_LOCATOR_KIND_UDPv6);
+ addr_to_loc (conn->m_base.m_factory, srcloc, &src);
- if(conn->m_base.gv->pcap_fp)
+ if (gv->pcap_fp)
{
- struct sockaddr_storage dest;
+ union addr dest;
socklen_t dest_len = sizeof (dest);
- if (ddsrt_getsockname (((ddsi_udp_conn_t) conn)->m_sock, (struct sockaddr *) &dest, &dest_len) != DDS_RETCODE_OK)
- memset(&dest, 0, sizeof(dest));
- write_pcap_received(conn->m_base.gv, ddsrt_time_wallclock(), &src, &dest, buf, (size_t) ret);
+ if (ddsrt_getsockname (conn->m_sock, &dest.a, &dest_len) != DDS_RETCODE_OK)
+ memset (&dest, 0, sizeof (dest));
+ write_pcap_received (gv, ddsrt_time_wallclock (), &src.x, &dest.x, buf, (size_t) ret);
}
/* Check for udp packet truncation */
- if ((((size_t) ret) > len)
#if DDSRT_MSGHDR_FLAGS
- || (msghdr.msg_flags & MSG_TRUNC)
+ const bool trunc_flag = (msghdr.msg_flags & MSG_TRUNC) != 0;
+#else
+ const bool trunc_flag = false;
#endif
- )
+ if ((size_t) ret > len || trunc_flag)
{
char addrbuf[DDSI_LOCSTRLEN];
nn_locator_t tmp;
- ddsi_ipaddr_to_loc(conn->m_factory, &tmp, (struct sockaddr *)&src, src.ss_family == AF_INET ? NN_LOCATOR_KIND_UDPv4 : NN_LOCATOR_KIND_UDPv6);
- ddsi_locator_to_string(addrbuf, sizeof(addrbuf), &tmp);
- DDS_CWARNING(&conn->m_base.gv->logconfig, "%s => %d truncated to %d\n", addrbuf, (int)ret, (int)len);
+ addr_to_loc (conn->m_base.m_factory, &tmp, &src);
+ ddsi_locator_to_string (addrbuf, sizeof (addrbuf), &tmp);
+ GVWARNING ("%s => %d truncated to %d\n", addrbuf, (int) ret, (int) len);
}
}
- else if (rc != DDS_RETCODE_BAD_PARAMETER &&
- rc != DDS_RETCODE_NO_CONNECTION)
+ else if (rc != DDS_RETCODE_BAD_PARAMETER && rc != DDS_RETCODE_NO_CONNECTION)
{
- DDS_CERROR(&conn->m_base.gv->logconfig, "UDP recvmsg sock %d: ret %d retcode %"PRId32"\n", (int) ((ddsi_udp_conn_t) conn)->m_sock, (int) ret, rc);
+ GVERROR ("UDP recvmsg sock %d: ret %d retcode %"PRId32"\n", (int) conn->m_sock, (int) ret, rc);
ret = -1;
}
return ret;
}
-static void set_msghdr_iov (ddsrt_msghdr_t *mhdr, ddsrt_iovec_t *iov, size_t iovlen)
+static void set_msghdr_iov (ddsrt_msghdr_t *mhdr, const ddsrt_iovec_t *iov, size_t iovlen)
{
- mhdr->msg_iov = iov;
- mhdr->msg_iovlen = (ddsrt_msg_iovlen_t)iovlen;
+ mhdr->msg_iov = (ddsrt_iovec_t *) iov;
+ mhdr->msg_iovlen = (ddsrt_msg_iovlen_t) iovlen;
}
-static ssize_t ddsi_udp_conn_write (ddsi_tran_conn_t conn, const nn_locator_t *dst, size_t niov, const ddsrt_iovec_t *iov, uint32_t flags)
+static ssize_t ddsi_udp_conn_write (ddsi_tran_conn_t conn_cmn, const nn_locator_t *dst, size_t niov, const ddsrt_iovec_t *iov, uint32_t flags)
{
+ ddsi_udp_conn_t conn = (ddsi_udp_conn_t) conn_cmn;
+ struct ddsi_domaingv * const gv = conn->m_base.m_base.gv;
dds_return_t rc;
ssize_t ret = -1;
unsigned retry = 2;
int sendflags = 0;
ddsrt_msghdr_t msg;
- struct sockaddr_storage dstaddr;
- assert(niov <= INT_MAX);
- ddsi_ipaddr_from_loc(&dstaddr, dst);
- set_msghdr_iov (&msg, (ddsrt_iovec_t *) iov, niov);
- msg.msg_name = &dstaddr;
- msg.msg_namelen = (socklen_t) ddsrt_sockaddr_get_size((struct sockaddr *) &dstaddr);
+ union addr dstaddr;
+ assert (niov <= INT_MAX);
+ ddsi_ipaddr_from_loc (&dstaddr.x, dst);
+ set_msghdr_iov (&msg, iov, niov);
+ msg.msg_name = &dstaddr.x;
+ msg.msg_namelen = (socklen_t) ddsrt_sockaddr_get_size (&dstaddr.a);
#if defined(__sun) && !defined(_XPG4_2)
msg.msg_accrights = NULL;
msg.msg_accrightslen = 0;
@@ -130,56 +146,53 @@ static ssize_t ddsi_udp_conn_write (ddsi_tran_conn_t conn, const nn_locator_t *d
#if DDSRT_MSGHDR_FLAGS
msg.msg_flags = (int) flags;
#else
- DDSRT_UNUSED_ARG(flags);
+ DDSRT_UNUSED_ARG (flags);
#endif
#if MSG_NOSIGNAL && !LWIP_SOCKET
sendflags |= MSG_NOSIGNAL;
#endif
do {
- ddsi_udp_conn_t uc = (ddsi_udp_conn_t) conn;
- rc = ddsrt_sendmsg (uc->m_sock, &msg, sendflags, &ret);
+ rc = ddsrt_sendmsg (conn->m_sock, &msg, sendflags, &ret);
#if defined _WIN32 && !defined WINCE
- if (rc == DDS_RETCODE_TRY_AGAIN) {
+ if (rc == DDS_RETCODE_TRY_AGAIN)
+ {
WSANETWORKEVENTS ev;
- WaitForSingleObject(uc->m_sockEvent, INFINITE);
- WSAEnumNetworkEvents(uc->m_sock, uc->m_sockEvent, &ev);
+ WaitForSingleObject (conn->m_sockEvent, INFINITE);
+ WSAEnumNetworkEvents (conn->m_sock, conn->m_sockEvent, &ev);
}
#endif
- } while ((rc == DDS_RETCODE_INTERRUPTED) ||
- (rc == DDS_RETCODE_TRY_AGAIN) ||
- (rc == DDS_RETCODE_NOT_ALLOWED && retry-- > 0));
- if (ret > 0 && conn->m_base.gv->pcap_fp)
+ } while (rc == DDS_RETCODE_INTERRUPTED || rc == DDS_RETCODE_TRY_AGAIN || (rc == DDS_RETCODE_NOT_ALLOWED && retry-- > 0));
+ if (ret > 0 && gv->pcap_fp)
{
- struct sockaddr_storage sa;
+ union addr sa;
socklen_t alen = sizeof (sa);
- if (ddsrt_getsockname (((ddsi_udp_conn_t) conn)->m_sock, (struct sockaddr *) &sa, &alen) != DDS_RETCODE_OK)
+ if (ddsrt_getsockname (conn->m_sock, &sa.a, &alen) != DDS_RETCODE_OK)
memset(&sa, 0, sizeof(sa));
- write_pcap_sent (conn->m_base.gv, ddsrt_time_wallclock (), &sa, &msg, (size_t) ret);
+ write_pcap_sent (gv, ddsrt_time_wallclock (), &sa.x, &msg, (size_t) ret);
}
- else if (rc != DDS_RETCODE_OK &&
- rc != DDS_RETCODE_NOT_ALLOWED &&
- rc != DDS_RETCODE_NO_CONNECTION)
+ else if (rc != DDS_RETCODE_OK && rc != DDS_RETCODE_NOT_ALLOWED && rc != DDS_RETCODE_NO_CONNECTION)
{
- DDS_CERROR(&conn->m_base.gv->logconfig, "ddsi_udp_conn_write failed with retcode %"PRId32"\n", rc);
+ GVERROR ("ddsi_udp_conn_write failed with retcode %"PRId32"\n", rc);
}
- return (rc == DDS_RETCODE_OK ? ret : -1);
+ return (rc == DDS_RETCODE_OK) ? ret : -1;
}
-static void ddsi_udp_disable_multiplexing (ddsi_tran_conn_t base)
+static void ddsi_udp_disable_multiplexing (ddsi_tran_conn_t conn_cmn)
{
#if defined _WIN32 && !defined WINCE
- ddsi_udp_conn_t uc = (ddsi_udp_conn_t) base;
+ ddsi_udp_conn_t conn = (ddsi_udp_conn_t) conn_cmn;
uint32_t zero = 0, dummy;
- WSAEventSelect(uc->m_sock, 0, 0);
- WSAIoctl(uc->m_sock, FIONBIO, &zero,sizeof(zero), NULL,0, &dummy, NULL,NULL);
+ WSAEventSelect (conn->m_sock, 0, 0);
+ WSAIoctl (conn->m_sock, FIONBIO, &zero,sizeof(zero), NULL,0, &dummy, NULL,NULL);
#else
- (void)base;
+ (void) conn_cmn;
#endif
}
-static ddsrt_socket_t ddsi_udp_conn_handle (ddsi_tran_base_t base)
+static ddsrt_socket_t ddsi_udp_conn_handle (ddsi_tran_base_t conn_cmn)
{
- return ((ddsi_udp_conn_t) base)->m_sock;
+ ddsi_udp_conn_t conn = (ddsi_udp_conn_t) conn_cmn;
+ return conn->m_sock;
}
static bool ddsi_udp_supports (const struct ddsi_tran_factory *fact, int32_t kind)
@@ -187,162 +200,171 @@ static bool ddsi_udp_supports (const struct ddsi_tran_factory *fact, int32_t kin
return kind == fact->m_kind || (kind == NN_LOCATOR_KIND_UDPv4MCGEN && fact->m_kind == NN_LOCATOR_KIND_UDPv4);
}
-static int ddsi_udp_conn_locator (ddsi_tran_factory_t fact, ddsi_tran_base_t base, nn_locator_t *loc)
+static int ddsi_udp_conn_locator (ddsi_tran_factory_t fact, ddsi_tran_base_t conn_cmn, nn_locator_t *loc)
{
+ ddsi_udp_conn_t conn = (ddsi_udp_conn_t) conn_cmn;
int ret = -1;
- ddsi_udp_conn_t uc = (ddsi_udp_conn_t) base;
- if (uc->m_sock != DDSRT_INVALID_SOCKET)
+ if (conn->m_sock != DDSRT_INVALID_SOCKET)
{
loc->kind = fact->m_kind;
- loc->port = uc->m_base.m_base.m_port;
- memcpy(loc->address, uc->m_base.m_base.gv->extloc.address, sizeof (loc->address));
+ loc->port = conn->m_base.m_base.m_port;
+ memcpy (loc->address, conn->m_base.m_base.gv->extloc.address, sizeof (loc->address));
ret = 0;
}
return ret;
}
-static uint16_t get_socket_port (struct ddsi_domaingv * const gv, ddsrt_socket_t sock)
+static uint16_t get_socket_port (struct ddsi_domaingv const * const gv, ddsrt_socket_t sock)
{
dds_return_t ret;
- struct sockaddr_storage addr;
+ union addr addr;
socklen_t addrlen = sizeof (addr);
-
- ret = ddsrt_getsockname (sock, (struct sockaddr *)&addr, &addrlen);
+ ret = ddsrt_getsockname (sock, &addr.a, &addrlen);
if (ret != DDS_RETCODE_OK)
{
GVERROR ("ddsi_udp_get_socket_port: getsockname returned %"PRId32"\n", ret);
return 0;
}
-
- return ddsrt_sockaddr_get_port ((struct sockaddr *)&addr);
+ return ddsrt_sockaddr_get_port (&addr.a);
}
-static dds_return_t set_dont_route (struct ddsi_domaingv * const gv, ddsrt_socket_t socket, bool ipv6)
+static dds_return_t set_dont_route (struct ddsi_domaingv const * const gv, ddsrt_socket_t socket, bool ipv6)
{
dds_return_t rc;
#if DDSRT_HAVE_IPV6
if (ipv6)
{
- const unsigned ipv6Flag = 1;
- if ((rc = ddsrt_setsockopt (socket, IPPROTO_IPV6, IPV6_UNICAST_HOPS, &ipv6Flag, sizeof (ipv6Flag))) != DDS_RETCODE_OK)
+ const unsigned uone = 1;
+ if ((rc = ddsrt_setsockopt (socket, IPPROTO_IPV6, IPV6_UNICAST_HOPS, &uone, sizeof (uone))) != DDS_RETCODE_OK)
GVERROR ("ddsi_udp_create_conn: set IPV6_UNICAST_HOPS = 1 failed: %s\n", dds_strretcode (rc));
return rc;
}
+#else
+ (void) ipv6;
#endif
const int one = 1;
- if ((rc = ddsrt_setsockopt (socket, SOL_SOCKET, SO_DONTROUTE, (char *) &one, sizeof (one))) != DDS_RETCODE_OK)
+ if ((rc = ddsrt_setsockopt (socket, SOL_SOCKET, SO_DONTROUTE, &one, sizeof (one))) != DDS_RETCODE_OK)
GVERROR ("ddsi_udp_create_conn: set SO_DONTROUTE = 1 failed: %s\n", dds_strretcode (rc));
return rc;
}
-static dds_return_t set_rcvbuf (struct ddsi_domaingv * const gv, ddsrt_socket_t sock, const struct config_maybe_uint32 *min_size)
+static dds_return_t set_rcvbuf (struct ddsi_domaingv const * const gv, ddsrt_socket_t sock, const struct config_maybe_uint32 *min_size)
{
- uint32_t ReceiveBufferSize;
- socklen_t optlen = (socklen_t) sizeof (ReceiveBufferSize);
+ uint32_t size;
+ socklen_t optlen = (socklen_t) sizeof (size);
uint32_t socket_min_rcvbuf_size;
dds_return_t rc;
- if (min_size->isdefault)
- socket_min_rcvbuf_size = 1048576;
- else
- socket_min_rcvbuf_size = min_size->value;
- rc = ddsrt_getsockopt (sock, SOL_SOCKET, SO_RCVBUF, (char *) &ReceiveBufferSize, &optlen);
+ socket_min_rcvbuf_size = min_size->isdefault ? 1048576 : min_size->value;
+ rc = ddsrt_getsockopt (sock, SOL_SOCKET, SO_RCVBUF, &size, &optlen);
if (rc == DDS_RETCODE_BAD_PARAMETER)
{
/* not all stacks support getting/setting RCVBUF */
GVLOG (DDS_LC_CONFIG, "cannot retrieve socket receive buffer size\n");
return DDS_RETCODE_OK;
}
-
- if (rc != DDS_RETCODE_OK)
+ else if (rc != DDS_RETCODE_OK)
{
GVERROR ("ddsi_udp_create_conn: get SO_RCVBUF failed: %s\n", dds_strretcode (rc));
- goto fail;
+ return rc;
}
- if (ReceiveBufferSize < socket_min_rcvbuf_size)
+ if (size < socket_min_rcvbuf_size)
{
/* make sure the receive buffersize is at least the minimum required */
- ReceiveBufferSize = socket_min_rcvbuf_size;
- (void) ddsrt_setsockopt (sock, SOL_SOCKET, SO_RCVBUF, (const char *) &ReceiveBufferSize, sizeof (ReceiveBufferSize));
+ size = socket_min_rcvbuf_size;
+ (void) ddsrt_setsockopt (sock, SOL_SOCKET, SO_RCVBUF, &size, sizeof (size));
/* We don't check the return code from setsockopt, because some O/Ss tend
to silently cap the buffer size. The only way to make sure is to read
the option value back and check it is now set correctly. */
- if ((rc = ddsrt_getsockopt (sock, SOL_SOCKET, SO_RCVBUF, (char *) &ReceiveBufferSize, &optlen)) != DDS_RETCODE_OK)
+ if ((rc = ddsrt_getsockopt (sock, SOL_SOCKET, SO_RCVBUF, &size, &optlen)) != DDS_RETCODE_OK)
{
GVERROR ("ddsi_udp_create_conn: get SO_RCVBUF failed: %s\n", dds_strretcode (rc));
- goto fail;
+ return rc;
}
- if (ReceiveBufferSize >= socket_min_rcvbuf_size)
- GVLOG (DDS_LC_CONFIG, "socket receive buffer size set to %"PRIu32" bytes\n", ReceiveBufferSize);
+ if (size >= socket_min_rcvbuf_size)
+ GVLOG (DDS_LC_CONFIG, "socket receive buffer size set to %"PRIu32" bytes\n", size);
+ else if (min_size->isdefault)
+ GVLOG (DDS_LC_CONFIG,
+ "failed to increase socket receive buffer size to %"PRIu32" bytes, continuing with %"PRIu32" bytes\n",
+ socket_min_rcvbuf_size, size);
else
- GVLOG (min_size->isdefault ? DDS_LC_CONFIG : DDS_LC_ERROR,
- "failed to increase socket receive buffer size to %"PRIu32" bytes, continuing with %"PRIu32" bytes\n",
- socket_min_rcvbuf_size, ReceiveBufferSize);
+ {
+ /* If the configuration states it must be >= X, then error out if the
+ kernel doesn't give us at least X */
+ GVLOG (DDS_LC_CONFIG | DDS_LC_ERROR,
+ "failed to increase socket receive buffer size to %"PRIu32" bytes, maximum is %"PRIu32" bytes\n",
+ socket_min_rcvbuf_size, size);
+ rc = DDS_RETCODE_NOT_ENOUGH_SPACE;
+ }
}
-fail:
return rc;
}
-static dds_return_t set_sndbuf (struct ddsi_domaingv * const gv, ddsrt_socket_t sock, uint32_t min_size)
+static dds_return_t set_sndbuf (struct ddsi_domaingv const * const gv, ddsrt_socket_t sock, uint32_t min_size)
{
- unsigned SendBufferSize;
- socklen_t optlen = (socklen_t) sizeof(SendBufferSize);
+ unsigned size;
+ socklen_t optlen = (socklen_t) sizeof(size);
dds_return_t rc;
- rc = ddsrt_getsockopt(sock, SOL_SOCKET, SO_SNDBUF,(char *)&SendBufferSize, &optlen);
+ rc = ddsrt_getsockopt (sock, SOL_SOCKET, SO_SNDBUF, &size, &optlen);
if (rc == DDS_RETCODE_BAD_PARAMETER)
{
/* not all stacks support getting/setting SNDBUF */
GVLOG (DDS_LC_CONFIG, "cannot retrieve socket send buffer size\n");
return DDS_RETCODE_OK;
}
-
- if (rc != DDS_RETCODE_OK)
+ else if (rc != DDS_RETCODE_OK)
{
GVERROR ("ddsi_udp_create_conn: get SO_SNDBUF failed: %s\n", dds_strretcode (rc));
- goto fail;
+ return rc;
}
- if (SendBufferSize < min_size)
+ if (size < min_size)
{
/* make sure the send buffersize is at least the minimum required */
- SendBufferSize = min_size;
- if ((rc = ddsrt_setsockopt (sock, SOL_SOCKET, SO_SNDBUF, (const char *) &SendBufferSize, sizeof (SendBufferSize))) != DDS_RETCODE_OK)
+ size = min_size;
+ if ((rc = ddsrt_setsockopt (sock, SOL_SOCKET, SO_SNDBUF, &size, sizeof (size))) != DDS_RETCODE_OK)
{
GVERROR ("ddsi_udp_create_conn: set SO_SNDBUF failed: %s\n", dds_strretcode (rc));
- goto fail;
+ return rc;
}
}
-fail:
- return rc;
+ return DDS_RETCODE_OK;
}
-static dds_return_t set_mc_options_transmit_ipv6 (struct ddsi_domaingv * const gv, ddsrt_socket_t sock)
+static dds_return_t set_mc_options_transmit_ipv6 (struct ddsi_domaingv const * const gv, ddsrt_socket_t sock)
{
+ /* Function is a never-called no-op if IPv6 is not supported to keep the call-site a bit cleaner */
#if DDSRT_HAVE_IPV6
- const unsigned interfaceNo = gv->interfaceNo;
+ const unsigned ifno = gv->interfaceNo;
const unsigned ttl = (unsigned) gv->config.multicast_ttl;
const unsigned loop = (unsigned) !!gv->config.enableMulticastLoopback;
dds_return_t rc;
- if ((rc = ddsrt_setsockopt (sock, IPPROTO_IPV6, IPV6_MULTICAST_IF, &interfaceNo, sizeof (interfaceNo))) != DDS_RETCODE_OK)
+ if ((rc = ddsrt_setsockopt (sock, IPPROTO_IPV6, IPV6_MULTICAST_IF, &ifno, sizeof (ifno))) != DDS_RETCODE_OK) {
GVERROR ("ddsi_udp_create_conn: set IPV6_MULTICAST_IF failed: %s\n", dds_strretcode (rc));
- else if ((rc = ddsrt_setsockopt (sock, IPPROTO_IPV6, IPV6_MULTICAST_HOPS, (char *) &ttl, sizeof (ttl))) != DDS_RETCODE_OK)
+ return rc;
+ }
+ if ((rc = ddsrt_setsockopt (sock, IPPROTO_IPV6, IPV6_MULTICAST_HOPS, &ttl, sizeof (ttl))) != DDS_RETCODE_OK) {
GVERROR ("ddsi_udp_create_conn: set IPV6_MULTICAST_HOPS failed: %s\n", dds_strretcode (rc));
- else if ((rc = ddsrt_setsockopt (sock, IPPROTO_IPV6, IPV6_MULTICAST_LOOP, &loop, sizeof (loop))) != DDS_RETCODE_OK)
+ return rc;
+ }
+ if ((rc = ddsrt_setsockopt (sock, IPPROTO_IPV6, IPV6_MULTICAST_LOOP, &loop, sizeof (loop))) != DDS_RETCODE_OK) {
GVERROR ("ddsi_udp_create_conn: set IPV6_MULTICAST_LOOP failed: %s\n", dds_strretcode (rc));
- return rc;
+ return rc;
+ }
+ return DDS_RETCODE_OK;
#else
(void) gv; (void) sock;
return DDS_RETCODE_ERROR;
#endif
}
-static dds_return_t set_mc_options_transmit_ipv4_if (struct ddsi_domaingv * const gv, ddsrt_socket_t sock)
+static dds_return_t set_mc_options_transmit_ipv4_if (struct ddsi_domaingv const * const gv, ddsrt_socket_t sock)
{
#if (defined(__linux) || defined(__APPLE__)) && !LWIP_SOCKET
if (gv->config.use_multicast_if_mreqn)
@@ -362,23 +384,29 @@ static dds_return_t set_mc_options_transmit_ipv4_if (struct ddsi_domaingv * cons
return ddsrt_setsockopt (sock, IPPROTO_IP, IP_MULTICAST_IF, gv->ownloc.address + 12, 4);
}
-static dds_return_t set_mc_options_transmit_ipv4 (struct ddsi_domaingv * const gv, ddsrt_socket_t sock)
+static dds_return_t set_mc_options_transmit_ipv4 (struct ddsi_domaingv const * const gv, ddsrt_socket_t sock)
{
const unsigned char ttl = (unsigned char) gv->config.multicast_ttl;
const unsigned char loop = (unsigned char) !!gv->config.enableMulticastLoopback;
dds_return_t rc;
- if ((rc = set_mc_options_transmit_ipv4_if (gv, sock)) != DDS_RETCODE_OK)
+ if ((rc = set_mc_options_transmit_ipv4_if (gv, sock)) != DDS_RETCODE_OK) {
GVERROR ("ddsi_udp_create_conn: set IP_MULTICAST_IF failed: %s\n", dds_strretcode (rc));
- else if ((rc = ddsrt_setsockopt (sock, IPPROTO_IP, IP_MULTICAST_TTL, (char *) &ttl, sizeof (ttl))) != DDS_RETCODE_OK)
+ return rc;
+ }
+ if ((rc = ddsrt_setsockopt (sock, IPPROTO_IP, IP_MULTICAST_TTL, &ttl, sizeof (ttl))) != DDS_RETCODE_OK) {
GVERROR ("ddsi_udp_create_conn: set IP_MULTICAST_TTL failed: %s\n", dds_strretcode (rc));
- else if ((rc = ddsrt_setsockopt (sock, IPPROTO_IP, IP_MULTICAST_LOOP, &loop, sizeof (loop))) != DDS_RETCODE_OK)
+ return rc;
+ }
+ if ((rc = ddsrt_setsockopt (sock, IPPROTO_IP, IP_MULTICAST_LOOP, &loop, sizeof (loop))) != DDS_RETCODE_OK) {
GVERROR ("ddsi_udp_create_conn: set IP_MULTICAST_LOOP failed: %s\n", dds_strretcode (rc));
- return rc;
+ return rc;
+ }
+ return DDS_RETCODE_OK;
}
-static ddsi_tran_conn_t ddsi_udp_create_conn (ddsi_tran_factory_t fact, uint32_t port, const ddsi_tran_qos_t *qos)
+static dds_return_t ddsi_udp_create_conn (ddsi_tran_conn_t *conn_out, ddsi_tran_factory_t fact, uint32_t port, const ddsi_tran_qos_t *qos)
{
- struct ddsi_domaingv * const gv = fact->gv;
+ struct ddsi_domaingv const * const gv = fact->gv;
const int one = 1;
dds_return_t rc;
@@ -406,31 +434,37 @@ static ddsi_tran_conn_t ddsi_udp_create_conn (ddsi_tran_factory_t fact, uint32_t
}
assert (purpose_str != NULL);
+ union addr socketname;
+ nn_locator_t ownloc_w_port = gv->ownloc;
+ assert (ownloc_w_port.port == NN_LOCATOR_PORT_INVALID);
+ if (port) {
+ /* PORT_INVALID maps to 0 in ipaddr_from_loc */
+ ownloc_w_port.port = port;
+ }
+ ddsi_ipaddr_from_loc (&socketname.x, &ownloc_w_port);
+ switch (fact->m_kind)
{
- int af = AF_UNSPEC;
- switch (fact->m_kind)
- {
- case NN_LOCATOR_KIND_UDPv4:
- af = AF_INET;
- break;
+ case NN_LOCATOR_KIND_UDPv4:
+ if (bind_to_any)
+ socketname.a4.sin_addr.s_addr = htonl (INADDR_ANY);
+ break;
#if DDSRT_HAVE_IPV6
- case NN_LOCATOR_KIND_UDPv6:
- af = AF_INET6;
- ipv6 = true;
- break;
+ case NN_LOCATOR_KIND_UDPv6:
+ ipv6 = true;
+ if (bind_to_any)
+ socketname.a6.sin6_addr = ddsrt_in6addr_any;
+ break;
#endif
- default:
- DDS_FATAL ("ddsi_udp_create_conn: unsupported kind %"PRId32"\n", fact->m_kind);
- }
- assert (af != AF_UNSPEC);
- if ((rc = ddsrt_socket (&sock, af, SOCK_DGRAM, 0)) != DDS_RETCODE_OK)
- {
- GVERROR ("ddsi_udp_create_conn: failed to create socket: %s\n", dds_strretcode (rc));
- goto fail;
- }
+ default:
+ DDS_FATAL ("ddsi_udp_create_conn: unsupported kind %"PRId32"\n", fact->m_kind);
+ }
+ if ((rc = ddsrt_socket (&sock, socketname.a.sa_family, SOCK_DGRAM, 0)) != DDS_RETCODE_OK)
+ {
+ GVERROR ("ddsi_udp_create_conn: failed to create socket: %s\n", dds_strretcode (rc));
+ goto fail;
}
- if (reuse_addr && (rc = ddsrt_setsockopt (sock, SOL_SOCKET, SO_REUSEADDR, (char *) &one, sizeof (one))) != DDS_RETCODE_OK)
+ if (reuse_addr && (rc = ddsrt_setsockopt (sock, SOL_SOCKET, SO_REUSEADDR, &one, sizeof (one))) != DDS_RETCODE_OK)
{
GVERROR ("ddsi_udp_create_conn: failed to enable address reuse: %s\n", dds_strretcode (rc));
if (rc != DDS_RETCODE_BAD_PARAMETER)
@@ -448,45 +482,21 @@ static ddsi_tran_conn_t ddsi_udp_create_conn (ddsi_tran_factory_t fact, uint32_t
if (gv->config.dontRoute && (rc = set_dont_route (gv, sock, ipv6)) != DDS_RETCODE_OK)
goto fail_w_socket;
+ if ((rc = ddsrt_bind (sock, &socketname.a, ddsrt_sockaddr_get_size (&socketname.a))) != DDS_RETCODE_OK)
{
- union {
- struct sockaddr_storage x;
- struct sockaddr_in a4;
- struct sockaddr_in6 a6;
- } socketname;
- nn_locator_t ownloc_w_port = gv->ownloc;
- assert (ownloc_w_port.port == NN_LOCATOR_PORT_INVALID);
- if (port) {
- /* PORT_INVALID maps to 0 in ipaddr_from_loc */
- ownloc_w_port.port = port;
- }
- ddsi_ipaddr_from_loc (&socketname.x, &ownloc_w_port);
+ /* PRECONDITION_NOT_MET (= EADDRINUSE) is expected if reuse_addr isn't set, should be handled at
+ a higher level and therefore needs to return a specific error message */
+ if (!reuse_addr && rc == DDS_RETCODE_PRECONDITION_NOT_MET)
+ goto fail_addrinuse;
+
+ char buf[DDSI_LOCATORSTRLEN];
if (bind_to_any)
- {
- switch (fact->m_kind)
- {
- case NN_LOCATOR_KIND_UDPv4:
- socketname.a4.sin_addr.s_addr = htonl (INADDR_ANY);
- break;
-#if DDSRT_HAVE_IPV6
- case NN_LOCATOR_KIND_UDPv6:
- socketname.a6.sin6_addr = ddsrt_in6addr_any;
- break;
-#endif
- default:
- DDS_FATAL ("ddsi_udp_create_conn: unsupported kind %"PRId32"\n", fact->m_kind);
- }
- }
- if ((rc = ddsrt_bind (sock, (struct sockaddr *) &socketname, ddsrt_sockaddr_get_size ((struct sockaddr *) &socketname))) != DDS_RETCODE_OK)
- {
- char buf[DDSI_LOCATORSTRLEN];
- if (bind_to_any)
- snprintf (buf, sizeof (buf), "ANY:%"PRIu32, port);
- else
- ddsi_locator_to_string (buf, sizeof (buf), &ownloc_w_port);
- GVERROR ("ddsi_udp_create_conn: failed to bind to %s: %s\n", buf, dds_strretcode (rc));
- goto fail_w_socket;
- }
+ snprintf (buf, sizeof (buf), "ANY:%"PRIu32, port);
+ else
+ ddsi_locator_to_string (buf, sizeof (buf), &ownloc_w_port);
+ GVERROR ("ddsi_udp_create_conn: failed to bind to %s: %s\n", buf,
+ (rc == DDS_RETCODE_PRECONDITION_NOT_MET) ? "address in use" : dds_strretcode (rc));
+ goto fail_w_socket;
}
rc = ipv6 ? set_mc_options_transmit_ipv6 (gv, sock) : set_mc_options_transmit_ipv4 (gv, sock);
@@ -494,9 +504,9 @@ static ddsi_tran_conn_t ddsi_udp_create_conn (ddsi_tran_factory_t fact, uint32_t
goto fail_w_socket;
#ifdef DDSI_INCLUDE_NETWORK_CHANNELS
- if ((qos->m_diffserv != 0) && (fact->m_kind == NN_LOCATOR_KIND_UDPv4))
+ if (qos->m_diffserv != 0 && fact->m_kind == NN_LOCATOR_KIND_UDPv4)
{
- if ((rc = ddsrt_setsockopt (sock, IPPROTO_IP, IP_TOS, (char *) &qos->m_diffserv, sizeof (qos->m_diffserv))) != DDS_RETCODE_OK)
+ if ((rc = ddsrt_setsockopt (sock, IPPROTO_IP, IP_TOS, &qos->m_diffserv, sizeof (qos->m_diffserv))) != DDS_RETCODE_OK)
{
GVERROR ("ddsi_udp_create_conn: set diffserv retcode %"PRId32"\n", rc);
goto fail_w_socket;
@@ -504,49 +514,52 @@ static ddsi_tran_conn_t ddsi_udp_create_conn (ddsi_tran_factory_t fact, uint32_t
}
#endif
- ddsi_udp_conn_t uc = (ddsi_udp_conn_t) ddsrt_malloc (sizeof (*uc));
- memset (uc, 0, sizeof (*uc));
+ ddsi_udp_conn_t conn = ddsrt_malloc (sizeof (*conn));
+ memset (conn, 0, sizeof (*conn));
- uc->m_sock = sock;
- uc->m_diffserv = qos->m_diffserv;
+ conn->m_sock = sock;
+ conn->m_diffserv = qos->m_diffserv;
#if defined _WIN32 && !defined WINCE
- uc->m_sockEvent = WSACreateEvent();
- WSAEventSelect(uc->m_sock, uc->m_sockEvent, FD_WRITE);
+ conn->m_sockEvent = WSACreateEvent ();
+ WSAEventSelect (conn->m_sock, conn->m_sockEvent, FD_WRITE);
#endif
- ddsi_factory_conn_init (fact, &uc->m_base);
- uc->m_base.m_base.m_port = get_socket_port (gv, sock);
- uc->m_base.m_base.m_trantype = DDSI_TRAN_CONN;
- uc->m_base.m_base.m_multicast = (qos->m_purpose == DDSI_TRAN_QOS_RECV_MC);
- uc->m_base.m_base.m_handle_fn = ddsi_udp_conn_handle;
+ ddsi_factory_conn_init (fact, &conn->m_base);
+ conn->m_base.m_base.m_port = get_socket_port (gv, sock);
+ conn->m_base.m_base.m_trantype = DDSI_TRAN_CONN;
+ conn->m_base.m_base.m_multicast = (qos->m_purpose == DDSI_TRAN_QOS_RECV_MC);
+ conn->m_base.m_base.m_handle_fn = ddsi_udp_conn_handle;
- uc->m_base.m_read_fn = ddsi_udp_conn_read;
- uc->m_base.m_write_fn = ddsi_udp_conn_write;
- uc->m_base.m_disable_multiplexing_fn = ddsi_udp_disable_multiplexing;
- uc->m_base.m_locator_fn = ddsi_udp_conn_locator;
+ conn->m_base.m_read_fn = ddsi_udp_conn_read;
+ conn->m_base.m_write_fn = ddsi_udp_conn_write;
+ conn->m_base.m_disable_multiplexing_fn = ddsi_udp_disable_multiplexing;
+ conn->m_base.m_locator_fn = ddsi_udp_conn_locator;
- GVTRACE ("ddsi_udp_create_conn %s socket %"PRIdSOCK" port %"PRIu32"\n", purpose_str, uc->m_sock, uc->m_base.m_base.m_port);
- return &uc->m_base;
+ GVTRACE ("ddsi_udp_create_conn %s socket %"PRIdSOCK" port %"PRIu32"\n", purpose_str, conn->m_sock, conn->m_base.m_base.m_port);
+ *conn_out = &conn->m_base;
+ return DDS_RETCODE_OK;
fail_w_socket:
ddsrt_close (sock);
fail:
- if (fact->gv->config.participantIndex != PARTICIPANT_INDEX_AUTO)
- GVERROR ("ddsi_udp_create_conn: failed for %s port %"PRIu32"\n", purpose_str, port);
- return NULL;
+ return DDS_RETCODE_ERROR;
+
+fail_addrinuse:
+ ddsrt_close (sock);
+ return DDS_RETCODE_PRECONDITION_NOT_MET;
}
static int joinleave_asm_mcgroup (ddsrt_socket_t socket, int join, const nn_locator_t *mcloc, const struct nn_interface *interf)
{
dds_return_t rc;
- struct sockaddr_storage mcip;
- ddsi_ipaddr_from_loc(&mcip, mcloc);
+ union addr mcip;
+ ddsi_ipaddr_from_loc (&mcip.x, mcloc);
#if DDSRT_HAVE_IPV6
if (mcloc->kind == NN_LOCATOR_KIND_UDPv6)
{
struct ipv6_mreq ipv6mreq;
memset (&ipv6mreq, 0, sizeof (ipv6mreq));
- memcpy (&ipv6mreq.ipv6mr_multiaddr, &((struct sockaddr_in6 *) &mcip)->sin6_addr, sizeof (ipv6mreq.ipv6mr_multiaddr));
+ memcpy (&ipv6mreq.ipv6mr_multiaddr, &mcip.a6, sizeof (ipv6mreq.ipv6mr_multiaddr));
ipv6mreq.ipv6mr_interface = interf ? interf->if_index : 0;
rc = ddsrt_setsockopt (socket, IPPROTO_IPV6, join ? IPV6_JOIN_GROUP : IPV6_LEAVE_GROUP, &ipv6mreq, sizeof (ipv6mreq));
}
@@ -554,12 +567,12 @@ static int joinleave_asm_mcgroup (ddsrt_socket_t socket, int join, const nn_loca
#endif
{
struct ip_mreq mreq;
- mreq.imr_multiaddr = ((struct sockaddr_in *) &mcip)->sin_addr;
+ mreq.imr_multiaddr = mcip.a4.sin_addr;
if (interf)
memcpy (&mreq.imr_interface, interf->loc.address + 12, sizeof (mreq.imr_interface));
else
mreq.imr_interface.s_addr = htonl (INADDR_ANY);
- rc = ddsrt_setsockopt (socket, IPPROTO_IP, join ? IP_ADD_MEMBERSHIP : IP_DROP_MEMBERSHIP, (char *) &mreq, sizeof (mreq));
+ rc = ddsrt_setsockopt (socket, IPPROTO_IP, join ? IP_ADD_MEMBERSHIP : IP_DROP_MEMBERSHIP, &mreq, sizeof (mreq));
}
return (rc == DDS_RETCODE_OK) ? 0 : -1;
}
@@ -568,17 +581,17 @@ static int joinleave_asm_mcgroup (ddsrt_socket_t socket, int join, const nn_loca
static int joinleave_ssm_mcgroup (ddsrt_socket_t socket, int join, const nn_locator_t *srcloc, const nn_locator_t *mcloc, const struct nn_interface *interf)
{
dds_return_t rc;
- struct sockaddr_storage mcip, srcip;
- ddsi_ipaddr_from_loc(&mcip, mcloc);
- ddsi_ipaddr_from_loc(&srcip, srcloc);
+ union addr mcip, srcip;
+ ddsi_ipaddr_from_loc (&mcip.x, mcloc);
+ ddsi_ipaddr_from_loc (&srcip.x, srcloc);
#if DDSRT_HAVE_IPV6
if (mcloc->kind == NN_LOCATOR_KIND_UDPv6)
{
struct group_source_req gsr;
memset (&gsr, 0, sizeof (gsr));
gsr.gsr_interface = interf ? interf->if_index : 0;
- memcpy (&gsr.gsr_group, &mcip, sizeof (gsr.gsr_group));
- memcpy (&gsr.gsr_source, &srcip, sizeof (gsr.gsr_source));
+ memcpy (&gsr.gsr_group, &mcip.a6, sizeof (gsr.gsr_group));
+ memcpy (&gsr.gsr_source, &srcip.a6, sizeof (gsr.gsr_source));
rc = ddsrt_setsockopt (socket, IPPROTO_IPV6, join ? MCAST_JOIN_SOURCE_GROUP : MCAST_LEAVE_SOURCE_GROUP, &gsr, sizeof (gsr));
}
else
@@ -586,8 +599,8 @@ static int joinleave_ssm_mcgroup (ddsrt_socket_t socket, int join, const nn_loca
{
struct ip_mreq_source mreq;
memset (&mreq, 0, sizeof (mreq));
- mreq.imr_sourceaddr = ((struct sockaddr_in *) &srcip)->sin_addr;
- mreq.imr_multiaddr = ((struct sockaddr_in *) &mcip)->sin_addr;
+ mreq.imr_sourceaddr = srcip.a4.sin_addr;
+ mreq.imr_multiaddr = mcip.a4.sin_addr;
if (interf)
memcpy (&mreq.imr_interface, interf->loc.address + 12, sizeof (mreq.imr_interface));
else
@@ -598,43 +611,42 @@ static int joinleave_ssm_mcgroup (ddsrt_socket_t socket, int join, const nn_loca
}
#endif
-static int ddsi_udp_join_mc (ddsi_tran_conn_t conn, const nn_locator_t *srcloc, const nn_locator_t *mcloc, const struct nn_interface *interf)
+static int ddsi_udp_join_mc (ddsi_tran_conn_t conn_cmn, const nn_locator_t *srcloc, const nn_locator_t *mcloc, const struct nn_interface *interf)
{
- ddsi_udp_conn_t uc = (ddsi_udp_conn_t) conn;
- (void)srcloc;
+ ddsi_udp_conn_t conn = (ddsi_udp_conn_t) conn_cmn;
+ (void) srcloc;
#ifdef DDSI_INCLUDE_SSM
if (srcloc)
- return joinleave_ssm_mcgroup(uc->m_sock, 1, srcloc, mcloc, interf);
+ return joinleave_ssm_mcgroup (conn->m_sock, 1, srcloc, mcloc, interf);
else
#endif
- return joinleave_asm_mcgroup(uc->m_sock, 1, mcloc, interf);
+ return joinleave_asm_mcgroup (conn->m_sock, 1, mcloc, interf);
}
-static int ddsi_udp_leave_mc (ddsi_tran_conn_t conn, const nn_locator_t *srcloc, const nn_locator_t *mcloc, const struct nn_interface *interf)
+static int ddsi_udp_leave_mc (ddsi_tran_conn_t conn_cmn, const nn_locator_t *srcloc, const nn_locator_t *mcloc, const struct nn_interface *interf)
{
- ddsi_udp_conn_t uc = (ddsi_udp_conn_t) conn;
- (void)srcloc;
+ ddsi_udp_conn_t conn = (ddsi_udp_conn_t) conn_cmn;
+ (void) srcloc;
#ifdef DDSI_INCLUDE_SSM
if (srcloc)
- return joinleave_ssm_mcgroup(uc->m_sock, 0, srcloc, mcloc, interf);
+ return joinleave_ssm_mcgroup (conn->m_sock, 0, srcloc, mcloc, interf);
else
#endif
- return joinleave_asm_mcgroup(uc->m_sock, 0, mcloc, interf);
+ return joinleave_asm_mcgroup (conn->m_sock, 0, mcloc, interf);
}
-static void ddsi_udp_release_conn (ddsi_tran_conn_t conn)
+static void ddsi_udp_release_conn (ddsi_tran_conn_t conn_cmn)
{
- ddsi_udp_conn_t uc = (ddsi_udp_conn_t) conn;
- DDS_CTRACE (&conn->m_base.gv->logconfig,
- "ddsi_udp_release_conn %s socket %"PRIdSOCK" port %"PRIu32"\n",
- conn->m_base.m_multicast ? "multicast" : "unicast",
- uc->m_sock,
- uc->m_base.m_base.m_port);
- ddsrt_close (uc->m_sock);
+ ddsi_udp_conn_t conn = (ddsi_udp_conn_t) conn_cmn;
+ struct ddsi_domaingv const * const gv = conn->m_base.m_base.gv;
+ GVTRACE ("ddsi_udp_release_conn %s socket %"PRIdSOCK" port %"PRIu32"\n",
+ conn_cmn->m_base.m_multicast ? "multicast" : "unicast",
+ conn->m_sock, conn->m_base.m_base.m_port);
+ ddsrt_close (conn->m_sock);
#if defined _WIN32 && !defined WINCE
- WSACloseEvent(uc->m_sockEvent);
+ WSACloseEvent (conn->m_sockEvent);
#endif
- ddsrt_free (conn);
+ ddsrt_free (conn_cmn);
}
static int ddsi_udp_is_mcaddr (const ddsi_tran_factory_t tran, const nn_locator_t *loc)
@@ -720,7 +732,8 @@ static char *ddsi_udp_locator_to_string (char *dst, size_t sizeof_dst, const nn_
static void ddsi_udp_fini (ddsi_tran_factory_t fact)
{
- DDS_CLOG (DDS_LC_CONFIG, &fact->gv->logconfig, "udp finalized\n");
+ struct ddsi_domaingv const * const gv = fact->gv;
+ GVLOG (DDS_LC_CONFIG, "udp finalized\n");
ddsrt_free (fact);
}
@@ -730,7 +743,7 @@ static int ddsi_udp_is_valid_port (ddsi_tran_factory_t fact, uint32_t port)
return (port <= 65535);
}
-int ddsi_udp_init (struct ddsi_domaingv *gv)
+int ddsi_udp_init (struct ddsi_domaingv*gv)
{
struct ddsi_tran_factory *fact = ddsrt_malloc (sizeof (*fact));
memset (fact, 0, sizeof (*fact));
diff --git a/src/core/ddsi/src/q_debmon.c b/src/core/ddsi/src/q_debmon.c
index 68f72af..f23a18e 100644
--- a/src/core/ddsi/src/q_debmon.c
+++ b/src/core/ddsi/src/q_debmon.c
@@ -369,8 +369,7 @@ struct debug_monitor *new_debug_monitor (struct ddsi_domaingv *gv, int32_t port)
goto err_invalid_port;
}
- dm->servsock = ddsi_factory_create_listener (dm->tran_factory, (uint32_t) port, NULL);
- if (dm->servsock == NULL)
+ if (ddsi_factory_create_listener (&dm->servsock, dm->tran_factory, (uint32_t) port, NULL) != DDS_RETCODE_OK)
{
GVWARNING ("debmon: can't create socket\n");
goto err_servsock;
diff --git a/src/core/ddsi/src/q_entity.c b/src/core/ddsi/src/q_entity.c
index 6917574..e9f9e8e 100644
--- a/src/core/ddsi/src/q_entity.c
+++ b/src/core/ddsi/src/q_entity.c
@@ -587,6 +587,7 @@ dds_return_t new_participant_guid (const ddsi_guid_t *ppguid, struct ddsi_domain
struct participant *pp;
ddsi_guid_t subguid, group_guid;
struct whc_writer_info *wrinfo;
+ ddsi_tran_conn_t ppconn;
/* no reserved bits may be set */
assert ((flags & ~(RTPS_PF_NO_BUILTIN_READERS | RTPS_PF_NO_BUILTIN_WRITERS | RTPS_PF_PRIVILEGED_PP | RTPS_PF_IS_DDSI2_PP | RTPS_PF_ONLY_LOCAL)) == 0);
@@ -603,6 +604,18 @@ dds_return_t new_participant_guid (const ddsi_guid_t *ppguid, struct ddsi_domain
if (entidx_lookup_participant_guid (gv->entity_index, ppguid) != NULL)
return DDS_RETCODE_PRECONDITION_NOT_MET;
+ if (gv->config.many_sockets_mode != MSM_MANY_UNICAST)
+ ppconn = NULL;
+ else
+ {
+ const ddsi_tran_qos_t qos = { .m_purpose = DDSI_TRAN_QOS_RECV_UC, .m_diffserv = 0 };
+ if (ddsi_factory_create_conn (&ppconn, gv->m_factory, 0, &qos) != DDS_RETCODE_OK)
+ {
+ GVERROR ("new_participant("PGUIDFMT", %x) failed: could not create network endpoint\n", PGUID (*ppguid), flags);
+ return DDS_RETCODE_OUT_OF_RESOURCES;
+ }
+ }
+
if (gv->config.max_participants == 0)
{
ddsrt_mutex_lock (&gv->participant_set_lock);
@@ -621,6 +634,8 @@ dds_return_t new_participant_guid (const ddsi_guid_t *ppguid, struct ddsi_domain
{
ddsrt_mutex_unlock (&gv->participant_set_lock);
GVERROR ("new_participant("PGUIDFMT", %x) failed: max participants reached\n", PGUID (*ppguid), flags);
+ if (ppconn)
+ ddsi_conn_free (ppconn);
return DDS_RETCODE_OUT_OF_RESOURCES;
}
}
@@ -649,16 +664,9 @@ dds_return_t new_participant_guid (const ddsi_guid_t *ppguid, struct ddsi_domain
GVLOGDISC ("}\n");
}
+ pp->m_conn = ppconn;
if (gv->config.many_sockets_mode == MSM_MANY_UNICAST)
- {
- const ddsi_tran_qos_t qos = { .m_purpose = DDSI_TRAN_QOS_RECV_UC, .m_diffserv = 0 };
- pp->m_conn = ddsi_factory_create_conn (gv->m_factory, 0, &qos);
ddsi_conn_locator (pp->m_conn, &pp->m_locator);
- }
- else
- {
- pp->m_conn = NULL;
- }
ddsrt_fibheap_init (&lease_fhdef_pp, &pp->leaseheap_man);
ddsrt_atomic_stvoidp (&pp->minl_man, NULL);
diff --git a/src/core/ddsi/src/q_init.c b/src/core/ddsi/src/q_init.c
index 1a1a0cb..d2479a3 100644
--- a/src/core/ddsi/src/q_init.c
+++ b/src/core/ddsi/src/q_init.c
@@ -72,13 +72,16 @@ static void add_peer_addresses (const struct ddsi_domaingv *gv, struct addrset *
}
enum make_uc_sockets_ret {
- MUSRET_SUCCESS,
- MUSRET_INVALID_PORTS,
- MUSRET_NOSOCKET
+ MUSRET_SUCCESS, /* unicast socket(s) created */
+ MUSRET_INVALID_PORTS, /* specified port numbers are invalid */
+ MUSRET_PORTS_IN_USE, /* ports were in use, keep trying */
+ MUSRET_ERROR /* generic error, no use continuing */
};
static enum make_uc_sockets_ret make_uc_sockets (struct ddsi_domaingv *gv, uint32_t * pdisc, uint32_t * pdata, int ppid)
{
+ dds_return_t rc;
+
if (gv->config.many_sockets_mode == MSM_NO_UNICAST)
{
assert (ppid == PARTICIPANT_INDEX_NONE);
@@ -97,33 +100,29 @@ static enum make_uc_sockets_ret make_uc_sockets (struct ddsi_domaingv *gv, uint3
return MUSRET_INVALID_PORTS;
const ddsi_tran_qos_t qos = { .m_purpose = DDSI_TRAN_QOS_RECV_UC, .m_diffserv = 0 };
- gv->disc_conn_uc = ddsi_factory_create_conn (gv->m_factory, *pdisc, &qos);
- if (gv->disc_conn_uc)
+ rc = ddsi_factory_create_conn (&gv->disc_conn_uc, gv->m_factory, *pdisc, &qos);
+ if (rc != DDS_RETCODE_OK)
+ goto fail_disc;
+
+ if (*pdata == 0 || *pdata == *pdisc)
+ gv->data_conn_uc = gv->disc_conn_uc;
+ else
{
- /* Check not configured to use same unicast port for data and discovery */
-
- if (*pdata != 0 && (*pdata != *pdisc))
- {
- gv->data_conn_uc = ddsi_factory_create_conn (gv->m_factory, *pdata, &qos);
- }
- else
- {
- gv->data_conn_uc = gv->disc_conn_uc;
- }
- if (gv->data_conn_uc == NULL)
- {
- ddsi_conn_free (gv->disc_conn_uc);
- gv->disc_conn_uc = NULL;
- }
- else
- {
- /* Set unicast locators */
- ddsi_conn_locator (gv->disc_conn_uc, &gv->loc_meta_uc);
- ddsi_conn_locator (gv->data_conn_uc, &gv->loc_default_uc);
- }
+ rc = ddsi_factory_create_conn (&gv->data_conn_uc, gv->m_factory, *pdata, &qos);
+ if (rc != DDS_RETCODE_OK)
+ goto fail_data;
}
+ ddsi_conn_locator (gv->disc_conn_uc, &gv->loc_meta_uc);
+ ddsi_conn_locator (gv->data_conn_uc, &gv->loc_default_uc);
+ return MUSRET_SUCCESS;
- return gv->data_conn_uc ? MUSRET_SUCCESS : MUSRET_NOSOCKET;
+fail_data:
+ ddsi_conn_free (gv->disc_conn_uc);
+ gv->disc_conn_uc = NULL;
+fail_disc:
+ if (rc == DDS_RETCODE_PRECONDITION_NOT_MET)
+ return MUSRET_PORTS_IN_USE;
+ return MUSRET_ERROR;
}
static void make_builtin_endpoint_xqos (dds_qos_t *q, const dds_qos_t *template)
@@ -675,7 +674,7 @@ int create_multicast_sockets (struct ddsi_domaingv *gv)
gv->config.extDomainId.value, port);
goto err_disc;
}
- if ((disc = ddsi_factory_create_conn (gv->m_factory, port, &qos)) == NULL)
+ if (ddsi_factory_create_conn (&disc, gv->m_factory, port, &qos) != DDS_RETCODE_OK)
goto err_disc;
if (gv->config.many_sockets_mode == MSM_NO_UNICAST)
{
@@ -691,10 +690,8 @@ int create_multicast_sockets (struct ddsi_domaingv *gv)
gv->config.extDomainId.value, port);
goto err_disc;
}
- if ((data = ddsi_factory_create_conn (gv->m_factory, port, &qos)) == NULL)
- {
+ if (ddsi_factory_create_conn (&data, gv->m_factory, port, &qos) != DDS_RETCODE_OK)
goto err_data;
- }
}
gv->disc_conn_mc = disc;
@@ -1192,18 +1189,21 @@ int rtps_init (struct ddsi_domaingv *gv)
GVERROR ("Failed to create unicast sockets for domain %"PRIu32" participant index %d: resulting port numbers (%"PRIu32", %"PRIu32") are out of range\n",
gv->config.extDomainId.value, gv->config.participantIndex, port_disc_uc, port_data_uc);
goto err_unicast_sockets;
- case MUSRET_NOSOCKET:
+ case MUSRET_PORTS_IN_USE:
GVERROR ("rtps_init: failed to create unicast sockets for domain %"PRId32" participant index %d (ports %"PRIu32", %"PRIu32")\n", gv->config.extDomainId.value, gv->config.participantIndex, port_disc_uc, port_data_uc);
goto err_unicast_sockets;
+ case MUSRET_ERROR:
+ /* something bad happened; assume make_uc_sockets logged the error */
+ goto err_unicast_sockets;
}
}
else if (gv->config.participantIndex == PARTICIPANT_INDEX_AUTO)
{
/* try to find a free one, and update gv->config.participantIndex */
- enum make_uc_sockets_ret musret = MUSRET_NOSOCKET;
+ enum make_uc_sockets_ret musret = MUSRET_PORTS_IN_USE;
int ppid;
GVLOG (DDS_LC_CONFIG, "rtps_init: trying to find a free participant index\n");
- for (ppid = 0; ppid <= gv->config.maxAutoParticipantIndex && musret == MUSRET_NOSOCKET; ppid++)
+ for (ppid = 0; ppid <= gv->config.maxAutoParticipantIndex && musret == MUSRET_PORTS_IN_USE; ppid++)
{
musret = make_uc_sockets (gv, &port_disc_uc, &port_data_uc, ppid);
switch (musret)
@@ -1214,8 +1214,11 @@ int rtps_init (struct ddsi_domaingv *gv)
GVERROR ("Failed to create unicast sockets for domain %"PRIu32" participant index %d: resulting port numbers (%"PRIu32", %"PRIu32") are out of range\n",
gv->config.extDomainId.value, ppid, port_disc_uc, port_data_uc);
goto err_unicast_sockets;
- case MUSRET_NOSOCKET: /* Try next one */
+ case MUSRET_PORTS_IN_USE: /* Try next one */
break;
+ case MUSRET_ERROR:
+ /* something bad happened; assume make_uc_sockets logged the error */
+ goto err_unicast_sockets;
}
}
if (ppid > gv->config.maxAutoParticipantIndex)
@@ -1235,7 +1238,7 @@ int rtps_init (struct ddsi_domaingv *gv)
if (gv->config.pcap_file && *gv->config.pcap_file)
{
- gv->pcap_fp = new_pcap_file (&gv->logconfig, gv->config.pcap_file);
+ gv->pcap_fp = new_pcap_file (gv, gv->config.pcap_file);
if (gv->pcap_fp)
{
ddsrt_mutex_init (&gv->pcap_lock);
@@ -1286,8 +1289,9 @@ int rtps_init (struct ddsi_domaingv *gv)
}
else
{
- gv->listener = ddsi_factory_create_listener (gv->m_factory, (uint32_t) gv->config.tcp_port, NULL);
- if (gv->listener == NULL || ddsi_listener_listen (gv->listener) != 0)
+ dds_return_t rc;
+ rc = ddsi_factory_create_listener (&gv->listener, gv->m_factory, (uint32_t) gv->config.tcp_port, NULL);
+ if (rc != DDS_RETCODE_OK || ddsi_listener_listen (gv->listener) != 0)
{
GVERROR ("Failed to create %s listener\n", gv->m_factory->m_typename);
if (gv->listener)
@@ -1308,7 +1312,10 @@ int rtps_init (struct ddsi_domaingv *gv)
/* Create shared transmit connection */
{
const ddsi_tran_qos_t qos = { .m_purpose = DDSI_TRAN_QOS_XMIT, .m_diffserv = 0 };
- gv->xmit_conn = ddsi_factory_create_conn (gv->m_factory, 0, &qos);
+ dds_return_t rc;
+ rc = ddsi_factory_create_conn (&gv->xmit_conn, gv->m_factory, 0, &qos);
+ if (rc != DDS_RETCODE_OK)
+ goto err_mc_conn;
}
#ifdef DDSI_INCLUDE_NETWORK_CHANNELS
diff --git a/src/core/ddsi/src/q_pcap.c b/src/core/ddsi/src/q_pcap.c
index 601c96d..45f6c67 100644
--- a/src/core/ddsi/src/q_pcap.c
+++ b/src/core/ddsi/src/q_pcap.c
@@ -76,7 +76,7 @@ static const ipv4_hdr_t ipv4_hdr_template = {
#define IPV4_HDR_SIZE 20
#define UDP_HDR_SIZE 8
-FILE *new_pcap_file (const struct ddsrt_log_cfg *logcfg, const char *name)
+FILE *new_pcap_file (struct ddsi_domaingv *gv, const char *name)
{
DDSRT_WARNING_MSVC_OFF(4996);
FILE *fp;
@@ -84,7 +84,7 @@ FILE *new_pcap_file (const struct ddsrt_log_cfg *logcfg, const char *name)
if ((fp = fopen (name, "wb")) == NULL)
{
- DDS_CWARNING (logcfg, "packet capture disabled: file %s could not be opened for writing\n", name);
+ GVWARNING ("packet capture disabled: file %s could not be opened for writing\n", name);
return NULL;
}
From f139dbcd5e8bd7d625cc8dfca02aa89e5e2e494e Mon Sep 17 00:00:00 2001
From: Erik Boasson
Date: Wed, 18 Mar 2020 16:29:03 +0100
Subject: [PATCH 30/30] MS C++ is troubled by C99 compound literals
Signed-off-by: Erik Boasson
---
src/ddsrt/include/dds/ddsrt/time.h | 12 +++++++++---
1 file changed, 9 insertions(+), 3 deletions(-)
diff --git a/src/ddsrt/include/dds/ddsrt/time.h b/src/ddsrt/include/dds/ddsrt/time.h
index 224862e..5df8358 100644
--- a/src/ddsrt/include/dds/ddsrt/time.h
+++ b/src/ddsrt/include/dds/ddsrt/time.h
@@ -193,7 +193,9 @@ inline dds_time_t ddsrt_time_add_duration(dds_time_t abstime, dds_duration_t rel
* @returns A timestamp in nanoseconds since UNIX Epoch.
*/
inline ddsrt_mtime_t ddsrt_mtime_add_duration(ddsrt_mtime_t abstime, dds_duration_t reltime) {
- return (ddsrt_mtime_t) { ddsrt_time_add_duration (abstime.v, reltime) };
+ ddsrt_mtime_t t;
+ t.v = ddsrt_time_add_duration (abstime.v, reltime);
+ return t;
}
/**
@@ -209,7 +211,9 @@ inline ddsrt_mtime_t ddsrt_mtime_add_duration(ddsrt_mtime_t abstime, dds_duratio
* @returns A timestamp in nanoseconds since UNIX Epoch.
*/
inline ddsrt_wctime_t ddsrt_wctime_add_duration(ddsrt_wctime_t abstime, dds_duration_t reltime) {
- return (ddsrt_wctime_t) { ddsrt_time_add_duration (abstime.v, reltime) };
+ ddsrt_wctime_t t;
+ t.v = ddsrt_time_add_duration (abstime.v, reltime);
+ return t;
}
/**
@@ -225,7 +229,9 @@ inline ddsrt_wctime_t ddsrt_wctime_add_duration(ddsrt_wctime_t abstime, dds_dura
* @returns A timestamp in nanoseconds since UNIX Epoch.
*/
inline ddsrt_etime_t ddsrt_etime_add_duration(ddsrt_etime_t abstime, dds_duration_t reltime) {
- return (ddsrt_etime_t) { ddsrt_time_add_duration (abstime.v, reltime) };
+ ddsrt_etime_t t;
+ t.v = ddsrt_time_add_duration (abstime.v, reltime);
+ return t;
}
#if _WIN32