Rearrange and fixup abstraction layer
- Replace os_result by dds_retcode_t and move DDS return code defines down. Eliminates the need to convert between different return code types. - Move dds_time_t down and remove os_time. Eliminates the need to convert between different time representations and reduces code duplication. - Remove use of Microsoft source-code annotation language (SAL). SAL annotations are Microsoft specific and not very well documented. This makes it very difficult for contributers to write. - Rearrange the abstraction layer to be feature-based. The previous layout falsely assumed that the operating system dictates which implementation is best suited. For general purpose operating systems this is mostly true, but embedded targets require a slightly different approach and may not even offer all features. The new layout makes it possible to mix-and-match feature implementations and allows for features to not be implemented at all. - Replace the os prefix by ddsrt to avoid name collisions. - Remove various portions of unused and unwanted code. - Export thread names on all supported platforms. - Return native thread identifier on POSIX compatible platforms. - Add timed wait for condition variables that takes an absolute time. - Remove system abstraction for errno. The os_getErrno and os_setErrno were incorrect. Functions that might fail now simply return a DDS return code instead. - Remove thread-specific memory abstraction. os_threadMemGet and accompanying functions were a mess and their use has been eliminated by other changes in this commit. - Replace attribute (re)defines by ddsrt_ prefixed equivalents to avoid name collisions and problems with faulty __nonnull__ attributes. Signed-off-by: Jeroen Koekkoek <jeroen@koekkoek.nl>
This commit is contained in:
parent
318968f40f
commit
cd6742ee12
439 changed files with 22117 additions and 28782 deletions
|
@ -64,7 +64,7 @@ PREPEND(srcs_ddsi "${CMAKE_CURRENT_LIST_DIR}/src"
|
|||
|
||||
# The includes should reside close to the code. As long as that's not the case,
|
||||
# pull them in from this CMakeLists.txt.
|
||||
PREPEND(hdrs_private_ddsi "${CMAKE_CURRENT_LIST_DIR}/include/ddsi"
|
||||
PREPEND(hdrs_private_ddsi "${CMAKE_CURRENT_LIST_DIR}/include/dds/ddsi"
|
||||
ddsi_ssl.h
|
||||
ddsi_tcp.h
|
||||
ddsi_tran.h
|
||||
|
@ -124,11 +124,7 @@ PREPEND(hdrs_private_ddsi "${CMAKE_CURRENT_LIST_DIR}/include/ddsi"
|
|||
)
|
||||
|
||||
target_sources(ddsc
|
||||
PRIVATE
|
||||
${srcs_ddsi}
|
||||
${hdrs_private_ddsi}
|
||||
)
|
||||
PRIVATE ${srcs_ddsi} ${hdrs_private_ddsi})
|
||||
|
||||
target_include_directories(ddsc
|
||||
PRIVATE
|
||||
"${CMAKE_CURRENT_LIST_DIR}/include")
|
||||
PRIVATE "${CMAKE_CURRENT_LIST_DIR}/include")
|
||||
|
|
|
@ -12,18 +12,19 @@
|
|||
#ifndef _DDS_IID_H_
|
||||
#define _DDS_IID_H_
|
||||
|
||||
#include "os/os.h"
|
||||
#include "ddsc/dds_export.h"
|
||||
#include "dds/export.h"
|
||||
#include "dds/ddsrt/atomics.h"
|
||||
#include "dds/ddsrt/sync.h"
|
||||
|
||||
#if defined (__cplusplus)
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
struct ddsi_iid {
|
||||
#if OS_ATOMIC64_SUPPORT
|
||||
os_atomic_uint64_t counter;
|
||||
#if DDSRT_ATOMIC64_SUPPORT
|
||||
ddsrt_atomic_uint64_t counter;
|
||||
#else
|
||||
os_mutex lock;
|
||||
ddsrt_mutex_t lock;
|
||||
uint64_t counter;
|
||||
#endif
|
||||
uint32_t key[4];
|
|
@ -12,13 +12,13 @@
|
|||
#ifndef DDSI_IPADDR_H
|
||||
#define DDSI_IPADDR_H
|
||||
|
||||
#include "ddsi/ddsi_tran.h"
|
||||
#include "dds/ddsi/ddsi_tran.h"
|
||||
|
||||
enum ddsi_nearby_address_result ddsi_ipaddr_is_nearby_address (ddsi_tran_factory_t tran, const nn_locator_t *loc, size_t ninterf, const struct nn_interface interf[]);
|
||||
enum ddsi_locator_from_string_result ddsi_ipaddr_from_string (ddsi_tran_factory_t tran, nn_locator_t *loc, const char *str, int32_t kind);
|
||||
int ddsi_ipaddr_compare (const os_sockaddr *const sa1, const os_sockaddr *const sa2);
|
||||
int ddsi_ipaddr_compare (const struct sockaddr *const sa1, const struct sockaddr *const sa2);
|
||||
char *ddsi_ipaddr_to_string (ddsi_tran_factory_t tran, char *dst, size_t sizeof_dst, const nn_locator_t *loc, int with_port);
|
||||
void ddsi_ipaddr_to_loc (nn_locator_t *dst, const os_sockaddr *src, int32_t kind);
|
||||
void ddsi_ipaddr_from_loc (os_sockaddr_storage *dst, const nn_locator_t *src);
|
||||
void ddsi_ipaddr_to_loc (nn_locator_t *dst, const struct sockaddr *src, int32_t kind);
|
||||
void ddsi_ipaddr_from_loc (struct sockaddr_storage *dst, const nn_locator_t *src);
|
||||
|
||||
#endif
|
|
@ -12,7 +12,7 @@
|
|||
#ifndef DDSI_MCGROUP_H
|
||||
#define DDSI_MCGROUP_H
|
||||
|
||||
#include "ddsi/ddsi_tran.h"
|
||||
#include "dds/ddsi/ddsi_tran.h"
|
||||
|
||||
struct nn_group_membership;
|
||||
|
|
@ -12,8 +12,9 @@
|
|||
#ifndef DDSI_SERDATA_H
|
||||
#define DDSI_SERDATA_H
|
||||
|
||||
#include "ddsi/q_time.h"
|
||||
#include "ddsi/ddsi_sertopic.h"
|
||||
#include "dds/ddsrt/sockets.h"
|
||||
#include "dds/ddsi/q_time.h"
|
||||
#include "dds/ddsi/ddsi_sertopic.h"
|
||||
|
||||
struct nn_rdata;
|
||||
struct nn_keyhash;
|
||||
|
@ -27,7 +28,7 @@ enum ddsi_serdata_kind {
|
|||
struct ddsi_serdata {
|
||||
const struct ddsi_serdata_ops *ops; /* cached from topic->serdata_ops */
|
||||
uint32_t hash;
|
||||
os_atomic_uint32_t refc;
|
||||
ddsrt_atomic_uint32_t refc;
|
||||
enum ddsi_serdata_kind kind;
|
||||
const struct ddsi_sertopic *topic;
|
||||
|
||||
|
@ -66,11 +67,11 @@ typedef void (*ddsi_serdata_to_ser_t) (const struct ddsi_serdata *d, size_t off,
|
|||
calls to to_ser_ref() may be issued in parallel, the separate ref/unref bit is there to at least
|
||||
have the option of lazily creating the serialised representation and freeing it when no one needs
|
||||
it, while the sample itself remains valid */
|
||||
typedef struct ddsi_serdata * (*ddsi_serdata_to_ser_ref_t) (const struct ddsi_serdata *d, size_t off, size_t sz, os_iovec_t *ref);
|
||||
typedef struct ddsi_serdata * (*ddsi_serdata_to_ser_ref_t) (const struct ddsi_serdata *d, size_t off, size_t sz, ddsrt_iovec_t *ref);
|
||||
|
||||
/* Release a lock on serialised data, ref must be a pointer previously obtained by calling
|
||||
to_ser_ref(d, off, sz) for some offset off. */
|
||||
typedef void (*ddsi_serdata_to_ser_unref_t) (struct ddsi_serdata *d, const os_iovec_t *ref);
|
||||
typedef void (*ddsi_serdata_to_ser_unref_t) (struct ddsi_serdata *d, const ddsrt_iovec_t *ref);
|
||||
|
||||
/* Turn serdata into an application sample (or just the key values if only key values are
|
||||
available); return false on error (typically out-of-memory, but if from_ser doesn't do any
|
||||
|
@ -112,12 +113,12 @@ DDS_EXPORT void ddsi_serdata_init (struct ddsi_serdata *d, const struct ddsi_ser
|
|||
|
||||
DDS_EXPORT inline struct ddsi_serdata *ddsi_serdata_ref (const struct ddsi_serdata *serdata_const) {
|
||||
struct ddsi_serdata *serdata = (struct ddsi_serdata *)serdata_const;
|
||||
os_atomic_inc32 (&serdata->refc);
|
||||
ddsrt_atomic_inc32 (&serdata->refc);
|
||||
return serdata;
|
||||
}
|
||||
|
||||
DDS_EXPORT inline void ddsi_serdata_unref (struct ddsi_serdata *serdata) {
|
||||
if (os_atomic_dec32_ov (&serdata->refc) == 1)
|
||||
if (ddsrt_atomic_dec32_ov (&serdata->refc) == 1)
|
||||
serdata->ops->free (serdata);
|
||||
}
|
||||
|
||||
|
@ -145,11 +146,11 @@ DDS_EXPORT inline void ddsi_serdata_to_ser (const struct ddsi_serdata *d, size_t
|
|||
d->ops->to_ser (d, off, sz, buf);
|
||||
}
|
||||
|
||||
DDS_EXPORT inline struct ddsi_serdata *ddsi_serdata_to_ser_ref (const struct ddsi_serdata *d, size_t off, size_t sz, os_iovec_t *ref) {
|
||||
DDS_EXPORT inline struct ddsi_serdata *ddsi_serdata_to_ser_ref (const struct ddsi_serdata *d, size_t off, size_t sz, ddsrt_iovec_t *ref) {
|
||||
return d->ops->to_ser_ref (d, off, sz, ref);
|
||||
}
|
||||
|
||||
DDS_EXPORT inline void ddsi_serdata_to_ser_unref (struct ddsi_serdata *d, const os_iovec_t *ref) {
|
||||
DDS_EXPORT inline void ddsi_serdata_to_ser_unref (struct ddsi_serdata *d, const ddsrt_iovec_t *ref) {
|
||||
d->ops->to_ser_unref (d, ref);
|
||||
}
|
||||
|
|
@ -12,27 +12,17 @@
|
|||
#ifndef DDSI_SERDATA_DEFAULT_H
|
||||
#define DDSI_SERDATA_DEFAULT_H
|
||||
|
||||
#include "os/os.h"
|
||||
#include "ddsi/q_plist.h" /* for nn_prismtech_writer_info */
|
||||
#include "ddsi/q_freelist.h"
|
||||
#include "util/ut_avl.h"
|
||||
#include "ddsi/ddsi_serdata.h"
|
||||
#include "ddsi/ddsi_sertopic.h"
|
||||
#include "dds/ddsrt/endian.h"
|
||||
#include "dds/ddsi/q_plist.h" /* for nn_prismtech_writer_info */
|
||||
#include "dds/ddsi/q_freelist.h"
|
||||
#include "dds/util/ut_avl.h"
|
||||
#include "dds/ddsi/ddsi_serdata.h"
|
||||
#include "dds/ddsi/ddsi_sertopic.h"
|
||||
|
||||
#include "ddsc/dds.h"
|
||||
#include "dds/dds.h"
|
||||
#include "dds__topic.h"
|
||||
|
||||
#ifndef PLATFORM_IS_LITTLE_ENDIAN
|
||||
# if OS_ENDIANNESS == OS_BIG_ENDIAN
|
||||
# define PLATFORM_IS_LITTLE_ENDIAN 0
|
||||
# elif OS_ENDIANNESS == OS_LITTLE_ENDIAN
|
||||
# define PLATFORM_IS_LITTLE_ENDIAN 1
|
||||
# else
|
||||
# error "invalid endianness setting"
|
||||
# endif
|
||||
#endif /* PLATFORM_IS_LITTLE_ENDIAN */
|
||||
|
||||
#if PLATFORM_IS_LITTLE_ENDIAN
|
||||
#if DDSRT_ENDIAN == DDSRT_LITTLE_ENDIAN
|
||||
#define CDR_BE 0x0000
|
||||
#define CDR_LE 0x0100
|
||||
#else
|
|
@ -12,8 +12,9 @@
|
|||
#ifndef DDSI_SERTOPIC_H
|
||||
#define DDSI_SERTOPIC_H
|
||||
|
||||
#include "util/ut_avl.h"
|
||||
#include "ddsc/dds_public_alloc.h"
|
||||
#include "dds/ddsrt/atomics.h"
|
||||
#include "dds/util/ut_avl.h"
|
||||
#include "dds/ddsc/dds_public_alloc.h"
|
||||
|
||||
struct ddsi_serdata;
|
||||
struct ddsi_serdata_ops;
|
||||
|
@ -32,7 +33,7 @@ struct ddsi_sertopic {
|
|||
char *name;
|
||||
char *typename;
|
||||
uint64_t iid;
|
||||
os_atomic_uint32_t refc; /* counts refs from entities, not from data */
|
||||
ddsrt_atomic_uint32_t refc; /* counts refs from entities, not from data */
|
||||
|
||||
topic_cb_t status_cb;
|
||||
struct dds_topic * status_cb_entity;
|
|
@ -12,11 +12,11 @@
|
|||
#ifndef _DDSI_TCP_H_
|
||||
#define _DDSI_TCP_H_
|
||||
|
||||
#include "ddsi/ddsi_tran.h"
|
||||
#include "dds/ddsi/ddsi_tran.h"
|
||||
|
||||
#ifdef DDSI_INCLUDE_SSL
|
||||
|
||||
#include "ddsi/ddsi_ssl.h"
|
||||
#include "dds/ddsi/ddsi_ssl.h"
|
||||
|
||||
struct ddsi_ssl_plugins
|
||||
{
|
||||
|
@ -24,11 +24,11 @@ struct ddsi_ssl_plugins
|
|||
void (*fini) (void);
|
||||
void (*ssl_free) (SSL *ssl);
|
||||
void (*bio_vfree) (BIO *bio);
|
||||
ssize_t (*read) (SSL *ssl, void *buf, size_t len, int *err);
|
||||
ssize_t (*write) (SSL *ssl, const void *msg, size_t len, int *err);
|
||||
SSL * (*connect) (os_socket sock);
|
||||
BIO * (*listen) (os_socket sock);
|
||||
SSL * (*accept) (BIO *bio, os_socket *sock);
|
||||
ssize_t (*read) (SSL *ssl, void *buf, size_t len, dds_retcode_t *err);
|
||||
ssize_t (*write) (SSL *ssl, const void *msg, size_t len, dds_retcode_t *err);
|
||||
SSL * (*connect) (ddsrt_socket_t sock);
|
||||
BIO * (*listen) (ddsrt_socket_t sock);
|
||||
SSL * (*accept) (BIO *bio, ddsrt_socket_t *sock);
|
||||
};
|
||||
|
||||
#endif
|
|
@ -13,7 +13,7 @@
|
|||
#define _DDS_TKMAP_H_
|
||||
|
||||
#include "dds__types.h"
|
||||
#include "os/os_atomics.h"
|
||||
#include "dds/ddsrt/atomics.h"
|
||||
|
||||
#if defined (__cplusplus)
|
||||
extern "C" {
|
||||
|
@ -27,13 +27,13 @@ struct ddsi_tkmap_instance
|
|||
{
|
||||
struct ddsi_serdata * m_sample;
|
||||
uint64_t m_iid;
|
||||
os_atomic_uint32_t m_refc;
|
||||
ddsrt_atomic_uint32_t m_refc;
|
||||
};
|
||||
|
||||
DDS_EXPORT struct ddsi_tkmap * ddsi_tkmap_new (void);
|
||||
DDS_EXPORT void ddsi_tkmap_free (_Inout_ _Post_invalid_ struct ddsi_tkmap *tkmap);
|
||||
DDS_EXPORT void ddsi_tkmap_instance_ref (_In_ struct ddsi_tkmap_instance *tk);
|
||||
DDS_EXPORT uint64_t ddsi_tkmap_lookup (_In_ struct ddsi_tkmap *tkmap, _In_ const struct ddsi_serdata *serdata);
|
||||
DDS_EXPORT void ddsi_tkmap_free (struct ddsi_tkmap *tkmap);
|
||||
DDS_EXPORT void ddsi_tkmap_instance_ref (struct ddsi_tkmap_instance *tk);
|
||||
DDS_EXPORT uint64_t ddsi_tkmap_lookup (struct ddsi_tkmap *tkmap, const struct ddsi_serdata *serdata);
|
||||
DDS_EXPORT struct ddsi_tkmap_instance * ddsi_tkmap_find(struct ddsi_serdata *sd, const bool rd, const bool create);
|
||||
DDS_EXPORT struct ddsi_tkmap_instance * ddsi_tkmap_find_by_id (struct ddsi_tkmap *map, uint64_t iid);
|
||||
DDS_EXPORT struct ddsi_tkmap_instance * ddsi_tkmap_lookup_instance_ref (struct ddsi_serdata * sd);
|
|
@ -14,8 +14,8 @@
|
|||
|
||||
/* DDSI Transport module */
|
||||
|
||||
#include "ddsi/q_globals.h"
|
||||
#include "ddsi/q_protocol.h"
|
||||
#include "dds/ddsi/q_globals.h"
|
||||
#include "dds/ddsi/q_protocol.h"
|
||||
|
||||
/* Types supporting handles */
|
||||
|
||||
|
@ -37,10 +37,10 @@ typedef struct ddsi_tran_qos * ddsi_tran_qos_t;
|
|||
/* Function pointer types */
|
||||
|
||||
typedef ssize_t (*ddsi_tran_read_fn_t) (ddsi_tran_conn_t, unsigned char *, size_t, bool, nn_locator_t *);
|
||||
typedef ssize_t (*ddsi_tran_write_fn_t) (ddsi_tran_conn_t, const nn_locator_t *, size_t, const os_iovec_t *, uint32_t);
|
||||
typedef ssize_t (*ddsi_tran_write_fn_t) (ddsi_tran_conn_t, const nn_locator_t *, size_t, const ddsrt_iovec_t *, uint32_t);
|
||||
typedef int (*ddsi_tran_locator_fn_t) (ddsi_tran_base_t, nn_locator_t *);
|
||||
typedef bool (*ddsi_tran_supports_fn_t) (int32_t);
|
||||
typedef os_socket (*ddsi_tran_handle_fn_t) (ddsi_tran_base_t);
|
||||
typedef ddsrt_socket_t (*ddsi_tran_handle_fn_t) (ddsi_tran_base_t);
|
||||
typedef int (*ddsi_tran_listen_fn_t) (ddsi_tran_listener_t);
|
||||
typedef void (*ddsi_tran_free_fn_t) (void);
|
||||
typedef void (*ddsi_tran_peer_locator_fn_t) (ddsi_tran_conn_t, nn_locator_t *);
|
||||
|
@ -76,7 +76,7 @@ typedef enum ddsi_locator_from_string_result (*ddsi_locator_from_string_fn_t) (d
|
|||
|
||||
typedef char * (*ddsi_locator_to_string_fn_t) (ddsi_tran_factory_t tran, char *dst, size_t sizeof_dst, const nn_locator_t *loc, int with_port);
|
||||
|
||||
typedef int (*ddsi_enumerate_interfaces_fn_t) (ddsi_tran_factory_t tran, os_ifaddrs_t **interfs);
|
||||
typedef int (*ddsi_enumerate_interfaces_fn_t) (ddsi_tran_factory_t tran, ddsrt_ifaddrs_t **interfs);
|
||||
|
||||
/* Data types */
|
||||
|
||||
|
@ -111,7 +111,7 @@ struct ddsi_tran_conn
|
|||
bool m_connless;
|
||||
bool m_stream;
|
||||
bool m_closed;
|
||||
os_atomic_uint32_t m_count;
|
||||
ddsrt_atomic_uint32_t m_count;
|
||||
|
||||
/* Relationships */
|
||||
|
||||
|
@ -198,14 +198,14 @@ inline ddsi_tran_listener_t ddsi_factory_create_listener (ddsi_tran_factory_t fa
|
|||
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 os_socket ddsi_tran_handle (ddsi_tran_base_t base) {
|
||||
inline ddsrt_socket_t ddsi_tran_handle (ddsi_tran_base_t base) {
|
||||
return base->m_handle_fn (base);
|
||||
}
|
||||
inline int ddsi_tran_locator (ddsi_tran_base_t base, nn_locator_t * loc) {
|
||||
return base->m_locator_fn (base, loc);
|
||||
}
|
||||
|
||||
inline os_socket ddsi_conn_handle (ddsi_tran_conn_t conn) {
|
||||
inline ddsrt_socket_t ddsi_conn_handle (ddsi_tran_conn_t conn) {
|
||||
return conn->m_base.m_handle_fn (&conn->m_base);
|
||||
}
|
||||
inline uint32_t ddsi_conn_type (ddsi_tran_conn_t conn) {
|
||||
|
@ -217,7 +217,7 @@ inline uint32_t ddsi_conn_port (ddsi_tran_conn_t conn) {
|
|||
inline int ddsi_conn_locator (ddsi_tran_conn_t conn, nn_locator_t * loc) {
|
||||
return conn->m_base.m_locator_fn (&conn->m_base, loc);
|
||||
}
|
||||
inline ssize_t ddsi_conn_write (ddsi_tran_conn_t conn, const nn_locator_t *dst, size_t niov, const os_iovec_t *iov, uint32_t flags) {
|
||||
inline ssize_t ddsi_conn_write (ddsi_tran_conn_t conn, const nn_locator_t *dst, size_t niov, const ddsrt_iovec_t *iov, uint32_t flags) {
|
||||
return conn->m_closed ? -1 : (conn->m_write_fn) (conn, dst, niov, iov, flags);
|
||||
}
|
||||
inline ssize_t ddsi_conn_read (ddsi_tran_conn_t conn, unsigned char * buf, size_t len, bool allow_spurious, nn_locator_t *srcloc) {
|
||||
|
@ -251,7 +251,7 @@ enum ddsi_locator_from_string_result ddsi_locator_from_string (nn_locator_t *loc
|
|||
char *ddsi_locator_to_string (char *dst, size_t sizeof_dst, const nn_locator_t *loc);
|
||||
char *ddsi_locator_to_string_no_port (char *dst, size_t sizeof_dst, const nn_locator_t *loc);
|
||||
|
||||
int ddsi_enumerate_interfaces (ddsi_tran_factory_t factory, os_ifaddrs_t **interfs);
|
||||
int ddsi_enumerate_interfaces (ddsi_tran_factory_t factory, ddsrt_ifaddrs_t **interfs);
|
||||
|
||||
inline int ddsi_listener_locator (ddsi_tran_listener_t listener, nn_locator_t * loc) {
|
||||
return listener->m_base.m_locator_fn (&listener->m_base, loc);
|
|
@ -12,12 +12,11 @@
|
|||
#ifndef NN_ADDRSET_H
|
||||
#define NN_ADDRSET_H
|
||||
|
||||
#include "os/os.h"
|
||||
|
||||
#include "util/ut_avl.h"
|
||||
#include "ddsi/q_log.h"
|
||||
#include "ddsi/q_protocol.h"
|
||||
#include "ddsi/q_feature_check.h"
|
||||
#include "dds/ddsrt/sync.h"
|
||||
#include "dds/util/ut_avl.h"
|
||||
#include "dds/ddsi/q_log.h"
|
||||
#include "dds/ddsi/q_protocol.h"
|
||||
#include "dds/ddsi/q_feature_check.h"
|
||||
|
||||
#if defined (__cplusplus)
|
||||
extern "C" {
|
||||
|
@ -29,8 +28,8 @@ typedef struct addrset_node {
|
|||
} * addrset_node_t;
|
||||
|
||||
struct addrset {
|
||||
os_mutex lock;
|
||||
os_atomic_uint32_t refc;
|
||||
ddsrt_mutex_t lock;
|
||||
ddsrt_atomic_uint32_t refc;
|
||||
ut_avlCTree_t ucaddrs, mcaddrs;
|
||||
};
|
||||
|
|
@ -15,7 +15,7 @@
|
|||
#include <assert.h>
|
||||
#include <string.h>
|
||||
|
||||
#include "ddsi/q_unused.h"
|
||||
#include "dds/ddsi/q_unused.h"
|
||||
|
||||
inline int nn_bitset_isset (unsigned numbits, const unsigned *bits, unsigned idx)
|
||||
{
|
|
@ -12,10 +12,12 @@
|
|||
#ifndef NN_BSWAP_H
|
||||
#define NN_BSWAP_H
|
||||
|
||||
#include "os/os.h"
|
||||
#include <stdint.h>
|
||||
|
||||
#include "ddsi/q_rtps.h" /* for nn_guid_t, nn_guid_prefix_t */
|
||||
#include "ddsi/q_protocol.h" /* for nn_sequence_number_t */
|
||||
#include "dds/ddsrt/endian.h"
|
||||
#include "dds/ddsrt/misc.h"
|
||||
#include "dds/ddsi/q_rtps.h" /* for nn_guid_t, nn_guid_prefix_t */
|
||||
#include "dds/ddsi/q_protocol.h" /* for nn_sequence_number_t */
|
||||
|
||||
inline uint16_t bswap2u (uint16_t x)
|
||||
{
|
||||
|
@ -55,7 +57,7 @@ inline void bswapSN (nn_sequence_number_t *sn)
|
|||
sn->low = bswap4u (sn->low);
|
||||
}
|
||||
|
||||
#if OS_ENDIANNESS == OS_LITTLE_ENDIAN
|
||||
#if DDSRT_ENDIAN == DDSRT_LITTLE_ENDIAN
|
||||
#define toBE2(x) bswap2 (x)
|
||||
#define toBE2u(x) bswap2u (x)
|
||||
#define toBE4(x) bswap4 (x)
|
|
@ -12,17 +12,15 @@
|
|||
#ifndef NN_CONFIG_H
|
||||
#define NN_CONFIG_H
|
||||
|
||||
#include "os/os.h"
|
||||
|
||||
#include "ddsi/q_log.h"
|
||||
#include "ddsi/q_thread.h"
|
||||
#include "dds/ddsi/q_log.h"
|
||||
#include "dds/ddsi/q_thread.h"
|
||||
#ifdef DDSI_INCLUDE_ENCRYPTION
|
||||
#include "ddsi/q_security.h"
|
||||
#include "dds/ddsi/q_security.h"
|
||||
#endif /* DDSI_INCLUDE_ENCRYPTION */
|
||||
#include "ddsi/q_xqos.h"
|
||||
#include "ddsi/ddsi_tran.h"
|
||||
#include "ddsi/q_feature_check.h"
|
||||
#include "ddsi/ddsi_rhc_plugin.h"
|
||||
#include "dds/ddsi/q_xqos.h"
|
||||
#include "dds/ddsi/ddsi_tran.h"
|
||||
#include "dds/ddsi/q_feature_check.h"
|
||||
#include "dds/ddsi/ddsi_rhc_plugin.h"
|
||||
|
||||
#if defined (__cplusplus)
|
||||
extern "C" {
|
||||
|
@ -86,7 +84,7 @@ struct q_security_plugins
|
|||
q_securityDecoderSet (*new_decoder) (void);
|
||||
c_bool (*free_encoder) (q_securityEncoderSet);
|
||||
c_bool (*free_decoder) (q_securityDecoderSet);
|
||||
ssize_t (*send_encoded) (ddsi_tran_conn_t, const nn_locator_t *dst, size_t niov, os_iovec_t *iov, q_securityEncoderSet *, uint32_t, uint32_t);
|
||||
ssize_t (*send_encoded) (ddsi_tran_conn_t, const nn_locator_t *dst, size_t niov, ddsrt_iovec_t *iov, q_securityEncoderSet *, uint32_t, uint32_t);
|
||||
char * (*cipher_type) (q_cipherType);
|
||||
c_bool (*cipher_type_from_string) (const char *, q_cipherType *);
|
||||
uint32_t (*header_size) (q_securityEncoderSet, uint32_t);
|
||||
|
@ -170,7 +168,7 @@ struct config_maybe_int64 {
|
|||
struct config_thread_properties_listelem {
|
||||
struct config_thread_properties_listelem *next;
|
||||
char *name;
|
||||
os_schedClass sched_class;
|
||||
ddsrt_sched_t sched_class;
|
||||
struct config_maybe_int32 sched_priority;
|
||||
struct config_maybe_uint32 stack_size;
|
||||
};
|
||||
|
@ -410,7 +408,7 @@ struct config
|
|||
|
||||
/* not used by ddsi2, only validated; user layer directly accesses
|
||||
the configuration tree */
|
||||
os_schedClass watchdog_sched_class;
|
||||
ddsrt_sched_t watchdog_sched_class;
|
||||
int32_t watchdog_sched_priority;
|
||||
q__schedPrioClass watchdog_sched_priority_class;
|
||||
};
|
||||
|
@ -428,14 +426,14 @@ struct ddsi_plugin
|
|||
struct ddsi_rhc_plugin rhc_plugin;
|
||||
};
|
||||
|
||||
extern struct config OSAPI_EXPORT config;
|
||||
extern struct config DDS_EXPORT config;
|
||||
extern struct ddsi_plugin ddsi_plugin;
|
||||
|
||||
struct cfgst;
|
||||
|
||||
struct cfgst *config_init (_In_opt_ const char *configfile);
|
||||
void config_print_cfgst (_In_ struct cfgst *cfgst);
|
||||
void config_fini (_In_ struct cfgst *cfgst);
|
||||
struct cfgst *config_init (const char *configfile);
|
||||
void config_print_cfgst (struct cfgst *cfgst);
|
||||
void config_fini (struct cfgst *cfgst);
|
||||
|
||||
#ifdef DDSI_INCLUDE_NETWORK_PARTITIONS
|
||||
struct config_partitionmapping_listelem *find_partitionmapping (const char *partition, const char *topic);
|
|
@ -12,7 +12,7 @@
|
|||
#ifndef NN_DDSI_DISCOVERY_H
|
||||
#define NN_DDSI_DISCOVERY_H
|
||||
|
||||
#include "ddsi/q_unused.h"
|
||||
#include "dds/ddsi/q_unused.h"
|
||||
|
||||
#if defined (__cplusplus)
|
||||
extern "C" {
|
|
@ -12,17 +12,17 @@
|
|||
#ifndef Q_ENTITY_H
|
||||
#define Q_ENTITY_H
|
||||
|
||||
#include "os/os.h"
|
||||
#include "util/ut_avl.h"
|
||||
#include "ddsi/q_rtps.h"
|
||||
#include "ddsi/q_protocol.h"
|
||||
#include "ddsi/q_lat_estim.h"
|
||||
#include "ddsi/q_ephash.h"
|
||||
#include "ddsi/q_hbcontrol.h"
|
||||
#include "ddsi/q_feature_check.h"
|
||||
#include "ddsi/q_inverse_uint32_set.h"
|
||||
#include "dds/ddsrt/atomics.h"
|
||||
#include "dds/util/ut_avl.h"
|
||||
#include "dds/ddsi/q_rtps.h"
|
||||
#include "dds/ddsi/q_protocol.h"
|
||||
#include "dds/ddsi/q_lat_estim.h"
|
||||
#include "dds/ddsi/q_ephash.h"
|
||||
#include "dds/ddsi/q_hbcontrol.h"
|
||||
#include "dds/ddsi/q_feature_check.h"
|
||||
#include "dds/ddsi/q_inverse_uint32_set.h"
|
||||
|
||||
#include "ddsi/ddsi_tran.h"
|
||||
#include "dds/ddsi/ddsi_tran.h"
|
||||
|
||||
#if defined (__cplusplus)
|
||||
extern "C" {
|
||||
|
@ -136,12 +136,12 @@ struct entity_common {
|
|||
char *name;
|
||||
uint64_t iid;
|
||||
struct ddsi_tkmap_instance *tk;
|
||||
os_mutex lock;
|
||||
ddsrt_mutex_t lock;
|
||||
bool onlylocal;
|
||||
};
|
||||
|
||||
struct local_reader_ary {
|
||||
os_mutex rdary_lock;
|
||||
ddsrt_mutex_t rdary_lock;
|
||||
unsigned valid: 1; /* always true until (proxy-)writer is being deleted; !valid => !fastpath_ok */
|
||||
unsigned fastpath_ok: 1; /* if not ok, fall back to using GUIDs (gives access to the reader-writer match data for handling readers that bumped into resource limits, hence can flip-flop, unlike "valid") */
|
||||
unsigned n_readers;
|
||||
|
@ -165,7 +165,7 @@ struct participant
|
|||
nn_locator_t m_locator;
|
||||
ddsi_tran_conn_t m_conn;
|
||||
struct avail_entityid_set avail_entityids; /* available entity ids [e.lock] */
|
||||
os_mutex refc_lock;
|
||||
ddsrt_mutex_t refc_lock;
|
||||
int32_t user_refc; /* number of non-built-in endpoints in this participant [refc_lock] */
|
||||
int32_t builtin_refc; /* number of built-in endpoints in this participant [refc_lock] */
|
||||
int builtins_deleted; /* whether deletion of built-in endpoints has been initiated [refc_lock] */
|
||||
|
@ -187,14 +187,14 @@ enum writer_state {
|
|||
WRST_DELETING /* writer is actually being deleted (removed from hash table) */
|
||||
};
|
||||
|
||||
#if OS_ATOMIC64_SUPPORT
|
||||
typedef os_atomic_uint64_t seq_xmit_t;
|
||||
#define INIT_SEQ_XMIT(wr, v) os_atomic_st64(&(wr)->seq_xmit, (uint64_t) (v))
|
||||
#define READ_SEQ_XMIT(wr) ((seqno_t) os_atomic_ld64(&(wr)->seq_xmit))
|
||||
#if DDSRT_ATOMIC64_SUPPORT
|
||||
typedef ddsrt_atomic_uint64_t seq_xmit_t;
|
||||
#define INIT_SEQ_XMIT(wr, v) ddsrt_atomic_st64(&(wr)->seq_xmit, (uint64_t) (v))
|
||||
#define READ_SEQ_XMIT(wr) ((seqno_t) ddsrt_atomic_ld64(&(wr)->seq_xmit))
|
||||
#define UPDATE_SEQ_XMIT_LOCKED(wr, nv) do { uint64_t ov_; do { \
|
||||
ov_ = os_atomic_ld64(&(wr)->seq_xmit); \
|
||||
ov_ = ddsrt_atomic_ld64(&(wr)->seq_xmit); \
|
||||
if ((uint64_t) nv <= ov_) break; \
|
||||
} while (!os_atomic_cas64(&(wr)->seq_xmit, ov_, (uint64_t) nv)); } while (0)
|
||||
} while (!ddsrt_atomic_cas64(&(wr)->seq_xmit, ov_, (uint64_t) nv)); } while (0)
|
||||
#define UPDATE_SEQ_XMIT_UNLOCKED(sx, nv) UPDATE_SEQ_XMIT_LOCKED(sx, nv)
|
||||
#else
|
||||
typedef seqno_t seq_xmit_t;
|
||||
|
@ -204,9 +204,9 @@ typedef seqno_t seq_xmit_t;
|
|||
if ((nv) > (wr)->seq_xmit) { (wr)->seq_xmit = (nv); } \
|
||||
} while (0)
|
||||
#define UPDATE_SEQ_XMIT_UNLOCKED(wr, nv) do { \
|
||||
os_mutexLock (&(wr)->e.lock); \
|
||||
ddsrt_mutex_lock (&(wr)->e.lock); \
|
||||
if ((nv) > (wr)->seq_xmit) { (wr)->seq_xmit = (nv); } \
|
||||
os_mutexUnlock (&(wr)->e.lock); \
|
||||
ddsrt_mutex_unlock (&(wr)->e.lock); \
|
||||
} while (0)
|
||||
#endif
|
||||
|
||||
|
@ -216,7 +216,7 @@ struct writer
|
|||
struct endpoint_common c;
|
||||
status_cb_t status_cb;
|
||||
void * status_cb_entity;
|
||||
os_cond throttle_cond; /* used to trigger a transmit thread blocked in throttle_writer() */
|
||||
ddsrt_cond_t throttle_cond; /* used to trigger a transmit thread blocked in throttle_writer() */
|
||||
seqno_t seq; /* last sequence number (transmitted seqs are 1 ... seq) */
|
||||
seqno_t cs_seq; /* 1st seq in coherent set (or 0) */
|
||||
seq_xmit_t seq_xmit; /* last sequence number actually transmitted */
|
||||
|
@ -295,7 +295,7 @@ struct proxy_participant
|
|||
unsigned prismtech_bes; /* prismtech-specific extension of built-in endpoints set */
|
||||
nn_guid_t privileged_pp_guid; /* if this PP depends on another PP for its SEDP writing */
|
||||
nn_plist_t *plist; /* settings/QoS for this participant */
|
||||
os_atomic_voidp_t lease; /* lease object for this participant, for automatic leases */
|
||||
ddsrt_atomic_voidp_t lease; /* lease object for this participant, for automatic leases */
|
||||
struct addrset *as_default; /* default address set to use for user data traffic */
|
||||
struct addrset *as_meta; /* default address set to use for discovery traffic */
|
||||
struct proxy_endpoint_common *endpoints; /* all proxy endpoints can be reached from here */
|
||||
|
@ -346,7 +346,7 @@ struct proxy_writer {
|
|||
seqno_t last_seq; /* highest known seq published by the writer, not last delivered */
|
||||
uint32_t last_fragnum; /* last known frag for last_seq, or ~0u if last_seq not partial */
|
||||
nn_count_t nackfragcount; /* last nackfrag seq number */
|
||||
os_atomic_uint32_t next_deliv_seq_lowword; /* lower 32-bits for next sequence number that will be delivered; for generating acks; 32-bit so atomic reads on all supported platforms */
|
||||
ddsrt_atomic_uint32_t next_deliv_seq_lowword; /* lower 32-bits for next sequence number that will be delivered; for generating acks; 32-bit so atomic reads on all supported platforms */
|
||||
unsigned last_fragnum_reset: 1; /* iff set, heartbeat advertising last_seq as highest seq resets last_fragnum */
|
||||
unsigned deliver_synchronously: 1; /* iff 1, delivery happens straight from receive thread for non-historical data; else through delivery queue "dqueue" */
|
||||
unsigned have_seen_heartbeat: 1; /* iff 1, we have received at least on heartbeat from this proxy writer */
|
|
@ -12,8 +12,7 @@
|
|||
#ifndef Q_EPHASH_H
|
||||
#define Q_EPHASH_H
|
||||
|
||||
#include "os/os_defs.h"
|
||||
#include "util/ut_hopscotch.h"
|
||||
#include "dds/util/ut_hopscotch.h"
|
||||
|
||||
#if defined (__cplusplus)
|
||||
extern "C" {
|
|
@ -42,10 +42,10 @@
|
|||
#error "SSM requires NETWORK_PARTITIONS"
|
||||
#endif
|
||||
|
||||
#include "os/os_socket.h"
|
||||
#ifndef OS_SOCKET_HAS_SSM
|
||||
#error "OS_SOCKET_HAS_SSM should be defined"
|
||||
#elif ! OS_SOCKET_HAS_SSM
|
||||
#include "dds/ddsrt/sockets.h"
|
||||
#ifndef DDSRT_HAVE_SSM
|
||||
#error "DDSRT_HAVE_SSM should be defined"
|
||||
#elif ! DDSRT_HAVE_SSM
|
||||
#undef DDSI_INCLUDE_SSM
|
||||
#endif
|
||||
#endif
|
|
@ -12,7 +12,8 @@
|
|||
#ifndef NN_FREELIST_H
|
||||
#define NN_FREELIST_H
|
||||
|
||||
#include "os/os.h"
|
||||
#include "dds/ddsrt/atomics.h"
|
||||
#include "dds/ddsrt/sync.h"
|
||||
|
||||
#define FREELIST_SIMPLE 1
|
||||
#define FREELIST_ATOMIC_LIFO 2
|
||||
|
@ -31,8 +32,8 @@
|
|||
#if FREELIST_TYPE == FREELIST_ATOMIC_LIFO
|
||||
|
||||
struct nn_freelist {
|
||||
os_atomic_lifo_t x;
|
||||
os_atomic_uint32_t count;
|
||||
ddsrt_atomic_lifo_t x;
|
||||
ddsrt_atomic_uint32_t count;
|
||||
uint32_t max;
|
||||
off_t linkoff;
|
||||
};
|
||||
|
@ -49,15 +50,15 @@ struct nn_freelistM {
|
|||
};
|
||||
|
||||
struct nn_freelist1 {
|
||||
os_mutex lock;
|
||||
ddsrt_mutex_t lock;
|
||||
uint32_t count;
|
||||
struct nn_freelistM *m;
|
||||
};
|
||||
|
||||
struct nn_freelist {
|
||||
struct nn_freelist1 inner[NN_FREELIST_NPAR];
|
||||
os_atomic_uint32_t cc;
|
||||
os_mutex lock;
|
||||
ddsrt_atomic_uint32_t cc;
|
||||
ddsrt_mutex_t lock;
|
||||
struct nn_freelistM *mlist;
|
||||
struct nn_freelistM *emlist;
|
||||
uint32_t count;
|
||||
|
@ -67,10 +68,10 @@ struct nn_freelist {
|
|||
|
||||
#endif
|
||||
|
||||
void nn_freelist_init (_Out_ struct nn_freelist *fl, uint32_t max, off_t linkoff);
|
||||
void nn_freelist_fini (_Inout_ _Post_invalid_ struct nn_freelist *fl, _In_ void (*free) (void *elem));
|
||||
_Check_return_ bool nn_freelist_push (_Inout_ struct nn_freelist *fl, _Inout_ _When_ (return != 0, _Post_invalid_) void *elem);
|
||||
_Check_return_ _Ret_maybenull_ void *nn_freelist_pushmany (_Inout_ struct nn_freelist *fl, _Inout_opt_ _When_ (return != 0, _Post_invalid_) void *first, _Inout_opt_ _When_ (return != 0, _Post_invalid_) void *last, uint32_t n);
|
||||
_Check_return_ _Ret_maybenull_ void *nn_freelist_pop (_Inout_ struct nn_freelist *fl);
|
||||
void nn_freelist_init (struct nn_freelist *fl, uint32_t max, off_t linkoff);
|
||||
void nn_freelist_fini (struct nn_freelist *fl, void (*free) (void *elem));
|
||||
bool nn_freelist_push (struct nn_freelist *fl, void *elem);
|
||||
void *nn_freelist_pushmany (struct nn_freelist *fl, void *first, void *last, uint32_t n);
|
||||
void *nn_freelist_pop (struct nn_freelist *fl);
|
||||
|
||||
#endif /* NN_FREELIST_H */
|
|
@ -12,8 +12,8 @@
|
|||
#ifndef Q_GC_H
|
||||
#define Q_GC_H
|
||||
|
||||
#include "ddsc/dds_export.h"
|
||||
#include "ddsi/q_thread.h"
|
||||
#include "dds/export.h"
|
||||
#include "dds/ddsi/q_thread.h"
|
||||
|
||||
#if defined (__cplusplus)
|
||||
extern "C" {
|
|
@ -14,20 +14,20 @@
|
|||
|
||||
#include <stdio.h>
|
||||
|
||||
#include "os/os.h"
|
||||
#include "dds/export.h"
|
||||
#include "dds/ddsrt/atomics.h"
|
||||
#include "dds/ddsrt/sockets.h"
|
||||
#include "dds/ddsrt/sync.h"
|
||||
#include "dds/util/ut_fibheap.h"
|
||||
|
||||
#include "util/ut_fibheap.h"
|
||||
|
||||
#include "ddsc/dds_export.h"
|
||||
|
||||
#include "ddsi/q_plist.h"
|
||||
#include "ddsi/q_protocol.h"
|
||||
#include "ddsi/q_nwif.h"
|
||||
#include "ddsi/q_sockwaitset.h"
|
||||
#include "ddsi/ddsi_iid.h"
|
||||
#include "dds/ddsi/q_plist.h"
|
||||
#include "dds/ddsi/q_protocol.h"
|
||||
#include "dds/ddsi/q_nwif.h"
|
||||
#include "dds/ddsi/q_sockwaitset.h"
|
||||
#include "dds/ddsi/ddsi_iid.h"
|
||||
|
||||
#ifdef DDSI_INCLUDE_ENCRYPTION
|
||||
#include "ddsi/q_security.h" /* for q_securityDecoderSet */
|
||||
#include "dds/ddsi/q_security.h" /* for q_securityDecoderSet */
|
||||
#endif /* DDSI_INCLUDE_ENCRYPTION */
|
||||
|
||||
#if defined (__cplusplus)
|
||||
|
@ -108,8 +108,8 @@ struct q_globals {
|
|||
struct nn_servicelease *servicelease;
|
||||
|
||||
/* Lease junk */
|
||||
os_mutex leaseheap_lock;
|
||||
os_mutex lease_locks[N_LEASE_LOCKS];
|
||||
ddsrt_mutex_t leaseheap_lock;
|
||||
ddsrt_mutex_t lease_locks[N_LEASE_LOCKS];
|
||||
ut_fibheap_t leaseheap;
|
||||
|
||||
/* Transport factory */
|
||||
|
@ -138,13 +138,13 @@ struct q_globals {
|
|||
/* In many sockets mode, the receive threads maintain a local array
|
||||
with participant GUIDs and sockets, participant_set_generation is
|
||||
used to notify them. */
|
||||
os_atomic_uint32_t participant_set_generation;
|
||||
ddsrt_atomic_uint32_t participant_set_generation;
|
||||
|
||||
/* nparticipants is used primarily for limiting the number of active
|
||||
participants, but also during shutdown to determine when it is
|
||||
safe to stop the GC thread. */
|
||||
os_mutex participant_set_lock;
|
||||
os_cond participant_set_cond;
|
||||
ddsrt_mutex_t participant_set_lock;
|
||||
ddsrt_cond_t participant_set_cond;
|
||||
uint32_t nparticipants;
|
||||
|
||||
/* For participants without (some) built-in writers, we fall back to
|
||||
|
@ -152,7 +152,7 @@ struct q_globals {
|
|||
built-in writers present. It MUST be created before any in need
|
||||
of it pops up! */
|
||||
struct participant *privileged_pp;
|
||||
os_mutex privileged_pp_lock;
|
||||
ddsrt_mutex_t privileged_pp_lock;
|
||||
|
||||
/* GUID to be used in next call to new_participant; also protected
|
||||
by privileged_pp_lock */
|
||||
|
@ -164,7 +164,7 @@ struct q_globals {
|
|||
int selected_interface;
|
||||
struct nn_interface interfaces[MAX_INTERFACES];
|
||||
|
||||
#if OS_SOCKET_HAS_IPV6
|
||||
#if DDSRT_HAVE_IPV6
|
||||
/* whether we're using an IPv6 link-local address (and therefore
|
||||
only listening to multicasts on that interface) */
|
||||
int ipv6_link_local;
|
||||
|
@ -201,9 +201,9 @@ struct q_globals {
|
|||
|
||||
/* qoslock serializes QoS changes, probably not strictly necessary,
|
||||
but a lot more straightforward that way */
|
||||
os_rwlock qoslock;
|
||||
ddsrt_rwlock_t qoslock;
|
||||
|
||||
os_mutex lock;
|
||||
ddsrt_mutex_t lock;
|
||||
|
||||
/* Receive thread. (We can only has one for now, cos of the signal
|
||||
trigger socket.) Receive buffer pool is per receive thread,
|
||||
|
@ -254,7 +254,7 @@ struct q_globals {
|
|||
we accept from writers we don't know) and have their very own
|
||||
do-nothing defragmentation and reordering thingummies, as well as a
|
||||
global mutex to in lieu of the proxy writer lock. */
|
||||
os_mutex spdp_lock;
|
||||
ddsrt_mutex_t spdp_lock;
|
||||
struct nn_defrag *spdp_defrag;
|
||||
struct nn_reorder *spdp_reorder;
|
||||
|
||||
|
@ -288,8 +288,8 @@ struct q_globals {
|
|||
remove the need to include kernelModule.h) */
|
||||
uint32_t myNetworkId;
|
||||
|
||||
os_mutex sendq_lock;
|
||||
os_cond sendq_cond;
|
||||
ddsrt_mutex_t sendq_lock;
|
||||
ddsrt_cond_t sendq_cond;
|
||||
unsigned sendq_length;
|
||||
struct nn_xpack *sendq_head;
|
||||
struct nn_xpack *sendq_tail;
|
||||
|
@ -305,10 +305,7 @@ struct q_globals {
|
|||
|
||||
/* File for dumping captured packets, NULL if disabled */
|
||||
FILE *pcap_fp;
|
||||
os_mutex pcap_lock;
|
||||
|
||||
/* Data structure to capture power events */
|
||||
os_timePowerEvents powerEvents;
|
||||
ddsrt_mutex_t pcap_lock;
|
||||
|
||||
struct nn_group_membership *mship;
|
||||
};
|
|
@ -12,7 +12,7 @@
|
|||
#ifndef NN_INVERSE_UINT32_SET_H
|
||||
#define NN_INVERSE_UINT32_SET_H
|
||||
|
||||
#include "util/ut_avl.h"
|
||||
#include "dds/util/ut_avl.h"
|
||||
|
||||
struct inverse_uint32_set_node {
|
||||
ut_avlNode_t avlnode;
|
|
@ -12,9 +12,7 @@
|
|||
#ifndef NN_LAT_ESTIM_H
|
||||
#define NN_LAT_ESTIM_H
|
||||
|
||||
#include "os/os_defs.h"
|
||||
|
||||
#include "ddsi/q_log.h"
|
||||
#include "dds/ddsi/q_log.h"
|
||||
|
||||
#if defined (__cplusplus)
|
||||
extern "C" {
|
|
@ -12,7 +12,7 @@
|
|||
#ifndef Q_LEASE_H
|
||||
#define Q_LEASE_H
|
||||
|
||||
#include "ddsi/q_time.h"
|
||||
#include "dds/ddsi/q_time.h"
|
||||
|
||||
#if defined (__cplusplus)
|
||||
extern "C" {
|
|
@ -14,30 +14,31 @@
|
|||
|
||||
#include <stdarg.h>
|
||||
|
||||
#include "os/os.h"
|
||||
#include "ddsi/q_time.h"
|
||||
#include "dds/ddsrt/log.h"
|
||||
#include "dds/ddsi/q_time.h"
|
||||
#include "dds/ddsrt/rusage.h"
|
||||
|
||||
#if defined (__cplusplus)
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/* LOG_THREAD_CPUTIME must be considered private. */
|
||||
#define LOG_THREAD_CPUTIME(guard) \
|
||||
do { \
|
||||
if (dds_get_log_mask() & DDS_LC_TIMING) { \
|
||||
nn_mtime_t tnowlt = now_mt(); \
|
||||
if (tnowlt.v >= (guard).v) { \
|
||||
os_rusage_t usage; \
|
||||
if (os_getrusage(OS_RUSAGE_THREAD, &usage) == 0) { \
|
||||
DDS_LOG( \
|
||||
DDS_LC_TIMING, \
|
||||
"thread_cputime %d.%09d\n", \
|
||||
(int)usage.stime.tv_sec, \
|
||||
(int)usage.stime.tv_nsec); \
|
||||
(guard).v = tnowlt.v + T_SECOND; \
|
||||
} \
|
||||
} \
|
||||
} \
|
||||
#define LOG_THREAD_CPUTIME(guard) \
|
||||
do { \
|
||||
if (dds_get_log_mask() & DDS_LC_TIMING) { \
|
||||
nn_mtime_t tnowlt = now_mt(); \
|
||||
if (tnowlt.v >= (guard).v) { \
|
||||
ddsrt_rusage_t usage; \
|
||||
if (ddsrt_getrusage(DDSRT_RUSAGE_THREAD, &usage) == 0) { \
|
||||
DDS_LOG( \
|
||||
DDS_LC_TIMING, \
|
||||
"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; \
|
||||
} \
|
||||
} \
|
||||
} \
|
||||
} while (0)
|
||||
|
||||
#if defined (__cplusplus)
|
|
@ -12,7 +12,7 @@
|
|||
#ifndef NN_MISC_H
|
||||
#define NN_MISC_H
|
||||
|
||||
#include "ddsi/q_protocol.h"
|
||||
#include "dds/ddsi/q_protocol.h"
|
||||
|
||||
#if defined (__cplusplus)
|
||||
extern "C" {
|
|
@ -12,8 +12,11 @@
|
|||
#ifndef Q_NWIF_H
|
||||
#define Q_NWIF_H
|
||||
|
||||
#include "os/os_socket.h"
|
||||
#include "ddsi/q_protocol.h" /* for nn_locator_t */
|
||||
#include <stdbool.h>
|
||||
|
||||
#include "dds/ddsrt/ifaddrs.h"
|
||||
#include "dds/ddsrt/sockets.h"
|
||||
#include "dds/ddsi/q_protocol.h" /* for nn_locator_t */
|
||||
|
||||
#if defined (__cplusplus)
|
||||
extern "C" {
|
||||
|
@ -29,7 +32,7 @@ struct nn_interface {
|
|||
char *name;
|
||||
};
|
||||
|
||||
int make_socket (os_socket *socket, unsigned short port, bool stream, bool reuse);
|
||||
int make_socket (ddsrt_socket_t *socket, unsigned short port, bool stream, bool reuse);
|
||||
int find_own_ip (const char *requested_address);
|
||||
unsigned locator_to_hopefully_unique_uint32 (const nn_locator_t *src);
|
||||
|
|
@ -13,7 +13,7 @@
|
|||
#define Q_PCAP_H
|
||||
|
||||
#include <stdio.h>
|
||||
#include "ddsi/q_time.h"
|
||||
#include "dds/ddsi/q_time.h"
|
||||
|
||||
#if defined (__cplusplus)
|
||||
extern "C" {
|
||||
|
@ -27,8 +27,8 @@ void write_pcap_received
|
|||
(
|
||||
FILE * fp,
|
||||
nn_wctime_t tstamp,
|
||||
const os_sockaddr_storage * src,
|
||||
const os_sockaddr_storage * dst,
|
||||
const struct sockaddr_storage * src,
|
||||
const struct sockaddr_storage * dst,
|
||||
unsigned char * buf,
|
||||
size_t sz
|
||||
);
|
||||
|
@ -37,8 +37,8 @@ void write_pcap_sent
|
|||
(
|
||||
FILE * fp,
|
||||
nn_wctime_t tstamp,
|
||||
const os_sockaddr_storage * src,
|
||||
const struct msghdr * hdr,
|
||||
const struct sockaddr_storage * src,
|
||||
const ddsrt_msghdr_t * hdr,
|
||||
size_t sz
|
||||
);
|
||||
|
|
@ -12,8 +12,8 @@
|
|||
#ifndef NN_PLIST_H
|
||||
#define NN_PLIST_H
|
||||
|
||||
#include "ddsi/q_feature_check.h"
|
||||
#include "ddsi/q_xqos.h"
|
||||
#include "dds/ddsi/q_feature_check.h"
|
||||
#include "dds/ddsi/q_xqos.h"
|
||||
|
||||
|
||||
#if defined (__cplusplus)
|
||||
|
@ -113,16 +113,6 @@ typedef struct nn_reader_favours_ssm {
|
|||
} nn_reader_favours_ssm_t;
|
||||
#endif
|
||||
|
||||
typedef struct nn_dataholder
|
||||
{
|
||||
char *class_id;
|
||||
nn_propertyseq_t properties;
|
||||
nn_binarypropertyseq_t binary_properties;
|
||||
} nn_dataholder_t;
|
||||
|
||||
typedef nn_dataholder_t nn_token_t;
|
||||
|
||||
|
||||
typedef struct nn_prismtech_participant_version_info
|
||||
{
|
||||
unsigned version;
|
||||
|
@ -185,8 +175,6 @@ typedef struct nn_plist {
|
|||
char *type_description;
|
||||
nn_sequence_number_t coherent_set_seqno;
|
||||
nn_prismtech_eotinfo_t eotinfo;
|
||||
nn_token_t identity_token;
|
||||
nn_token_t permissions_token;
|
||||
#ifdef DDSI_INCLUDE_SSM
|
||||
nn_reader_favours_ssm_t reader_favours_ssm;
|
||||
#endif
|
|
@ -12,17 +12,11 @@
|
|||
#ifndef NN_PROTOCOL_H
|
||||
#define NN_PROTOCOL_H
|
||||
|
||||
#include "os/os.h"
|
||||
#include "ddsi/q_feature_check.h"
|
||||
#include "dds/ddsrt/endian.h"
|
||||
#include "dds/ddsi/q_feature_check.h"
|
||||
|
||||
#if OS_ENDIANNESS == OS_LITTLE_ENDIAN
|
||||
#define PLATFORM_IS_LITTLE_ENDIAN 1
|
||||
#else
|
||||
#define PLATFORM_IS_LITTLE_ENDIAN 0
|
||||
#endif
|
||||
|
||||
#include "ddsi/q_rtps.h"
|
||||
#include "ddsi/q_time.h"
|
||||
#include "dds/ddsi/q_rtps.h"
|
||||
#include "dds/ddsi/q_time.h"
|
||||
|
||||
#if defined (__cplusplus)
|
||||
extern "C" {
|
||||
|
@ -134,7 +128,7 @@ typedef struct Header {
|
|||
nn_vendorid_t vendorid;
|
||||
nn_guid_prefix_t guid_prefix;
|
||||
} Header_t;
|
||||
#if PLATFORM_IS_LITTLE_ENDIAN
|
||||
#if DDSRT_ENDIAN == DDSRT_LITTLE_ENDIAN
|
||||
#define NN_PROTOCOLID_AS_UINT32 (((uint32_t)'R' << 0) | ((uint32_t)'T' << 8) | ((uint32_t)'P' << 16) | ((uint32_t)'S' << 24))
|
||||
#else
|
||||
#define NN_PROTOCOLID_AS_UINT32 (((uint32_t)'R' << 24) | ((uint32_t)'T' << 16) | ((uint32_t)'P' << 8) | ((uint32_t)'S' << 0))
|
||||
|
@ -192,7 +186,7 @@ typedef struct InfoSRC {
|
|||
nn_guid_prefix_t guid_prefix;
|
||||
} InfoSRC_t;
|
||||
|
||||
#if PLATFORM_IS_LITTLE_ENDIAN
|
||||
#if DDSRT_ENDIAN == DDSRT_LITTLE_ENDIAN
|
||||
#define PL_CDR_BE 0x0200u
|
||||
#define PL_CDR_LE 0x0300u
|
||||
#else
|
|
@ -12,9 +12,10 @@
|
|||
#ifndef NN_RADMIN_H
|
||||
#define NN_RADMIN_H
|
||||
|
||||
#include "os/os_thread.h"
|
||||
#include "ddsi/q_rtps.h"
|
||||
#include "ddsi/ddsi_tran.h"
|
||||
#include "dds/ddsrt/atomics.h"
|
||||
#include "dds/ddsrt/threads.h"
|
||||
#include "dds/ddsi/q_rtps.h"
|
||||
#include "dds/ddsi/ddsi_tran.h"
|
||||
|
||||
#if defined (__cplusplus)
|
||||
extern "C" {
|
||||
|
@ -72,7 +73,7 @@ struct nn_rmsg {
|
|||
decrementing of refcounts until after a sample has been added to
|
||||
all radmins even though be delivery of it may take place in
|
||||
concurrently. */
|
||||
os_atomic_uint32_t refcount;
|
||||
ddsrt_atomic_uint32_t refcount;
|
||||
|
||||
/* Worst-case memory requirement is gigantic (64kB UDP packet, only
|
||||
1-byte final fragments, each of one a new interval, or maybe 1
|
||||
|
@ -130,7 +131,7 @@ struct nn_rdata {
|
|||
uint16_t submsg_zoff; /* offset to submessage from packet start, or 0 */
|
||||
uint16_t payload_zoff; /* offset to payload from packet start */
|
||||
#ifndef NDEBUG
|
||||
os_atomic_uint32_t refcount_bias_added;
|
||||
ddsrt_atomic_uint32_t refcount_bias_added;
|
||||
#endif
|
||||
};
|
||||
|
||||
|
@ -195,7 +196,7 @@ typedef int32_t nn_reorder_result_t;
|
|||
typedef void (*nn_dqueue_callback_t) (void *arg);
|
||||
|
||||
struct nn_rbufpool *nn_rbufpool_new (uint32_t rbuf_size, uint32_t max_rmsg_size);
|
||||
void nn_rbufpool_setowner (struct nn_rbufpool *rbp, os_threadId tid);
|
||||
void nn_rbufpool_setowner (struct nn_rbufpool *rbp, ddsrt_thread_t tid);
|
||||
void nn_rbufpool_free (struct nn_rbufpool *rbp);
|
||||
|
||||
struct nn_rmsg *nn_rmsg_new (struct nn_rbufpool *rbufpool);
|
|
@ -12,8 +12,7 @@
|
|||
#ifndef NN_RTPS_H
|
||||
#define NN_RTPS_H
|
||||
|
||||
#include "os/os_defs.h"
|
||||
#include "ddsi/ddsi_vendor.h"
|
||||
#include "dds/ddsi/ddsi_vendor.h"
|
||||
|
||||
#if defined (__cplusplus)
|
||||
extern "C" {
|
|
@ -12,8 +12,6 @@
|
|||
#ifndef Q_SOCKWAITSET_H
|
||||
#define Q_SOCKWAITSET_H
|
||||
|
||||
#include "os/os_defs.h"
|
||||
|
||||
#if defined (__cplusplus)
|
||||
extern "C" {
|
||||
#endif
|
||||
|
@ -41,8 +39,8 @@ void os_sockWaitsetFree (os_sockWaitset ws);
|
|||
Triggers the waitset, from any thread. It is level
|
||||
triggered, when called while no thread is waiting in
|
||||
os_sockWaitsetWait the trigger will cause an (early) wakeup on the
|
||||
next call to os_sockWaitsetWait. Returns os_resultSuccess if
|
||||
successfully triggered, os_resultInvalid if an error occurs.
|
||||
next call to os_sockWaitsetWait. Returns DDS_RETCODE_OK if
|
||||
successfully triggered, DDS_RETCODE_BAD_PARAMETER if an error occurs.
|
||||
|
||||
Triggering a waitset may require resources and they may be counted.
|
||||
Do not trigger a waitset arbitrarily often without ensuring
|
|
@ -12,9 +12,11 @@
|
|||
#ifndef Q_THREAD_H
|
||||
#define Q_THREAD_H
|
||||
|
||||
#include "os/os.h"
|
||||
#include "ddsc/dds_export.h"
|
||||
#include "ddsi/q_static_assert.h"
|
||||
#include "dds/export.h"
|
||||
#include "dds/ddsrt/atomics.h"
|
||||
#include "dds/ddsrt/sync.h"
|
||||
#include "dds/ddsrt/threads.h"
|
||||
#include "dds/ddsi/q_static_assert.h"
|
||||
|
||||
#if defined (__cplusplus)
|
||||
extern "C" {
|
||||
|
@ -58,8 +60,8 @@ struct logbuf;
|
|||
#define THREAD_BASE \
|
||||
volatile vtime_t vtime; \
|
||||
volatile vtime_t watchdog; \
|
||||
os_threadId tid; \
|
||||
os_threadId extTid; \
|
||||
ddsrt_thread_t tid; \
|
||||
ddsrt_thread_t extTid; \
|
||||
enum thread_state state; \
|
||||
char *name /* note: no semicolon! */
|
||||
|
||||
|
@ -77,16 +79,16 @@ struct thread_state1 {
|
|||
#undef THREAD_BASE
|
||||
|
||||
struct thread_states {
|
||||
os_mutex lock;
|
||||
ddsrt_mutex_t lock;
|
||||
unsigned nthreads;
|
||||
struct thread_state1 *ts; /* [nthreads] */
|
||||
};
|
||||
|
||||
extern DDS_EXPORT struct thread_states thread_states;
|
||||
extern os_threadLocal struct thread_state1 *tsd_thread_state;
|
||||
extern ddsrt_thread_local struct thread_state1 *tsd_thread_state;
|
||||
|
||||
DDS_EXPORT void thread_states_init_static (void);
|
||||
DDS_EXPORT void thread_states_init (_In_ unsigned maxthreads);
|
||||
DDS_EXPORT void thread_states_init (unsigned maxthreads);
|
||||
DDS_EXPORT void thread_states_fini (void);
|
||||
|
||||
DDS_EXPORT void upgrade_main_thread (void);
|
||||
|
@ -95,43 +97,43 @@ DDS_EXPORT const struct config_thread_properties_listelem *lookup_thread_propert
|
|||
DDS_EXPORT struct thread_state1 *create_thread (const char *name, uint32_t (*f) (void *arg), void *arg);
|
||||
DDS_EXPORT struct thread_state1 *lookup_thread_state (void);
|
||||
DDS_EXPORT struct thread_state1 *lookup_thread_state_real (void);
|
||||
DDS_EXPORT int join_thread (_Inout_ struct thread_state1 *ts1);
|
||||
DDS_EXPORT int join_thread (struct thread_state1 *ts1);
|
||||
DDS_EXPORT void log_stack_traces (void);
|
||||
DDS_EXPORT struct thread_state1 *get_thread_state (_In_ os_threadId id);
|
||||
DDS_EXPORT struct thread_state1 * init_thread_state (_In_z_ const char *tname);
|
||||
DDS_EXPORT void reset_thread_state (_Inout_opt_ struct thread_state1 *ts1);
|
||||
DDS_EXPORT int thread_exists (_In_z_ const char *name);
|
||||
DDS_EXPORT struct thread_state1 *get_thread_state (ddsrt_thread_t id);
|
||||
DDS_EXPORT struct thread_state1 * init_thread_state (const char *tname);
|
||||
DDS_EXPORT void reset_thread_state (struct thread_state1 *ts1);
|
||||
DDS_EXPORT int thread_exists (const char *name);
|
||||
|
||||
DDS_EXPORT inline int vtime_awake_p (_In_ vtime_t vtime)
|
||||
DDS_EXPORT inline int vtime_awake_p (vtime_t vtime)
|
||||
{
|
||||
return (vtime % 2) == 0;
|
||||
}
|
||||
|
||||
DDS_EXPORT inline int vtime_asleep_p (_In_ vtime_t vtime)
|
||||
DDS_EXPORT inline int vtime_asleep_p (vtime_t vtime)
|
||||
{
|
||||
return (vtime % 2) == 1;
|
||||
}
|
||||
|
||||
DDS_EXPORT inline int vtime_gt (_In_ vtime_t vtime1, _In_ vtime_t vtime0)
|
||||
DDS_EXPORT inline int vtime_gt (vtime_t vtime1, vtime_t vtime0)
|
||||
{
|
||||
Q_STATIC_ASSERT_CODE (sizeof (vtime_t) == sizeof (svtime_t));
|
||||
return (svtime_t) (vtime1 - vtime0) > 0;
|
||||
}
|
||||
|
||||
DDS_EXPORT inline void thread_state_asleep (_Inout_ struct thread_state1 *ts1)
|
||||
DDS_EXPORT inline void thread_state_asleep (struct thread_state1 *ts1)
|
||||
{
|
||||
vtime_t vt = ts1->vtime;
|
||||
vtime_t wd = ts1->watchdog;
|
||||
if (vtime_awake_p (vt))
|
||||
{
|
||||
os_atomic_fence_rel ();
|
||||
ddsrt_atomic_fence_rel ();
|
||||
ts1->vtime = vt + 1;
|
||||
}
|
||||
else
|
||||
{
|
||||
os_atomic_fence_rel ();
|
||||
ddsrt_atomic_fence_rel ();
|
||||
ts1->vtime = vt + 2;
|
||||
os_atomic_fence_acq ();
|
||||
ddsrt_atomic_fence_acq ();
|
||||
}
|
||||
|
||||
if ( wd % 2 ){
|
||||
|
@ -141,7 +143,7 @@ DDS_EXPORT inline void thread_state_asleep (_Inout_ struct thread_state1 *ts1)
|
|||
}
|
||||
}
|
||||
|
||||
DDS_EXPORT inline void thread_state_awake (_Inout_ struct thread_state1 *ts1)
|
||||
DDS_EXPORT inline void thread_state_awake (struct thread_state1 *ts1)
|
||||
{
|
||||
vtime_t vt = ts1->vtime;
|
||||
vtime_t wd = ts1->watchdog;
|
||||
|
@ -149,10 +151,10 @@ DDS_EXPORT inline void thread_state_awake (_Inout_ struct thread_state1 *ts1)
|
|||
ts1->vtime = vt + 1;
|
||||
else
|
||||
{
|
||||
os_atomic_fence_rel ();
|
||||
ddsrt_atomic_fence_rel ();
|
||||
ts1->vtime = vt + 2;
|
||||
}
|
||||
os_atomic_fence_acq ();
|
||||
ddsrt_atomic_fence_acq ();
|
||||
|
||||
if ( wd % 2 ){
|
||||
ts1->watchdog = wd + 1;
|
||||
|
@ -161,7 +163,7 @@ DDS_EXPORT inline void thread_state_awake (_Inout_ struct thread_state1 *ts1)
|
|||
}
|
||||
}
|
||||
|
||||
DDS_EXPORT inline void thread_state_blocked (_Inout_ struct thread_state1 *ts1)
|
||||
DDS_EXPORT inline void thread_state_blocked (struct thread_state1 *ts1)
|
||||
{
|
||||
vtime_t wd = ts1->watchdog;
|
||||
if ( wd % 2 ){
|
||||
|
@ -171,7 +173,7 @@ DDS_EXPORT inline void thread_state_blocked (_Inout_ struct thread_state1 *ts1)
|
|||
}
|
||||
}
|
||||
|
||||
DDS_EXPORT inline void thread_state_unblocked (_Inout_ struct thread_state1 *ts1)
|
||||
DDS_EXPORT inline void thread_state_unblocked (struct thread_state1 *ts1)
|
||||
{
|
||||
vtime_t wd = ts1->watchdog;
|
||||
if ( wd % 2 ){
|
|
@ -12,8 +12,9 @@
|
|||
#ifndef NN_TIME_H
|
||||
#define NN_TIME_H
|
||||
|
||||
#include "os/os.h"
|
||||
#include "ddsc/dds_export.h"
|
||||
#include <stdint.h>
|
||||
|
||||
#include "dds/export.h"
|
||||
|
||||
#if defined (__cplusplus)
|
||||
extern "C" {
|
||||
|
@ -29,14 +30,7 @@ typedef struct {
|
|||
unsigned fraction;
|
||||
} nn_ddsi_time_t;
|
||||
|
||||
#if DDSI_DURATION_ACCORDING_TO_SPEC /* what the spec says */
|
||||
typedef struct { /* why different from ddsi_time_t? */
|
||||
int sec;
|
||||
int nanosec;
|
||||
} nn_duration_t;
|
||||
#else /* this is what I used to do & what wireshark does - probably right */
|
||||
typedef nn_ddsi_time_t nn_duration_t;
|
||||
#endif
|
||||
|
||||
typedef struct {
|
||||
int64_t v;
|
||||
|
@ -59,9 +53,9 @@ int valid_ddsi_timestamp (nn_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 (_Out_ int * __restrict sec, _Out_ int * __restrict usec, _In_ nn_mtime_t t);
|
||||
DDS_EXPORT void wctime_to_sec_usec (_Out_ int * __restrict sec, _Out_ int * __restrict usec, _In_ nn_wctime_t t);
|
||||
DDS_EXPORT void etime_to_sec_usec (_Out_ int * __restrict sec, _Out_ int * __restrict usec, _In_ nn_etime_t t);
|
||||
DDS_EXPORT void mtime_to_sec_usec (int * __restrict sec, int * __restrict usec, nn_mtime_t t);
|
||||
DDS_EXPORT void wctime_to_sec_usec (int * __restrict sec, int * __restrict usec, nn_wctime_t t);
|
||||
DDS_EXPORT void etime_to_sec_usec (int * __restrict sec, int * __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);
|
|
@ -12,8 +12,7 @@
|
|||
#ifndef Q_TRANSMIT_H
|
||||
#define Q_TRANSMIT_H
|
||||
|
||||
#include "os/os_defs.h"
|
||||
#include "ddsi/q_rtps.h" /* for nn_entityid_t */
|
||||
#include "dds/ddsi/q_rtps.h" /* for nn_entityid_t */
|
||||
|
||||
#if defined (__cplusplus)
|
||||
extern "C" {
|
|
@ -12,6 +12,8 @@
|
|||
#ifndef Q_WHC_H
|
||||
#define Q_WHC_H
|
||||
|
||||
#include <stddef.h>
|
||||
|
||||
#if defined (__cplusplus)
|
||||
extern "C" {
|
||||
#endif
|
||||
|
@ -69,7 +71,7 @@ typedef void (*whc_free_t)(struct whc *whc);
|
|||
/* min_seq is lowest sequence number that must be retained because of
|
||||
reliable readers that have not acknowledged all data */
|
||||
/* max_drop_seq must go soon, it's way too ugly. */
|
||||
/* plist may be NULL or os_malloc'd, WHC takes ownership of plist */
|
||||
/* 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, struct nn_plist *plist, struct ddsi_serdata *serdata, struct ddsi_tkmap_instance *tk);
|
||||
typedef unsigned (*whc_downgrade_to_volatile_t)(struct whc *whc, struct whc_state *st);
|
||||
typedef unsigned (*whc_remove_acked_messages_t)(struct whc *whc, seqno_t max_drop_seq, struct whc_state *whcst, struct whc_node **deferred_free_list);
|
|
@ -14,9 +14,9 @@
|
|||
|
||||
#include <stddef.h>
|
||||
|
||||
#include "ddsi/q_protocol.h" /* for, e.g., SubmessageKind_t */
|
||||
#include "ddsi/q_xqos.h" /* for, e.g., octetseq, stringseq */
|
||||
#include "ddsi/ddsi_tran.h"
|
||||
#include "dds/ddsi/q_protocol.h" /* for, e.g., SubmessageKind_t */
|
||||
#include "dds/ddsi/q_xqos.h" /* for, e.g., octetseq, stringseq */
|
||||
#include "dds/ddsi/ddsi_tran.h"
|
||||
|
||||
#if defined (__cplusplus)
|
||||
extern "C" {
|
||||
|
@ -135,7 +135,6 @@ void nn_xmsg_addpar_subscription_keys (struct nn_xmsg *m, unsigned pid, const st
|
|||
|
||||
void nn_xmsg_addpar_parvinfo (struct nn_xmsg *m, unsigned pid, const struct nn_prismtech_participant_version_info *pvi);
|
||||
void nn_xmsg_addpar_eotinfo (struct nn_xmsg *m, unsigned pid, const struct nn_prismtech_eotinfo *txnid);
|
||||
void nn_xmsg_addpar_dataholder (_In_ struct nn_xmsg *m, _In_ unsigned pid, _In_ const struct nn_dataholder *dh);
|
||||
void nn_xmsg_addpar_sentinel (struct nn_xmsg *m);
|
||||
int nn_xmsg_addpar_sentinel_ifparam (struct nn_xmsg *m);
|
||||
|
|
@ -13,10 +13,10 @@
|
|||
#define NN_XQOS_H
|
||||
|
||||
/*XXX*/
|
||||
#include "ddsi/q_protocol.h"
|
||||
#include "ddsi/q_rtps.h"
|
||||
#include "dds/ddsi/q_protocol.h"
|
||||
#include "dds/ddsi/q_rtps.h"
|
||||
/*XXX*/
|
||||
#include "ddsi/q_log.h"
|
||||
#include "dds/ddsi/q_log.h"
|
||||
|
||||
#if defined (__cplusplus)
|
||||
extern "C" {
|
||||
|
@ -33,33 +33,6 @@ typedef nn_octetseq_t nn_userdata_qospolicy_t;
|
|||
typedef nn_octetseq_t nn_topicdata_qospolicy_t;
|
||||
typedef nn_octetseq_t nn_groupdata_qospolicy_t;
|
||||
|
||||
typedef struct nn_property {
|
||||
char *name;
|
||||
char *value;
|
||||
bool propagate;
|
||||
} nn_property_t;
|
||||
|
||||
typedef struct nn_propertyseq {
|
||||
uint32_t n;
|
||||
nn_property_t *props;
|
||||
} nn_propertyseq_t;
|
||||
|
||||
typedef struct nn_binaryproperty {
|
||||
char *name;
|
||||
nn_octetseq_t value;
|
||||
bool propagate;
|
||||
} nn_binaryproperty_t;
|
||||
|
||||
typedef struct nn_binarypropertyseq {
|
||||
uint32_t n;
|
||||
nn_binaryproperty_t *props;
|
||||
} nn_binarypropertyseq_t;
|
||||
|
||||
typedef struct nn_property_qospolicy {
|
||||
nn_propertyseq_t value;
|
||||
nn_binarypropertyseq_t binary_value;
|
||||
} nn_property_qospolicy_t;
|
||||
|
||||
typedef enum nn_durability_kind {
|
||||
NN_VOLATILE_DURABILITY_QOS,
|
||||
NN_TRANSIENT_LOCAL_DURABILITY_QOS,
|
||||
|
@ -264,7 +237,6 @@ typedef struct nn_share_qospolicy {
|
|||
#define QP_PRISMTECH_ENTITY_FACTORY ((uint64_t)1 << 27)
|
||||
#define QP_PRISMTECH_SYNCHRONOUS_ENDPOINT ((uint64_t)1 << 28)
|
||||
#define QP_RTI_TYPECODE ((uint64_t)1 << 29)
|
||||
#define QP_PROPERTY ((uint64_t)1 << 30)
|
||||
|
||||
/* Partition QoS is not RxO according to the specification (DDS 1.2,
|
||||
section 7.1.3), but communication will not take place unless it
|
||||
|
@ -319,8 +291,6 @@ typedef struct nn_xqos {
|
|||
/*x xR*/nn_share_qospolicy_t share;
|
||||
/*xxx */nn_synchronous_endpoint_qospolicy_t synchronous_endpoint;
|
||||
|
||||
/*xxx */nn_property_qospolicy_t property;
|
||||
|
||||
/* X*/nn_octetseq_t rti_typecode;
|
||||
} nn_xqos_t;
|
||||
|
|
@ -12,8 +12,7 @@
|
|||
#ifndef SYSDEPS_H
|
||||
#define SYSDEPS_H
|
||||
|
||||
#include "os/os.h"
|
||||
|
||||
#include "dds/ddsrt/threads.h"
|
||||
|
||||
#if defined (__cplusplus)
|
||||
extern "C" {
|
||||
|
@ -23,7 +22,7 @@ extern "C" {
|
|||
#define ASSERT_WRLOCK_HELD(x) ((void) 0)
|
||||
#define ASSERT_MUTEX_HELD(x) ((void) 0)
|
||||
|
||||
void log_stacktrace (const char *name, os_threadId tid);
|
||||
void log_stacktrace (const char *name, ddsrt_thread_t tid);
|
||||
|
||||
#if defined (__cplusplus)
|
||||
}
|
|
@ -10,20 +10,21 @@
|
|||
* SPDX-License-Identifier: EPL-2.0 OR BSD-3-Clause
|
||||
*/
|
||||
#include "ddsi_eth.h"
|
||||
#include "dds/ddsi/q_config.h"
|
||||
|
||||
int ddsi_eth_enumerate_interfaces(ddsi_tran_factory_t fact, os_ifaddrs_t **ifs)
|
||||
int ddsi_eth_enumerate_interfaces(ddsi_tran_factory_t fact, ddsrt_ifaddrs_t **ifs)
|
||||
{
|
||||
int afs[] = { AF_INET, OS_AF_NULL };
|
||||
int afs[] = { AF_INET, DDSRT_AF_TERM };
|
||||
|
||||
(void)fact;
|
||||
|
||||
#if OS_SOCKET_HAVE_IPV6
|
||||
#if DDSRT_HAVE_IPV6
|
||||
if (config.transport_selector == TRANS_TCP6 ||
|
||||
config.transport_selector == TRANS_UDP6)
|
||||
{
|
||||
afs[0] = AF_INET6;
|
||||
}
|
||||
#endif /* OS_SOCKET_HAVE_IPV6 */
|
||||
#endif /* DDSRT_HAVE_IPV6 */
|
||||
|
||||
return -os_getifaddrs(ifs, afs);
|
||||
return -ddsrt_getifaddrs(ifs, afs);
|
||||
}
|
||||
|
|
|
@ -12,9 +12,8 @@
|
|||
#ifndef DDSI_ETH_H
|
||||
#define DDSI_ETH_H
|
||||
|
||||
#include "ddsi/ddsi_tran.h"
|
||||
#include "os/os.h"
|
||||
#include "dds/ddsi/ddsi_tran.h"
|
||||
|
||||
int ddsi_eth_enumerate_interfaces(ddsi_tran_factory_t fact, os_ifaddrs_t **ifs);
|
||||
int ddsi_eth_enumerate_interfaces(ddsi_tran_factory_t fact, ddsrt_ifaddrs_t **ifs);
|
||||
|
||||
#endif /* DDSI_ETH_H */
|
||||
|
|
|
@ -9,9 +9,12 @@
|
|||
*
|
||||
* SPDX-License-Identifier: EPL-2.0 OR BSD-3-Clause
|
||||
*/
|
||||
#include "ddsi/ddsi_iid.h"
|
||||
#include "ddsi/q_time.h"
|
||||
#include "ddsi/q_globals.h"
|
||||
#include "dds/ddsrt/atomics.h"
|
||||
#include "dds/ddsrt/process.h"
|
||||
#include "dds/ddsrt/sync.h"
|
||||
#include "dds/ddsi/ddsi_iid.h"
|
||||
#include "dds/ddsi/q_time.h"
|
||||
#include "dds/ddsi/q_globals.h"
|
||||
|
||||
static void dds_tea_encrypt (uint32_t v[2], const uint32_t k[4])
|
||||
{
|
||||
|
@ -45,12 +48,12 @@ uint64_t ddsi_iid_gen (void)
|
|||
uint64_t iid;
|
||||
union { uint64_t u64; uint32_t u32[2]; } tmp;
|
||||
|
||||
#if OS_ATOMIC64_SUPPORT
|
||||
tmp.u64 = os_atomic_inc64_nv (&gv.dds_iid.counter);
|
||||
#if DDSRT_ATOMIC64_SUPPORT
|
||||
tmp.u64 = ddsrt_atomic_inc64_nv (&gv.dds_iid.counter);
|
||||
#else
|
||||
os_mutexLock (&gv.dds_iid.lock);
|
||||
ddsrt_mutex_lock (&gv.dds_iid.lock);
|
||||
tmp.u64 = ++gv.dds_iid.counter;
|
||||
os_mutexUnlock (&gv.dds_iid.lock);
|
||||
ddsrt_mutex_unlock (&gv.dds_iid.lock);
|
||||
#endif
|
||||
|
||||
dds_tea_encrypt (tmp.u32, gv.dds_iid.key);
|
||||
|
@ -63,19 +66,19 @@ void ddsi_iid_init (void)
|
|||
union { uint64_t u64; uint32_t u32[2]; } tmp;
|
||||
nn_wctime_t tnow = now ();
|
||||
|
||||
#if ! OS_ATOMIC64_SUPPORT
|
||||
os_mutexInit (&gv.dds_iid.lock);
|
||||
#if ! DDSRT_ATOMIC64_SUPPORT
|
||||
ddsrt_mutex_init (&gv.dds_iid.lock);
|
||||
#endif
|
||||
|
||||
gv.dds_iid.key[0] = (uint32_t) os_getpid();
|
||||
gv.dds_iid.key[0] = (uint32_t) ddsrt_getpid();
|
||||
gv.dds_iid.key[1] = (uint32_t) tnow.v;
|
||||
gv.dds_iid.key[2] = (uint32_t) (tnow.v >> 32);
|
||||
gv.dds_iid.key[3] = 0xdeadbeef;
|
||||
|
||||
tmp.u64 = 0;
|
||||
dds_tea_decrypt (tmp.u32, gv.dds_iid.key);
|
||||
#if OS_ATOMIC64_SUPPORT
|
||||
os_atomic_st64 (&gv.dds_iid.counter, tmp.u64);
|
||||
#if DDSRT_ATOMIC64_SUPPORT
|
||||
ddsrt_atomic_st64 (&gv.dds_iid.counter, tmp.u64);
|
||||
#else
|
||||
gv.dds_iid.counter = tmp.u64;
|
||||
#endif
|
||||
|
@ -83,7 +86,7 @@ void ddsi_iid_init (void)
|
|||
|
||||
void ddsi_iid_fini (void)
|
||||
{
|
||||
#if ! OS_ATOMIC64_SUPPORT
|
||||
os_mutexDestroy (&gv.dds_iid.lock);
|
||||
#if ! DDSRT_ATOMIC64_SUPPORT
|
||||
ddsrt_mutex_destroy (&gv.dds_iid.lock);
|
||||
#endif
|
||||
}
|
||||
|
|
|
@ -11,32 +11,35 @@
|
|||
*/
|
||||
#include <assert.h>
|
||||
#include <string.h>
|
||||
#include "os/os.h"
|
||||
#include "ddsi/ddsi_ipaddr.h"
|
||||
#include "ddsi/q_nwif.h"
|
||||
#include "ddsi/q_config.h"
|
||||
|
||||
int ddsi_ipaddr_compare (const os_sockaddr *const sa1, const os_sockaddr *const sa2)
|
||||
#include "dds/ddsrt/endian.h"
|
||||
#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"
|
||||
|
||||
int ddsi_ipaddr_compare (const struct sockaddr *const sa1, const struct sockaddr *const sa2)
|
||||
{
|
||||
int eq;
|
||||
size_t sz;
|
||||
|
||||
if ((eq = sa1->sa_family - sa2->sa_family) == 0) {
|
||||
switch(sa1->sa_family) {
|
||||
#if (OS_SOCKET_HAS_IPV6 == 1)
|
||||
#if DDSRT_HAVE_IPV6
|
||||
case AF_INET6: {
|
||||
os_sockaddr_in6 *sin61, *sin62;
|
||||
sin61 = (os_sockaddr_in6 *)sa1;
|
||||
sin62 = (os_sockaddr_in6 *)sa2;
|
||||
struct sockaddr_in6 *sin61, *sin62;
|
||||
sin61 = (struct sockaddr_in6 *)sa1;
|
||||
sin62 = (struct sockaddr_in6 *)sa2;
|
||||
sz = sizeof(sin61->sin6_addr);
|
||||
eq = memcmp(&sin61->sin6_addr, &sin62->sin6_addr, sz);
|
||||
break;
|
||||
}
|
||||
#endif /* OS_SOCKET_HAS_IPV6 */
|
||||
#endif
|
||||
case AF_INET: {
|
||||
os_sockaddr_in *sin1, *sin2;
|
||||
sin1 = (os_sockaddr_in *)sa1;
|
||||
sin2 = (os_sockaddr_in *)sa2;
|
||||
struct sockaddr_in *sin1, *sin2;
|
||||
sin1 = (struct sockaddr_in *)sa1;
|
||||
sin2 = (struct sockaddr_in *)sa2;
|
||||
sz = sizeof(sin1->sin_addr);
|
||||
eq = memcmp(&sin1->sin_addr, &sin2->sin_addr, sz);
|
||||
break;
|
||||
|
@ -52,7 +55,7 @@ int ddsi_ipaddr_compare (const os_sockaddr *const sa1, const os_sockaddr *const
|
|||
|
||||
enum ddsi_nearby_address_result ddsi_ipaddr_is_nearby_address (ddsi_tran_factory_t tran, const nn_locator_t *loc, size_t ninterf, const struct nn_interface interf[])
|
||||
{
|
||||
os_sockaddr_storage tmp, iftmp, nmtmp, ownip;
|
||||
struct sockaddr_storage tmp, iftmp, nmtmp, ownip;
|
||||
size_t i;
|
||||
(void)tran;
|
||||
ddsi_ipaddr_from_loc(&tmp, loc);
|
||||
|
@ -61,9 +64,9 @@ enum ddsi_nearby_address_result ddsi_ipaddr_is_nearby_address (ddsi_tran_factory
|
|||
ddsi_ipaddr_from_loc(&iftmp, &interf[i].loc);
|
||||
ddsi_ipaddr_from_loc(&nmtmp, &interf[i].netmask);
|
||||
ddsi_ipaddr_from_loc(&ownip, &gv.ownloc);
|
||||
if (os_sockaddrSameSubnet ((os_sockaddr *) &tmp, (os_sockaddr *) &iftmp, (os_sockaddr *) &nmtmp))
|
||||
if (ddsrt_sockaddr_insamesubnet ((struct sockaddr *) &tmp, (struct sockaddr *) &iftmp, (struct sockaddr *) &nmtmp))
|
||||
{
|
||||
if (ddsi_ipaddr_compare((os_sockaddr *)&iftmp, (os_sockaddr *)&ownip) == 0)
|
||||
if (ddsi_ipaddr_compare((struct sockaddr *)&iftmp, (struct sockaddr *)&ownip) == 0)
|
||||
return DNAR_SAME;
|
||||
else
|
||||
return DNAR_LOCAL;
|
||||
|
@ -75,39 +78,39 @@ enum ddsi_nearby_address_result ddsi_ipaddr_is_nearby_address (ddsi_tran_factory
|
|||
enum ddsi_locator_from_string_result ddsi_ipaddr_from_string (ddsi_tran_factory_t tran, nn_locator_t *loc, const char *str, int32_t kind)
|
||||
{
|
||||
int af = AF_INET;
|
||||
os_sockaddr_storage tmpaddr;
|
||||
struct sockaddr_storage tmpaddr;
|
||||
|
||||
switch (kind) {
|
||||
case NN_LOCATOR_KIND_UDPv4:
|
||||
case NN_LOCATOR_KIND_TCPv4:
|
||||
break;
|
||||
#if OS_SOCKET_HAS_IPV6
|
||||
#if DDSRT_HAVE_IPV6
|
||||
case NN_LOCATOR_KIND_UDPv6:
|
||||
case NN_LOCATOR_KIND_TCPv6:
|
||||
af = AF_INET6;
|
||||
break;
|
||||
#endif /* OS_SOCKET_HAS_IPV6 */
|
||||
#endif
|
||||
default:
|
||||
return AFSR_MISMATCH;
|
||||
}
|
||||
|
||||
(void)tran;
|
||||
if (os_sockaddrfromstr(af, str, (os_sockaddr *) &tmpaddr) != 0) {
|
||||
#if OS_SOCKET_HAS_DNS
|
||||
if (ddsrt_sockaddrfromstr(af, str, (struct sockaddr *) &tmpaddr) != 0) {
|
||||
#if DDSRT_HAVE_DNS
|
||||
/* Not a valid IP address. User may have specified a hostname instead. */
|
||||
os_hostent_t *hent = NULL;
|
||||
if (os_gethostbyname(str, af, &hent) != 0) {
|
||||
ddsrt_hostent_t *hent = NULL;
|
||||
if (ddsrt_gethostbyname(str, af, &hent) != 0) {
|
||||
return AFSR_UNKNOWN;
|
||||
}
|
||||
memcpy(&tmpaddr, &hent->addrs[0], sizeof(hent->addrs[0]));
|
||||
#else
|
||||
return AFSR_INVALID;
|
||||
#endif /* OS_SOCKET_HAS_DNS */
|
||||
#endif
|
||||
}
|
||||
if (tmpaddr.ss_family != af) {
|
||||
return AFSR_MISMATCH;
|
||||
}
|
||||
ddsi_ipaddr_to_loc (loc, (os_sockaddr *)&tmpaddr, kind);
|
||||
ddsi_ipaddr_to_loc (loc, (struct sockaddr *)&tmpaddr, kind);
|
||||
/* This is just an address, so there is no valid value for port, other than INVALID.
|
||||
Without a guarantee that tmpaddr has port 0, best is to set it explicitly here */
|
||||
loc->port = NN_LOCATOR_PORT_INVALID;
|
||||
|
@ -116,7 +119,7 @@ enum ddsi_locator_from_string_result ddsi_ipaddr_from_string (ddsi_tran_factory_
|
|||
|
||||
char *ddsi_ipaddr_to_string (ddsi_tran_factory_t tran, char *dst, size_t sizeof_dst, const nn_locator_t *loc, int with_port)
|
||||
{
|
||||
os_sockaddr_storage src;
|
||||
struct sockaddr_storage src;
|
||||
size_t pos;
|
||||
(void)tran;
|
||||
assert (sizeof_dst > 1);
|
||||
|
@ -124,17 +127,17 @@ char *ddsi_ipaddr_to_string (ddsi_tran_factory_t tran, char *dst, size_t sizeof_
|
|||
switch (src.ss_family)
|
||||
{
|
||||
case AF_INET:
|
||||
os_sockaddrtostr ((const os_sockaddr *) &src, dst, sizeof_dst);
|
||||
ddsrt_sockaddrtostr ((const struct sockaddr *) &src, dst, sizeof_dst);
|
||||
if (with_port) {
|
||||
pos = strlen (dst);
|
||||
assert(pos <= sizeof_dst);
|
||||
snprintf (dst + pos, sizeof_dst - pos, ":%d", loc->port);
|
||||
}
|
||||
break;
|
||||
#if OS_SOCKET_HAS_IPV6
|
||||
#if DDSRT_HAVE_IPV6
|
||||
case AF_INET6:
|
||||
dst[0] = '[';
|
||||
os_sockaddrtostr ((const os_sockaddr *) &src, dst + 1, sizeof_dst);
|
||||
ddsrt_sockaddrtostr ((const struct sockaddr *) &src, dst + 1, sizeof_dst);
|
||||
pos = strlen (dst);
|
||||
if (with_port) {
|
||||
assert(pos <= sizeof_dst);
|
||||
|
@ -152,14 +155,14 @@ char *ddsi_ipaddr_to_string (ddsi_tran_factory_t tran, char *dst, size_t sizeof_
|
|||
return dst;
|
||||
}
|
||||
|
||||
void ddsi_ipaddr_to_loc (nn_locator_t *dst, const os_sockaddr *src, int32_t kind)
|
||||
void ddsi_ipaddr_to_loc (nn_locator_t *dst, const struct sockaddr *src, int32_t kind)
|
||||
{
|
||||
dst->kind = kind;
|
||||
switch (src->sa_family)
|
||||
{
|
||||
case AF_INET:
|
||||
{
|
||||
const os_sockaddr_in *x = (const os_sockaddr_in *) src;
|
||||
const struct sockaddr_in *x = (const struct sockaddr_in *) src;
|
||||
assert (kind == NN_LOCATOR_KIND_UDPv4 || kind == NN_LOCATOR_KIND_TCPv4);
|
||||
if (x->sin_addr.s_addr == htonl (INADDR_ANY))
|
||||
{
|
||||
|
@ -175,10 +178,10 @@ void ddsi_ipaddr_to_loc (nn_locator_t *dst, const os_sockaddr *src, int32_t kind
|
|||
}
|
||||
break;
|
||||
}
|
||||
#if OS_SOCKET_HAS_IPV6
|
||||
#if DDSRT_HAVE_IPV6
|
||||
case AF_INET6:
|
||||
{
|
||||
const os_sockaddr_in6 *x = (const os_sockaddr_in6 *) src;
|
||||
const struct sockaddr_in6 *x = (const struct sockaddr_in6 *) src;
|
||||
assert (kind == NN_LOCATOR_KIND_UDPv6 || kind == NN_LOCATOR_KIND_TCPv6);
|
||||
if (IN6_IS_ADDR_UNSPECIFIED (&x->sin6_addr))
|
||||
{
|
||||
|
@ -199,13 +202,13 @@ void ddsi_ipaddr_to_loc (nn_locator_t *dst, const os_sockaddr *src, int32_t kind
|
|||
}
|
||||
}
|
||||
|
||||
void ddsi_ipaddr_from_loc (os_sockaddr_storage *dst, const nn_locator_t *src)
|
||||
void ddsi_ipaddr_from_loc (struct sockaddr_storage *dst, const nn_locator_t *src)
|
||||
{
|
||||
memset (dst, 0, sizeof (*dst));
|
||||
switch (src->kind)
|
||||
{
|
||||
case NN_LOCATOR_KIND_INVALID:
|
||||
#if OS_SOCKET_HAS_IPV6
|
||||
#if DDSRT_HAVE_IPV6
|
||||
dst->ss_family = (config.transport_selector == TRANS_UDP6 || config.transport_selector == TRANS_TCP6) ? AF_INET6 : AF_INET;
|
||||
#else
|
||||
dst->ss_family = AF_INET;
|
||||
|
@ -214,17 +217,17 @@ void ddsi_ipaddr_from_loc (os_sockaddr_storage *dst, const nn_locator_t *src)
|
|||
case NN_LOCATOR_KIND_UDPv4:
|
||||
case NN_LOCATOR_KIND_TCPv4:
|
||||
{
|
||||
os_sockaddr_in *x = (os_sockaddr_in *) dst;
|
||||
struct sockaddr_in *x = (struct sockaddr_in *) dst;
|
||||
x->sin_family = AF_INET;
|
||||
x->sin_port = (src->port == NN_LOCATOR_PORT_INVALID) ? 0 : htons ((unsigned short) src->port);
|
||||
memcpy (&x->sin_addr.s_addr, src->address + 12, 4);
|
||||
break;
|
||||
}
|
||||
#if OS_SOCKET_HAS_IPV6
|
||||
#if DDSRT_HAVE_IPV6
|
||||
case NN_LOCATOR_KIND_UDPv6:
|
||||
case NN_LOCATOR_KIND_TCPv6:
|
||||
{
|
||||
os_sockaddr_in6 *x = (os_sockaddr_in6 *) dst;
|
||||
struct sockaddr_in6 *x = (struct sockaddr_in6 *) dst;
|
||||
x->sin6_family = AF_INET6;
|
||||
x->sin6_port = (src->port == NN_LOCATOR_PORT_INVALID) ? 0 : htons ((unsigned short) src->port);
|
||||
memcpy (&x->sin6_addr.s6_addr, src->address, 16);
|
||||
|
|
|
@ -12,13 +12,15 @@
|
|||
#include <ctype.h>
|
||||
#include <assert.h>
|
||||
#include <string.h>
|
||||
#include "os/os.h"
|
||||
#include "os/os_atomics.h"
|
||||
#include "ddsi/ddsi_tran.h"
|
||||
#include "ddsi/ddsi_mcgroup.h"
|
||||
#include "ddsi/q_config.h"
|
||||
#include "ddsi/q_log.h"
|
||||
#include "util/ut_avl.h"
|
||||
#include "dds/ddsrt/log.h"
|
||||
#include "dds/ddsrt/heap.h"
|
||||
#include "dds/ddsrt/sync.h"
|
||||
#include "dds/ddsrt/atomics.h"
|
||||
#include "dds/ddsi/ddsi_tran.h"
|
||||
#include "dds/ddsi/ddsi_mcgroup.h"
|
||||
#include "dds/ddsi/q_config.h"
|
||||
#include "dds/ddsi/q_log.h"
|
||||
#include "dds/util/ut_avl.h"
|
||||
|
||||
struct nn_group_membership_node {
|
||||
ut_avlNode_t avlnode;
|
||||
|
@ -29,7 +31,7 @@ struct nn_group_membership_node {
|
|||
};
|
||||
|
||||
struct nn_group_membership {
|
||||
os_mutex lock;
|
||||
ddsrt_mutex_t lock;
|
||||
ut_avlTree_t mships;
|
||||
};
|
||||
|
||||
|
@ -62,17 +64,17 @@ static ut_avlTreedef_t mship_td = UT_AVL_TREEDEF_INITIALIZER(offsetof (struct nn
|
|||
|
||||
struct nn_group_membership *new_group_membership (void)
|
||||
{
|
||||
struct nn_group_membership *mship = os_malloc (sizeof (*mship));
|
||||
os_mutexInit (&mship->lock);
|
||||
struct nn_group_membership *mship = ddsrt_malloc (sizeof (*mship));
|
||||
ddsrt_mutex_init (&mship->lock);
|
||||
ut_avlInit (&mship_td, &mship->mships);
|
||||
return mship;
|
||||
}
|
||||
|
||||
void free_group_membership (struct nn_group_membership *mship)
|
||||
{
|
||||
ut_avlFree (&mship_td, &mship->mships, os_free);
|
||||
os_mutexDestroy (&mship->lock);
|
||||
os_free (mship);
|
||||
ut_avlFree (&mship_td, &mship->mships, ddsrt_free);
|
||||
ddsrt_mutex_destroy (&mship->lock);
|
||||
ddsrt_free (mship);
|
||||
}
|
||||
|
||||
static int reg_group_membership (struct nn_group_membership *mship, ddsi_tran_conn_t conn, const nn_locator_t *srcloc, const nn_locator_t *mcloc)
|
||||
|
@ -91,7 +93,7 @@ static int reg_group_membership (struct nn_group_membership *mship, ddsi_tran_co
|
|||
n->count++;
|
||||
} else {
|
||||
isnew = 1;
|
||||
n = os_malloc (sizeof (*n));
|
||||
n = ddsrt_malloc (sizeof (*n));
|
||||
n->conn = conn;
|
||||
n->srcloc = key.srcloc;
|
||||
n->mcloc = key.mcloc;
|
||||
|
@ -121,7 +123,7 @@ static int unreg_group_membership (struct nn_group_membership *mship, ddsi_tran_
|
|||
{
|
||||
mustdel = 1;
|
||||
ut_avlDeleteDPath (&mship_td, &mship->mships, n, &dp);
|
||||
os_free (n);
|
||||
ddsrt_free (n);
|
||||
}
|
||||
return mustdel;
|
||||
}
|
||||
|
@ -136,7 +138,7 @@ static char *make_joinleave_msg (char *buf, size_t bufsz, ddsi_tran_conn_t conn,
|
|||
ddsi_locator_to_string_no_port(srcstr, sizeof(srcstr), srcloc);
|
||||
}
|
||||
#else
|
||||
OS_UNUSED_ARG (srcloc);
|
||||
DDSRT_UNUSED_ARG (srcloc);
|
||||
#endif
|
||||
ddsi_locator_to_string_no_port (mcstr, sizeof(mcstr), mcloc);
|
||||
if (interf)
|
||||
|
@ -223,7 +225,7 @@ static int joinleave_mcgroups (ddsi_tran_conn_t conn, int join, const nn_locator
|
|||
int ddsi_join_mc (ddsi_tran_conn_t conn, const nn_locator_t *srcloc, const nn_locator_t *mcloc)
|
||||
{
|
||||
int ret;
|
||||
os_mutexLock (&gv.mship->lock);
|
||||
ddsrt_mutex_lock (&gv.mship->lock);
|
||||
if (!reg_group_membership (gv.mship, conn, srcloc, mcloc))
|
||||
{
|
||||
char buf[256];
|
||||
|
@ -234,14 +236,14 @@ int ddsi_join_mc (ddsi_tran_conn_t conn, const nn_locator_t *srcloc, const nn_lo
|
|||
{
|
||||
ret = joinleave_mcgroups (conn, 1, srcloc, mcloc);
|
||||
}
|
||||
os_mutexUnlock (&gv.mship->lock);
|
||||
ddsrt_mutex_unlock (&gv.mship->lock);
|
||||
return ret;
|
||||
}
|
||||
|
||||
int ddsi_leave_mc (ddsi_tran_conn_t conn, const nn_locator_t *srcloc, const nn_locator_t *mcloc)
|
||||
{
|
||||
int ret;
|
||||
os_mutexLock (&gv.mship->lock);
|
||||
ddsrt_mutex_lock (&gv.mship->lock);
|
||||
if (!unreg_group_membership (gv.mship, conn, srcloc, mcloc))
|
||||
{
|
||||
char buf[256];
|
||||
|
@ -252,7 +254,7 @@ int ddsi_leave_mc (ddsi_tran_conn_t conn, const nn_locator_t *srcloc, const nn_l
|
|||
{
|
||||
ret = joinleave_mcgroups (conn, 0, srcloc, mcloc);
|
||||
}
|
||||
os_mutexUnlock (&gv.mship->lock);
|
||||
ddsrt_mutex_unlock (&gv.mship->lock);
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
@ -265,7 +267,7 @@ void ddsi_transfer_group_membership (ddsi_tran_conn_t conn, ddsi_tran_conn_t new
|
|||
/* ordering is on socket, then src IP, then mc IP; IP compare checks family first and AF_INET, AF_INET6
|
||||
are neither 0 nor maximum representable, min and max define the range of key values that relate to
|
||||
oldsock */
|
||||
os_mutexLock (&gv.mship->lock);
|
||||
ddsrt_mutex_lock (&gv.mship->lock);
|
||||
n = ut_avlLookupSuccEq (&mship_td, &gv.mship->mships, &min);
|
||||
while (n != NULL && cmp_group_membership (n, &max) <= 0)
|
||||
{
|
||||
|
@ -275,7 +277,7 @@ void ddsi_transfer_group_membership (ddsi_tran_conn_t conn, ddsi_tran_conn_t new
|
|||
ut_avlInsert (&mship_td, &gv.mship->mships, n);
|
||||
n = nn;
|
||||
}
|
||||
os_mutexUnlock (&gv.mship->lock);
|
||||
ddsrt_mutex_unlock (&gv.mship->lock);
|
||||
}
|
||||
|
||||
int ddsi_rejoin_transferred_mcgroups (ddsi_tran_conn_t conn)
|
||||
|
@ -286,13 +288,13 @@ int ddsi_rejoin_transferred_mcgroups (ddsi_tran_conn_t conn)
|
|||
memset(&min, 0, sizeof(min));
|
||||
memset(&max, 0xff, sizeof(max));
|
||||
min.conn = max.conn = conn;
|
||||
os_mutexLock (&gv.mship->lock);
|
||||
ddsrt_mutex_lock (&gv.mship->lock);
|
||||
for (n = ut_avlIterSuccEq (&mship_td, &gv.mship->mships, &it, &min); n != NULL && ret >= 0 && cmp_group_membership(n, &max) <= 0; n = ut_avlIterNext (&it))
|
||||
{
|
||||
int have_srcloc = (memcmp(&n->srcloc, &min.srcloc, sizeof(n->srcloc)) != 0);
|
||||
assert (n->conn == conn);
|
||||
ret = joinleave_mcgroups (conn, 1, have_srcloc ? &n->srcloc : NULL, &n->mcloc);
|
||||
}
|
||||
os_mutexUnlock (&gv.mship->lock);
|
||||
ddsrt_mutex_unlock (&gv.mship->lock);
|
||||
return ret;
|
||||
}
|
||||
|
|
|
@ -9,17 +9,19 @@
|
|||
*
|
||||
* SPDX-License-Identifier: EPL-2.0 OR BSD-3-Clause
|
||||
*/
|
||||
#include "os/os.h"
|
||||
#include "ddsi/ddsi_tran.h"
|
||||
#include "ddsi/ddsi_raweth.h"
|
||||
#include "ddsi/ddsi_ipaddr.h"
|
||||
#include "ddsi/ddsi_mcgroup.h"
|
||||
#include "ddsi/q_nwif.h"
|
||||
#include "ddsi/q_config.h"
|
||||
#include "ddsi/q_log.h"
|
||||
#include "ddsi/q_error.h"
|
||||
#include "ddsi/q_pcap.h"
|
||||
#include "os/os_atomics.h"
|
||||
#include "dds/ddsi/ddsi_tran.h"
|
||||
#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_error.h"
|
||||
#include "dds/ddsi/q_pcap.h"
|
||||
#include "dds/ddsrt/atomics.h"
|
||||
#include "dds/ddsrt/heap.h"
|
||||
#include "dds/ddsrt/log.h"
|
||||
#include "dds/ddsrt/sockets.h"
|
||||
|
||||
#ifdef __linux
|
||||
#include <linux/if_packet.h>
|
||||
|
@ -28,6 +30,7 @@
|
|||
#include <string.h>
|
||||
#include <assert.h>
|
||||
#include <stdlib.h>
|
||||
#include <errno.h>
|
||||
|
||||
typedef struct ddsi_tran_factory * ddsi_raweth_factory_t;
|
||||
|
||||
|
@ -40,14 +43,14 @@ typedef struct ddsi_raweth_config
|
|||
typedef struct ddsi_raweth_conn
|
||||
{
|
||||
struct ddsi_tran_conn m_base;
|
||||
os_socket m_sock;
|
||||
ddsrt_socket_t m_sock;
|
||||
int m_ifindex;
|
||||
}
|
||||
* ddsi_raweth_conn_t;
|
||||
|
||||
static struct ddsi_raweth_config ddsi_raweth_config_g;
|
||||
static struct ddsi_tran_factory ddsi_raweth_factory_g;
|
||||
static os_atomic_uint32_t init_g = OS_ATOMIC_UINT32_INIT(0);
|
||||
static ddsrt_atomic_uint32_t init_g = DDSRT_ATOMIC_UINT32_INIT(0);
|
||||
|
||||
static char *ddsi_raweth_to_string (ddsi_tran_factory_t tran, char *dst, size_t sizeof_dst, const nn_locator_t *loc, int with_port)
|
||||
{
|
||||
|
@ -65,8 +68,8 @@ static char *ddsi_raweth_to_string (ddsi_tran_factory_t tran, char *dst, size_t
|
|||
|
||||
static ssize_t ddsi_raweth_conn_read (ddsi_tran_conn_t conn, unsigned char * buf, size_t len, bool allow_spurious, nn_locator_t *srcloc)
|
||||
{
|
||||
int err;
|
||||
ssize_t ret;
|
||||
dds_retcode_t rc;
|
||||
ssize_t ret = 0;
|
||||
struct msghdr msghdr;
|
||||
struct sockaddr_ll src;
|
||||
struct iovec msg_iov;
|
||||
|
@ -84,9 +87,8 @@ static ssize_t ddsi_raweth_conn_read (ddsi_tran_conn_t conn, unsigned char * buf
|
|||
msghdr.msg_iovlen = 1;
|
||||
|
||||
do {
|
||||
ret = recvmsg(((ddsi_raweth_conn_t) conn)->m_sock, &msghdr, 0);
|
||||
err = (ret == -1) ? os_getErrno() : 0;
|
||||
} while (err == os_sockEINTR);
|
||||
rc = ddsrt_recvmsg(((ddsi_raweth_conn_t) conn)->m_sock, &msghdr, 0, &ret);
|
||||
} while (rc == DDS_RETCODE_INTERRUPTED);
|
||||
|
||||
if (ret > 0)
|
||||
{
|
||||
|
@ -100,7 +102,7 @@ static ssize_t ddsi_raweth_conn_read (ddsi_tran_conn_t conn, unsigned char * buf
|
|||
|
||||
/* Check for udp packet truncation */
|
||||
if ((((size_t) ret) > len)
|
||||
#if OS_MSGHDR_FLAGS
|
||||
#if DDSRT_MSGHDR_FLAGS
|
||||
|| (msghdr.msg_flags & MSG_TRUNC)
|
||||
#endif
|
||||
)
|
||||
|
@ -112,17 +114,19 @@ static ssize_t ddsi_raweth_conn_read (ddsi_tran_conn_t conn, unsigned char * buf
|
|||
DDS_WARNING("%s => %d truncated to %d\n", addrbuf, (int)ret, (int)len);
|
||||
}
|
||||
}
|
||||
else if (err != os_sockENOTSOCK && err != os_sockECONNRESET)
|
||||
else if (rc != DDS_RETCODE_OK &&
|
||||
rc != DDS_RETCODE_BAD_PARAMETER &&
|
||||
rc != DDS_RETCODE_NO_CONNECTION)
|
||||
{
|
||||
DDS_ERROR("UDP recvmsg sock %d: ret %d errno %d\n", (int) ((ddsi_raweth_conn_t) conn)->m_sock, (int) ret, err);
|
||||
DDS_ERROR("UDP recvmsg sock %d: ret %d retcode %d\n", (int) ((ddsi_raweth_conn_t) conn)->m_sock, (int) ret, rc);
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
static ssize_t ddsi_raweth_conn_write (ddsi_tran_conn_t conn, const nn_locator_t *dst, size_t niov, const os_iovec_t *iov, uint32_t flags)
|
||||
static ssize_t ddsi_raweth_conn_write (ddsi_tran_conn_t conn, const nn_locator_t *dst, size_t niov, const ddsrt_iovec_t *iov, uint32_t flags)
|
||||
{
|
||||
ddsi_raweth_conn_t uc = (ddsi_raweth_conn_t) conn;
|
||||
int err;
|
||||
dds_retcode_t rc;
|
||||
ssize_t ret;
|
||||
unsigned retry = 2;
|
||||
int sendflags = 0;
|
||||
|
@ -139,37 +143,27 @@ static ssize_t ddsi_raweth_conn_write (ddsi_tran_conn_t conn, const nn_locator_t
|
|||
msg.msg_name = &dstaddr;
|
||||
msg.msg_namelen = sizeof(dstaddr);
|
||||
msg.msg_flags = (int) flags;
|
||||
msg.msg_iov = (os_iovec_t *) iov;
|
||||
msg.msg_iov = (ddsrt_iovec_t *) iov;
|
||||
msg.msg_iovlen = niov;
|
||||
#ifdef MSG_NOSIGNAL
|
||||
sendflags |= MSG_NOSIGNAL;
|
||||
#endif
|
||||
do {
|
||||
ret = sendmsg (uc->m_sock, &msg, sendflags);
|
||||
err = (ret == -1) ? os_getErrno() : 0;
|
||||
} while (err == os_sockEINTR || err == os_sockEWOULDBLOCK || (err == os_sockEPERM && retry-- > 0));
|
||||
if (ret == -1)
|
||||
rc = ddsrt_sendmsg (uc->m_sock, &msg, sendflags, &ret);
|
||||
} while ((rc == DDS_RETCODE_INTERRUPTED) ||
|
||||
(rc == DDS_RETCODE_TRY_AGAIN) ||
|
||||
(rc == DDS_RETCODE_NOT_ALLOWED && retry-- > 0));
|
||||
if (rc != DDS_RETCODE_OK &&
|
||||
rc != DDS_RETCODE_INTERRUPTED &&
|
||||
rc != DDS_RETCODE_NOT_ALLOWED &&
|
||||
rc != DDS_RETCODE_NO_CONNECTION)
|
||||
{
|
||||
switch (err)
|
||||
{
|
||||
case os_sockEINTR:
|
||||
case os_sockEPERM:
|
||||
case os_sockECONNRESET:
|
||||
#ifdef os_sockENETUNREACH
|
||||
case os_sockENETUNREACH:
|
||||
#endif
|
||||
#ifdef os_sockEHOSTUNREACH
|
||||
case os_sockEHOSTUNREACH:
|
||||
#endif
|
||||
break;
|
||||
default:
|
||||
DDS_ERROR("ddsi_raweth_conn_write failed with error code %d", err);
|
||||
}
|
||||
DDS_ERROR("ddsi_raweth_conn_write failed with retcode %d", rc);
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
static os_socket ddsi_raweth_conn_handle (ddsi_tran_base_t base)
|
||||
static ddsrt_socket_t ddsi_raweth_conn_handle (ddsi_tran_base_t base)
|
||||
{
|
||||
return ((ddsi_raweth_conn_t) base)->m_sock;
|
||||
}
|
||||
|
@ -183,7 +177,7 @@ static int ddsi_raweth_conn_locator (ddsi_tran_base_t base, nn_locator_t *loc)
|
|||
{
|
||||
ddsi_raweth_conn_t uc = (ddsi_raweth_conn_t) base;
|
||||
int ret = -1;
|
||||
if (uc->m_sock != OS_INVALID_SOCKET)
|
||||
if (uc->m_sock != DDSRT_INVALID_SOCKET)
|
||||
{
|
||||
loc->kind = NN_LOCATOR_KIND_RAWETH;
|
||||
loc->port = uc->m_base.m_base.m_port;
|
||||
|
@ -195,8 +189,8 @@ static int ddsi_raweth_conn_locator (ddsi_tran_base_t base, nn_locator_t *loc)
|
|||
|
||||
static ddsi_tran_conn_t ddsi_raweth_create_conn (uint32_t port, ddsi_tran_qos_t qos)
|
||||
{
|
||||
os_socket sock;
|
||||
int rc;
|
||||
ddsrt_socket_t sock;
|
||||
dds_retcode_t rc;
|
||||
ddsi_raweth_conn_t uc = NULL;
|
||||
struct sockaddr_ll addr;
|
||||
bool mcast = (bool) (qos ? qos->m_multicast : 0);
|
||||
|
@ -209,10 +203,10 @@ static ddsi_tran_conn_t ddsi_raweth_create_conn (uint32_t port, ddsi_tran_qos_t
|
|||
return NULL;
|
||||
}
|
||||
|
||||
if ((sock = socket(PF_PACKET, SOCK_DGRAM, htons((uint16_t)port))) == -1)
|
||||
rc = ddsrt_socket(&sock, PF_PACKET, SOCK_DGRAM, htons((uint16_t)port));
|
||||
if (rc != DDS_RETCODE_OK)
|
||||
{
|
||||
rc = os_getErrno();
|
||||
DDS_ERROR("ddsi_raweth_create_conn %s port %u failed ... errno = %d\n", mcast ? "multicast" : "unicast", port, rc);
|
||||
DDS_ERROR("ddsi_raweth_create_conn %s port %u failed ... retcode = %d\n", mcast ? "multicast" : "unicast", port, rc);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
@ -221,15 +215,15 @@ static ddsi_tran_conn_t ddsi_raweth_create_conn (uint32_t port, ddsi_tran_qos_t
|
|||
addr.sll_protocol = htons((uint16_t)port);
|
||||
addr.sll_ifindex = (int)gv.interfaceNo;
|
||||
addr.sll_pkttype = PACKET_HOST | PACKET_BROADCAST | PACKET_MULTICAST;
|
||||
if (bind(sock, (struct sockaddr *)&addr, sizeof(addr)) == -1)
|
||||
rc = ddsrt_bind(sock, (struct sockaddr *)&addr, sizeof(addr));
|
||||
if (rc != DDS_RETCODE_OK)
|
||||
{
|
||||
rc = os_getErrno();
|
||||
close(sock);
|
||||
DDS_ERROR("ddsi_raweth_create_conn %s bind port %u failed ... errno = %d\n", mcast ? "multicast" : "unicast", port, rc);
|
||||
ddsrt_close(sock);
|
||||
DDS_ERROR("ddsi_raweth_create_conn %s bind port %u failed ... retcode = %d\n", mcast ? "multicast" : "unicast", port, rc);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
uc = (ddsi_raweth_conn_t) os_malloc (sizeof (*uc));
|
||||
uc = (ddsi_raweth_conn_t) ddsrt_malloc (sizeof (*uc));
|
||||
memset (uc, 0, sizeof (*uc));
|
||||
uc->m_sock = sock;
|
||||
uc->m_ifindex = addr.sll_ifindex;
|
||||
|
@ -256,7 +250,7 @@ static int isbroadcast(const nn_locator_t *loc)
|
|||
return 1;
|
||||
}
|
||||
|
||||
static int joinleave_asm_mcgroup (os_socket socket, int join, const nn_locator_t *mcloc, const struct nn_interface *interf)
|
||||
static int joinleave_asm_mcgroup (ddsrt_socket_t socket, int join, const nn_locator_t *mcloc, const struct nn_interface *interf)
|
||||
{
|
||||
int rc;
|
||||
struct packet_mreq mreq;
|
||||
|
@ -264,8 +258,8 @@ static int joinleave_asm_mcgroup (os_socket socket, int join, const nn_locator_t
|
|||
mreq.mr_type = PACKET_MR_MULTICAST;
|
||||
mreq.mr_alen = 6;
|
||||
memcpy(mreq.mr_address, mcloc + 10, 6);
|
||||
rc = setsockopt(socket, SOL_PACKET, join ? PACKET_ADD_MEMBERSHIP : PACKET_DROP_MEMBERSHIP, &mreq, sizeof(mreq));
|
||||
return (rc == -1) ? os_getErrno() : 0;
|
||||
rc = ddsrt_setsockopt(socket, SOL_PACKET, join ? PACKET_ADD_MEMBERSHIP : PACKET_DROP_MEMBERSHIP, &mreq, sizeof(mreq));
|
||||
return (rc == DDS_RETCODE_OK) ? 0 : rc;
|
||||
}
|
||||
|
||||
static int ddsi_raweth_join_mc (ddsi_tran_conn_t conn, const nn_locator_t *srcloc, const nn_locator_t *mcloc, const struct nn_interface *interf)
|
||||
|
@ -302,8 +296,8 @@ static void ddsi_raweth_release_conn (ddsi_tran_conn_t conn)
|
|||
uc->m_sock,
|
||||
uc->m_base.m_base.m_port
|
||||
);
|
||||
os_sockFree (uc->m_sock);
|
||||
os_free (conn);
|
||||
ddsrt_close (uc->m_sock);
|
||||
ddsrt_free (conn);
|
||||
}
|
||||
|
||||
static int ddsi_raweth_is_mcaddr (const ddsi_tran_factory_t tran, const nn_locator_t *loc)
|
||||
|
@ -357,25 +351,25 @@ static enum ddsi_locator_from_string_result ddsi_raweth_address_from_string (dds
|
|||
|
||||
static void ddsi_raweth_deinit(void)
|
||||
{
|
||||
if (os_atomic_dec32_nv(&init_g) == 0) {
|
||||
if (ddsrt_atomic_dec32_nv(&init_g) == 0) {
|
||||
if (ddsi_raweth_config_g.mship)
|
||||
free_group_membership(ddsi_raweth_config_g.mship);
|
||||
DDS_LOG(DDS_LC_CONFIG, "raweth de-initialized\n");
|
||||
}
|
||||
}
|
||||
|
||||
static int ddsi_raweth_enumerate_interfaces (ddsi_tran_factory_t factory, os_ifaddrs_t **interfs)
|
||||
static int ddsi_raweth_enumerate_interfaces (ddsi_tran_factory_t factory, ddsrt_ifaddrs_t **interfs)
|
||||
{
|
||||
int afs[] = { AF_PACKET, OS_AF_NULL };
|
||||
int afs[] = { AF_PACKET, DDSRT_AF_TERM };
|
||||
|
||||
(void)factory;
|
||||
|
||||
return -os_getifaddrs(interfs, afs);
|
||||
return -ddsrt_getifaddrs(interfs, afs);
|
||||
}
|
||||
|
||||
int ddsi_raweth_init (void)
|
||||
{
|
||||
if (os_atomic_inc32_nv(&init_g) == 1) {
|
||||
if (ddsrt_atomic_inc32_nv(&init_g) == 1) {
|
||||
memset (&ddsi_raweth_factory_g, 0, sizeof (ddsi_raweth_factory_g));
|
||||
ddsi_raweth_factory_g.m_free_fn = ddsi_raweth_deinit;
|
||||
ddsi_raweth_factory_g.m_kind = NN_LOCATOR_KIND_RAWETH;
|
||||
|
|
|
@ -9,9 +9,9 @@
|
|||
*
|
||||
* SPDX-License-Identifier: EPL-2.0 OR BSD-3-Clause
|
||||
*/
|
||||
#include "ddsi/q_entity.h"
|
||||
#include "ddsi/q_xqos.h"
|
||||
#include "ddsi/ddsi_rhc_plugin.h"
|
||||
#include "dds/ddsi/q_entity.h"
|
||||
#include "dds/ddsi/q_xqos.h"
|
||||
#include "dds/ddsi/ddsi_rhc_plugin.h"
|
||||
|
||||
DDS_EXPORT void make_proxy_writer_info(struct proxy_writer_info *pwr_info, const struct entity_common *e, const struct nn_xqos *xqos)
|
||||
{
|
||||
|
|
|
@ -14,12 +14,11 @@
|
|||
#include <assert.h>
|
||||
#include <string.h>
|
||||
|
||||
#include "os/os.h"
|
||||
#include "ddsi/q_md5.h"
|
||||
#include "ddsi/q_bswap.h"
|
||||
#include "ddsi/q_config.h"
|
||||
#include "ddsi/q_freelist.h"
|
||||
#include "ddsi/ddsi_serdata.h"
|
||||
#include "dds/ddsi/q_md5.h"
|
||||
#include "dds/ddsi/q_bswap.h"
|
||||
#include "dds/ddsi/q_config.h"
|
||||
#include "dds/ddsi/q_freelist.h"
|
||||
#include "dds/ddsi/ddsi_serdata.h"
|
||||
|
||||
void ddsi_serdata_init (struct ddsi_serdata *d, const struct ddsi_sertopic *tp, enum ddsi_serdata_kind kind)
|
||||
{
|
||||
|
@ -30,7 +29,7 @@ void ddsi_serdata_init (struct ddsi_serdata *d, const struct ddsi_sertopic *tp,
|
|||
d->statusinfo = 0;
|
||||
d->timestamp.v = INT64_MIN;
|
||||
d->twrite.v = INT64_MIN;
|
||||
os_atomic_st32 (&d->refc, 1);
|
||||
ddsrt_atomic_st32 (&d->refc, 1);
|
||||
}
|
||||
|
||||
extern inline struct ddsi_serdata *ddsi_serdata_ref (const struct ddsi_serdata *serdata_const);
|
||||
|
@ -41,8 +40,8 @@ extern inline struct ddsi_serdata *ddsi_serdata_from_keyhash (const struct ddsi_
|
|||
extern inline struct ddsi_serdata *ddsi_serdata_from_sample (const struct ddsi_sertopic *topic, enum ddsi_serdata_kind kind, const void *sample);
|
||||
extern inline struct ddsi_serdata *ddsi_serdata_to_topicless (const struct ddsi_serdata *d);
|
||||
extern inline void ddsi_serdata_to_ser (const struct ddsi_serdata *d, size_t off, size_t sz, void *buf);
|
||||
extern inline struct ddsi_serdata *ddsi_serdata_to_ser_ref (const struct ddsi_serdata *d, size_t off, size_t sz, os_iovec_t *ref);
|
||||
extern inline void ddsi_serdata_to_ser_unref (struct ddsi_serdata *d, const os_iovec_t *ref);
|
||||
extern inline struct ddsi_serdata *ddsi_serdata_to_ser_ref (const struct ddsi_serdata *d, size_t off, size_t sz, ddsrt_iovec_t *ref);
|
||||
extern inline void ddsi_serdata_to_ser_unref (struct ddsi_serdata *d, const ddsrt_iovec_t *ref);
|
||||
extern inline bool ddsi_serdata_to_sample (const struct ddsi_serdata *d, void *sample, void **bufptr, void *buflim);
|
||||
extern inline bool ddsi_serdata_topicless_to_sample (const struct ddsi_sertopic *topic, const struct ddsi_serdata *d, void *sample, void **bufptr, void *buflim);
|
||||
extern inline bool ddsi_serdata_eqkey (const struct ddsi_serdata *a, const struct ddsi_serdata *b);
|
||||
|
|
|
@ -9,24 +9,22 @@
|
|||
*
|
||||
* SPDX-License-Identifier: EPL-2.0 OR BSD-3-Clause
|
||||
*/
|
||||
#include <stddef.h>
|
||||
#include <stdlib.h>
|
||||
#include <ctype.h>
|
||||
#include <assert.h>
|
||||
#include <string.h>
|
||||
|
||||
#include "os/os.h"
|
||||
#include "ddsi/q_md5.h"
|
||||
#include "ddsi/q_bswap.h"
|
||||
#include "ddsi/q_config.h"
|
||||
#include "ddsi/q_freelist.h"
|
||||
#include <assert.h>
|
||||
#include <string.h>
|
||||
#include "os/os.h"
|
||||
#include "dds/ddsrt/heap.h"
|
||||
#include "dds/ddsrt/log.h"
|
||||
#include "dds/ddsi/q_md5.h"
|
||||
#include "dds/ddsi/q_bswap.h"
|
||||
#include "dds/ddsi/q_config.h"
|
||||
#include "dds/ddsi/q_freelist.h"
|
||||
#include "dds__key.h"
|
||||
#include "ddsi/ddsi_tkmap.h"
|
||||
#include "dds/ddsi/ddsi_tkmap.h"
|
||||
#include "dds__stream.h"
|
||||
#include "ddsi/q_radmin.h"
|
||||
#include "ddsi/ddsi_serdata_default.h"
|
||||
#include "dds/ddsi/q_radmin.h"
|
||||
#include "dds/ddsi/ddsi_serdata_default.h"
|
||||
|
||||
#define MAX_POOL_SIZE 16384
|
||||
#define CLEAR_PADDING 0
|
||||
|
@ -43,7 +41,7 @@ static size_t alignup_size (size_t x, size_t a);
|
|||
struct serdatapool * ddsi_serdatapool_new (void)
|
||||
{
|
||||
struct serdatapool * pool;
|
||||
pool = os_malloc (sizeof (*pool));
|
||||
pool = ddsrt_malloc (sizeof (*pool));
|
||||
nn_freelist_init (&pool->freelist, MAX_POOL_SIZE, offsetof (struct ddsi_serdata_default, next));
|
||||
return pool;
|
||||
}
|
||||
|
@ -52,7 +50,7 @@ static void serdata_free_wrap (void *elem)
|
|||
{
|
||||
#ifndef NDEBUG
|
||||
struct ddsi_serdata_default *d = elem;
|
||||
assert(os_atomic_ld32(&d->c.refc) == 0);
|
||||
assert(ddsrt_atomic_ld32(&d->c.refc) == 0);
|
||||
#endif
|
||||
dds_free(elem);
|
||||
}
|
||||
|
@ -61,7 +59,7 @@ void ddsi_serdatapool_free (struct serdatapool * pool)
|
|||
{
|
||||
DDS_TRACE("ddsi_serdatapool_free(%p)\n", (void *) pool);
|
||||
nn_freelist_fini (&pool->freelist, serdata_free_wrap);
|
||||
os_free (pool);
|
||||
ddsrt_free (pool);
|
||||
}
|
||||
|
||||
static size_t alignup_size (size_t x, size_t a)
|
||||
|
@ -77,7 +75,7 @@ static void *serdata_default_append (struct ddsi_serdata_default **d, size_t n)
|
|||
if ((*d)->pos + n > (*d)->size)
|
||||
{
|
||||
size_t size1 = alignup_size ((*d)->pos + n, 128);
|
||||
*d = os_realloc (*d, offsetof (struct ddsi_serdata_default, data) + size1);
|
||||
*d = ddsrt_realloc (*d, offsetof (struct ddsi_serdata_default, data) + size1);
|
||||
(*d)->size = (uint32_t)size1;
|
||||
}
|
||||
assert ((*d)->pos + n <= (*d)->size);
|
||||
|
@ -205,7 +203,7 @@ static bool serdata_default_eqkey_nokey (const struct ddsi_serdata *acmn, const
|
|||
static void serdata_default_free(struct ddsi_serdata *dcmn)
|
||||
{
|
||||
struct ddsi_serdata_default *d = (struct ddsi_serdata_default *)dcmn;
|
||||
assert(os_atomic_ld32(&d->c.refc) == 0);
|
||||
assert(ddsrt_atomic_ld32(&d->c.refc) == 0);
|
||||
if (!nn_freelist_push (&gv.serpool->freelist, d))
|
||||
dds_free (d);
|
||||
}
|
||||
|
@ -227,7 +225,7 @@ static void serdata_default_init(struct ddsi_serdata_default *d, const struct dd
|
|||
static struct ddsi_serdata_default *serdata_default_allocnew(struct serdatapool *pool)
|
||||
{
|
||||
const uint32_t init_size = 128;
|
||||
struct ddsi_serdata_default *d = os_malloc(offsetof (struct ddsi_serdata_default, data) + init_size);
|
||||
struct ddsi_serdata_default *d = ddsrt_malloc(offsetof (struct ddsi_serdata_default, data) + init_size);
|
||||
d->size = init_size;
|
||||
d->pool = pool;
|
||||
return d;
|
||||
|
@ -239,7 +237,7 @@ static struct ddsi_serdata_default *serdata_default_new(const struct ddsi_sertop
|
|||
if ((d = nn_freelist_pop (&gv.serpool->freelist)) == NULL)
|
||||
d = serdata_default_allocnew(gv.serpool);
|
||||
else
|
||||
os_atomic_st32(&d->c.refc, 1);
|
||||
ddsrt_atomic_st32(&d->c.refc, 1);
|
||||
serdata_default_init(d, tp, kind);
|
||||
return d;
|
||||
}
|
||||
|
@ -478,17 +476,17 @@ static void serdata_default_to_ser (const struct ddsi_serdata *serdata_common, s
|
|||
memcpy (buf, (char *)&d->hdr + off, sz);
|
||||
}
|
||||
|
||||
static struct ddsi_serdata *serdata_default_to_ser_ref (const struct ddsi_serdata *serdata_common, size_t off, size_t sz, os_iovec_t *ref)
|
||||
static struct ddsi_serdata *serdata_default_to_ser_ref (const struct ddsi_serdata *serdata_common, size_t off, size_t sz, ddsrt_iovec_t *ref)
|
||||
{
|
||||
const struct ddsi_serdata_default *d = (const struct ddsi_serdata_default *)serdata_common;
|
||||
assert (off < d->pos + sizeof(struct CDRHeader));
|
||||
assert (sz <= alignup_size (d->pos + sizeof(struct CDRHeader), 4) - off);
|
||||
ref->iov_base = (char *)&d->hdr + off;
|
||||
ref->iov_len = (os_iov_len_t)sz;
|
||||
ref->iov_len = (ddsrt_iov_len_t)sz;
|
||||
return ddsi_serdata_ref(serdata_common);
|
||||
}
|
||||
|
||||
static void serdata_default_to_ser_unref (struct ddsi_serdata *serdata_common, const os_iovec_t *ref)
|
||||
static void serdata_default_to_ser_unref (struct ddsi_serdata *serdata_common, const ddsrt_iovec_t *ref)
|
||||
{
|
||||
(void)ref;
|
||||
ddsi_serdata_unref(serdata_common);
|
||||
|
|
|
@ -14,20 +14,20 @@
|
|||
#include <assert.h>
|
||||
#include <string.h>
|
||||
|
||||
#include "os/os.h"
|
||||
#include "ddsi/q_md5.h"
|
||||
#include "ddsi/q_bswap.h"
|
||||
#include "ddsi/q_config.h"
|
||||
#include "ddsi/q_freelist.h"
|
||||
#include "ddsi/ddsi_sertopic.h"
|
||||
#include "ddsi/ddsi_serdata.h"
|
||||
#include "ddsi/q_md5.h"
|
||||
#include "dds/ddsrt/heap.h"
|
||||
#include "dds/ddsi/q_md5.h"
|
||||
#include "dds/ddsi/q_bswap.h"
|
||||
#include "dds/ddsi/q_config.h"
|
||||
#include "dds/ddsi/q_freelist.h"
|
||||
#include "dds/ddsi/ddsi_sertopic.h"
|
||||
#include "dds/ddsi/ddsi_serdata.h"
|
||||
#include "dds/ddsi/q_md5.h"
|
||||
|
||||
struct ddsi_sertopic *ddsi_sertopic_ref (const struct ddsi_sertopic *sertopic_const)
|
||||
{
|
||||
struct ddsi_sertopic *sertopic = (struct ddsi_sertopic *)sertopic_const;
|
||||
if (sertopic)
|
||||
os_atomic_inc32 (&sertopic->refc);
|
||||
ddsrt_atomic_inc32 (&sertopic->refc);
|
||||
return sertopic;
|
||||
}
|
||||
|
||||
|
@ -35,13 +35,13 @@ void ddsi_sertopic_unref (struct ddsi_sertopic *sertopic)
|
|||
{
|
||||
if (sertopic)
|
||||
{
|
||||
if (os_atomic_dec32_ov (&sertopic->refc) == 1)
|
||||
if (ddsrt_atomic_dec32_ov (&sertopic->refc) == 1)
|
||||
{
|
||||
ddsi_sertopic_deinit (sertopic);
|
||||
os_free (sertopic->name_typename);
|
||||
os_free (sertopic->name);
|
||||
os_free (sertopic->typename);
|
||||
os_free (sertopic);
|
||||
ddsrt_free (sertopic->name_typename);
|
||||
ddsrt_free (sertopic->name);
|
||||
ddsrt_free (sertopic->typename);
|
||||
ddsrt_free (sertopic);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -14,13 +14,12 @@
|
|||
#include <assert.h>
|
||||
#include <string.h>
|
||||
|
||||
#include "os/os.h"
|
||||
#include "ddsi/q_md5.h"
|
||||
#include "ddsi/q_bswap.h"
|
||||
#include "ddsi/q_config.h"
|
||||
#include "ddsi/q_freelist.h"
|
||||
#include "ddsi/ddsi_sertopic.h"
|
||||
#include "ddsi/ddsi_serdata_default.h"
|
||||
#include "dds/ddsi/q_md5.h"
|
||||
#include "dds/ddsi/q_bswap.h"
|
||||
#include "dds/ddsi/q_config.h"
|
||||
#include "dds/ddsi/q_freelist.h"
|
||||
#include "dds/ddsi/ddsi_sertopic.h"
|
||||
#include "dds/ddsi/ddsi_serdata_default.h"
|
||||
|
||||
/* FIXME: sertopic /= ddstopic so a lot of stuff needs to be moved here from dds_topic.c and the free function needs to be implemented properly */
|
||||
|
||||
|
|
|
@ -9,11 +9,10 @@
|
|||
*
|
||||
* SPDX-License-Identifier: EPL-2.0 OR BSD-3-Clause
|
||||
*/
|
||||
#include "os/os.h"
|
||||
#include "ddsi/ddsi_tcp.h"
|
||||
#include "ddsi/ddsi_ssl.h"
|
||||
#include "ddsi/q_config.h"
|
||||
#include "ddsi/q_log.h"
|
||||
#include "dds/ddsi/ddsi_tcp.h"
|
||||
#include "dds/ddsi/ddsi_ssl.h"
|
||||
#include "dds/ddsi/q_config.h"
|
||||
#include "dds/ddsrt/log.h"
|
||||
|
||||
#ifdef DDSI_INCLUDE_SSL
|
||||
|
||||
|
@ -24,6 +23,11 @@
|
|||
#include <openssl/err.h>
|
||||
#include <openssl/opensslconf.h>
|
||||
|
||||
#include "dds/ddsrt/heap.h"
|
||||
#include "dds/ddsrt/sockets.h"
|
||||
#include "dds/ddsrt/sync.h"
|
||||
#include "dds/ddsrt/threads.h"
|
||||
|
||||
static SSL_CTX *ddsi_ssl_ctx = NULL;
|
||||
|
||||
static SSL *ddsi_ssl_new (void)
|
||||
|
@ -58,64 +62,80 @@ static int ddsi_ssl_verify (int ok, X509_STORE_CTX *store)
|
|||
return ok;
|
||||
}
|
||||
|
||||
static ssize_t ddsi_ssl_read (SSL *ssl, void *buf, size_t len, int *err)
|
||||
static ssize_t ddsi_ssl_read (SSL *ssl, void *buf, size_t len, dds_retcode_t *rc)
|
||||
{
|
||||
assert (len <= INT32_MAX);
|
||||
if (SSL_get_shutdown (ssl) != 0)
|
||||
{
|
||||
*rc = DDS_RETCODE_ERROR;
|
||||
return -1;
|
||||
}
|
||||
|
||||
/* Returns -1 on error or 0 on shutdown */
|
||||
const int ret = SSL_read (ssl, buf, (int) len);
|
||||
switch (SSL_get_error (ssl, ret))
|
||||
int rcvd = SSL_read (ssl, buf, (int) len);
|
||||
switch (SSL_get_error (ssl, rcvd))
|
||||
{
|
||||
case SSL_ERROR_NONE:
|
||||
return ret;
|
||||
*rc = DDS_RETCODE_OK;
|
||||
break;
|
||||
case SSL_ERROR_WANT_READ:
|
||||
case SSL_ERROR_WANT_WRITE:
|
||||
*err = os_sockEAGAIN;
|
||||
return -1;
|
||||
*rc = DDS_RETCODE_TRY_AGAIN;
|
||||
rcvd = -1;
|
||||
break;
|
||||
case SSL_ERROR_ZERO_RETURN:
|
||||
default:
|
||||
/* Connection closed or error */
|
||||
*err = os_getErrno ();
|
||||
return -1;
|
||||
*rc = DDS_RETCODE_ERROR;
|
||||
rcvd = -1;
|
||||
break;
|
||||
}
|
||||
|
||||
return rcvd;
|
||||
}
|
||||
|
||||
static ssize_t ddsi_ssl_write (SSL *ssl, const void *buf, size_t len, int *err)
|
||||
static ssize_t ddsi_ssl_write (SSL *ssl, const void *buf, size_t len, dds_retcode_t *rc)
|
||||
{
|
||||
assert(len <= INT32_MAX);
|
||||
|
||||
if (SSL_get_shutdown (ssl) != 0)
|
||||
{
|
||||
*rc = DDS_RETCODE_ERROR;
|
||||
return -1;
|
||||
}
|
||||
|
||||
/* Returns -1 on error or 0 on shutdown */
|
||||
const int ret = SSL_write (ssl, buf, (int) len);
|
||||
switch (SSL_get_error (ssl, ret))
|
||||
int sent = SSL_write (ssl, buf, (int) len);
|
||||
switch (SSL_get_error (ssl, sent))
|
||||
{
|
||||
case SSL_ERROR_NONE:
|
||||
return ret;
|
||||
*rc = DDS_RETCODE_OK;
|
||||
break;
|
||||
case SSL_ERROR_WANT_READ:
|
||||
case SSL_ERROR_WANT_WRITE:
|
||||
*err = os_sockEAGAIN;
|
||||
return -1;
|
||||
*rc = DDS_RETCODE_TRY_AGAIN;
|
||||
sent = -1;
|
||||
break;
|
||||
case SSL_ERROR_ZERO_RETURN:
|
||||
default:
|
||||
/* Connection closed or error */
|
||||
*err = os_getErrno ();
|
||||
return -1;
|
||||
*rc = DDS_RETCODE_ERROR;
|
||||
sent = -1;
|
||||
break;
|
||||
}
|
||||
|
||||
return sent;
|
||||
}
|
||||
|
||||
/* Standard OpenSSL init and thread support routines. See O'Reilly. */
|
||||
#if OPENSSL_VERSION_NUMBER < 0x10100000L
|
||||
static unsigned long ddsi_ssl_id (void)
|
||||
{
|
||||
return (unsigned long) os_threadIdToInteger (os_threadIdSelf ());
|
||||
return (unsigned long) ddsrt_gettid ();
|
||||
}
|
||||
|
||||
typedef struct CRYPTO_dynlock_value {
|
||||
os_mutex m_mutex;
|
||||
ddsrt_mutex_t m_mutex;
|
||||
} CRYPTO_dynlock_value;
|
||||
|
||||
static CRYPTO_dynlock_value *ddsi_ssl_locks = NULL;
|
||||
|
@ -125,9 +145,9 @@ static void ddsi_ssl_dynlock_lock (int mode, CRYPTO_dynlock_value *lock, const c
|
|||
(void) file;
|
||||
(void) line;
|
||||
if (mode & CRYPTO_LOCK)
|
||||
os_mutexLock (&lock->m_mutex);
|
||||
ddsrt_mutex_lock (&lock->m_mutex);
|
||||
else
|
||||
os_mutexUnlock (&lock->m_mutex);
|
||||
ddsrt_mutex_unlock (&lock->m_mutex);
|
||||
}
|
||||
|
||||
static void ddsi_ssl_lock (int mode, int n, const char *file, int line)
|
||||
|
@ -139,8 +159,8 @@ static CRYPTO_dynlock_value *ddsi_ssl_dynlock_create (const char *file, int line
|
|||
{
|
||||
(void) file;
|
||||
(void) line;
|
||||
CRYPTO_dynlock_value *val = os_malloc (sizeof (*val));
|
||||
os_mutexInit (&val->m_mutex);
|
||||
CRYPTO_dynlock_value *val = ddsrt_malloc (sizeof (*val));
|
||||
ddsrt_mutex_init (&val->m_mutex);
|
||||
return val;
|
||||
}
|
||||
|
||||
|
@ -148,8 +168,8 @@ static void ddsi_ssl_dynlock_destroy (CRYPTO_dynlock_value *lock, const char *fi
|
|||
{
|
||||
(void) file;
|
||||
(void) line;
|
||||
os_mutexDestroy (&lock->m_mutex);
|
||||
os_free (lock);
|
||||
ddsrt_mutex_destroy (&lock->m_mutex);
|
||||
ddsrt_free (lock);
|
||||
}
|
||||
#endif
|
||||
|
||||
|
@ -159,9 +179,9 @@ static int ddsi_ssl_password (char *buf, int num, int rwflag, void *udata)
|
|||
(void) udata;
|
||||
if (num < 0 || (size_t) num < strlen (config.ssl_key_pass) + 1)
|
||||
return 0;
|
||||
OS_WARNING_MSVC_OFF(4996);
|
||||
DDSRT_WARNING_MSVC_OFF(4996);
|
||||
strcpy (buf, config.ssl_key_pass);
|
||||
OS_WARNING_MSVC_ON(4996);
|
||||
DDSRT_WARNING_MSVC_ON(4996);
|
||||
return (int) strlen (config.ssl_key_pass);
|
||||
}
|
||||
|
||||
|
@ -265,7 +285,7 @@ static void dds_report_tls_version (const SSL *ssl, const char *oper)
|
|||
}
|
||||
}
|
||||
|
||||
static SSL *ddsi_ssl_connect (os_socket sock)
|
||||
static SSL *ddsi_ssl_connect (ddsrt_socket_t sock)
|
||||
{
|
||||
SSL *ssl;
|
||||
int err;
|
||||
|
@ -275,9 +295,9 @@ static SSL *ddsi_ssl_connect (os_socket sock)
|
|||
safe to do so, and moreover, that it will remain safe to do so, given Microsoft's track
|
||||
record of maintaining backwards compatibility. The SSL API is in the wrong of course ... */
|
||||
ssl = ddsi_ssl_new ();
|
||||
OS_WARNING_MSVC_OFF(4244);
|
||||
DDSRT_WARNING_MSVC_OFF(4244);
|
||||
SSL_set_fd (ssl, sock);
|
||||
OS_WARNING_MSVC_ON(4244);
|
||||
DDSRT_WARNING_MSVC_ON(4244);
|
||||
err = SSL_connect (ssl);
|
||||
if (err != 1)
|
||||
{
|
||||
|
@ -289,17 +309,17 @@ static SSL *ddsi_ssl_connect (os_socket sock)
|
|||
return ssl;
|
||||
}
|
||||
|
||||
static BIO *ddsi_ssl_listen (os_socket sock)
|
||||
static BIO *ddsi_ssl_listen (ddsrt_socket_t sock)
|
||||
{
|
||||
/* See comment in ddsi_ssl_connect concerning casting the socket to an int */
|
||||
BIO * bio = BIO_new (BIO_s_accept ());
|
||||
OS_WARNING_MSVC_OFF(4244);
|
||||
DDSRT_WARNING_MSVC_OFF(4244);
|
||||
BIO_set_fd (bio, sock, BIO_NOCLOSE);
|
||||
OS_WARNING_MSVC_ON(4244);
|
||||
DDSRT_WARNING_MSVC_ON(4244);
|
||||
return bio;
|
||||
}
|
||||
|
||||
static SSL *ddsi_ssl_accept (BIO *bio, os_socket *sock)
|
||||
static SSL *ddsi_ssl_accept (BIO *bio, ddsrt_socket_t *sock)
|
||||
{
|
||||
SSL *ssl = NULL;
|
||||
BIO *nbio;
|
||||
|
@ -308,14 +328,14 @@ static SSL *ddsi_ssl_accept (BIO *bio, os_socket *sock)
|
|||
if (BIO_do_accept (bio) > 0)
|
||||
{
|
||||
nbio = BIO_pop (bio);
|
||||
*sock = (os_socket) BIO_get_fd (nbio, NULL);
|
||||
*sock = (ddsrt_socket_t) BIO_get_fd (nbio, NULL);
|
||||
ssl = ddsi_ssl_new ();
|
||||
SSL_set_bio (ssl, nbio, nbio);
|
||||
err = SSL_accept (ssl);
|
||||
if (err <= 0)
|
||||
{
|
||||
SSL_free (ssl);
|
||||
*sock = OS_INVALID_SOCKET;
|
||||
*sock = DDSRT_INVALID_SOCKET;
|
||||
ssl = NULL;
|
||||
}
|
||||
}
|
||||
|
@ -334,9 +354,9 @@ static bool ddsi_ssl_init (void)
|
|||
{
|
||||
const int locks = CRYPTO_num_locks ();
|
||||
assert (locks >= 0);
|
||||
ddsi_ssl_locks = os_malloc (sizeof (CRYPTO_dynlock_value) * (size_t) locks);
|
||||
ddsi_ssl_locks = ddsrt_malloc (sizeof (CRYPTO_dynlock_value) * (size_t) locks);
|
||||
for (int i = 0; i < locks; i++)
|
||||
os_mutexInit (&ddsi_ssl_locks[i].m_mutex);
|
||||
ddsrt_mutex_init (&ddsi_ssl_locks[i].m_mutex);
|
||||
}
|
||||
#endif
|
||||
/* Leave these in place: OpenSSL 1.1 defines them as no-op macros that not even reference the symbol,
|
||||
|
@ -367,8 +387,8 @@ static void ddsi_ssl_fini (void)
|
|||
{
|
||||
const int locks = CRYPTO_num_locks ();
|
||||
for (int i = 0; i < locks; i++)
|
||||
os_mutexDestroy (&ddsi_ssl_locks[i].m_mutex);
|
||||
os_free (ddsi_ssl_locks);
|
||||
ddsrt_mutex_destroy (&ddsi_ssl_locks[i].m_mutex);
|
||||
ddsrt_free (ddsi_ssl_locks);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
|
|
@ -13,21 +13,23 @@
|
|||
#include <assert.h>
|
||||
#include <string.h>
|
||||
|
||||
#include "dds/ddsrt/heap.h"
|
||||
#include "dds/ddsrt/log.h"
|
||||
#include "dds/ddsrt/sockets.h"
|
||||
#include "ddsi_eth.h"
|
||||
#include "ddsi/ddsi_tran.h"
|
||||
#include "ddsi/ddsi_tcp.h"
|
||||
#include "ddsi/ddsi_ipaddr.h"
|
||||
#include "util/ut_avl.h"
|
||||
#include "ddsi/q_nwif.h"
|
||||
#include "ddsi/q_config.h"
|
||||
#include "ddsi/q_log.h"
|
||||
#include "ddsi/q_entity.h"
|
||||
#include "os/os.h"
|
||||
#include "dds/ddsi/ddsi_tran.h"
|
||||
#include "dds/ddsi/ddsi_tcp.h"
|
||||
#include "dds/ddsi/ddsi_ipaddr.h"
|
||||
#include "dds/util/ut_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"
|
||||
|
||||
#define INVALID_PORT (~0u)
|
||||
|
||||
typedef struct ddsi_tran_factory * ddsi_tcp_factory_g_t;
|
||||
static os_atomic_uint32_t ddsi_tcp_init_g = OS_ATOMIC_UINT32_INIT(0);
|
||||
static ddsrt_atomic_uint32_t ddsi_tcp_init_g = DDSRT_ATOMIC_UINT32_INIT(0);
|
||||
|
||||
#ifdef DDSI_INCLUDE_SSL
|
||||
static struct ddsi_ssl_plugins ddsi_tcp_ssl_plugin;
|
||||
|
@ -49,10 +51,10 @@ static const char * ddsi_name = "tcp";
|
|||
typedef struct ddsi_tcp_conn
|
||||
{
|
||||
struct ddsi_tran_conn m_base;
|
||||
os_sockaddr_storage m_peer_addr;
|
||||
struct sockaddr_storage m_peer_addr;
|
||||
uint32_t m_peer_port;
|
||||
os_mutex m_mutex;
|
||||
os_socket m_sock;
|
||||
ddsrt_mutex_t m_mutex;
|
||||
ddsrt_socket_t m_sock;
|
||||
#ifdef DDSI_INCLUDE_SSL
|
||||
SSL * m_ssl;
|
||||
#endif
|
||||
|
@ -62,7 +64,7 @@ typedef struct ddsi_tcp_conn
|
|||
typedef struct ddsi_tcp_listener
|
||||
{
|
||||
struct ddsi_tran_listener m_base;
|
||||
os_socket m_sock;
|
||||
ddsrt_socket_t m_sock;
|
||||
#ifdef DDSI_INCLUDE_SSL
|
||||
BIO * m_bio;
|
||||
#endif
|
||||
|
@ -75,8 +77,8 @@ static struct ddsi_tcp_conn ddsi_tcp_conn_client;
|
|||
|
||||
static int ddsi_tcp_cmp_conn (const struct ddsi_tcp_conn *c1, const struct ddsi_tcp_conn *c2)
|
||||
{
|
||||
const os_sockaddr *a1s = (os_sockaddr *)&c1->m_peer_addr;
|
||||
const os_sockaddr *a2s = (os_sockaddr *)&c2->m_peer_addr;
|
||||
const struct sockaddr *a1s = (struct sockaddr *)&c1->m_peer_addr;
|
||||
const struct sockaddr *a2s = (struct sockaddr *)&c2->m_peer_addr;
|
||||
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)
|
||||
|
@ -104,13 +106,13 @@ static const ut_avlTreedef_t ddsi_tcp_treedef = UT_AVL_TREEDEF_INITIALIZER_INDKE
|
|||
0
|
||||
);
|
||||
|
||||
static os_mutex ddsi_tcp_cache_lock_g;
|
||||
static ddsrt_mutex_t ddsi_tcp_cache_lock_g;
|
||||
static ut_avlTree_t ddsi_tcp_cache_g;
|
||||
static struct ddsi_tran_factory ddsi_tcp_factory_g;
|
||||
|
||||
static ddsi_tcp_conn_t ddsi_tcp_new_conn (os_socket, bool, os_sockaddr *);
|
||||
static ddsi_tcp_conn_t ddsi_tcp_new_conn (ddsrt_socket_t, bool, struct sockaddr *);
|
||||
|
||||
static char *sockaddr_to_string_with_port (char *dst, size_t sizeof_dst, const os_sockaddr *src)
|
||||
static char *sockaddr_to_string_with_port (char *dst, size_t sizeof_dst, const struct sockaddr *src)
|
||||
{
|
||||
nn_locator_t loc;
|
||||
ddsi_ipaddr_to_loc(&loc, src, src->sa_family == AF_INET ? NN_LOCATOR_KIND_TCPv4 : NN_LOCATOR_KIND_TCPv6);
|
||||
|
@ -143,42 +145,43 @@ static void ddsi_tcp_cache_dump (void)
|
|||
}
|
||||
*/
|
||||
|
||||
static unsigned short get_socket_port (os_socket socket)
|
||||
static unsigned short get_socket_port (ddsrt_socket_t socket)
|
||||
{
|
||||
os_sockaddr_storage addr;
|
||||
struct sockaddr_storage addr;
|
||||
socklen_t addrlen = sizeof (addr);
|
||||
if (getsockname (socket, (os_sockaddr *) &addr, &addrlen) < 0)
|
||||
{
|
||||
int err = os_getErrno();
|
||||
DDS_ERROR("ddsi_tcp_get_socket_port: getsockname errno %d\n", err);
|
||||
dds_retcode_t ret;
|
||||
|
||||
ret = ddsrt_getsockname(socket, (struct sockaddr *)&addr, &addrlen);
|
||||
if (ret != DDS_RETCODE_OK) {
|
||||
DDS_ERROR("ddsi_tcp_get_socket_port: ddsrt_getsockname retcode %d\n", ret);
|
||||
return 0;
|
||||
}
|
||||
return os_sockaddr_get_port((os_sockaddr *)&addr);
|
||||
return ddsrt_sockaddr_get_port((struct sockaddr *)&addr);
|
||||
}
|
||||
|
||||
static void ddsi_tcp_conn_set_socket (ddsi_tcp_conn_t conn, os_socket sock)
|
||||
static void ddsi_tcp_conn_set_socket (ddsi_tcp_conn_t conn, ddsrt_socket_t sock)
|
||||
{
|
||||
conn->m_sock = sock;
|
||||
conn->m_base.m_base.m_port = (sock == OS_INVALID_SOCKET) ? INVALID_PORT : get_socket_port (sock);
|
||||
conn->m_base.m_base.m_port = (sock == DDSRT_INVALID_SOCKET) ? INVALID_PORT : get_socket_port (sock);
|
||||
}
|
||||
|
||||
static void ddsi_tcp_sock_free (os_socket sock, const char * msg)
|
||||
static void ddsi_tcp_sock_free (ddsrt_socket_t sock, const char * msg)
|
||||
{
|
||||
if (sock != OS_INVALID_SOCKET)
|
||||
if (sock != DDSRT_INVALID_SOCKET)
|
||||
{
|
||||
if (msg)
|
||||
{
|
||||
DDS_LOG(DDS_LC_TCP, "%s %s free socket %"PRIsock"\n", ddsi_name, msg, sock);
|
||||
DDS_LOG(DDS_LC_TCP, "%s %s free socket %"PRIdSOCK"\n", ddsi_name, msg, sock);
|
||||
}
|
||||
os_sockFree (sock);
|
||||
ddsrt_close (sock);
|
||||
}
|
||||
}
|
||||
|
||||
static void ddsi_tcp_sock_new (os_socket * sock, unsigned short port)
|
||||
static void ddsi_tcp_sock_new (ddsrt_socket_t * sock, unsigned short port)
|
||||
{
|
||||
if (make_socket (sock, port, true, true) != 0)
|
||||
{
|
||||
*sock = OS_INVALID_SOCKET;
|
||||
*sock = DDSRT_INVALID_SOCKET;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -186,27 +189,27 @@ static void ddsi_tcp_node_free (void * ptr)
|
|||
{
|
||||
ddsi_tcp_node_t node = (ddsi_tcp_node_t) ptr;
|
||||
ddsi_conn_free ((ddsi_tran_conn_t) node->m_conn);
|
||||
os_free (node);
|
||||
ddsrt_free (node);
|
||||
}
|
||||
|
||||
static void ddsi_tcp_conn_connect (ddsi_tcp_conn_t conn, const struct msghdr * msg)
|
||||
static void ddsi_tcp_conn_connect (ddsi_tcp_conn_t conn, const ddsrt_msghdr_t * msg)
|
||||
{
|
||||
int ret;
|
||||
char buff[DDSI_LOCSTRLEN];
|
||||
os_socket sock;
|
||||
ddsrt_socket_t sock;
|
||||
dds_retcode_t ret;
|
||||
|
||||
ddsi_tcp_sock_new (&sock, 0);
|
||||
if (sock != OS_INVALID_SOCKET)
|
||||
if (sock != DDSRT_INVALID_SOCKET)
|
||||
{
|
||||
/* Attempt to connect, expected that may fail */
|
||||
|
||||
do
|
||||
{
|
||||
ret = connect (sock, msg->msg_name, msg->msg_namelen);
|
||||
ret = ddsrt_connect(sock, msg->msg_name, msg->msg_namelen);
|
||||
}
|
||||
while ((ret == -1) && (os_getErrno() == os_sockEINTR));
|
||||
while (ret == DDS_RETCODE_INTERRUPTED);
|
||||
|
||||
if (ret != 0)
|
||||
if (ret != DDS_RETCODE_OK)
|
||||
{
|
||||
ddsi_tcp_sock_free (sock, NULL);
|
||||
return;
|
||||
|
@ -219,18 +222,18 @@ static void ddsi_tcp_conn_connect (ddsi_tcp_conn_t conn, const struct msghdr * m
|
|||
conn->m_ssl = (ddsi_tcp_ssl_plugin.connect) (sock);
|
||||
if (conn->m_ssl == NULL)
|
||||
{
|
||||
ddsi_tcp_conn_set_socket (conn, OS_INVALID_SOCKET);
|
||||
ddsi_tcp_conn_set_socket (conn, DDSRT_INVALID_SOCKET);
|
||||
return;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
sockaddr_to_string_with_port(buff, sizeof(buff), (os_sockaddr *) msg->msg_name);
|
||||
DDS_LOG(DDS_LC_TCP, "%s connect socket %"PRIsock" port %u to %s\n", ddsi_name, sock, get_socket_port (sock), buff);
|
||||
sockaddr_to_string_with_port(buff, sizeof(buff), (struct sockaddr *) msg->msg_name);
|
||||
DDS_LOG(DDS_LC_TCP, "%s connect socket %"PRIdSOCK" port %u to %s\n", ddsi_name, sock, get_socket_port (sock), buff);
|
||||
|
||||
/* Also may need to receive on connection so add to waitset */
|
||||
|
||||
os_sockSetNonBlocking (conn->m_sock, true);
|
||||
(void)ddsrt_setsocknonblocking(conn->m_sock, true);
|
||||
|
||||
assert (gv.n_recv_threads > 0);
|
||||
assert (gv.recv_threads[0].arg.mode == RTM_MANY);
|
||||
|
@ -245,12 +248,12 @@ static void ddsi_tcp_cache_add (ddsi_tcp_conn_t conn, ut_avlIPath_t * path)
|
|||
ddsi_tcp_node_t node;
|
||||
char buff[DDSI_LOCSTRLEN];
|
||||
|
||||
os_atomic_inc32 (&conn->m_base.m_count);
|
||||
ddsrt_atomic_inc32 (&conn->m_base.m_count);
|
||||
|
||||
/* If path set, then cache does not contain connection */
|
||||
if (path)
|
||||
{
|
||||
node = os_malloc (sizeof (*node));
|
||||
node = ddsrt_malloc (sizeof (*node));
|
||||
node->m_conn = conn;
|
||||
ut_avlInsertIPath (&ddsi_tcp_treedef, &ddsi_tcp_cache_g, node, path);
|
||||
}
|
||||
|
@ -267,14 +270,14 @@ static void ddsi_tcp_cache_add (ddsi_tcp_conn_t conn, ut_avlIPath_t * path)
|
|||
}
|
||||
else
|
||||
{
|
||||
node = os_malloc (sizeof (*node));
|
||||
node = ddsrt_malloc (sizeof (*node));
|
||||
node->m_conn = conn;
|
||||
ut_avlInsert (&ddsi_tcp_treedef, &ddsi_tcp_cache_g, node);
|
||||
}
|
||||
}
|
||||
|
||||
sockaddr_to_string_with_port(buff, sizeof(buff), (os_sockaddr *)&conn->m_peer_addr);
|
||||
DDS_LOG(DDS_LC_TCP, "%s cache %s %s socket %"PRIsock" to %s\n", ddsi_name, action, conn->m_base.m_server ? "server" : "client", conn->m_sock, buff);
|
||||
sockaddr_to_string_with_port(buff, sizeof(buff), (struct sockaddr *)&conn->m_peer_addr);
|
||||
DDS_LOG(DDS_LC_TCP, "%s cache %s %s socket %"PRIdSOCK" to %s\n", ddsi_name, action, conn->m_base.m_server ? "server" : "client", conn->m_sock, buff);
|
||||
}
|
||||
|
||||
static void ddsi_tcp_cache_remove (ddsi_tcp_conn_t conn)
|
||||
|
@ -283,16 +286,16 @@ static void ddsi_tcp_cache_remove (ddsi_tcp_conn_t conn)
|
|||
ddsi_tcp_node_t node;
|
||||
ut_avlDPath_t path;
|
||||
|
||||
os_mutexLock (&ddsi_tcp_cache_lock_g);
|
||||
ddsrt_mutex_lock (&ddsi_tcp_cache_lock_g);
|
||||
node = ut_avlLookupDPath (&ddsi_tcp_treedef, &ddsi_tcp_cache_g, conn, &path);
|
||||
if (node)
|
||||
{
|
||||
sockaddr_to_string_with_port(buff, sizeof(buff), (os_sockaddr *)&conn->m_peer_addr);
|
||||
DDS_LOG(DDS_LC_TCP, "%s cache removed socket %"PRIsock" to %s\n", ddsi_name, conn->m_sock, buff);
|
||||
sockaddr_to_string_with_port(buff, sizeof(buff), (struct sockaddr *)&conn->m_peer_addr);
|
||||
DDS_LOG(DDS_LC_TCP, "%s cache removed socket %"PRIdSOCK" to %s\n", ddsi_name, conn->m_sock, buff);
|
||||
ut_avlDeleteDPath (&ddsi_tcp_treedef, &ddsi_tcp_cache_g, node, &path);
|
||||
ddsi_tcp_node_free (node);
|
||||
}
|
||||
os_mutexUnlock (&ddsi_tcp_cache_lock_g);
|
||||
ddsrt_mutex_unlock (&ddsi_tcp_cache_lock_g);
|
||||
}
|
||||
|
||||
/*
|
||||
|
@ -300,7 +303,7 @@ static void ddsi_tcp_cache_remove (ddsi_tcp_conn_t conn)
|
|||
create new connection.
|
||||
*/
|
||||
|
||||
static ddsi_tcp_conn_t ddsi_tcp_cache_find (const struct msghdr * msg)
|
||||
static ddsi_tcp_conn_t ddsi_tcp_cache_find (const ddsrt_msghdr_t * msg)
|
||||
{
|
||||
ut_avlIPath_t path;
|
||||
ddsi_tcp_node_t node;
|
||||
|
@ -308,12 +311,12 @@ static ddsi_tcp_conn_t ddsi_tcp_cache_find (const struct msghdr * msg)
|
|||
ddsi_tcp_conn_t ret = NULL;
|
||||
|
||||
memset (&key, 0, sizeof (key));
|
||||
key.m_peer_port = os_sockaddr_get_port (msg->msg_name);
|
||||
key.m_peer_port = ddsrt_sockaddr_get_port (msg->msg_name);
|
||||
memcpy (&key.m_peer_addr, msg->msg_name, msg->msg_namelen);
|
||||
|
||||
/* Check cache for existing connection to target */
|
||||
|
||||
os_mutexLock (&ddsi_tcp_cache_lock_g);
|
||||
ddsrt_mutex_lock (&ddsi_tcp_cache_lock_g);
|
||||
node = ut_avlLookupIPath (&ddsi_tcp_treedef, &ddsi_tcp_cache_g, &key, &path);
|
||||
if (node)
|
||||
{
|
||||
|
@ -329,52 +332,49 @@ static ddsi_tcp_conn_t ddsi_tcp_cache_find (const struct msghdr * msg)
|
|||
}
|
||||
if (ret == NULL)
|
||||
{
|
||||
ret = ddsi_tcp_new_conn (OS_INVALID_SOCKET, false, (os_sockaddr *)&key.m_peer_addr);
|
||||
ret = ddsi_tcp_new_conn (DDSRT_INVALID_SOCKET, false, (struct sockaddr *)&key.m_peer_addr);
|
||||
ddsi_tcp_cache_add (ret, &path);
|
||||
}
|
||||
os_mutexUnlock (&ddsi_tcp_cache_lock_g);
|
||||
ddsrt_mutex_unlock (&ddsi_tcp_cache_lock_g);
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
static ssize_t ddsi_tcp_conn_read_plain (ddsi_tcp_conn_t tcp, void * buf, size_t len, int * err)
|
||||
static ssize_t ddsi_tcp_conn_read_plain (ddsi_tcp_conn_t tcp, void * buf, size_t len, dds_retcode_t *rc)
|
||||
{
|
||||
OS_WARNING_MSVC_OFF(4267);
|
||||
ssize_t ret = recv (tcp->m_sock, buf, len, 0);
|
||||
*err = (ret == -1) ? os_getErrno () : 0;
|
||||
return ret;
|
||||
OS_WARNING_MSVC_ON(4267);
|
||||
ssize_t rcvd = -1;
|
||||
|
||||
assert(rc != NULL);
|
||||
*rc = ddsrt_recv(tcp->m_sock, buf, len, 0, &rcvd);
|
||||
|
||||
return (*rc == DDS_RETCODE_OK ? rcvd : -1);
|
||||
}
|
||||
|
||||
#ifdef DDSI_INCLUDE_SSL
|
||||
static ssize_t ddsi_tcp_conn_read_ssl (ddsi_tcp_conn_t tcp, void * buf, size_t len, int * err)
|
||||
static ssize_t ddsi_tcp_conn_read_ssl (ddsi_tcp_conn_t tcp, void * buf, size_t len, dds_retcode_t *rc)
|
||||
{
|
||||
return (ddsi_tcp_ssl_plugin.read) (tcp->m_ssl, buf, len, err);
|
||||
return (ddsi_tcp_ssl_plugin.read) (tcp->m_ssl, buf, len, rc);
|
||||
}
|
||||
#endif
|
||||
|
||||
static bool ddsi_tcp_select (os_socket sock, bool read, size_t pos)
|
||||
static bool ddsi_tcp_select (ddsrt_socket_t sock, bool read, size_t pos)
|
||||
{
|
||||
int ret;
|
||||
dds_retcode_t rc;
|
||||
fd_set fds;
|
||||
os_time timeout;
|
||||
fd_set * rdset = read ? &fds : NULL;
|
||||
fd_set * wrset = read ? NULL : &fds;
|
||||
int64_t tval = read ? config.tcp_read_timeout : config.tcp_write_timeout;
|
||||
int32_t ready = 0;
|
||||
|
||||
FD_ZERO (&fds);
|
||||
FD_SET (sock, &fds);
|
||||
timeout.tv_sec = (int) (tval / T_SECOND);
|
||||
timeout.tv_nsec = (int) (tval % T_SECOND);
|
||||
|
||||
DDS_LOG(DDS_LC_TCP, "%s blocked %s: sock %d\n", ddsi_name, read ? "read" : "write", (int) sock);
|
||||
do
|
||||
{
|
||||
ret = os_sockSelect ((int32_t)sock + 1, rdset, wrset, NULL, &timeout); /* The variable "sock" with os_socket type causes the possible loss of data. So type casting done */
|
||||
}
|
||||
while (ret == -1 && os_getErrno () == os_sockEINTR);
|
||||
do {
|
||||
rc = ddsrt_select (sock + 1, rdset, wrset, NULL, tval, &ready);
|
||||
} while (rc == DDS_RETCODE_INTERRUPTED);
|
||||
|
||||
if (ret <= 0)
|
||||
if (rc != DDS_RETCODE_OK)
|
||||
{
|
||||
DDS_WARNING
|
||||
(
|
||||
|
@ -383,25 +383,16 @@ static bool ddsi_tcp_select (os_socket sock, bool read, size_t pos)
|
|||
);
|
||||
}
|
||||
|
||||
return (ret > 0);
|
||||
}
|
||||
|
||||
static int err_is_AGAIN_or_WOULDBLOCK (int err)
|
||||
{
|
||||
if (err == os_sockEAGAIN)
|
||||
return 1;
|
||||
if (err == os_sockEWOULDBLOCK)
|
||||
return 1;
|
||||
return 0;
|
||||
return (ready > 0);
|
||||
}
|
||||
|
||||
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)
|
||||
{
|
||||
dds_retcode_t rc;
|
||||
ddsi_tcp_conn_t tcp = (ddsi_tcp_conn_t) conn;
|
||||
ssize_t (*rd) (ddsi_tcp_conn_t, void *, size_t, int * err) = ddsi_tcp_conn_read_plain;
|
||||
size_t pos = 0;
|
||||
ssize_t n;
|
||||
int err;
|
||||
|
||||
#ifdef DDSI_INCLUDE_SSL
|
||||
if (ddsi_tcp_ssl_plugin.read)
|
||||
|
@ -412,7 +403,7 @@ static ssize_t ddsi_tcp_conn_read (ddsi_tran_conn_t conn, unsigned char * buf, s
|
|||
|
||||
while (true)
|
||||
{
|
||||
n = rd (tcp, (char *) buf + pos, len - pos, &err);
|
||||
n = rd (tcp, (char *) buf + pos, len - pos, &rc);
|
||||
if (n > 0)
|
||||
{
|
||||
pos += (size_t) n;
|
||||
|
@ -420,21 +411,21 @@ static ssize_t ddsi_tcp_conn_read (ddsi_tran_conn_t conn, unsigned char * buf, s
|
|||
{
|
||||
if (srcloc)
|
||||
{
|
||||
ddsi_ipaddr_to_loc(srcloc, (os_sockaddr *)&tcp->m_peer_addr, tcp->m_peer_addr.ss_family == AF_INET ? NN_LOCATOR_KIND_TCPv4 : NN_LOCATOR_KIND_TCPv6);
|
||||
ddsi_ipaddr_to_loc(srcloc, (struct sockaddr *)&tcp->m_peer_addr, tcp->m_peer_addr.ss_family == AF_INET ? NN_LOCATOR_KIND_TCPv4 : NN_LOCATOR_KIND_TCPv6);
|
||||
}
|
||||
return (ssize_t) pos;
|
||||
}
|
||||
}
|
||||
else if (n == 0)
|
||||
{
|
||||
DDS_LOG(DDS_LC_TCP, "%s read: sock %"PRIsock" closed-by-peer\n", ddsi_name, tcp->m_sock);
|
||||
DDS_LOG(DDS_LC_TCP, "%s read: sock %"PRIdSOCK" closed-by-peer\n", ddsi_name, tcp->m_sock);
|
||||
break;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (err != os_sockEINTR)
|
||||
if (rc != DDS_RETCODE_INTERRUPTED)
|
||||
{
|
||||
if (err_is_AGAIN_or_WOULDBLOCK (err))
|
||||
if (rc == DDS_RETCODE_TRY_AGAIN)
|
||||
{
|
||||
if (allow_spurious && pos == 0)
|
||||
return 0;
|
||||
|
@ -443,7 +434,7 @@ static ssize_t ddsi_tcp_conn_read (ddsi_tran_conn_t conn, unsigned char * buf, s
|
|||
}
|
||||
else
|
||||
{
|
||||
DDS_LOG(DDS_LC_TCP, "%s read: sock %"PRIsock" error %d\n", ddsi_name, tcp->m_sock, err);
|
||||
DDS_LOG(DDS_LC_TCP, "%s read: sock %"PRIdSOCK" error %d\n", ddsi_name, tcp->m_sock, rc);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
@ -454,25 +445,23 @@ static ssize_t ddsi_tcp_conn_read (ddsi_tran_conn_t conn, unsigned char * buf, s
|
|||
return -1;
|
||||
}
|
||||
|
||||
static ssize_t ddsi_tcp_conn_write_plain (ddsi_tcp_conn_t conn, const void * buf, size_t len, int * err)
|
||||
static ssize_t ddsi_tcp_conn_write_plain (ddsi_tcp_conn_t conn, const void * buf, size_t len, dds_retcode_t *rc)
|
||||
{
|
||||
ssize_t ret;
|
||||
ssize_t sent = -1;
|
||||
int sendflags = 0;
|
||||
|
||||
#ifdef MSG_NOSIGNAL
|
||||
sendflags |= MSG_NOSIGNAL;
|
||||
#endif
|
||||
OS_WARNING_MSVC_OFF(4267);
|
||||
ret = send (conn->m_sock, buf, len, sendflags);
|
||||
*err = (ret == -1) ? os_getErrno () : 0;
|
||||
return ret;
|
||||
OS_WARNING_MSVC_ON(4267);
|
||||
*rc = ddsrt_send(conn->m_sock, buf, len, sendflags, &sent);
|
||||
|
||||
return (*rc == DDS_RETCODE_OK ? sent : -1);
|
||||
}
|
||||
|
||||
#ifdef DDSI_INCLUDE_SSL
|
||||
static ssize_t ddsi_tcp_conn_write_ssl (ddsi_tcp_conn_t conn, const void * buf, size_t len, int * err)
|
||||
static ssize_t ddsi_tcp_conn_write_ssl (ddsi_tcp_conn_t conn, const void * buf, size_t len, dds_retcode_t *rc)
|
||||
{
|
||||
return (ddsi_tcp_ssl_plugin.write) (conn->m_ssl, buf, len, err);
|
||||
return (ddsi_tcp_ssl_plugin.write) (conn->m_ssl, buf, len, rc);
|
||||
}
|
||||
#endif
|
||||
|
||||
|
@ -486,23 +475,22 @@ static ssize_t ddsi_tcp_block_write
|
|||
{
|
||||
/* Write all bytes of buf even in the presence of signals,
|
||||
partial writes and blocking (typically write buffer full) */
|
||||
|
||||
dds_retcode_t rc;
|
||||
size_t pos = 0;
|
||||
ssize_t n;
|
||||
int err;
|
||||
ssize_t n = -1;
|
||||
|
||||
while (pos != sz)
|
||||
{
|
||||
n = (wr) (conn, (const char *) buf + pos, sz - pos, &err);
|
||||
n = (wr) (conn, (const char *) buf + pos, sz - pos, &rc);
|
||||
if (n > 0)
|
||||
{
|
||||
pos += (size_t) n;
|
||||
}
|
||||
else if (n == -1)
|
||||
{
|
||||
if (err != os_sockEINTR)
|
||||
if (rc != DDS_RETCODE_INTERRUPTED)
|
||||
{
|
||||
if (err_is_AGAIN_or_WOULDBLOCK (err))
|
||||
if (rc == DDS_RETCODE_TRY_AGAIN)
|
||||
{
|
||||
if (ddsi_tcp_select (conn->m_sock, false, pos) == false)
|
||||
{
|
||||
|
@ -511,7 +499,7 @@ static ssize_t ddsi_tcp_block_write
|
|||
}
|
||||
else
|
||||
{
|
||||
DDS_LOG(DDS_LC_TCP, "%s write: sock %"PRIsock" error %d\n", ddsi_name, conn->m_sock, err);
|
||||
DDS_LOG(DDS_LC_TCP, "%s write: sock %"PRIdSOCK" error %d\n", ddsi_name, conn->m_sock, rc);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
@ -521,7 +509,7 @@ static ssize_t ddsi_tcp_block_write
|
|||
return (pos == sz) ? (ssize_t) pos : -1;
|
||||
}
|
||||
|
||||
static size_t iovlen_sum (size_t niov, const os_iovec_t *iov)
|
||||
static size_t iovlen_sum (size_t niov, const ddsrt_iovec_t *iov)
|
||||
{
|
||||
size_t tot = 0;
|
||||
while (niov--) {
|
||||
|
@ -530,32 +518,32 @@ static size_t iovlen_sum (size_t niov, const os_iovec_t *iov)
|
|||
return tot;
|
||||
}
|
||||
|
||||
static void set_msghdr_iov (struct msghdr *mhdr, os_iovec_t *iov, size_t iovlen)
|
||||
static void set_msghdr_iov (ddsrt_msghdr_t *mhdr, ddsrt_iovec_t *iov, size_t iovlen)
|
||||
{
|
||||
mhdr->msg_iov = iov;
|
||||
mhdr->msg_iovlen = (os_msg_iovlen_t)iovlen;
|
||||
mhdr->msg_iovlen = (ddsrt_msg_iovlen_t)iovlen;
|
||||
}
|
||||
|
||||
static ssize_t ddsi_tcp_conn_write (ddsi_tran_conn_t base, const nn_locator_t *dst, size_t niov, const os_iovec_t *iov, uint32_t flags)
|
||||
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)
|
||||
{
|
||||
#ifdef DDSI_INCLUDE_SSL
|
||||
char msgbuf[4096]; /* stack buffer for merging smallish writes without requiring allocations */
|
||||
os_iovec_t iovec; /* iovec used for msgbuf */
|
||||
ddsrt_iovec_t iovec; /* iovec used for msgbuf */
|
||||
#endif
|
||||
ssize_t ret;
|
||||
size_t len;
|
||||
ddsi_tcp_conn_t conn;
|
||||
int piecewise;
|
||||
bool connect = false;
|
||||
struct msghdr msg;
|
||||
os_sockaddr_storage dstaddr;
|
||||
ddsrt_msghdr_t msg;
|
||||
struct sockaddr_storage dstaddr;
|
||||
assert(niov <= INT_MAX);
|
||||
ddsi_ipaddr_from_loc(&dstaddr, dst);
|
||||
memset(&msg, 0, sizeof(msg));
|
||||
set_msghdr_iov (&msg, (os_iovec_t *) iov, niov);
|
||||
set_msghdr_iov (&msg, (ddsrt_iovec_t *) iov, niov);
|
||||
msg.msg_name = &dstaddr;
|
||||
msg.msg_namelen = (socklen_t) os_sockaddr_get_size((os_sockaddr *) &dstaddr);
|
||||
#if OS_MSGHDR_FLAGS
|
||||
msg.msg_namelen = (socklen_t) ddsrt_sockaddr_get_size((struct sockaddr *) &dstaddr);
|
||||
#if DDSRT_MSGHDR_FLAGS
|
||||
msg.msg_flags = (int) flags;
|
||||
#endif
|
||||
len = iovlen_sum (niov, iov);
|
||||
|
@ -567,16 +555,16 @@ static ssize_t ddsi_tcp_conn_write (ddsi_tran_conn_t base, const nn_locator_t *d
|
|||
return -1;
|
||||
}
|
||||
|
||||
os_mutexLock (&conn->m_mutex);
|
||||
ddsrt_mutex_lock (&conn->m_mutex);
|
||||
|
||||
/* If not connected attempt to conect */
|
||||
|
||||
if ((conn->m_sock == OS_INVALID_SOCKET) && ! conn->m_base.m_server)
|
||||
if ((conn->m_sock == DDSRT_INVALID_SOCKET) && ! conn->m_base.m_server)
|
||||
{
|
||||
ddsi_tcp_conn_connect (conn, &msg);
|
||||
if (conn->m_sock == OS_INVALID_SOCKET)
|
||||
if (conn->m_sock == DDSRT_INVALID_SOCKET)
|
||||
{
|
||||
os_mutexUnlock (&conn->m_mutex);
|
||||
ddsrt_mutex_unlock (&conn->m_mutex);
|
||||
return -1;
|
||||
}
|
||||
connect = true;
|
||||
|
@ -586,8 +574,8 @@ 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_LOG(DDS_LC_TCP, "%s write: sock %"PRIsock" message filtered\n", ddsi_name, conn->m_sock);
|
||||
os_mutexUnlock (&conn->m_mutex);
|
||||
DDS_LOG(DDS_LC_TCP, "%s write: sock %"PRIdSOCK" message filtered\n", ddsi_name, conn->m_sock);
|
||||
ddsrt_mutex_unlock (&conn->m_mutex);
|
||||
return (ssize_t) len;
|
||||
}
|
||||
|
||||
|
@ -602,8 +590,8 @@ static ssize_t ddsi_tcp_conn_write (ddsi_tran_conn_t base, const nn_locator_t *d
|
|||
{
|
||||
int i;
|
||||
char * ptr;
|
||||
iovec.iov_len = (os_iov_len_t) len;
|
||||
iovec.iov_base = (len <= sizeof (msgbuf)) ? msgbuf : os_malloc (len);
|
||||
iovec.iov_len = (ddsrt_iov_len_t) len;
|
||||
iovec.iov_base = (len <= sizeof (msgbuf)) ? msgbuf : ddsrt_malloc (len);
|
||||
ptr = iovec.iov_base;
|
||||
for (i = 0; i < (int) msg.msg_iovlen; i++)
|
||||
{
|
||||
|
@ -620,7 +608,7 @@ static ssize_t ddsi_tcp_conn_write (ddsi_tran_conn_t base, const nn_locator_t *d
|
|||
#endif
|
||||
{
|
||||
int sendflags = 0;
|
||||
int err;
|
||||
dds_retcode_t rc;
|
||||
#ifdef MSG_NOSIGNAL
|
||||
sendflags |= MSG_NOSIGNAL;
|
||||
#endif
|
||||
|
@ -628,13 +616,12 @@ static ssize_t ddsi_tcp_conn_write (ddsi_tran_conn_t base, const nn_locator_t *d
|
|||
msg.msg_namelen = 0;
|
||||
do
|
||||
{
|
||||
ret = sendmsg (conn->m_sock, &msg, sendflags);
|
||||
err = (ret == -1) ? os_getErrno () : 0;
|
||||
rc = ddsrt_sendmsg (conn->m_sock, &msg, sendflags, &ret);
|
||||
}
|
||||
while ((ret == -1) && (err == os_sockEINTR));
|
||||
while (rc == DDS_RETCODE_INTERRUPTED);
|
||||
if (ret == -1)
|
||||
{
|
||||
if (err_is_AGAIN_or_WOULDBLOCK (err))
|
||||
if (rc == DDS_RETCODE_TRY_AGAIN)
|
||||
{
|
||||
piecewise = 1;
|
||||
ret = 0;
|
||||
|
@ -642,17 +629,15 @@ static ssize_t ddsi_tcp_conn_write (ddsi_tran_conn_t base, const nn_locator_t *d
|
|||
else
|
||||
{
|
||||
piecewise = 0;
|
||||
switch (err)
|
||||
switch (rc)
|
||||
{
|
||||
case os_sockECONNRESET:
|
||||
#ifdef os_sockEPIPE
|
||||
case os_sockEPIPE:
|
||||
#endif
|
||||
DDS_LOG(DDS_LC_TCP, "%s write: sock %"PRIsock" ECONNRESET\n", ddsi_name, conn->m_sock);
|
||||
case DDS_RETCODE_NO_CONNECTION:
|
||||
case DDS_RETCODE_ILLEGAL_OPERATION:
|
||||
DDS_LOG(DDS_LC_TCP, "%s write: sock %"PRIdSOCK" DDS_RETCODE_NO_CONNECTION\n", ddsi_name, conn->m_sock);
|
||||
break;
|
||||
default:
|
||||
if (! conn->m_base.m_closed && (conn->m_sock != OS_INVALID_SOCKET))
|
||||
DDS_WARNING("%s write failed on socket %"PRIsock" with errno %d\n", ddsi_name, conn->m_sock, err);
|
||||
if (! conn->m_base.m_closed && (conn->m_sock != DDSRT_INVALID_SOCKET))
|
||||
DDS_WARNING("%s write failed on socket %"PRIdSOCK" with errno %d\n", ddsi_name, conn->m_sock, rc);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
@ -661,7 +646,7 @@ static ssize_t ddsi_tcp_conn_write (ddsi_tran_conn_t base, const nn_locator_t *d
|
|||
{
|
||||
if (ret == 0)
|
||||
{
|
||||
DDS_LOG(DDS_LC_TCP, "%s write: sock %"PRIsock" eof\n", ddsi_name, conn->m_sock);
|
||||
DDS_LOG(DDS_LC_TCP, "%s write: sock %"PRIdSOCK" eof\n", ddsi_name, conn->m_sock);
|
||||
}
|
||||
piecewise = (ret > 0 && (size_t) ret < len);
|
||||
}
|
||||
|
@ -695,11 +680,11 @@ static ssize_t ddsi_tcp_conn_write (ddsi_tran_conn_t base, const nn_locator_t *d
|
|||
/* If allocated memory for merging original fragments into a single buffer, free it */
|
||||
if (msg.msg_iov == &iovec && iovec.iov_base != msgbuf)
|
||||
{
|
||||
os_free (iovec.iov_base);
|
||||
ddsrt_free (iovec.iov_base);
|
||||
}
|
||||
#endif
|
||||
|
||||
os_mutexUnlock (&conn->m_mutex);
|
||||
ddsrt_mutex_unlock (&conn->m_mutex);
|
||||
|
||||
if (ret == -1)
|
||||
{
|
||||
|
@ -709,7 +694,7 @@ static ssize_t ddsi_tcp_conn_write (ddsi_tran_conn_t base, const nn_locator_t *d
|
|||
return ((size_t) ret == len) ? ret : -1;
|
||||
}
|
||||
|
||||
static os_socket ddsi_tcp_conn_handle (ddsi_tran_base_t base)
|
||||
static ddsrt_socket_t ddsi_tcp_conn_handle (ddsi_tran_base_t base)
|
||||
{
|
||||
return ((ddsi_tcp_conn_t) base)->m_sock;
|
||||
}
|
||||
|
@ -753,55 +738,56 @@ static ddsi_tran_conn_t ddsi_tcp_accept (ddsi_tran_listener_t listener)
|
|||
{
|
||||
ddsi_tcp_listener_t tl = (ddsi_tcp_listener_t) listener;
|
||||
ddsi_tcp_conn_t tcp = NULL;
|
||||
os_socket sock = OS_INVALID_SOCKET;
|
||||
os_sockaddr_storage addr;
|
||||
ddsrt_socket_t sock = DDSRT_INVALID_SOCKET;
|
||||
struct sockaddr_storage addr;
|
||||
socklen_t addrlen = sizeof (addr);
|
||||
char buff[DDSI_LOCSTRLEN];
|
||||
int err = 0;
|
||||
dds_retcode_t rc = DDS_RETCODE_OK;
|
||||
#ifdef DDSI_INCLUDE_SSL
|
||||
SSL * ssl = NULL;
|
||||
#endif
|
||||
|
||||
memset (&addr, 0, addrlen);
|
||||
do
|
||||
{
|
||||
do {
|
||||
#ifdef DDSI_INCLUDE_SSL
|
||||
if (ddsi_tcp_ssl_plugin.accept)
|
||||
{
|
||||
ssl = (ddsi_tcp_ssl_plugin.accept) (tl->m_bio, &sock);
|
||||
if (ssl == NULL) {
|
||||
assert(sock == DDSRT_INVALID_SOCKET);
|
||||
rc = DDS_RETCODE_ERROR;
|
||||
}
|
||||
}
|
||||
else
|
||||
#endif
|
||||
{
|
||||
sock = accept (tl->m_sock, NULL, NULL);
|
||||
rc = ddsrt_accept(tl->m_sock, NULL, NULL, &sock);
|
||||
}
|
||||
if (! gv.rtps_keepgoing)
|
||||
{
|
||||
ddsi_tcp_sock_free (sock, NULL);
|
||||
return NULL;
|
||||
}
|
||||
err = (sock == OS_INVALID_SOCKET) ? os_getErrno () : 0;
|
||||
}
|
||||
while ((err == os_sockEINTR) || (err == os_sockEAGAIN) || (err == os_sockEWOULDBLOCK));
|
||||
} while (rc == DDS_RETCODE_INTERRUPTED || rc == DDS_RETCODE_TRY_AGAIN);
|
||||
|
||||
if (sock == OS_INVALID_SOCKET)
|
||||
if (sock == DDSRT_INVALID_SOCKET)
|
||||
{
|
||||
getsockname (tl->m_sock, (struct sockaddr *) &addr, &addrlen);
|
||||
sockaddr_to_string_with_port(buff, sizeof(buff), (os_sockaddr *)&addr);
|
||||
DDS_LOG((err == 0) ? DDS_LC_ERROR : DDS_LC_FATAL, "%s accept failed on socket %"PRIsock" at %s errno %d\n", ddsi_name, tl->m_sock, buff, err);
|
||||
(void)ddsrt_getsockname (tl->m_sock, (struct sockaddr *) &addr, &addrlen);
|
||||
sockaddr_to_string_with_port(buff, sizeof(buff), (struct sockaddr *)&addr);
|
||||
DDS_LOG((rc == DDS_RETCODE_OK) ? DDS_LC_ERROR : DDS_LC_FATAL, "%s accept failed on socket %"PRIdSOCK" at %s retcode %d\n", ddsi_name, tl->m_sock, buff, rc);
|
||||
}
|
||||
else if (getpeername (sock, (struct sockaddr *) &addr, &addrlen) == -1)
|
||||
{
|
||||
DDS_WARNING("%s accepted new socket %"PRIsock" on socket %"PRIsock" but no peer address, errno %d\n", ddsi_name, sock, tl->m_sock, os_getErrno());
|
||||
os_sockFree (sock);
|
||||
DDS_WARNING("%s accepted new socket %"PRIdSOCK" on socket %"PRIdSOCK" but no peer address, errno %d\n", ddsi_name, sock, tl->m_sock, rc);
|
||||
ddsrt_close (sock);
|
||||
}
|
||||
else
|
||||
{
|
||||
sockaddr_to_string_with_port(buff, sizeof(buff), (os_sockaddr *)&addr);
|
||||
DDS_LOG(DDS_LC_TCP, "%s accept new socket %"PRIsock" on socket %"PRIsock" from %s\n", ddsi_name, sock, tl->m_sock, buff);
|
||||
sockaddr_to_string_with_port(buff, sizeof(buff), (struct sockaddr *)&addr);
|
||||
DDS_LOG(DDS_LC_TCP, "%s accept new socket %"PRIdSOCK" on socket %"PRIdSOCK" from %s\n", ddsi_name, sock, tl->m_sock, buff);
|
||||
|
||||
os_sockSetNonBlocking (sock, true);
|
||||
tcp = ddsi_tcp_new_conn (sock, true, (os_sockaddr *)&addr);
|
||||
(void)ddsrt_setsocknonblocking (sock, true);
|
||||
tcp = ddsi_tcp_new_conn (sock, true, (struct sockaddr *)&addr);
|
||||
#ifdef DDSI_INCLUDE_SSL
|
||||
tcp->m_ssl = ssl;
|
||||
#endif
|
||||
|
@ -811,14 +797,14 @@ static ddsi_tran_conn_t ddsi_tcp_accept (ddsi_tran_listener_t listener)
|
|||
|
||||
/* Add connection to cache for bi-dir */
|
||||
|
||||
os_mutexLock (&ddsi_tcp_cache_lock_g);
|
||||
ddsrt_mutex_lock (&ddsi_tcp_cache_lock_g);
|
||||
ddsi_tcp_cache_add (tcp, NULL);
|
||||
os_mutexUnlock (&ddsi_tcp_cache_lock_g);
|
||||
ddsrt_mutex_unlock (&ddsi_tcp_cache_lock_g);
|
||||
}
|
||||
return tcp ? &tcp->m_base : NULL;
|
||||
}
|
||||
|
||||
static os_socket ddsi_tcp_listener_handle (ddsi_tran_base_t base)
|
||||
static ddsrt_socket_t ddsi_tcp_listener_handle (ddsi_tran_base_t base)
|
||||
{
|
||||
return ((ddsi_tcp_listener_t) base)->m_sock;
|
||||
}
|
||||
|
@ -833,8 +819,8 @@ static void ddsi_tcp_conn_peer_locator (ddsi_tran_conn_t conn, nn_locator_t * lo
|
|||
{
|
||||
char buff[DDSI_LOCSTRLEN];
|
||||
ddsi_tcp_conn_t tc = (ddsi_tcp_conn_t) conn;
|
||||
assert (tc->m_sock != OS_INVALID_SOCKET);
|
||||
ddsi_ipaddr_to_loc (loc, (os_sockaddr *)&tc->m_peer_addr, tc->m_peer_addr.ss_family == AF_INET ? NN_LOCATOR_KIND_TCPv4 : NN_LOCATOR_KIND_TCPv6);
|
||||
assert (tc->m_sock != DDSRT_INVALID_SOCKET);
|
||||
ddsi_ipaddr_to_loc (loc, (struct sockaddr *)&tc->m_peer_addr, tc->m_peer_addr.ss_family == AF_INET ? NN_LOCATOR_KIND_TCPv4 : NN_LOCATOR_KIND_TCPv6);
|
||||
ddsi_locator_to_string(buff, sizeof(buff), loc);
|
||||
DDS_LOG(DDS_LC_TCP, "(%s EP:%s)", ddsi_name, buff);
|
||||
}
|
||||
|
@ -851,16 +837,16 @@ static void ddsi_tcp_base_init (struct ddsi_tran_conn * base)
|
|||
base->m_disable_multiplexing_fn = 0;
|
||||
}
|
||||
|
||||
static ddsi_tcp_conn_t ddsi_tcp_new_conn (os_socket sock, bool server, os_sockaddr * peer)
|
||||
static ddsi_tcp_conn_t ddsi_tcp_new_conn (ddsrt_socket_t sock, bool server, struct sockaddr * peer)
|
||||
{
|
||||
ddsi_tcp_conn_t conn = (ddsi_tcp_conn_t) os_malloc (sizeof (*conn));
|
||||
ddsi_tcp_conn_t conn = (ddsi_tcp_conn_t) ddsrt_malloc (sizeof (*conn));
|
||||
|
||||
memset (conn, 0, sizeof (*conn));
|
||||
ddsi_tcp_base_init (&conn->m_base);
|
||||
os_mutexInit (&conn->m_mutex);
|
||||
conn->m_sock = OS_INVALID_SOCKET;
|
||||
(void)memcpy(&conn->m_peer_addr, peer, os_sockaddr_get_size(peer));
|
||||
conn->m_peer_port = os_sockaddr_get_port (peer);
|
||||
ddsrt_mutex_init (&conn->m_mutex);
|
||||
conn->m_sock = DDSRT_INVALID_SOCKET;
|
||||
(void)memcpy(&conn->m_peer_addr, peer, ddsrt_sockaddr_get_size(peer));
|
||||
conn->m_peer_port = ddsrt_sockaddr_get_port (peer);
|
||||
conn->m_base.m_server = server;
|
||||
conn->m_base.m_base.m_port = INVALID_PORT;
|
||||
ddsi_tcp_conn_set_socket (conn, sock);
|
||||
|
@ -871,8 +857,8 @@ static ddsi_tcp_conn_t ddsi_tcp_new_conn (os_socket sock, bool server, os_sockad
|
|||
static ddsi_tran_listener_t ddsi_tcp_create_listener (int port, ddsi_tran_qos_t qos)
|
||||
{
|
||||
char buff[DDSI_LOCSTRLEN];
|
||||
os_socket sock;
|
||||
os_sockaddr_storage addr;
|
||||
ddsrt_socket_t sock;
|
||||
struct sockaddr_storage addr;
|
||||
socklen_t addrlen = sizeof (addr);
|
||||
ddsi_tcp_listener_t tl = NULL;
|
||||
|
||||
|
@ -880,9 +866,10 @@ static ddsi_tran_listener_t ddsi_tcp_create_listener (int port, ddsi_tran_qos_t
|
|||
|
||||
ddsi_tcp_sock_new (&sock, (unsigned short) port);
|
||||
|
||||
if (sock != OS_INVALID_SOCKET)
|
||||
if (sock != DDSRT_INVALID_SOCKET)
|
||||
{
|
||||
tl = (ddsi_tcp_listener_t) os_malloc (sizeof (*tl));
|
||||
dds_retcode_t ret;
|
||||
tl = (ddsi_tcp_listener_t) ddsrt_malloc (sizeof (*tl));
|
||||
memset (tl, 0, sizeof (*tl));
|
||||
|
||||
tl->m_sock = sock;
|
||||
|
@ -896,17 +883,16 @@ static ddsi_tran_listener_t ddsi_tcp_create_listener (int port, ddsi_tran_qos_t
|
|||
tl->m_base.m_base.m_handle_fn = ddsi_tcp_listener_handle;
|
||||
tl->m_base.m_base.m_locator_fn = ddsi_tcp_locator;
|
||||
|
||||
if (getsockname (sock, (os_sockaddr *) &addr, &addrlen) == -1)
|
||||
{
|
||||
int err = os_getErrno ();
|
||||
DDS_ERROR("ddsi_tcp_create_listener: getsockname errno %d\n", err);
|
||||
ddsi_tcp_sock_free (sock, NULL);
|
||||
os_free (tl);
|
||||
return NULL;
|
||||
ret = ddsrt_getsockname(sock, (struct sockaddr *)&addr, &addrlen);
|
||||
if (ret != DDS_RETCODE_OK) {
|
||||
DDS_ERROR("ddsi_tcp_create_listener: ddsrt_getsockname returned %d\n", ret);
|
||||
ddsi_tcp_sock_free(sock, NULL);
|
||||
ddsrt_free(tl);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
sockaddr_to_string_with_port(buff, sizeof(buff), (os_sockaddr *)&addr);
|
||||
DDS_LOG(DDS_LC_TCP, "%s create listener socket %"PRIsock" on %s\n", ddsi_name, sock, buff);
|
||||
sockaddr_to_string_with_port(buff, sizeof(buff), (struct sockaddr *)&addr);
|
||||
DDS_LOG(DDS_LC_TCP, "%s create listener socket %"PRIdSOCK" on %s\n", ddsi_name, sock, buff);
|
||||
}
|
||||
|
||||
return tl ? &tl->m_base : NULL;
|
||||
|
@ -915,8 +901,8 @@ static ddsi_tran_listener_t ddsi_tcp_create_listener (int port, ddsi_tran_qos_t
|
|||
static void ddsi_tcp_conn_delete (ddsi_tcp_conn_t conn)
|
||||
{
|
||||
char buff[DDSI_LOCSTRLEN];
|
||||
sockaddr_to_string_with_port(buff, sizeof(buff), (os_sockaddr *)&conn->m_peer_addr);
|
||||
DDS_LOG(DDS_LC_TCP, "%s free %s connnection on socket %"PRIsock" to %s\n", ddsi_name, conn->m_base.m_server ? "server" : "client", conn->m_sock, buff);
|
||||
sockaddr_to_string_with_port(buff, sizeof(buff), (struct sockaddr *)&conn->m_peer_addr);
|
||||
DDS_LOG(DDS_LC_TCP, "%s free %s connnection on socket %"PRIdSOCK" to %s\n", ddsi_name, conn->m_base.m_server ? "server" : "client", conn->m_sock, buff);
|
||||
|
||||
#ifdef DDSI_INCLUDE_SSL
|
||||
if (ddsi_tcp_ssl_plugin.ssl_free)
|
||||
|
@ -928,8 +914,8 @@ static void ddsi_tcp_conn_delete (ddsi_tcp_conn_t conn)
|
|||
{
|
||||
ddsi_tcp_sock_free (conn->m_sock, "connection");
|
||||
}
|
||||
os_mutexDestroy (&conn->m_mutex);
|
||||
os_free (conn);
|
||||
ddsrt_mutex_destroy (&conn->m_mutex);
|
||||
ddsrt_free (conn);
|
||||
}
|
||||
|
||||
static void ddsi_tcp_close_conn (ddsi_tran_conn_t tc)
|
||||
|
@ -939,10 +925,10 @@ static void ddsi_tcp_close_conn (ddsi_tran_conn_t tc)
|
|||
char buff[DDSI_LOCSTRLEN];
|
||||
nn_locator_t loc;
|
||||
ddsi_tcp_conn_t conn = (ddsi_tcp_conn_t) tc;
|
||||
sockaddr_to_string_with_port(buff, sizeof(buff), (os_sockaddr *)&conn->m_peer_addr);
|
||||
DDS_LOG(DDS_LC_TCP, "%s close %s connnection on socket %"PRIsock" to %s\n", ddsi_name, conn->m_base.m_server ? "server" : "client", conn->m_sock, buff);
|
||||
sockaddr_to_string_with_port(buff, sizeof(buff), (struct sockaddr *)&conn->m_peer_addr);
|
||||
DDS_LOG(DDS_LC_TCP, "%s close %s connnection on socket %"PRIdSOCK" to %s\n", ddsi_name, conn->m_base.m_server ? "server" : "client", conn->m_sock, buff);
|
||||
(void) shutdown (conn->m_sock, 2);
|
||||
ddsi_ipaddr_to_loc(&loc, (os_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(&loc, (struct sockaddr *)&conn->m_peer_addr, conn->m_peer_addr.ss_family == AF_INET ? NN_LOCATOR_KIND_TCPv4 : NN_LOCATOR_KIND_TCPv6);
|
||||
loc.port = conn->m_peer_port;
|
||||
purge_proxy_participants (&loc, conn->m_base.m_server);
|
||||
}
|
||||
|
@ -959,34 +945,35 @@ static void ddsi_tcp_release_conn (ddsi_tran_conn_t conn)
|
|||
static void ddsi_tcp_unblock_listener (ddsi_tran_listener_t listener)
|
||||
{
|
||||
ddsi_tcp_listener_t tl = (ddsi_tcp_listener_t) listener;
|
||||
os_socket sock;
|
||||
int ret;
|
||||
ddsrt_socket_t sock;
|
||||
dds_retcode_t ret;
|
||||
|
||||
/* Connect to own listener socket to wake listener from blocking 'accept()' */
|
||||
ddsi_tcp_sock_new (&sock, 0);
|
||||
if (sock != OS_INVALID_SOCKET)
|
||||
if (sock != DDSRT_INVALID_SOCKET)
|
||||
{
|
||||
os_sockaddr_storage addr;
|
||||
struct sockaddr_storage addr;
|
||||
socklen_t addrlen = sizeof (addr);
|
||||
if (getsockname (tl->m_sock, (os_sockaddr *) &addr, &addrlen) == -1)
|
||||
DDS_WARNING("%s failed to get listener address error %d\n", ddsi_name, os_getErrno());
|
||||
else
|
||||
{
|
||||
|
||||
ret = ddsrt_getsockname(tl->m_sock, (struct sockaddr *)&addr, &addrlen);
|
||||
if (ret != DDS_RETCODE_OK) {
|
||||
DDS_WARNING("%s failed to get listener address error %d\n", ddsi_name, ret);
|
||||
} else {
|
||||
switch (addr.ss_family) {
|
||||
case AF_INET:
|
||||
{
|
||||
os_sockaddr_in *socketname = (os_sockaddr_in*)&addr;
|
||||
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 OS_SOCKET_HAS_IPV6
|
||||
#if DDSRT_HAVE_IPV6
|
||||
case AF_INET6:
|
||||
{
|
||||
os_sockaddr_in6 *socketname = (os_sockaddr_in6*)&addr;
|
||||
if (memcmp(&socketname->sin6_addr, &os_in6addr_any, sizeof(socketname->sin6_addr)) == 0) {
|
||||
socketname->sin6_addr = os_in6addr_loopback;
|
||||
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;
|
||||
|
@ -994,14 +981,13 @@ static void ddsi_tcp_unblock_listener (ddsi_tran_listener_t listener)
|
|||
}
|
||||
do
|
||||
{
|
||||
ret = connect (sock, (struct sockaddr *) &addr, (unsigned) os_sockaddr_get_size((os_sockaddr *)&addr));
|
||||
}
|
||||
while ((ret == -1) && (os_getErrno() == os_sockEINTR));
|
||||
if (ret == -1)
|
||||
ret = ddsrt_connect(sock, (struct sockaddr *)&addr, ddsrt_sockaddr_get_size((struct sockaddr *)&addr));
|
||||
} while (ret == DDS_RETCODE_INTERRUPTED);
|
||||
if (ret != DDS_RETCODE_OK)
|
||||
{
|
||||
char buff[DDSI_LOCSTRLEN];
|
||||
sockaddr_to_string_with_port(buff, sizeof(buff), (os_sockaddr *)&addr);
|
||||
DDS_WARNING("%s failed to connect to own listener (%s) error %d\n", ddsi_name, buff, os_getErrno());
|
||||
sockaddr_to_string_with_port(buff, sizeof(buff), (struct sockaddr *)&addr);
|
||||
DDS_WARNING("%s failed to connect to own listener (%s) error %d\n", ddsi_name, buff, ret);
|
||||
}
|
||||
}
|
||||
ddsi_tcp_sock_free (sock, NULL);
|
||||
|
@ -1018,14 +1004,14 @@ static void ddsi_tcp_release_listener (ddsi_tran_listener_t listener)
|
|||
}
|
||||
#endif
|
||||
ddsi_tcp_sock_free (tl->m_sock, "listener");
|
||||
os_free (tl);
|
||||
ddsrt_free (tl);
|
||||
}
|
||||
|
||||
static void ddsi_tcp_release_factory (void)
|
||||
{
|
||||
if (os_atomic_dec32_nv (&ddsi_tcp_init_g) == 0) {
|
||||
if (ddsrt_atomic_dec32_nv (&ddsi_tcp_init_g) == 0) {
|
||||
ut_avlFree (&ddsi_tcp_treedef, &ddsi_tcp_cache_g, ddsi_tcp_node_free);
|
||||
os_mutexDestroy (&ddsi_tcp_cache_lock_g);
|
||||
ddsrt_mutex_destroy (&ddsi_tcp_cache_lock_g);
|
||||
#ifdef DDSI_INCLUDE_SSL
|
||||
if (ddsi_tcp_ssl_plugin.fini)
|
||||
{
|
||||
|
@ -1062,7 +1048,7 @@ static enum ddsi_nearby_address_result ddsi_tcp_is_nearby_address (ddsi_tran_fac
|
|||
|
||||
int ddsi_tcp_init (void)
|
||||
{
|
||||
if (os_atomic_inc32_nv (&ddsi_tcp_init_g) == 1)
|
||||
if (ddsrt_atomic_inc32_nv (&ddsi_tcp_init_g) == 1)
|
||||
{
|
||||
memset (&ddsi_tcp_factory_g, 0, sizeof (ddsi_tcp_factory_g));
|
||||
ddsi_tcp_factory_g.m_kind = NN_LOCATOR_KIND_TCPv4;
|
||||
|
@ -1085,7 +1071,7 @@ int ddsi_tcp_init (void)
|
|||
ddsi_tcp_factory_g.m_is_nearby_address_fn = ddsi_tcp_is_nearby_address;
|
||||
ddsi_factory_add (&ddsi_tcp_factory_g);
|
||||
|
||||
#if OS_SOCKET_HAS_IPV6
|
||||
#if DDSRT_HAVE_IPV6
|
||||
if (config.transport_selector == TRANS_TCP6)
|
||||
{
|
||||
ddsi_tcp_factory_g.m_kind = NN_LOCATOR_KIND_TCPv6;
|
||||
|
@ -1110,7 +1096,7 @@ int ddsi_tcp_init (void)
|
|||
#endif
|
||||
|
||||
ut_avlInit (&ddsi_tcp_treedef, &ddsi_tcp_cache_g);
|
||||
os_mutexInit (&ddsi_tcp_cache_lock_g);
|
||||
ddsrt_mutex_init (&ddsi_tcp_cache_lock_g);
|
||||
|
||||
DDS_LOG(DDS_LC_CONFIG, "%s initialized\n", ddsi_name);
|
||||
}
|
||||
|
|
|
@ -11,17 +11,20 @@
|
|||
*/
|
||||
#include <assert.h>
|
||||
#include <string.h>
|
||||
#include "ddsi/q_thread.h"
|
||||
#include "ddsi/q_unused.h"
|
||||
#include "ddsi/q_gc.h"
|
||||
#include "ddsi/q_globals.h"
|
||||
#include "ddsi/q_config.h"
|
||||
#include "ddsi/ddsi_iid.h"
|
||||
#include "ddsi/ddsi_tkmap.h"
|
||||
#include "util/ut_hopscotch.h"
|
||||
|
||||
#include "dds/ddsrt/heap.h"
|
||||
#include "dds/ddsrt/log.h"
|
||||
#include "dds/ddsrt/sync.h"
|
||||
#include "dds/ddsi/q_thread.h"
|
||||
#include "dds/ddsi/q_unused.h"
|
||||
#include "dds/ddsi/q_gc.h"
|
||||
#include "dds/ddsi/q_globals.h"
|
||||
#include "dds/ddsi/q_config.h"
|
||||
#include "dds/ddsi/ddsi_iid.h"
|
||||
#include "dds/ddsi/ddsi_tkmap.h"
|
||||
#include "dds/util/ut_hopscotch.h"
|
||||
#include "dds__stream.h"
|
||||
#include "os/os.h"
|
||||
#include "ddsi/ddsi_serdata.h"
|
||||
#include "dds/ddsi/ddsi_serdata.h"
|
||||
|
||||
#define REFC_DELETE 0x80000000
|
||||
#define REFC_MASK 0x0fffffff
|
||||
|
@ -29,13 +32,13 @@
|
|||
struct ddsi_tkmap
|
||||
{
|
||||
struct ut_chh * m_hh;
|
||||
os_mutex m_lock;
|
||||
os_cond m_cond;
|
||||
ddsrt_mutex_t m_lock;
|
||||
ddsrt_cond_t m_cond;
|
||||
};
|
||||
|
||||
static void gc_buckets_impl (struct gcreq *gcreq)
|
||||
{
|
||||
os_free (gcreq->arg);
|
||||
ddsrt_free (gcreq->arg);
|
||||
gcreq_free (gcreq);
|
||||
}
|
||||
|
||||
|
@ -85,8 +88,8 @@ struct ddsi_tkmap *ddsi_tkmap_new (void)
|
|||
{
|
||||
struct ddsi_tkmap *tkmap = dds_alloc (sizeof (*tkmap));
|
||||
tkmap->m_hh = ut_chhNew (1, dds_tk_hash_void, dds_tk_equals_void, gc_buckets);
|
||||
os_mutexInit (&tkmap->m_lock);
|
||||
os_condInit (&tkmap->m_cond, &tkmap->m_lock);
|
||||
ddsrt_mutex_init (&tkmap->m_lock);
|
||||
ddsrt_cond_init (&tkmap->m_cond);
|
||||
return tkmap;
|
||||
}
|
||||
|
||||
|
@ -94,19 +97,19 @@ static void free_tkmap_instance (void *vtk, UNUSED_ARG(void *f_arg))
|
|||
{
|
||||
struct ddsi_tkmap_instance *tk = vtk;
|
||||
ddsi_serdata_unref (tk->m_sample);
|
||||
os_free (tk);
|
||||
ddsrt_free (tk);
|
||||
}
|
||||
|
||||
void ddsi_tkmap_free (_Inout_ _Post_invalid_ struct ddsi_tkmap * map)
|
||||
void ddsi_tkmap_free (struct ddsi_tkmap * map)
|
||||
{
|
||||
ut_chhEnumUnsafe (map->m_hh, free_tkmap_instance, NULL);
|
||||
ut_chhFree (map->m_hh);
|
||||
os_condDestroy (&map->m_cond);
|
||||
os_mutexDestroy (&map->m_lock);
|
||||
ddsrt_cond_destroy (&map->m_cond);
|
||||
ddsrt_mutex_destroy (&map->m_lock);
|
||||
dds_free (map);
|
||||
}
|
||||
|
||||
uint64_t ddsi_tkmap_lookup (_In_ struct ddsi_tkmap * map, _In_ const struct ddsi_serdata * sd)
|
||||
uint64_t ddsi_tkmap_lookup (struct ddsi_tkmap * map, const struct ddsi_serdata * sd)
|
||||
{
|
||||
struct ddsi_tkmap_instance dummy;
|
||||
struct ddsi_tkmap_instance * tk;
|
||||
|
@ -116,8 +119,7 @@ uint64_t ddsi_tkmap_lookup (_In_ struct ddsi_tkmap * map, _In_ const struct ddsi
|
|||
return (tk) ? tk->m_iid : DDS_HANDLE_NIL;
|
||||
}
|
||||
|
||||
_Check_return_
|
||||
struct ddsi_tkmap_instance *ddsi_tkmap_find_by_id (_In_ struct ddsi_tkmap *map, _In_ uint64_t iid)
|
||||
struct ddsi_tkmap_instance *ddsi_tkmap_find_by_id (struct ddsi_tkmap *map, uint64_t iid)
|
||||
{
|
||||
/* This is not a function that should be used liberally, as it linearly scans the key-to-iid map. */
|
||||
struct ut_chhIter it;
|
||||
|
@ -130,7 +132,7 @@ struct ddsi_tkmap_instance *ddsi_tkmap_find_by_id (_In_ struct ddsi_tkmap *map,
|
|||
if (tk == NULL)
|
||||
/* Common case of it not existing at all */
|
||||
return NULL;
|
||||
else if (!((refc = os_atomic_ld32 (&tk->m_refc)) & REFC_DELETE) && os_atomic_cas32 (&tk->m_refc, refc, refc+1))
|
||||
else if (!((refc = ddsrt_atomic_ld32 (&tk->m_refc)) & REFC_DELETE) && ddsrt_atomic_cas32 (&tk->m_refc, refc, refc+1))
|
||||
/* Common case of it existing, not in the process of being deleted and no one else concurrently modifying the refcount */
|
||||
return tk;
|
||||
else
|
||||
|
@ -150,11 +152,11 @@ struct ddsi_tkmap_instance *ddsi_tkmap_find_by_id (_In_ struct ddsi_tkmap *map,
|
|||
#define DDS_DEBUG_KEYHASH 1
|
||||
#endif
|
||||
|
||||
_Check_return_
|
||||
struct ddsi_tkmap_instance * ddsi_tkmap_find(
|
||||
_In_ struct ddsi_serdata * sd,
|
||||
_In_ const bool rd,
|
||||
_In_ const bool create)
|
||||
struct ddsi_tkmap_instance *
|
||||
ddsi_tkmap_find(
|
||||
struct ddsi_serdata * sd,
|
||||
const bool rd,
|
||||
const bool create)
|
||||
{
|
||||
struct ddsi_tkmap_instance dummy;
|
||||
struct ddsi_tkmap_instance * tk;
|
||||
|
@ -166,19 +168,19 @@ retry:
|
|||
if ((tk = ut_chhLookup(map->m_hh, &dummy)) != NULL)
|
||||
{
|
||||
uint32_t new;
|
||||
new = os_atomic_inc32_nv(&tk->m_refc);
|
||||
new = ddsrt_atomic_inc32_nv(&tk->m_refc);
|
||||
if (new & REFC_DELETE)
|
||||
{
|
||||
/* for the unlikely case of spinning 2^31 times across all threads ... */
|
||||
os_atomic_dec32(&tk->m_refc);
|
||||
ddsrt_atomic_dec32(&tk->m_refc);
|
||||
|
||||
/* simplest action would be to just spin, but that can potentially take a long time;
|
||||
we can block until someone signals some entry is removed from the map if we take
|
||||
some lock & wait for some condition */
|
||||
os_mutexLock(&map->m_lock);
|
||||
while ((tk = ut_chhLookup(map->m_hh, &dummy)) != NULL && (os_atomic_ld32(&tk->m_refc) & REFC_DELETE))
|
||||
os_condWait(&map->m_cond, &map->m_lock);
|
||||
os_mutexUnlock(&map->m_lock);
|
||||
ddsrt_mutex_lock(&map->m_lock);
|
||||
while ((tk = ut_chhLookup(map->m_hh, &dummy)) != NULL && (ddsrt_atomic_ld32(&tk->m_refc) & REFC_DELETE))
|
||||
ddsrt_cond_wait(&map->m_cond, &map->m_lock);
|
||||
ddsrt_mutex_unlock(&map->m_lock);
|
||||
goto retry;
|
||||
}
|
||||
}
|
||||
|
@ -188,7 +190,7 @@ retry:
|
|||
return NULL;
|
||||
|
||||
tk->m_sample = ddsi_serdata_to_topicless (sd);
|
||||
os_atomic_st32 (&tk->m_refc, 1);
|
||||
ddsrt_atomic_st32 (&tk->m_refc, 1);
|
||||
tk->m_iid = ddsi_iid_gen ();
|
||||
if (!ut_chhAdd (map->m_hh, tk))
|
||||
{
|
||||
|
@ -206,23 +208,22 @@ retry:
|
|||
return tk;
|
||||
}
|
||||
|
||||
_Check_return_
|
||||
struct ddsi_tkmap_instance * ddsi_tkmap_lookup_instance_ref (_In_ struct ddsi_serdata * sd)
|
||||
struct ddsi_tkmap_instance * ddsi_tkmap_lookup_instance_ref (struct ddsi_serdata * sd)
|
||||
{
|
||||
return ddsi_tkmap_find (sd, true, true);
|
||||
}
|
||||
|
||||
void ddsi_tkmap_instance_ref (_In_ struct ddsi_tkmap_instance *tk)
|
||||
void ddsi_tkmap_instance_ref (struct ddsi_tkmap_instance *tk)
|
||||
{
|
||||
os_atomic_inc32 (&tk->m_refc);
|
||||
ddsrt_atomic_inc32 (&tk->m_refc);
|
||||
}
|
||||
|
||||
void ddsi_tkmap_instance_unref (_In_ struct ddsi_tkmap_instance * tk)
|
||||
void ddsi_tkmap_instance_unref (struct ddsi_tkmap_instance * tk)
|
||||
{
|
||||
uint32_t old, new;
|
||||
assert (vtime_awake_p(lookup_thread_state()->vtime));
|
||||
do {
|
||||
old = os_atomic_ld32(&tk->m_refc);
|
||||
old = ddsrt_atomic_ld32(&tk->m_refc);
|
||||
if (old == 1)
|
||||
new = REFC_DELETE;
|
||||
else
|
||||
|
@ -230,7 +231,7 @@ void ddsi_tkmap_instance_unref (_In_ struct ddsi_tkmap_instance * tk)
|
|||
assert(!(old & REFC_DELETE));
|
||||
new = old - 1;
|
||||
}
|
||||
} while (!os_atomic_cas32(&tk->m_refc, old, new));
|
||||
} while (!ddsrt_atomic_cas32(&tk->m_refc, old, new));
|
||||
if (new == REFC_DELETE)
|
||||
{
|
||||
struct ddsi_tkmap *map = gv.m_tkmap;
|
||||
|
@ -241,9 +242,9 @@ void ddsi_tkmap_instance_unref (_In_ struct ddsi_tkmap_instance * tk)
|
|||
(void)removed;
|
||||
|
||||
/* Signal any threads blocked in their retry loops in lookup */
|
||||
os_mutexLock(&map->m_lock);
|
||||
os_condBroadcast(&map->m_cond);
|
||||
os_mutexUnlock(&map->m_lock);
|
||||
ddsrt_mutex_lock(&map->m_lock);
|
||||
ddsrt_cond_broadcast(&map->m_cond);
|
||||
ddsrt_mutex_unlock(&map->m_lock);
|
||||
|
||||
/* Schedule freeing of memory until after all those who may have found a pointer have
|
||||
progressed to where they no longer hold that pointer */
|
||||
|
|
|
@ -10,12 +10,15 @@
|
|||
* SPDX-License-Identifier: EPL-2.0 OR BSD-3-Clause
|
||||
*/
|
||||
#include <assert.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <ctype.h>
|
||||
#include "os/os.h"
|
||||
#include "ddsi/ddsi_tran.h"
|
||||
#include "ddsi/q_config.h"
|
||||
#include "ddsi/q_log.h"
|
||||
|
||||
#include "dds/ddsrt/heap.h"
|
||||
#include "dds/ddsrt/ifaddrs.h"
|
||||
#include "dds/ddsi/ddsi_tran.h"
|
||||
#include "dds/ddsi/q_config.h"
|
||||
#include "dds/ddsi/q_log.h"
|
||||
|
||||
static ddsi_tran_factory_t ddsi_tran_factories = NULL;
|
||||
|
||||
|
@ -23,16 +26,16 @@ 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, int port, ddsi_tran_qos_t qos);
|
||||
extern inline bool ddsi_factory_supports (ddsi_tran_factory_t factory, int32_t kind);
|
||||
extern inline os_socket ddsi_conn_handle (ddsi_tran_conn_t conn);
|
||||
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 os_socket ddsi_tran_handle (ddsi_tran_base_t base);
|
||||
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 int ddsi_tran_locator (ddsi_tran_base_t base, nn_locator_t * loc);
|
||||
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);
|
||||
extern inline ssize_t ddsi_conn_read (ddsi_tran_conn_t conn, unsigned char * buf, size_t len, bool allow_spurious, nn_locator_t *srcloc);
|
||||
extern inline ssize_t ddsi_conn_write (ddsi_tran_conn_t conn, const nn_locator_t *dst, size_t niov, const os_iovec_t *iov, uint32_t flags);
|
||||
extern inline ssize_t ddsi_conn_write (ddsi_tran_conn_t conn, const nn_locator_t *dst, size_t niov, const ddsrt_iovec_t *iov, uint32_t flags);
|
||||
|
||||
void ddsi_factory_add (ddsi_tran_factory_t factory)
|
||||
{
|
||||
|
@ -115,7 +118,7 @@ void ddsi_conn_free (ddsi_tran_conn_t conn)
|
|||
{
|
||||
conn->m_closed = true;
|
||||
/* FIXME: rethink the socket waitset & the deleting of entries; the biggest issue is TCP handling that can open & close sockets at will and yet expects the waitset to wake up at the apprioriate times. (This pretty much works with the select-based version, but not the kqueue-based one.) TCP code can also have connections without a socket ... Calling sockWaitsetRemove here (where there shouldn't be any knowledge of it) at least ensures that it is removed in time and that there can't be aliasing of connections and sockets. */
|
||||
if (ddsi_conn_handle (conn) != OS_INVALID_SOCKET)
|
||||
if (ddsi_conn_handle (conn) != DDSRT_INVALID_SOCKET)
|
||||
{
|
||||
unsigned i;
|
||||
for (i = 0; i < gv.n_recv_threads; i++)
|
||||
|
@ -142,7 +145,7 @@ void ddsi_conn_free (ddsi_tran_conn_t conn)
|
|||
(conn->m_factory->m_close_conn_fn) (conn);
|
||||
}
|
||||
}
|
||||
if (os_atomic_dec32_ov (&conn->m_count) == 1)
|
||||
if (ddsrt_atomic_dec32_ov (&conn->m_count) == 1)
|
||||
{
|
||||
(conn->m_factory->m_release_conn_fn) (conn);
|
||||
}
|
||||
|
@ -151,12 +154,12 @@ void ddsi_conn_free (ddsi_tran_conn_t conn)
|
|||
|
||||
void ddsi_conn_add_ref (ddsi_tran_conn_t conn)
|
||||
{
|
||||
os_atomic_inc32 (&conn->m_count);
|
||||
ddsrt_atomic_inc32 (&conn->m_count);
|
||||
}
|
||||
|
||||
void ddsi_factory_conn_init (ddsi_tran_factory_t factory, ddsi_tran_conn_t conn)
|
||||
{
|
||||
os_atomic_st32 (&conn->m_count, 1);
|
||||
ddsrt_atomic_st32 (&conn->m_count, 1);
|
||||
conn->m_connless = factory->m_connless;
|
||||
conn->m_stream = factory->m_stream;
|
||||
conn->m_factory = factory;
|
||||
|
@ -181,7 +184,7 @@ bool ddsi_conn_peer_locator (ddsi_tran_conn_t conn, nn_locator_t * loc)
|
|||
|
||||
void ddsi_tran_free_qos (ddsi_tran_qos_t qos)
|
||||
{
|
||||
os_free (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)
|
||||
|
@ -197,7 +200,7 @@ int ddsi_conn_leave_mc (ddsi_tran_conn_t conn, const nn_locator_t *srcloc, const
|
|||
ddsi_tran_qos_t ddsi_tran_create_qos (void)
|
||||
{
|
||||
ddsi_tran_qos_t qos;
|
||||
qos = (ddsi_tran_qos_t) os_malloc (sizeof (*qos));
|
||||
qos = (ddsi_tran_qos_t) ddsrt_malloc (sizeof (*qos));
|
||||
memset (qos, 0, sizeof (*qos));
|
||||
return qos;
|
||||
}
|
||||
|
@ -243,7 +246,9 @@ int ddsi_is_mcaddr (const nn_locator_t *loc)
|
|||
int ddsi_is_ssm_mcaddr (const nn_locator_t *loc)
|
||||
{
|
||||
ddsi_tran_factory_t tran = ddsi_factory_find_supported_kind(loc->kind);
|
||||
return tran ? tran->m_is_ssm_mcaddr_fn (tran, loc) : 0;
|
||||
if (tran && tran->m_is_ssm_mcaddr_fn != 0)
|
||||
return tran->m_is_ssm_mcaddr_fn (tran, loc);
|
||||
return 0;
|
||||
}
|
||||
|
||||
enum ddsi_nearby_address_result ddsi_is_nearby_address (const nn_locator_t *loc, size_t ninterf, const struct nn_interface interf[])
|
||||
|
@ -300,7 +305,7 @@ char *ddsi_locator_to_string_no_port (char *dst, size_t sizeof_dst, const nn_loc
|
|||
return dst;
|
||||
}
|
||||
|
||||
int ddsi_enumerate_interfaces (ddsi_tran_factory_t factory, os_ifaddrs_t **interfs)
|
||||
int ddsi_enumerate_interfaces (ddsi_tran_factory_t factory, ddsrt_ifaddrs_t **interfs)
|
||||
{
|
||||
return factory->m_enumerate_interfaces_fn (factory, interfs);
|
||||
}
|
||||
|
|
|
@ -11,17 +11,19 @@
|
|||
*/
|
||||
#include <assert.h>
|
||||
#include <string.h>
|
||||
#include "os/os.h"
|
||||
#include "os/os_atomics.h"
|
||||
#include "dds/ddsrt/atomics.h"
|
||||
#include "dds/ddsrt/heap.h"
|
||||
#include "dds/ddsrt/log.h"
|
||||
#include "dds/ddsrt/sockets.h"
|
||||
#include "ddsi_eth.h"
|
||||
#include "ddsi/ddsi_tran.h"
|
||||
#include "ddsi/ddsi_udp.h"
|
||||
#include "ddsi/ddsi_ipaddr.h"
|
||||
#include "ddsi/ddsi_mcgroup.h"
|
||||
#include "ddsi/q_nwif.h"
|
||||
#include "ddsi/q_config.h"
|
||||
#include "ddsi/q_log.h"
|
||||
#include "ddsi/q_pcap.h"
|
||||
#include "dds/ddsi/ddsi_tran.h"
|
||||
#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"
|
||||
|
||||
extern void ddsi_factory_conn_init (ddsi_tran_factory_t factory, ddsi_tran_conn_t conn);
|
||||
|
||||
|
@ -36,8 +38,8 @@ typedef struct ddsi_udp_config
|
|||
typedef struct ddsi_udp_conn
|
||||
{
|
||||
struct ddsi_tran_conn m_base;
|
||||
os_socket m_sock;
|
||||
#if defined _WIN32 && !defined WINCE
|
||||
ddsrt_socket_t m_sock;
|
||||
#if defined _WIN32
|
||||
WSAEVENT m_sockEvent;
|
||||
#endif
|
||||
int m_diffserv;
|
||||
|
@ -46,134 +48,125 @@ typedef struct ddsi_udp_conn
|
|||
|
||||
static struct ddsi_udp_config ddsi_udp_config_g;
|
||||
static struct ddsi_tran_factory ddsi_udp_factory_g;
|
||||
static os_atomic_uint32_t ddsi_udp_init_g = OS_ATOMIC_UINT32_INIT(0);
|
||||
static ddsrt_atomic_uint32_t ddsi_udp_init_g = DDSRT_ATOMIC_UINT32_INIT(0);
|
||||
|
||||
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)
|
||||
{
|
||||
int err;
|
||||
ssize_t ret;
|
||||
struct msghdr msghdr;
|
||||
os_sockaddr_storage src;
|
||||
os_iovec_t msg_iov;
|
||||
dds_retcode_t rc;
|
||||
ssize_t ret = 0;
|
||||
ddsrt_msghdr_t msghdr;
|
||||
struct sockaddr_storage 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 = (os_iov_len_t)len; /* Windows uses unsigned, POSIX (except Linux) int */
|
||||
msg_iov.iov_len = (ddsrt_iov_len_t)len; /* Windows uses unsigned, POSIX (except Linux) int */
|
||||
|
||||
msghdr.msg_name = &src;
|
||||
msghdr.msg_namelen = srclen;
|
||||
msghdr.msg_iov = &msg_iov;
|
||||
msghdr.msg_iovlen = 1;
|
||||
#if !defined(__sun) || defined(_XPG4_2)
|
||||
msghdr.msg_control = NULL;
|
||||
msghdr.msg_controllen = 0;
|
||||
#else
|
||||
#if defined(__sun) && !defined(_XPG4_2)
|
||||
msghdr.msg_accrights = NULL;
|
||||
msghdr.msg_accrightslen = 0;
|
||||
#else
|
||||
msghdr.msg_control = NULL;
|
||||
msghdr.msg_controllen = 0;
|
||||
#endif
|
||||
|
||||
do {
|
||||
ret = recvmsg(((ddsi_udp_conn_t) conn)->m_sock, &msghdr, 0);
|
||||
err = (ret == -1) ? os_getErrno() : 0;
|
||||
} while (err == os_sockEINTR);
|
||||
rc = ddsrt_recvmsg(((ddsi_udp_conn_t) conn)->m_sock, &msghdr, 0, &ret);
|
||||
} while (rc == DDS_RETCODE_INTERRUPTED);
|
||||
|
||||
if (ret > 0)
|
||||
{
|
||||
if (srcloc)
|
||||
ddsi_ipaddr_to_loc(srcloc, (os_sockaddr *)&src, src.ss_family == AF_INET ? NN_LOCATOR_KIND_UDPv4 : NN_LOCATOR_KIND_UDPv6);
|
||||
ddsi_ipaddr_to_loc(srcloc, (struct sockaddr *)&src, src.ss_family == AF_INET ? NN_LOCATOR_KIND_UDPv4 : NN_LOCATOR_KIND_UDPv6);
|
||||
|
||||
/* Check for udp packet truncation */
|
||||
if ((((size_t) ret) > len)
|
||||
#if OS_MSGHDR_FLAGS
|
||||
#if DDSRT_MSGHDR_FLAGS
|
||||
|| (msghdr.msg_flags & MSG_TRUNC)
|
||||
#endif
|
||||
)
|
||||
{
|
||||
char addrbuf[DDSI_LOCSTRLEN];
|
||||
nn_locator_t tmp;
|
||||
ddsi_ipaddr_to_loc(&tmp, (os_sockaddr *)&src, src.ss_family == AF_INET ? NN_LOCATOR_KIND_UDPv4 : NN_LOCATOR_KIND_UDPv6);
|
||||
ddsi_ipaddr_to_loc(&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_WARNING("%s => %d truncated to %d\n", addrbuf, (int)ret, (int)len);
|
||||
}
|
||||
}
|
||||
else if (err != os_sockENOTSOCK && err != os_sockECONNRESET)
|
||||
else if (rc != DDS_RETCODE_BAD_PARAMETER &&
|
||||
rc != DDS_RETCODE_NO_CONNECTION)
|
||||
{
|
||||
DDS_ERROR("UDP recvmsg sock %d: ret %d errno %d\n", (int) ((ddsi_udp_conn_t) conn)->m_sock, (int) ret, err);
|
||||
DDS_ERROR("UDP recvmsg sock %d: ret %d retcode %d\n", (int) ((ddsi_udp_conn_t) conn)->m_sock, (int) ret, rc);
|
||||
ret = -1;
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
static void set_msghdr_iov (struct msghdr *mhdr, os_iovec_t *iov, size_t iovlen)
|
||||
static void set_msghdr_iov (ddsrt_msghdr_t *mhdr, ddsrt_iovec_t *iov, size_t iovlen)
|
||||
{
|
||||
mhdr->msg_iov = iov;
|
||||
mhdr->msg_iovlen = (os_msg_iovlen_t)iovlen;
|
||||
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 os_iovec_t *iov, uint32_t flags)
|
||||
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)
|
||||
{
|
||||
int err;
|
||||
dds_retcode_t rc;
|
||||
ssize_t ret;
|
||||
unsigned retry = 2;
|
||||
int sendflags = 0;
|
||||
struct msghdr msg;
|
||||
os_sockaddr_storage dstaddr;
|
||||
ddsrt_msghdr_t msg;
|
||||
struct sockaddr_storage dstaddr;
|
||||
assert(niov <= INT_MAX);
|
||||
ddsi_ipaddr_from_loc(&dstaddr, dst);
|
||||
set_msghdr_iov (&msg, (os_iovec_t *) iov, niov);
|
||||
set_msghdr_iov (&msg, (ddsrt_iovec_t *) iov, niov);
|
||||
msg.msg_name = &dstaddr;
|
||||
msg.msg_namelen = (socklen_t) os_sockaddr_get_size((os_sockaddr *) &dstaddr);
|
||||
#if !defined(__sun) || defined(_XPG4_2)
|
||||
msg.msg_control = NULL;
|
||||
msg.msg_controllen = 0;
|
||||
#else
|
||||
msg.msg_namelen = (socklen_t) ddsrt_sockaddr_get_size((struct sockaddr *) &dstaddr);
|
||||
#if defined(__sun) && !defined(_XPG4_2)
|
||||
msg.msg_accrights = NULL;
|
||||
msg.msg_accrightslen = 0;
|
||||
#else
|
||||
msg.msg_control = NULL;
|
||||
msg.msg_controllen = 0;
|
||||
#endif
|
||||
#if OS_MSGHDR_FLAGS
|
||||
#if DDSRT_MSGHDR_FLAGS
|
||||
msg.msg_flags = (int) flags;
|
||||
#else
|
||||
OS_UNUSED_ARG(flags);
|
||||
DDSRT_UNUSED_ARG(flags);
|
||||
#endif
|
||||
#ifdef MSG_NOSIGNAL
|
||||
sendflags |= MSG_NOSIGNAL;
|
||||
#endif
|
||||
do {
|
||||
ddsi_udp_conn_t uc = (ddsi_udp_conn_t) conn;
|
||||
ret = sendmsg (uc->m_sock, &msg, sendflags);
|
||||
err = (ret == -1) ? os_getErrno() : 0;
|
||||
rc = ddsrt_sendmsg (uc->m_sock, &msg, sendflags, &ret);
|
||||
#if defined _WIN32 && !defined WINCE
|
||||
if (err == os_sockEWOULDBLOCK) {
|
||||
if (rc == DDS_RETCODE_TRY_AGAIN) {
|
||||
WSANETWORKEVENTS ev;
|
||||
WaitForSingleObject(uc->m_sockEvent, INFINITE);
|
||||
WSAEnumNetworkEvents(uc->m_sock, uc->m_sockEvent, &ev);
|
||||
}
|
||||
#endif
|
||||
} while (err == os_sockEINTR || err == os_sockEWOULDBLOCK || (err == os_sockEPERM && retry-- > 0));
|
||||
} while ((rc == DDS_RETCODE_INTERRUPTED) ||
|
||||
(rc == DDS_RETCODE_TRY_AGAIN) ||
|
||||
(rc == DDS_RETCODE_NOT_ALLOWED && retry-- > 0));
|
||||
if (ret > 0 && gv.pcap_fp)
|
||||
{
|
||||
os_sockaddr_storage sa;
|
||||
struct sockaddr_storage sa;
|
||||
socklen_t alen = sizeof (sa);
|
||||
if (getsockname (((ddsi_udp_conn_t) conn)->m_sock, (struct sockaddr *) &sa, &alen) == -1)
|
||||
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 (gv.pcap_fp, now (), &sa, &msg, (size_t) ret);
|
||||
}
|
||||
else if (ret == -1)
|
||||
else if (rc != DDS_RETCODE_OK &&
|
||||
rc != DDS_RETCODE_NOT_ALLOWED &&
|
||||
rc != DDS_RETCODE_NO_CONNECTION)
|
||||
{
|
||||
switch (err)
|
||||
{
|
||||
case os_sockEPERM:
|
||||
case os_sockECONNRESET:
|
||||
#ifdef os_sockENETUNREACH
|
||||
case os_sockENETUNREACH:
|
||||
#endif
|
||||
#ifdef os_sockEHOSTUNREACH
|
||||
case os_sockEHOSTUNREACH:
|
||||
#endif
|
||||
break;
|
||||
default:
|
||||
DDS_ERROR("ddsi_udp_conn_write failed with error code %d", err);
|
||||
}
|
||||
DDS_ERROR("ddsi_udp_conn_write failed with retcode %d", rc);
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
@ -190,7 +183,7 @@ static void ddsi_udp_disable_multiplexing (ddsi_tran_conn_t base)
|
|||
#endif
|
||||
}
|
||||
|
||||
static os_socket ddsi_udp_conn_handle (ddsi_tran_base_t base)
|
||||
static ddsrt_socket_t ddsi_udp_conn_handle (ddsi_tran_base_t base)
|
||||
{
|
||||
return ((ddsi_udp_conn_t) base)->m_sock;
|
||||
}
|
||||
|
@ -206,7 +199,7 @@ static int ddsi_udp_conn_locator (ddsi_tran_base_t base, nn_locator_t *loc)
|
|||
{
|
||||
int ret = -1;
|
||||
ddsi_udp_conn_t uc = (ddsi_udp_conn_t) base;
|
||||
if (uc->m_sock != OS_INVALID_SOCKET)
|
||||
if (uc->m_sock != DDSRT_INVALID_SOCKET)
|
||||
{
|
||||
loc->kind = ddsi_udp_factory_g.m_kind;
|
||||
loc->port = uc->m_base.m_base.m_port;
|
||||
|
@ -216,18 +209,20 @@ static int ddsi_udp_conn_locator (ddsi_tran_base_t base, nn_locator_t *loc)
|
|||
return ret;
|
||||
}
|
||||
|
||||
static unsigned short get_socket_port (os_socket socket)
|
||||
static unsigned short get_socket_port (ddsrt_socket_t socket)
|
||||
{
|
||||
os_sockaddr_storage addr;
|
||||
dds_retcode_t ret;
|
||||
struct sockaddr_storage addr;
|
||||
socklen_t addrlen = sizeof (addr);
|
||||
if (getsockname (socket, (os_sockaddr *) &addr, &addrlen) < 0)
|
||||
|
||||
ret = ddsrt_getsockname (socket, (struct sockaddr *)&addr, &addrlen);
|
||||
if (ret != DDS_RETCODE_OK)
|
||||
{
|
||||
int err = os_getErrno();
|
||||
DDS_ERROR("ddsi_udp_get_socket_port: getsockname errno %d\n", err);
|
||||
DDS_ERROR("ddsi_udp_get_socket_port: getsockname returned %d\n", ret);
|
||||
return 0;
|
||||
}
|
||||
|
||||
return os_sockaddr_get_port((os_sockaddr *)&addr);
|
||||
return ddsrt_sockaddr_get_port((struct sockaddr *)&addr);
|
||||
}
|
||||
|
||||
static ddsi_tran_conn_t ddsi_udp_create_conn
|
||||
|
@ -237,7 +232,7 @@ static ddsi_tran_conn_t ddsi_udp_create_conn
|
|||
)
|
||||
{
|
||||
int ret;
|
||||
os_socket sock;
|
||||
ddsrt_socket_t sock;
|
||||
ddsi_udp_conn_t uc = NULL;
|
||||
bool mcast = (bool) (qos ? qos->m_multicast : false);
|
||||
|
||||
|
@ -253,7 +248,7 @@ static ddsi_tran_conn_t ddsi_udp_create_conn
|
|||
|
||||
if (ret == 0)
|
||||
{
|
||||
uc = (ddsi_udp_conn_t) os_malloc (sizeof (*uc));
|
||||
uc = (ddsi_udp_conn_t) ddsrt_malloc (sizeof (*uc));
|
||||
memset (uc, 0, sizeof (*uc));
|
||||
|
||||
uc->m_sock = sock;
|
||||
|
@ -276,7 +271,7 @@ static ddsi_tran_conn_t ddsi_udp_create_conn
|
|||
|
||||
DDS_TRACE
|
||||
(
|
||||
"ddsi_udp_create_conn %s socket %"PRIsock" port %u\n",
|
||||
"ddsi_udp_create_conn %s socket %"PRIdSOCK" port %u\n",
|
||||
mcast ? "multicast" : "unicast",
|
||||
uc->m_sock,
|
||||
uc->m_base.m_base.m_port
|
||||
|
@ -284,11 +279,10 @@ static ddsi_tran_conn_t ddsi_udp_create_conn
|
|||
#ifdef DDSI_INCLUDE_NETWORK_CHANNELS
|
||||
if ((uc->m_diffserv != 0) && (ddsi_udp_factory_g.m_kind == NN_LOCATOR_KIND_UDPv4))
|
||||
{
|
||||
if (os_sockSetsockopt (sock, IPPROTO_IP, IP_TOS, (char*) &uc->m_diffserv, sizeof (uc->m_diffserv)) != os_resultSuccess)
|
||||
{
|
||||
int err = os_getErrno();
|
||||
DDS_ERROR("ddsi_udp_create_conn: set diffserv error %d\n", err);
|
||||
}
|
||||
dds_retcode_t rc;
|
||||
rc = ddsrt_setsockopt(sock, IPPROTO_IP, IP_TOS, (char *)&uc->m_diffserv, sizeof(uc->m_diffserv));
|
||||
if (rc != DDS_RETCODE_OK)
|
||||
DDS_ERROR("ddsi_udp_create_conn: set diffserv retcode %d\n", rc);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
@ -308,42 +302,42 @@ static ddsi_tran_conn_t ddsi_udp_create_conn
|
|||
return uc ? &uc->m_base : NULL;
|
||||
}
|
||||
|
||||
static int joinleave_asm_mcgroup (os_socket socket, int join, const nn_locator_t *mcloc, const struct nn_interface *interf)
|
||||
static int joinleave_asm_mcgroup (ddsrt_socket_t socket, int join, const nn_locator_t *mcloc, const struct nn_interface *interf)
|
||||
{
|
||||
os_result rc;
|
||||
os_sockaddr_storage mcip;
|
||||
dds_retcode_t rc;
|
||||
struct sockaddr_storage mcip;
|
||||
ddsi_ipaddr_from_loc(&mcip, mcloc);
|
||||
#if OS_SOCKET_HAS_IPV6
|
||||
#if DDSRT_HAVE_IPV6
|
||||
if (config.transport_selector == TRANS_UDP6)
|
||||
{
|
||||
os_ipv6_mreq ipv6mreq;
|
||||
struct ipv6_mreq ipv6mreq;
|
||||
memset (&ipv6mreq, 0, sizeof (ipv6mreq));
|
||||
memcpy (&ipv6mreq.ipv6mr_multiaddr, &((os_sockaddr_in6 *) &mcip)->sin6_addr, sizeof (ipv6mreq.ipv6mr_multiaddr));
|
||||
memcpy (&ipv6mreq.ipv6mr_multiaddr, &((struct sockaddr_in6 *) &mcip)->sin6_addr, sizeof (ipv6mreq.ipv6mr_multiaddr));
|
||||
ipv6mreq.ipv6mr_interface = interf ? interf->if_index : 0;
|
||||
rc = os_sockSetsockopt (socket, IPPROTO_IPV6, join ? IPV6_JOIN_GROUP : IPV6_LEAVE_GROUP, &ipv6mreq, sizeof (ipv6mreq));
|
||||
rc = ddsrt_setsockopt (socket, IPPROTO_IPV6, join ? IPV6_JOIN_GROUP : IPV6_LEAVE_GROUP, &ipv6mreq, sizeof (ipv6mreq));
|
||||
}
|
||||
else
|
||||
#endif
|
||||
{
|
||||
struct ip_mreq mreq;
|
||||
mreq.imr_multiaddr = ((os_sockaddr_in *) &mcip)->sin_addr;
|
||||
mreq.imr_multiaddr = ((struct sockaddr_in *) &mcip)->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 = os_sockSetsockopt (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, (char *) &mreq, sizeof (mreq));
|
||||
}
|
||||
return (rc != os_resultSuccess) ? os_getErrno() : 0;
|
||||
return (rc == DDS_RETCODE_OK) ? 0 : -1;
|
||||
}
|
||||
|
||||
#ifdef DDSI_INCLUDE_SSM
|
||||
static int joinleave_ssm_mcgroup (os_socket socket, int join, const nn_locator_t *srcloc, const nn_locator_t *mcloc, const struct nn_interface *interf)
|
||||
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)
|
||||
{
|
||||
os_result rc;
|
||||
os_sockaddr_storage mcip, srcip;
|
||||
dds_retcode_t rc;
|
||||
struct sockaddr_storage mcip, srcip;
|
||||
ddsi_ipaddr_from_loc(&mcip, mcloc);
|
||||
ddsi_ipaddr_from_loc(&srcip, srcloc);
|
||||
#if OS_SOCKET_HAS_IPV6
|
||||
#if DDSRT_HAVE_IPV6
|
||||
if (config.transport_selector == TRANS_UDP6)
|
||||
{
|
||||
struct group_source_req gsr;
|
||||
|
@ -351,22 +345,22 @@ static int joinleave_ssm_mcgroup (os_socket socket, int join, const nn_locator_t
|
|||
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));
|
||||
rc = os_sockSetsockopt (socket, IPPROTO_IPV6, join ? MCAST_JOIN_SOURCE_GROUP : MCAST_LEAVE_SOURCE_GROUP, &gsr, sizeof (gsr));
|
||||
rc = ddsrt_setsockopt (socket, IPPROTO_IPV6, join ? MCAST_JOIN_SOURCE_GROUP : MCAST_LEAVE_SOURCE_GROUP, &gsr, sizeof (gsr));
|
||||
}
|
||||
else
|
||||
#endif
|
||||
{
|
||||
struct ip_mreq_source mreq;
|
||||
memset (&mreq, 0, sizeof (mreq));
|
||||
mreq.imr_sourceaddr = ((os_sockaddr_in *) &srcip)->sin_addr;
|
||||
mreq.imr_multiaddr = ((os_sockaddr_in *) &mcip)->sin_addr;
|
||||
mreq.imr_sourceaddr = ((struct sockaddr_in *) &srcip)->sin_addr;
|
||||
mreq.imr_multiaddr = ((struct sockaddr_in *) &mcip)->sin_addr;
|
||||
if (interf)
|
||||
memcpy (&mreq.imr_interface, interf->loc.address + 12, sizeof (mreq.imr_interface));
|
||||
else
|
||||
mreq.imr_interface.s_addr = INADDR_ANY;
|
||||
rc = os_sockSetsockopt (socket, IPPROTO_IP, join ? IP_ADD_SOURCE_MEMBERSHIP : IP_DROP_SOURCE_MEMBERSHIP, &mreq, sizeof (mreq));
|
||||
rc = ddsrt_setsockopt (socket, IPPROTO_IP, join ? IP_ADD_SOURCE_MEMBERSHIP : IP_DROP_SOURCE_MEMBERSHIP, &mreq, sizeof (mreq));
|
||||
}
|
||||
return (rc != os_resultSuccess) ? os_getErrno() : 0;
|
||||
return (rc == DDS_RETCODE_OK) ? 0 : -1;
|
||||
}
|
||||
#endif
|
||||
|
||||
|
@ -399,21 +393,21 @@ static void ddsi_udp_release_conn (ddsi_tran_conn_t conn)
|
|||
ddsi_udp_conn_t uc = (ddsi_udp_conn_t) conn;
|
||||
DDS_TRACE
|
||||
(
|
||||
"ddsi_udp_release_conn %s socket %"PRIsock" port %u\n",
|
||||
"ddsi_udp_release_conn %s socket %"PRIdSOCK" port %u\n",
|
||||
conn->m_base.m_multicast ? "multicast" : "unicast",
|
||||
uc->m_sock,
|
||||
uc->m_base.m_base.m_port
|
||||
);
|
||||
os_sockFree (uc->m_sock);
|
||||
ddsrt_close (uc->m_sock);
|
||||
#if defined _WIN32 && !defined WINCE
|
||||
WSACloseEvent(uc->m_sockEvent);
|
||||
#endif
|
||||
os_free (conn);
|
||||
ddsrt_free (conn);
|
||||
}
|
||||
|
||||
void ddsi_udp_fini (void)
|
||||
{
|
||||
if(os_atomic_dec32_nv (&ddsi_udp_init_g) == 0) {
|
||||
if(ddsrt_atomic_dec32_nv (&ddsi_udp_init_g) == 0) {
|
||||
free_group_membership(ddsi_udp_config_g.mship);
|
||||
memset (&ddsi_udp_factory_g, 0, sizeof (ddsi_udp_factory_g));
|
||||
DDS_LOG(DDS_LC_CONFIG, "udp finalized\n");
|
||||
|
@ -433,7 +427,7 @@ static int ddsi_udp_is_mcaddr (const ddsi_tran_factory_t tran, const nn_locator_
|
|||
const nn_udpv4mcgen_address_t *mcgen = (const nn_udpv4mcgen_address_t *) loc->address;
|
||||
return IN_MULTICAST (ntohl (mcgen->ipv4.s_addr));
|
||||
}
|
||||
#if OS_SOCKET_HAS_IPV6
|
||||
#if DDSRT_HAVE_IPV6
|
||||
case NN_LOCATOR_KIND_UDPv6: {
|
||||
const struct in6_addr *ipv6 = (const struct in6_addr *) loc->address;
|
||||
return IN6_IS_ADDR_MULTICAST (ipv6);
|
||||
|
@ -455,7 +449,7 @@ static int ddsi_udp_is_ssm_mcaddr (const ddsi_tran_factory_t tran, const nn_loca
|
|||
const struct in_addr *x = (const struct in_addr *) (loc->address + 12);
|
||||
return (((uint32_t) ntohl (x->s_addr)) >> 24) == 232;
|
||||
}
|
||||
#if OS_SOCKET_HAS_IPV6
|
||||
#if DDSRT_HAVE_IPV6
|
||||
case NN_LOCATOR_KIND_UDPv6: {
|
||||
const struct in6_addr *x = (const struct in6_addr *) loc->address;
|
||||
return x->s6_addr[0] == 0xff && (x->s6_addr[1] & 0xf0) == 0x30;
|
||||
|
@ -478,7 +472,7 @@ static char *ddsi_udp_locator_to_string (ddsi_tran_factory_t tran, char *dst, si
|
|||
if (loc->kind != NN_LOCATOR_KIND_UDPv4MCGEN) {
|
||||
return ddsi_ipaddr_to_string(tran, dst, sizeof_dst, loc, with_port);
|
||||
} else {
|
||||
os_sockaddr_in src;
|
||||
struct sockaddr_in src;
|
||||
nn_udpv4mcgen_address_t mcgen;
|
||||
size_t pos;
|
||||
int cnt;
|
||||
|
@ -487,7 +481,7 @@ static char *ddsi_udp_locator_to_string (ddsi_tran_factory_t tran, char *dst, si
|
|||
memset (&src, 0, sizeof (src));
|
||||
src.sin_family = AF_INET;
|
||||
memcpy (&src.sin_addr.s_addr, &mcgen.ipv4, 4);
|
||||
os_sockaddrtostr ((const os_sockaddr *) &src, dst, sizeof_dst);
|
||||
ddsrt_sockaddrtostr ((const struct sockaddr *) &src, dst, sizeof_dst);
|
||||
pos = strlen (dst);
|
||||
assert (pos <= sizeof_dst);
|
||||
cnt = snprintf (dst + pos, sizeof_dst - pos, ";%u;%u;%u", mcgen.base, mcgen.count, mcgen.idx);
|
||||
|
@ -503,7 +497,7 @@ static char *ddsi_udp_locator_to_string (ddsi_tran_factory_t tran, char *dst, si
|
|||
|
||||
static void ddsi_udp_deinit(void)
|
||||
{
|
||||
if (os_atomic_dec32_nv(&ddsi_udp_init_g) == 0) {
|
||||
if (ddsrt_atomic_dec32_nv(&ddsi_udp_init_g) == 0) {
|
||||
if (ddsi_udp_config_g.mship)
|
||||
free_group_membership(ddsi_udp_config_g.mship);
|
||||
DDS_LOG(DDS_LC_CONFIG, "udp de-initialized\n");
|
||||
|
@ -516,7 +510,7 @@ int ddsi_udp_init (void)
|
|||
* this can be removed. Or the call does, in which case it should be done right.
|
||||
* The lack of locking suggests it isn't needed.
|
||||
*/
|
||||
if (os_atomic_inc32_nv (&ddsi_udp_init_g) == 1)
|
||||
if (ddsrt_atomic_inc32_nv (&ddsi_udp_init_g) == 1)
|
||||
{
|
||||
memset (&ddsi_udp_factory_g, 0, sizeof (ddsi_udp_factory_g));
|
||||
ddsi_udp_factory_g.m_free_fn = ddsi_udp_deinit;
|
||||
|
@ -538,7 +532,7 @@ int ddsi_udp_init (void)
|
|||
ddsi_udp_factory_g.m_locator_from_string_fn = ddsi_udp_address_from_string;
|
||||
ddsi_udp_factory_g.m_locator_to_string_fn = ddsi_udp_locator_to_string;
|
||||
ddsi_udp_factory_g.m_enumerate_interfaces_fn = ddsi_eth_enumerate_interfaces;
|
||||
#if OS_SOCKET_HAS_IPV6
|
||||
#if DDSRT_HAVE_IPV6
|
||||
if (config.transport_selector == TRANS_UDP6)
|
||||
{
|
||||
ddsi_udp_factory_g.m_kind = NN_LOCATOR_KIND_UDPv6;
|
||||
|
|
|
@ -11,7 +11,7 @@
|
|||
*/
|
||||
#include <string.h>
|
||||
|
||||
#include "ddsi/ddsi_vendor.h"
|
||||
#include "dds/ddsi/ddsi_vendor.h"
|
||||
|
||||
extern inline bool vendor_equals (nn_vendorid_t a, nn_vendorid_t b);
|
||||
extern inline bool vendor_is_rti (nn_vendorid_t vendor);
|
||||
|
|
|
@ -13,14 +13,15 @@
|
|||
#include <stddef.h>
|
||||
#include <assert.h>
|
||||
|
||||
#include "os/os.h"
|
||||
|
||||
#include "util/ut_avl.h"
|
||||
#include "ddsi/q_log.h"
|
||||
#include "ddsi/q_misc.h"
|
||||
#include "ddsi/q_config.h"
|
||||
#include "ddsi/q_addrset.h"
|
||||
#include "ddsi/q_globals.h" /* gv.mattr */
|
||||
#include "dds/ddsrt/heap.h"
|
||||
#include "dds/ddsrt/log.h"
|
||||
#include "dds/ddsrt/string.h"
|
||||
#include "dds/util/ut_avl.h"
|
||||
#include "dds/ddsi/q_log.h"
|
||||
#include "dds/ddsi/q_misc.h"
|
||||
#include "dds/ddsi/q_config.h"
|
||||
#include "dds/ddsi/q_addrset.h"
|
||||
#include "dds/ddsi/q_globals.h" /* gv.mattr */
|
||||
|
||||
/* So what does one do with const & mutexes? I need to take lock in a
|
||||
pure function just in case some other thread is trying to change
|
||||
|
@ -31,9 +32,9 @@
|
|||
|
||||
Today, I'm taking the latter interpretation. But all the
|
||||
const-discarding casts get moved into LOCK/UNLOCK macros. */
|
||||
#define LOCK(as) (os_mutexLock (&((struct addrset *) (as))->lock))
|
||||
#define TRYLOCK(as) (os_mutexTryLock (&((struct addrset *) (as))->lock))
|
||||
#define UNLOCK(as) (os_mutexUnlock (&((struct addrset *) (as))->lock))
|
||||
#define LOCK(as) (ddsrt_mutex_lock (&((struct addrset *) (as))->lock))
|
||||
#define TRYLOCK(as) (ddsrt_mutex_trylock (&((struct addrset *) (as))->lock))
|
||||
#define UNLOCK(as) (ddsrt_mutex_unlock (&((struct addrset *) (as))->lock))
|
||||
|
||||
static int compare_locators_vwrap (const void *va, const void *vb);
|
||||
|
||||
|
@ -125,7 +126,7 @@ static int add_addresses_to_addrset_1 (struct addrset *as, const char *ip, int p
|
|||
return 0;
|
||||
}
|
||||
|
||||
OS_WARNING_MSVC_OFF(4996);
|
||||
DDSRT_WARNING_MSVC_OFF(4996);
|
||||
int add_addresses_to_addrset (struct addrset *as, const char *addrs, int port_mode, const char *msgtag, int req_mc)
|
||||
{
|
||||
/* port_mode: -1 => take from string, if 0 & unicast, add for a range of participant indices;
|
||||
|
@ -133,10 +134,10 @@ int add_addresses_to_addrset (struct addrset *as, const char *addrs, int port_mo
|
|||
*/
|
||||
char *addrs_copy, *ip, *cursor, *a;
|
||||
int retval = -1;
|
||||
addrs_copy = os_strdup (addrs);
|
||||
ip = os_malloc (strlen (addrs) + 1);
|
||||
addrs_copy = ddsrt_strdup (addrs);
|
||||
ip = ddsrt_malloc (strlen (addrs) + 1);
|
||||
cursor = addrs_copy;
|
||||
while ((a = os_strsep (&cursor, ",")) != NULL)
|
||||
while ((a = ddsrt_strsep (&cursor, ",")) != NULL)
|
||||
{
|
||||
int port = 0, pos;
|
||||
int mcgen_base = -1, mcgen_count = -1, mcgen_idx = -1;
|
||||
|
@ -174,11 +175,11 @@ int add_addresses_to_addrset (struct addrset *as, const char *addrs, int port_mo
|
|||
}
|
||||
retval = 0;
|
||||
error:
|
||||
os_free (ip);
|
||||
os_free (addrs_copy);
|
||||
ddsrt_free (ip);
|
||||
ddsrt_free (addrs_copy);
|
||||
return retval;
|
||||
}
|
||||
OS_WARNING_MSVC_ON(4996);
|
||||
DDSRT_WARNING_MSVC_ON(4996);
|
||||
|
||||
int compare_locators (const nn_locator_t *a, const nn_locator_t *b)
|
||||
{
|
||||
|
@ -198,9 +199,9 @@ static int compare_locators_vwrap (const void *va, const void *vb)
|
|||
|
||||
struct addrset *new_addrset (void)
|
||||
{
|
||||
struct addrset *as = os_malloc (sizeof (*as));
|
||||
os_atomic_st32 (&as->refc, 1);
|
||||
os_mutexInit (&as->lock);
|
||||
struct addrset *as = ddsrt_malloc (sizeof (*as));
|
||||
ddsrt_atomic_st32 (&as->refc, 1);
|
||||
ddsrt_mutex_init (&as->lock);
|
||||
ut_avlCInit (&addrset_treedef, &as->ucaddrs);
|
||||
ut_avlCInit (&addrset_treedef, &as->mcaddrs);
|
||||
return as;
|
||||
|
@ -210,19 +211,19 @@ struct addrset *ref_addrset (struct addrset *as)
|
|||
{
|
||||
if (as != NULL)
|
||||
{
|
||||
os_atomic_inc32 (&as->refc);
|
||||
ddsrt_atomic_inc32 (&as->refc);
|
||||
}
|
||||
return as;
|
||||
}
|
||||
|
||||
void unref_addrset (struct addrset *as)
|
||||
{
|
||||
if ((as != NULL) && (os_atomic_dec32_ov (&as->refc) == 1))
|
||||
if ((as != NULL) && (ddsrt_atomic_dec32_ov (&as->refc) == 1))
|
||||
{
|
||||
ut_avlCFree (&addrset_treedef, &as->ucaddrs, os_free);
|
||||
ut_avlCFree (&addrset_treedef, &as->mcaddrs, os_free);
|
||||
os_mutexDestroy (&as->lock);
|
||||
os_free (as);
|
||||
ut_avlCFree (&addrset_treedef, &as->ucaddrs, ddsrt_free);
|
||||
ut_avlCFree (&addrset_treedef, &as->mcaddrs, ddsrt_free);
|
||||
ddsrt_mutex_destroy (&as->lock);
|
||||
ddsrt_free (as);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -299,8 +300,8 @@ int addrset_any_non_ssm_mc (const struct addrset *as, nn_locator_t *dst)
|
|||
int addrset_purge (struct addrset *as)
|
||||
{
|
||||
LOCK (as);
|
||||
ut_avlCFree (&addrset_treedef, &as->ucaddrs, os_free);
|
||||
ut_avlCFree (&addrset_treedef, &as->mcaddrs, os_free);
|
||||
ut_avlCFree (&addrset_treedef, &as->ucaddrs, ddsrt_free);
|
||||
ut_avlCFree (&addrset_treedef, &as->mcaddrs, ddsrt_free);
|
||||
UNLOCK (as);
|
||||
return 0;
|
||||
}
|
||||
|
@ -314,7 +315,7 @@ void add_to_addrset (struct addrset *as, const nn_locator_t *loc)
|
|||
LOCK (as);
|
||||
if (ut_avlCLookupIPath (&addrset_treedef, tree, loc, &path) == NULL)
|
||||
{
|
||||
struct addrset_node *n = os_malloc (sizeof (*n));
|
||||
struct addrset_node *n = ddsrt_malloc (sizeof (*n));
|
||||
n->loc = *loc;
|
||||
ut_avlCInsertIPath (&addrset_treedef, tree, n, &path);
|
||||
}
|
||||
|
@ -331,7 +332,7 @@ void remove_from_addrset (struct addrset *as, const nn_locator_t *loc)
|
|||
if ((n = ut_avlCLookupDPath (&addrset_treedef, tree, loc, &path)) != NULL)
|
||||
{
|
||||
ut_avlCDeleteDPath (&addrset_treedef, tree, n, &path);
|
||||
os_free (n);
|
||||
ddsrt_free (n);
|
||||
}
|
||||
UNLOCK (as);
|
||||
}
|
||||
|
@ -395,7 +396,7 @@ void addrset_purge_ssm (struct addrset *as)
|
|||
if (ddsi_is_ssm_mcaddr (&n1->loc))
|
||||
{
|
||||
ut_avlCDelete (&addrset_treedef, &as->mcaddrs, n1);
|
||||
os_free (n1);
|
||||
ddsrt_free (n1);
|
||||
}
|
||||
}
|
||||
UNLOCK (as);
|
||||
|
@ -608,7 +609,7 @@ int addrset_eq_onesidederr (const struct addrset *a, const struct addrset *b)
|
|||
if (a == NULL || b == NULL)
|
||||
return 0;
|
||||
LOCK (a);
|
||||
if (TRYLOCK (b) == os_resultSuccess)
|
||||
if (TRYLOCK (b))
|
||||
{
|
||||
iseq =
|
||||
addrset_eq_onesidederr1 (&a->ucaddrs, &b->ucaddrs) &&
|
||||
|
|
|
@ -9,7 +9,7 @@
|
|||
*
|
||||
* SPDX-License-Identifier: EPL-2.0 OR BSD-3-Clause
|
||||
*/
|
||||
#include "ddsi/q_bitset.h"
|
||||
#include "dds/ddsi/q_bitset.h"
|
||||
|
||||
extern inline int nn_bitset_isset (unsigned numbits, const unsigned *bits, unsigned idx);
|
||||
extern inline void nn_bitset_set (unsigned numbits, unsigned *bits, unsigned idx);
|
||||
|
|
|
@ -9,7 +9,7 @@
|
|||
*
|
||||
* SPDX-License-Identifier: EPL-2.0 OR BSD-3-Clause
|
||||
*/
|
||||
#include "ddsi/q_bswap.h"
|
||||
#include "dds/ddsi/q_bswap.h"
|
||||
|
||||
nn_guid_prefix_t nn_hton_guid_prefix (nn_guid_prefix_t p)
|
||||
{
|
||||
|
|
|
@ -9,7 +9,7 @@
|
|||
*
|
||||
* SPDX-License-Identifier: EPL-2.0 OR BSD-3-Clause
|
||||
*/
|
||||
#include "ddsi/q_bswap.h"
|
||||
#include "dds/ddsi/q_bswap.h"
|
||||
|
||||
extern inline uint16_t bswap2u (uint16_t x);
|
||||
extern inline uint32_t bswap4u (uint32_t x);
|
||||
|
|
|
@ -17,21 +17,23 @@
|
|||
#include <limits.h>
|
||||
#include <string.h>
|
||||
|
||||
#include "os/os.h"
|
||||
#include "dds/ddsrt/heap.h"
|
||||
#include "dds/ddsrt/log.h"
|
||||
#include "dds/ddsrt/string.h"
|
||||
#include "dds/ddsrt/strtod.h"
|
||||
#include "dds/ddsi/q_config.h"
|
||||
#include "dds/ddsi/q_log.h"
|
||||
#include "dds/util/ut_avl.h"
|
||||
#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/ddsi/q_error.h"
|
||||
|
||||
#include "ddsi/q_config.h"
|
||||
#include "ddsi/q_log.h"
|
||||
#include "util/ut_avl.h"
|
||||
#include "ddsi/q_unused.h"
|
||||
#include "ddsi/q_misc.h"
|
||||
#include "ddsi/q_addrset.h"
|
||||
#include "ddsi/q_nwif.h"
|
||||
#include "ddsi/q_error.h"
|
||||
#include "dds/util/ut_xmlparser.h"
|
||||
#include "dds/util/ut_expand_envvars.h"
|
||||
|
||||
#include "util/ut_xmlparser.h"
|
||||
#include "util/ut_expand_envvars.h"
|
||||
|
||||
#include "ddsc/ddsc_project.h"
|
||||
#include "dds/version.h"
|
||||
|
||||
#define WARN_DEPRECATED_ALIAS 1
|
||||
#define WARN_DEPRECATED_UNIT 1
|
||||
|
@ -789,7 +791,7 @@ static const struct cfgelem tracing_cfgelems[] = {
|
|||
<li><i>finest</i>: <i>finer</i> + trace</li></ul>\n\
|
||||
<p>While <i>none</i> prevents any message from being written to a DDSI2 log file.</p>\n\
|
||||
<p>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 <i>config</i>, <i>fine</i> and <i>finest</i>.</p>" },
|
||||
{ LEAF("OutputFile"), 1, DDSC_PROJECT_NAME_NOSPACE_SMALL".log", ABSOFF(tracingOutputFileName), 0, uf_tracingOutputFileName, ff_free, pf_string,
|
||||
{ LEAF("OutputFile"), 1, DDS_PROJECT_NAME_NOSPACE_SMALL".log", ABSOFF(tracingOutputFileName), 0, uf_tracingOutputFileName, ff_free, pf_string,
|
||||
"<p>This option specifies where the logging is printed to. Note that <i>stdout</i> and <i>stderr</i> 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.</p>" },
|
||||
{ LEAF_W_ATTRS("Timestamps", timestamp_cfgattrs), 1, "true", ABSOFF(tracingTimestamps), 0, uf_boolean, 0, pf_boolean,
|
||||
"<p>This option has no effect.</p>" },
|
||||
|
@ -896,7 +898,7 @@ static const struct cfgelem root_cfgelems[] = {
|
|||
|
||||
static const struct cfgelem cyclonedds_root_cfgelems[] =
|
||||
{
|
||||
{ DDSC_PROJECT_NAME_NOSPACE, root_cfgelems, NULL, NODATA, NULL },
|
||||
{ DDS_PROJECT_NAME_NOSPACE, root_cfgelems, NULL, NODATA, NULL },
|
||||
END_MARKER
|
||||
};
|
||||
|
||||
|
@ -1010,16 +1012,16 @@ struct cfg_note_buf {
|
|||
static size_t cfg_note_vsnprintf(struct cfg_note_buf *bb, const char *fmt, va_list ap)
|
||||
{
|
||||
int x;
|
||||
x = os_vsnprintf(bb->buf + bb->bufpos, bb->bufsize - bb->bufpos, fmt, ap);
|
||||
x = vsnprintf(bb->buf + bb->bufpos, bb->bufsize - bb->bufpos, fmt, ap);
|
||||
if ( x >= 0 && (size_t) x >= bb->bufsize - bb->bufpos ) {
|
||||
size_t nbufsize = ((bb->bufsize + (size_t) x + 1) + 1023) & (size_t) (-1024);
|
||||
char *nbuf = os_realloc(bb->buf, nbufsize);
|
||||
char *nbuf = ddsrt_realloc(bb->buf, nbufsize);
|
||||
bb->buf = nbuf;
|
||||
bb->bufsize = nbufsize;
|
||||
return nbufsize;
|
||||
}
|
||||
if ( x < 0 )
|
||||
DDS_FATAL("cfg_note_vsnprintf: os_vsnprintf failed\n");
|
||||
DDS_FATAL("cfg_note_vsnprintf: vsnprintf failed\n");
|
||||
else
|
||||
bb->bufpos += (size_t) x;
|
||||
return 0;
|
||||
|
@ -1038,9 +1040,9 @@ static void cfg_note_snprintf(struct cfg_note_buf *bb, const char *fmt, ...)
|
|||
if ( r > 0 ) {
|
||||
int s;
|
||||
va_start(ap, fmt);
|
||||
s = os_vsnprintf(bb->buf + bb->bufpos, bb->bufsize - bb->bufpos, fmt, ap);
|
||||
s = vsnprintf(bb->buf + bb->bufpos, bb->bufsize - bb->bufpos, fmt, ap);
|
||||
if ( s < 0 || (size_t) s >= bb->bufsize - bb->bufpos )
|
||||
DDS_FATAL("cfg_note_snprintf: os_vsnprintf failed\n");
|
||||
DDS_FATAL("cfg_note_snprintf: vsnprintf failed\n");
|
||||
va_end(ap);
|
||||
bb->bufpos += (size_t) s;
|
||||
}
|
||||
|
@ -1063,7 +1065,7 @@ static size_t cfg_note(struct cfgst *cfgst, uint32_t cat, size_t bsz, const char
|
|||
|
||||
bb.bufpos = 0;
|
||||
bb.bufsize = (bsz == 0) ? 1024 : bsz;
|
||||
if ( (bb.buf = os_malloc(bb.bufsize)) == NULL )
|
||||
if ( (bb.buf = ddsrt_malloc(bb.bufsize)) == NULL )
|
||||
DDS_FATAL("cfg_note: out of memory\n");
|
||||
|
||||
cfg_note_snprintf(&bb, "config: ");
|
||||
|
@ -1092,7 +1094,7 @@ static size_t cfg_note(struct cfgst *cfgst, uint32_t cat, size_t bsz, const char
|
|||
/* Can't reset ap ... and va_copy isn't widely available - so
|
||||
instead abort and hope the caller tries again with a larger
|
||||
initial buffer */
|
||||
os_free(bb.buf);
|
||||
ddsrt_free(bb.buf);
|
||||
return r;
|
||||
}
|
||||
|
||||
|
@ -1111,7 +1113,7 @@ static size_t cfg_note(struct cfgst *cfgst, uint32_t cat, size_t bsz, const char
|
|||
break;
|
||||
}
|
||||
|
||||
os_free(bb.buf);
|
||||
ddsrt_free(bb.buf);
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
@ -1156,7 +1158,7 @@ static int list_index(const char *list[], const char *elem)
|
|||
{
|
||||
int i;
|
||||
for ( i = 0; list[i] != NULL; i++ ) {
|
||||
if ( os_strcasecmp(list[i], elem) == 0 )
|
||||
if ( ddsrt_strcasecmp(list[i], elem) == 0 )
|
||||
return i;
|
||||
}
|
||||
return -1;
|
||||
|
@ -1208,7 +1210,7 @@ static void *cfg_deref_address(UNUSED_ARG(struct cfgst *cfgst), void *parent, st
|
|||
static void *if_common(UNUSED_ARG(struct cfgst *cfgst), void *parent, struct cfgelem const * const cfgelem, unsigned size)
|
||||
{
|
||||
struct config_listelem **current = (struct config_listelem **) ((char *) parent + cfgelem->elem_offset);
|
||||
struct config_listelem *new = os_malloc(size);
|
||||
struct config_listelem *new = ddsrt_malloc(size);
|
||||
new->next = *current;
|
||||
*current = new;
|
||||
return new;
|
||||
|
@ -1289,7 +1291,7 @@ static int if_peer(struct cfgst *cfgst, void *parent, struct cfgelem const * con
|
|||
static void ff_free(struct cfgst *cfgst, void *parent, struct cfgelem const * const cfgelem)
|
||||
{
|
||||
void **elem = cfg_address(cfgst, parent, cfgelem);
|
||||
os_free(*elem);
|
||||
ddsrt_free(*elem);
|
||||
}
|
||||
|
||||
static int uf_boolean(struct cfgst *cfgst, void *parent, struct cfgelem const * const cfgelem, UNUSED_ARG(int first), const char *value)
|
||||
|
@ -1350,17 +1352,17 @@ static int uf_logcat(struct cfgst *cfgst, UNUSED_ARG(void *parent), UNUSED_ARG(s
|
|||
{
|
||||
static const char **vs = logcat_names;
|
||||
static const uint32_t *lc = logcat_codes;
|
||||
char *copy = os_strdup(value), *cursor = copy, *tok;
|
||||
while ( (tok = os_strsep(&cursor, ",")) != NULL ) {
|
||||
char *copy = ddsrt_strdup(value), *cursor = copy, *tok;
|
||||
while ( (tok = ddsrt_strsep(&cursor, ",")) != NULL ) {
|
||||
int idx = list_index(vs, tok);
|
||||
if ( idx < 0 ) {
|
||||
int ret = cfg_error(cfgst, "'%s' in '%s' undefined", tok, value);
|
||||
os_free(copy);
|
||||
ddsrt_free(copy);
|
||||
return ret;
|
||||
}
|
||||
enabled_logcats |= lc[idx];
|
||||
}
|
||||
os_free(copy);
|
||||
ddsrt_free(copy);
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
@ -1497,11 +1499,11 @@ static void pf_retransmit_merging(struct cfgst *cfgst, void *parent, struct cfge
|
|||
static int uf_string(struct cfgst *cfgst, void *parent, struct cfgelem const * const cfgelem, UNUSED_ARG(int first), const char *value)
|
||||
{
|
||||
char **elem = cfg_address(cfgst, parent, cfgelem);
|
||||
*elem = os_strdup(value);
|
||||
*elem = ddsrt_strdup(value);
|
||||
return 1;
|
||||
}
|
||||
|
||||
OS_WARNING_MSVC_OFF(4996);
|
||||
DDSRT_WARNING_MSVC_OFF(4996);
|
||||
static int uf_natint64_unit(struct cfgst *cfgst, int64_t *elem, const char *value, const struct unit *unittab, int64_t def_mult, int64_t max)
|
||||
{
|
||||
int pos;
|
||||
|
@ -1531,7 +1533,7 @@ static int uf_natint64_unit(struct cfgst *cfgst, int64_t *elem, const char *valu
|
|||
return cfg_error(cfgst, "%s: invalid value", value);
|
||||
}
|
||||
}
|
||||
OS_WARNING_MSVC_ON(4996);
|
||||
DDSRT_WARNING_MSVC_ON(4996);
|
||||
|
||||
#ifdef DDSI_INCLUDE_BANDWIDTH_LIMITING
|
||||
static int uf_bandwidth(struct cfgst *cfgst, void *parent, struct cfgelem const * const cfgelem, UNUSED_ARG(int first), const char *value)
|
||||
|
@ -1589,7 +1591,7 @@ static int uf_tracingOutputFileName(struct cfgst *cfgst, UNUSED_ARG(void *parent
|
|||
{
|
||||
struct config *cfg = cfgst->cfg;
|
||||
{
|
||||
cfg->tracingOutputFileName = os_strdup(value);
|
||||
cfg->tracingOutputFileName = ddsrt_strdup(value);
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
|
@ -1602,7 +1604,7 @@ static int uf_ipv4(struct cfgst *cfgst, void *parent, struct cfgelem const * con
|
|||
|
||||
static int uf_networkAddress(struct cfgst *cfgst, void *parent, struct cfgelem const * const cfgelem, int first, const char *value)
|
||||
{
|
||||
if ( os_strcasecmp(value, "auto") != 0 )
|
||||
if ( ddsrt_strcasecmp(value, "auto") != 0 )
|
||||
return uf_ipv4(cfgst, parent, cfgelem, first, value);
|
||||
else {
|
||||
char **elem = cfg_address(cfgst, parent, cfgelem);
|
||||
|
@ -1616,17 +1618,17 @@ static void ff_networkAddresses(struct cfgst *cfgst, void *parent, struct cfgele
|
|||
char ***elem = cfg_address(cfgst, parent, cfgelem);
|
||||
int i;
|
||||
for ( i = 0; (*elem)[i]; i++ )
|
||||
os_free((*elem)[i]);
|
||||
os_free(*elem);
|
||||
ddsrt_free((*elem)[i]);
|
||||
ddsrt_free(*elem);
|
||||
}
|
||||
|
||||
static int uf_networkAddresses_simple(struct cfgst *cfgst, void *parent, struct cfgelem const * const cfgelem, UNUSED_ARG(int first), const char *value)
|
||||
{
|
||||
char ***elem = cfg_address(cfgst, parent, cfgelem);
|
||||
if ( (*elem = os_malloc(2 * sizeof(char *))) == NULL )
|
||||
if ( (*elem = ddsrt_malloc(2 * sizeof(char *))) == NULL )
|
||||
return cfg_error(cfgst, "out of memory");
|
||||
if ( ((*elem)[0] = os_strdup(value)) == NULL ) {
|
||||
os_free(*elem);
|
||||
if ( ((*elem)[0] = ddsrt_strdup(value)) == NULL ) {
|
||||
ddsrt_free(*elem);
|
||||
*elem = NULL;
|
||||
return cfg_error(cfgst, "out of memory");
|
||||
}
|
||||
|
@ -1641,7 +1643,7 @@ static int uf_networkAddresses(struct cfgst *cfgst, void *parent, struct cfgelem
|
|||
static const char *keywords[] = { "all", "any", "none" };
|
||||
int i;
|
||||
for ( i = 0; i < (int) (sizeof(keywords) / sizeof(*keywords)); i++ ) {
|
||||
if ( os_strcasecmp(value, keywords[i]) == 0 )
|
||||
if ( ddsrt_strcasecmp(value, keywords[i]) == 0 )
|
||||
return uf_networkAddresses_simple(cfgst, parent, cfgelem, first, keywords[i]);
|
||||
}
|
||||
}
|
||||
|
@ -1662,23 +1664,23 @@ static int uf_networkAddresses(struct cfgst *cfgst, void *parent, struct cfgelem
|
|||
count += (*scan++ == ',');
|
||||
}
|
||||
|
||||
copy = os_strdup(value);
|
||||
copy = ddsrt_strdup(value);
|
||||
|
||||
/* Allocate an array of address strings (which may be oversized a
|
||||
bit because of the counting of the commas) */
|
||||
*elem = os_malloc((count + 1) * sizeof(char *));
|
||||
*elem = ddsrt_malloc((count + 1) * sizeof(char *));
|
||||
|
||||
{
|
||||
char *cursor = copy, *tok;
|
||||
unsigned idx = 0;
|
||||
while ( (tok = os_strsep(&cursor, ",")) != NULL ) {
|
||||
while ( (tok = ddsrt_strsep(&cursor, ",")) != NULL ) {
|
||||
assert(idx < count);
|
||||
(*elem)[idx] = os_strdup(tok);
|
||||
(*elem)[idx] = ddsrt_strdup(tok);
|
||||
idx++;
|
||||
}
|
||||
(*elem)[idx] = NULL;
|
||||
}
|
||||
os_free(copy);
|
||||
ddsrt_free(copy);
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
|
@ -1692,21 +1694,21 @@ static int uf_allow_multicast(struct cfgst *cfgst, void *parent, struct cfgelem
|
|||
static const char *vs[] = { "false", "spdp", "asm", "true", NULL };
|
||||
static const unsigned bs[] = { AMC_FALSE, AMC_SPDP, AMC_ASM, AMC_TRUE };
|
||||
#endif
|
||||
char *copy = os_strdup(value), *cursor = copy, *tok;
|
||||
char *copy = ddsrt_strdup(value), *cursor = copy, *tok;
|
||||
unsigned *elem = cfg_address(cfgst, parent, cfgelem);
|
||||
if ( copy == NULL )
|
||||
return cfg_error(cfgst, "out of memory");
|
||||
*elem = 0;
|
||||
while ( (tok = os_strsep(&cursor, ",")) != NULL ) {
|
||||
while ( (tok = ddsrt_strsep(&cursor, ",")) != NULL ) {
|
||||
int idx = list_index(vs, tok);
|
||||
if ( idx < 0 ) {
|
||||
int ret = cfg_error(cfgst, "'%s' in '%s' undefined", tok, value);
|
||||
os_free(copy);
|
||||
ddsrt_free(copy);
|
||||
return ret;
|
||||
}
|
||||
*elem |= bs[idx];
|
||||
}
|
||||
os_free(copy);
|
||||
ddsrt_free(copy);
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
@ -1737,10 +1739,10 @@ static int uf_sched_prio_class(struct cfgst *cfgst, void *parent, struct cfgelem
|
|||
|
||||
prio = cfg_address(cfgst, parent, cfgelem);
|
||||
|
||||
if ( os_strcasecmp(value, "relative") == 0 ) {
|
||||
if ( ddsrt_strcasecmp(value, "relative") == 0 ) {
|
||||
*prio = Q__SCHED_PRIO_RELATIVE;
|
||||
ret = 1;
|
||||
} else if ( os_strcasecmp(value, "absolute") == 0 ) {
|
||||
} else if ( ddsrt_strcasecmp(value, "absolute") == 0 ) {
|
||||
*prio = Q__SCHED_PRIO_ABSOLUTE;
|
||||
ret = 1;
|
||||
} else {
|
||||
|
@ -1769,9 +1771,9 @@ static void pf_sched_prio_class(struct cfgst *cfgst, void *parent, struct cfgele
|
|||
static int uf_sched_class(struct cfgst *cfgst, void *parent, struct cfgelem const * const cfgelem, UNUSED_ARG(int first), const char *value)
|
||||
{
|
||||
static const char *vs[] = { "realtime", "timeshare", "default" };
|
||||
static const os_schedClass ms[] = { OS_SCHED_REALTIME, OS_SCHED_TIMESHARE, OS_SCHED_DEFAULT };
|
||||
static const ddsrt_sched_t ms[] = { DDSRT_SCHED_REALTIME, DDSRT_SCHED_TIMESHARE, DDSRT_SCHED_DEFAULT };
|
||||
int idx = list_index(vs, value);
|
||||
os_schedClass *elem = cfg_address(cfgst, parent, cfgelem);
|
||||
ddsrt_sched_t *elem = cfg_address(cfgst, parent, cfgelem);
|
||||
assert(sizeof(vs) / sizeof(*vs) == sizeof(ms) / sizeof(*ms));
|
||||
if ( idx < 0 )
|
||||
return cfg_error(cfgst, "'%s': undefined value", value);
|
||||
|
@ -1781,22 +1783,22 @@ static int uf_sched_class(struct cfgst *cfgst, void *parent, struct cfgelem cons
|
|||
|
||||
static void pf_sched_class(struct cfgst *cfgst, void *parent, struct cfgelem const * const cfgelem, int is_default)
|
||||
{
|
||||
os_schedClass *p = cfg_address(cfgst, parent, cfgelem);
|
||||
ddsrt_sched_t *p = cfg_address(cfgst, parent, cfgelem);
|
||||
const char *str = "INVALID";
|
||||
switch ( *p ) {
|
||||
case OS_SCHED_DEFAULT: str = "default"; break;
|
||||
case OS_SCHED_TIMESHARE: str = "timeshare"; break;
|
||||
case OS_SCHED_REALTIME: str = "realtime"; break;
|
||||
case DDSRT_SCHED_DEFAULT: str = "default"; break;
|
||||
case DDSRT_SCHED_TIMESHARE: str = "timeshare"; break;
|
||||
case DDSRT_SCHED_REALTIME: str = "realtime"; break;
|
||||
}
|
||||
cfg_log(cfgst, "%s%s", str, is_default ? " [def]" : "");
|
||||
}
|
||||
|
||||
OS_WARNING_MSVC_OFF(4996);
|
||||
DDSRT_WARNING_MSVC_OFF(4996);
|
||||
static int uf_maybe_int32(struct cfgst *cfgst, void *parent, struct cfgelem const * const cfgelem, UNUSED_ARG(int first), const char *value)
|
||||
{
|
||||
struct config_maybe_int32 *elem = cfg_address(cfgst, parent, cfgelem);
|
||||
int pos;
|
||||
if ( os_strcasecmp(value, "default") == 0 ) {
|
||||
if ( ddsrt_strcasecmp(value, "default") == 0 ) {
|
||||
elem->isdefault = 1;
|
||||
elem->value = 0;
|
||||
return 1;
|
||||
|
@ -1807,13 +1809,13 @@ static int uf_maybe_int32(struct cfgst *cfgst, void *parent, struct cfgelem cons
|
|||
return cfg_error(cfgst, "'%s': neither 'default' nor a decimal integer\n", value);
|
||||
}
|
||||
}
|
||||
OS_WARNING_MSVC_ON(4996);
|
||||
DDSRT_WARNING_MSVC_ON(4996);
|
||||
|
||||
static int uf_maybe_memsize(struct cfgst *cfgst, void *parent, struct cfgelem const * const cfgelem, UNUSED_ARG(int first), const char *value)
|
||||
{
|
||||
struct config_maybe_uint32 *elem = cfg_address(cfgst, parent, cfgelem);
|
||||
int64_t size = 0;
|
||||
if ( os_strcasecmp(value, "default") == 0 ) {
|
||||
if ( ddsrt_strcasecmp(value, "default") == 0 ) {
|
||||
elem->isdefault = 1;
|
||||
elem->value = 0;
|
||||
return 1;
|
||||
|
@ -1831,8 +1833,9 @@ static int uf_float(struct cfgst *cfgst, void *parent, struct cfgelem const * co
|
|||
{
|
||||
float *elem = cfg_address(cfgst, parent, cfgelem);
|
||||
char *endptr;
|
||||
float f = os_strtof(value, &endptr);
|
||||
if ( *value == 0 || *endptr != 0 )
|
||||
float f;
|
||||
dds_retcode_t rc = ddsrt_strtof(value, &endptr, &f);
|
||||
if (rc != DDS_RETCODE_OK || *value == 0 || *endptr != 0 )
|
||||
return cfg_error(cfgst, "%s: not a floating point number", value);
|
||||
*elem = f;
|
||||
return 1;
|
||||
|
@ -1858,7 +1861,7 @@ static int uf_duration_gen(struct cfgst *cfgst, void *parent, struct cfgelem con
|
|||
|
||||
static int uf_duration_inf(struct cfgst *cfgst, void *parent, struct cfgelem const * const cfgelem, UNUSED_ARG(int first), const char *value)
|
||||
{
|
||||
if ( os_strcasecmp(value, "inf") == 0 ) {
|
||||
if ( ddsrt_strcasecmp(value, "inf") == 0 ) {
|
||||
int64_t *elem = cfg_address(cfgst, parent, cfgelem);
|
||||
*elem = T_NEVER;
|
||||
return 1;
|
||||
|
@ -1934,12 +1937,12 @@ static int uf_int_min_max(struct cfgst *cfgst, void *parent, struct cfgelem cons
|
|||
return 1;
|
||||
}
|
||||
|
||||
OS_WARNING_MSVC_OFF(4996);
|
||||
DDSRT_WARNING_MSVC_OFF(4996);
|
||||
static int uf_domainId(struct cfgst *cfgst, void *parent, struct cfgelem const * const cfgelem, UNUSED_ARG(int first), const char *value)
|
||||
{
|
||||
struct config_maybe_int32 *elem = cfg_address(cfgst, parent, cfgelem);
|
||||
int pos;
|
||||
if (os_strcasecmp(value, "any") == 0) {
|
||||
if (ddsrt_strcasecmp(value, "any") == 0) {
|
||||
elem->isdefault = 1;
|
||||
elem->value = 0;
|
||||
return 1;
|
||||
|
@ -1950,15 +1953,15 @@ static int uf_domainId(struct cfgst *cfgst, void *parent, struct cfgelem const *
|
|||
return cfg_error(cfgst, "'%s': neither 'any' nor a decimal integer in 0 .. 230\n", value);
|
||||
}
|
||||
}
|
||||
OS_WARNING_MSVC_ON(4996);
|
||||
DDSRT_WARNING_MSVC_ON(4996);
|
||||
|
||||
static int uf_participantIndex(struct cfgst *cfgst, void *parent, struct cfgelem const * const cfgelem, int first, const char *value)
|
||||
{
|
||||
int *elem = cfg_address(cfgst, parent, cfgelem);
|
||||
if ( os_strcasecmp(value, "auto") == 0 ) {
|
||||
if ( ddsrt_strcasecmp(value, "auto") == 0 ) {
|
||||
*elem = PARTICIPANT_INDEX_AUTO;
|
||||
return 1;
|
||||
} else if ( os_strcasecmp(value, "none") == 0 ) {
|
||||
} else if ( ddsrt_strcasecmp(value, "none") == 0 ) {
|
||||
*elem = PARTICIPANT_INDEX_NONE;
|
||||
return 1;
|
||||
} else {
|
||||
|
@ -2058,7 +2061,7 @@ static int do_update(struct cfgst *cfgst, update_fun_t upd, void *parent, struct
|
|||
int ok;
|
||||
key.e = cfgelem;
|
||||
if ( (n = ut_avlLookupIPath(&cfgst_found_treedef, &cfgst->found, &key, &np)) == NULL ) {
|
||||
if ( (n = os_malloc(sizeof(*n))) == NULL )
|
||||
if ( (n = ddsrt_malloc(sizeof(*n))) == NULL )
|
||||
return cfg_error(cfgst, "out of memory");
|
||||
|
||||
n->key = key;
|
||||
|
@ -2107,7 +2110,7 @@ static int set_defaults(struct cfgst *cfgst, void *parent, int isattr, struct cf
|
|||
if ( (n = ut_avlLookup(&cfgst_found_treedef, &cfgst->found, &key)) != NULL ) {
|
||||
if ( clear_found ) {
|
||||
ut_avlDelete(&cfgst_found_treedef, &cfgst->found, n);
|
||||
os_free(n);
|
||||
ddsrt_free(n);
|
||||
}
|
||||
}
|
||||
if ( ce->children ) {
|
||||
|
@ -2443,7 +2446,7 @@ static void free_all_elements(struct cfgst *cfgst, void *parent, struct cfgelem
|
|||
free_all_elements(cfgst, p, ce->children);
|
||||
r = p;
|
||||
p = p->next;
|
||||
os_free(r);
|
||||
ddsrt_free(r);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -2478,7 +2481,7 @@ static void free_configured_elements(struct cfgst *cfgst, void *parent, struct c
|
|||
free_all_elements(cfgst, p, ce->children);
|
||||
r = p;
|
||||
p = p->next;
|
||||
os_free(r);
|
||||
ddsrt_free(r);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -2489,7 +2492,7 @@ static int matching_name_index(const char *name_w_aliases, const char *name)
|
|||
const char *ns = name_w_aliases, *p = strchr(ns, '|');
|
||||
int idx = 0;
|
||||
while ( p ) {
|
||||
if ( os_strncasecmp(ns, name, (size_t) (p - ns)) == 0 && name[p - ns] == 0 ) {
|
||||
if ( ddsrt_strncasecmp(ns, name, (size_t) (p - ns)) == 0 && name[p - ns] == 0 ) {
|
||||
/* ns upto the pipe symbol is a prefix of name, and name is terminated at that point */
|
||||
return idx;
|
||||
}
|
||||
|
@ -2498,13 +2501,13 @@ static int matching_name_index(const char *name_w_aliases, const char *name)
|
|||
p = strchr(ns, '|');
|
||||
idx++;
|
||||
}
|
||||
return (os_strcasecmp(ns, name) == 0) ? idx : -1;
|
||||
return (ddsrt_strcasecmp(ns, name) == 0) ? idx : -1;
|
||||
}
|
||||
|
||||
static const struct cfgelem *lookup_redirect(const char *target)
|
||||
{
|
||||
const struct cfgelem *cfgelem = ddsi2_cfgelems;
|
||||
char *target_copy = os_strdup(target), *p1;
|
||||
char *target_copy = ddsrt_strdup(target), *p1;
|
||||
const char *p = target_copy;
|
||||
while ( p ) {
|
||||
p1 = strchr(p, '/');
|
||||
|
@ -2520,7 +2523,7 @@ static const struct cfgelem *lookup_redirect(const char *target)
|
|||
}
|
||||
p = p1;
|
||||
}
|
||||
os_free(target_copy);
|
||||
ddsrt_free(target_copy);
|
||||
return cfgelem;
|
||||
}
|
||||
|
||||
|
@ -2601,7 +2604,7 @@ static int proc_attr(void *varg, UNUSED_ARG(uintptr_t eleminfo), const char *nam
|
|||
if ( cfgelem == NULL )
|
||||
return 1;
|
||||
for ( cfg_attr = cfgelem->attributes; cfg_attr && cfg_attr->name; cfg_attr++ ) {
|
||||
if ( os_strcasecmp(cfg_attr->name, name) == 0 )
|
||||
if ( ddsrt_strcasecmp(cfg_attr->name, name) == 0 )
|
||||
break;
|
||||
}
|
||||
if ( cfg_attr == NULL || cfg_attr->name == NULL )
|
||||
|
@ -2613,7 +2616,7 @@ static int proc_attr(void *varg, UNUSED_ARG(uintptr_t eleminfo), const char *nam
|
|||
cfgst_push(cfgst, 1, cfg_attr, parent);
|
||||
ok = do_update(cfgst, cfg_attr->update, parent, cfg_attr, xvalue, 0);
|
||||
cfgst_pop(cfgst);
|
||||
os_free(xvalue);
|
||||
ddsrt_free(xvalue);
|
||||
return ok;
|
||||
}
|
||||
}
|
||||
|
@ -2633,7 +2636,7 @@ static int proc_elem_data(void *varg, UNUSED_ARG(uintptr_t eleminfo), const char
|
|||
cfgst_push(cfgst, 0, NULL, parent);
|
||||
ok = do_update(cfgst, cfgelem->update, parent, cfgelem, xvalue, 0);
|
||||
cfgst_pop(cfgst);
|
||||
os_free(xvalue);
|
||||
ddsrt_free(xvalue);
|
||||
return ok;
|
||||
}
|
||||
}
|
||||
|
@ -2673,10 +2676,10 @@ static int set_default_channel(struct config *cfg)
|
|||
if ( cfg->channels == NULL ) {
|
||||
/* create one default channel if none configured */
|
||||
struct config_channel_listelem *c;
|
||||
if ( (c = os_malloc(sizeof(*c))) == NULL )
|
||||
if ( (c = ddsrt_malloc(sizeof(*c))) == NULL )
|
||||
return ERR_OUT_OF_MEMORY;
|
||||
c->next = NULL;
|
||||
c->name = os_strdup("user");
|
||||
c->name = ddsrt_strdup("user");
|
||||
c->priority = 0;
|
||||
c->resolution = 1 * T_MILLISECOND;
|
||||
#ifdef DDSI_INCLUDE_BANDWIDTH_LIMITING
|
||||
|
@ -2716,7 +2719,7 @@ static int sort_channels_check_nodups(struct config *cfg)
|
|||
n++;
|
||||
assert(n > 0);
|
||||
|
||||
ary = os_malloc(n * sizeof(*ary));
|
||||
ary = ddsrt_malloc(n * sizeof(*ary));
|
||||
|
||||
i = 0;
|
||||
for ( c = cfg->channels; c; c = c->next )
|
||||
|
@ -2740,15 +2743,12 @@ static int sort_channels_check_nodups(struct config *cfg)
|
|||
cfg->max_channel = ary[i];
|
||||
}
|
||||
|
||||
os_free(ary);
|
||||
ddsrt_free(ary);
|
||||
return result;
|
||||
}
|
||||
#endif /* DDSI_INCLUDE_NETWORK_CHANNELS */
|
||||
|
||||
struct cfgst * config_init
|
||||
(
|
||||
_In_opt_ const char *configfile
|
||||
)
|
||||
struct cfgst * config_init (const char *configfile)
|
||||
{
|
||||
int ok = 1;
|
||||
struct cfgst *cfgst;
|
||||
|
@ -2764,7 +2764,7 @@ struct cfgst * config_init
|
|||
ends up on the right value */
|
||||
config.domainId.value = 0;
|
||||
|
||||
cfgst = os_malloc(sizeof(*cfgst));
|
||||
cfgst = ddsrt_malloc(sizeof(*cfgst));
|
||||
memset(cfgst, 0, sizeof(*cfgst));
|
||||
|
||||
ut_avlInit(&cfgst_found_treedef, &cfgst->found);
|
||||
|
@ -2773,22 +2773,22 @@ struct cfgst * config_init
|
|||
|
||||
/* configfile == NULL will get you the default configuration */
|
||||
if ( configfile ) {
|
||||
char *copy = os_strdup(configfile), *cursor = copy, *tok;
|
||||
while ( (tok = os_strsep(&cursor, ",")) != NULL ) {
|
||||
char *copy = ddsrt_strdup(configfile), *cursor = copy, *tok;
|
||||
while ( (tok = ddsrt_strsep(&cursor, ",")) != NULL ) {
|
||||
struct ut_xmlpCallbacks cb;
|
||||
struct ut_xmlpState *qx;
|
||||
FILE *fp;
|
||||
|
||||
OS_WARNING_MSVC_OFF(4996);
|
||||
DDSRT_WARNING_MSVC_OFF(4996);
|
||||
if ( (fp = fopen(tok, "r")) == NULL ) {
|
||||
if ( strncmp(tok, "file://", 7) != 0 || (fp = fopen(tok + 7, "r")) == NULL ) {
|
||||
DDS_ERROR("can't open configuration file %s\n", tok);
|
||||
os_free(copy);
|
||||
os_free(cfgst);
|
||||
ddsrt_free(copy);
|
||||
ddsrt_free(cfgst);
|
||||
return NULL;
|
||||
}
|
||||
}
|
||||
OS_WARNING_MSVC_ON(4996);
|
||||
DDSRT_WARNING_MSVC_ON(4996);
|
||||
|
||||
cb.attr = proc_attr;
|
||||
cb.elem_close = proc_elem_close;
|
||||
|
@ -2798,8 +2798,8 @@ struct cfgst * config_init
|
|||
|
||||
if ( (qx = ut_xmlpNewFile(fp, cfgst, &cb)) == NULL ) {
|
||||
fclose(fp);
|
||||
os_free(copy);
|
||||
os_free(cfgst);
|
||||
ddsrt_free(copy);
|
||||
ddsrt_free(cfgst);
|
||||
return NULL;
|
||||
}
|
||||
cfgst_push(cfgst, 0, &root_cfgelem, &config);
|
||||
|
@ -2812,7 +2812,7 @@ struct cfgst * config_init
|
|||
ut_xmlpFree(qx);
|
||||
fclose(fp);
|
||||
}
|
||||
os_free(copy);
|
||||
ddsrt_free(copy);
|
||||
}
|
||||
|
||||
/* Set defaults for everything not set that we have a default value
|
||||
|
@ -2910,11 +2910,11 @@ struct cfgst * config_init
|
|||
config.nof_networkPartitions = 0;
|
||||
while ( p ) {
|
||||
#ifdef DDSI_INCLUDE_ENCRYPTION
|
||||
if ( os_strcasecmp(p->profileName, "null") == 0 )
|
||||
if ( ddsrt_strcasecmp(p->profileName, "null") == 0 )
|
||||
p->securityProfile = NULL;
|
||||
else {
|
||||
struct config_securityprofile_listelem *s = config.securityProfiles;
|
||||
while ( s && os_strcasecmp(p->profileName, s->name) != 0 )
|
||||
while ( s && ddsrt_strcasecmp(p->profileName, s->name) != 0 )
|
||||
s = s->next;
|
||||
if ( s )
|
||||
p->securityProfile = s;
|
||||
|
@ -2941,7 +2941,7 @@ struct cfgst * config_init
|
|||
struct config_partitionmapping_listelem * m = config.partitionMappings;
|
||||
while ( m ) {
|
||||
struct config_networkpartition_listelem * p = config.networkPartitions;
|
||||
while ( p && os_strcasecmp(m->networkPartition, p->name) != 0 ) {
|
||||
while ( p && ddsrt_strcasecmp(m->networkPartition, p->name) != 0 ) {
|
||||
p = p->next;
|
||||
}
|
||||
if ( p ) {
|
||||
|
@ -2966,20 +2966,20 @@ struct cfgst * config_init
|
|||
config.valid = 1;
|
||||
return cfgst;
|
||||
} else {
|
||||
ut_avlFree(&cfgst_found_treedef, &cfgst->found, os_free);
|
||||
os_free(cfgst);
|
||||
ut_avlFree(&cfgst_found_treedef, &cfgst->found, ddsrt_free);
|
||||
ddsrt_free(cfgst);
|
||||
return NULL;
|
||||
}
|
||||
}
|
||||
|
||||
void config_print_cfgst(_In_ struct cfgst *cfgst)
|
||||
void config_print_cfgst(struct cfgst *cfgst)
|
||||
{
|
||||
if ( cfgst == NULL )
|
||||
return;
|
||||
print_configitems(cfgst, cfgst->cfg, 0, root_cfgelems, 0);
|
||||
}
|
||||
|
||||
void config_fini(_In_ struct cfgst *cfgst)
|
||||
void config_fini(struct cfgst *cfgst)
|
||||
{
|
||||
assert(cfgst);
|
||||
assert(cfgst->cfg == &config);
|
||||
|
@ -2994,15 +2994,15 @@ void config_fini(_In_ struct cfgst *cfgst)
|
|||
memset(&config, 0, sizeof(config));
|
||||
config.valid = 0;
|
||||
|
||||
ut_avlFree(&cfgst_found_treedef, &cfgst->found, os_free);
|
||||
os_free(cfgst);
|
||||
ut_avlFree(&cfgst_found_treedef, &cfgst->found, ddsrt_free);
|
||||
ddsrt_free(cfgst);
|
||||
}
|
||||
|
||||
#ifdef DDSI_INCLUDE_NETWORK_PARTITIONS
|
||||
static char *get_partition_search_pattern(const char *partition, const char *topic)
|
||||
{
|
||||
size_t sz = strlen(partition) + strlen(topic) + 2;
|
||||
char *pt = os_malloc(sz);
|
||||
char *pt = ddsrt_malloc(sz);
|
||||
snprintf(pt, sz, "%s.%s", partition, topic);
|
||||
return pt;
|
||||
}
|
||||
|
@ -3014,7 +3014,7 @@ struct config_partitionmapping_listelem *find_partitionmapping(const char *parti
|
|||
for ( pm = config.partitionMappings; pm; pm = pm->next )
|
||||
if ( WildcardOverlap(pt, pm->DCPSPartitionTopic) )
|
||||
break;
|
||||
os_free(pt);
|
||||
ddsrt_free(pt);
|
||||
return pm;
|
||||
}
|
||||
|
||||
|
@ -3034,7 +3034,7 @@ int is_ignored_partition(const char *partition, const char *topic)
|
|||
for ( ip = config.ignoredPartitions; ip; ip = ip->next )
|
||||
if ( WildcardOverlap(pt, ip->DCPSPartitionTopic) )
|
||||
break;
|
||||
os_free(pt);
|
||||
ddsrt_free(pt);
|
||||
return ip != NULL;
|
||||
}
|
||||
#endif /* DDSI_INCLUDE_NETWORK_PARTITIONS */
|
||||
|
|
|
@ -15,31 +15,33 @@
|
|||
#include <string.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
#include "os/os.h"
|
||||
|
||||
#include "util/ut_avl.h"
|
||||
#include "ddsi/q_protocol.h"
|
||||
#include "ddsi/q_rtps.h"
|
||||
#include "ddsi/q_misc.h"
|
||||
#include "ddsi/q_config.h"
|
||||
#include "ddsi/q_log.h"
|
||||
#include "ddsi/q_plist.h"
|
||||
#include "ddsi/q_unused.h"
|
||||
#include "ddsi/q_xevent.h"
|
||||
#include "ddsi/q_addrset.h"
|
||||
#include "ddsi/q_ddsi_discovery.h"
|
||||
#include "ddsi/q_radmin.h"
|
||||
#include "ddsi/q_ephash.h"
|
||||
#include "ddsi/q_entity.h"
|
||||
#include "ddsi/q_globals.h"
|
||||
#include "ddsi/q_xmsg.h"
|
||||
#include "ddsi/q_bswap.h"
|
||||
#include "ddsi/q_transmit.h"
|
||||
#include "ddsi/q_lease.h"
|
||||
#include "ddsi/q_error.h"
|
||||
#include "ddsi/ddsi_serdata_default.h"
|
||||
#include "ddsi/q_md5.h"
|
||||
#include "ddsi/q_feature_check.h"
|
||||
#include "dds/version.h"
|
||||
#include "dds/ddsrt/heap.h"
|
||||
#include "dds/ddsrt/log.h"
|
||||
#include "dds/ddsrt/sync.h"
|
||||
#include "dds/util/ut_avl.h"
|
||||
#include "dds/ddsi/q_protocol.h"
|
||||
#include "dds/ddsi/q_rtps.h"
|
||||
#include "dds/ddsi/q_misc.h"
|
||||
#include "dds/ddsi/q_config.h"
|
||||
#include "dds/ddsi/q_log.h"
|
||||
#include "dds/ddsi/q_plist.h"
|
||||
#include "dds/ddsi/q_unused.h"
|
||||
#include "dds/ddsi/q_xevent.h"
|
||||
#include "dds/ddsi/q_addrset.h"
|
||||
#include "dds/ddsi/q_ddsi_discovery.h"
|
||||
#include "dds/ddsi/q_radmin.h"
|
||||
#include "dds/ddsi/q_ephash.h"
|
||||
#include "dds/ddsi/q_entity.h"
|
||||
#include "dds/ddsi/q_globals.h"
|
||||
#include "dds/ddsi/q_xmsg.h"
|
||||
#include "dds/ddsi/q_bswap.h"
|
||||
#include "dds/ddsi/q_transmit.h"
|
||||
#include "dds/ddsi/q_lease.h"
|
||||
#include "dds/ddsi/q_error.h"
|
||||
#include "dds/ddsi/ddsi_serdata_default.h"
|
||||
#include "dds/ddsi/q_md5.h"
|
||||
#include "dds/ddsi/q_feature_check.h"
|
||||
|
||||
static int get_locator (nn_locator_t *loc, const nn_locators_t *locs, int uc_same_subnet)
|
||||
{
|
||||
|
@ -95,7 +97,7 @@ static int get_locator (nn_locator_t *loc, const nn_locators_t *locs, int uc_sam
|
|||
}
|
||||
}
|
||||
|
||||
#if OS_SOCKET_HAS_IPV6
|
||||
#if DDSRT_HAVE_IPV6
|
||||
if ((l->loc.kind == NN_LOCATOR_KIND_UDPv6) || (l->loc.kind == NN_LOCATOR_KIND_TCPv6))
|
||||
{
|
||||
/* We (cowardly) refuse to accept advertised link-local
|
||||
|
@ -293,16 +295,16 @@ int spdp_write (struct participant *pp)
|
|||
NN_PRISMTECH_FL_SUPPORTS_STATUSINFOX;
|
||||
if (config.besmode == BESMODE_MINIMAL)
|
||||
ps.prismtech_participant_version_info.flags |= NN_PRISMTECH_FL_MINIMAL_BES_MODE;
|
||||
os_mutexLock (&gv.privileged_pp_lock);
|
||||
ddsrt_mutex_lock (&gv.privileged_pp_lock);
|
||||
if (pp->is_ddsi2_pp)
|
||||
ps.prismtech_participant_version_info.flags |= NN_PRISMTECH_FL_PARTICIPANT_IS_DDSI2;
|
||||
os_mutexUnlock (&gv.privileged_pp_lock);
|
||||
ddsrt_mutex_unlock (&gv.privileged_pp_lock);
|
||||
|
||||
os_gethostname(node, sizeof(node)-1);
|
||||
ddsrt_gethostname(node, sizeof(node)-1);
|
||||
node[sizeof(node)-1] = '\0';
|
||||
size = strlen(node) + strlen(OS_VERSION) + strlen(OS_HOST_NAME) + strlen(OS_TARGET_NAME) + 4; /* + ///'\0' */
|
||||
ps.prismtech_participant_version_info.internals = os_malloc(size);
|
||||
(void) snprintf(ps.prismtech_participant_version_info.internals, size, "%s/%s/%s/%s", node, OS_VERSION, OS_HOST_NAME, OS_TARGET_NAME);
|
||||
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);
|
||||
DDS_TRACE("spdp_write(%x:%x:%x:%x) - internals: %s\n", PGUID (pp->e.guid), ps.prismtech_participant_version_info.internals);
|
||||
}
|
||||
|
||||
|
@ -471,16 +473,16 @@ static void make_participants_dependent_on_ddsi2 (const nn_guid_t *ddsi2guid, nn
|
|||
struct lease *d2pp_lease;
|
||||
if ((d2pp = ephash_lookup_proxy_participant_guid (ddsi2guid)) == NULL)
|
||||
return;
|
||||
d2pp_lease = os_atomic_ldvoidp (&d2pp->lease);
|
||||
d2pp_lease = ddsrt_atomic_ldvoidp (&d2pp->lease);
|
||||
ephash_enum_proxy_participant_init (&it);
|
||||
while ((pp = ephash_enum_proxy_participant_next (&it)) != NULL)
|
||||
{
|
||||
if (vendor_is_eclipse_or_opensplice (pp->vendor) && pp->e.guid.prefix.u[0] == ddsi2guid->prefix.u[0] && !pp->is_ddsi2_pp)
|
||||
{
|
||||
DDS_TRACE("proxy participant %x:%x:%x:%x depends on ddsi2 %x:%x:%x:%x", PGUID (pp->e.guid), PGUID (*ddsi2guid));
|
||||
os_mutexLock (&pp->e.lock);
|
||||
ddsrt_mutex_lock (&pp->e.lock);
|
||||
pp->privileged_pp_guid = *ddsi2guid;
|
||||
os_mutexUnlock (&pp->e.lock);
|
||||
ddsrt_mutex_unlock (&pp->e.lock);
|
||||
proxy_participant_reassign_lease (pp, d2pp_lease);
|
||||
DDS_TRACE("\n");
|
||||
|
||||
|
@ -587,15 +589,15 @@ static int handle_SPDP_alive (const struct receiver_state *rst, nn_wctime_t time
|
|||
regardless of
|
||||
config.arrival_of_data_asserts_pp_and_ep_liveliness. */
|
||||
DDS_LOG(DDS_LC_TRACE, "SPDP ST0 %x:%x:%x:%x (known)", PGUID (datap->participant_guid));
|
||||
lease_renew (os_atomic_ldvoidp (&proxypp->lease), now_et ());
|
||||
os_mutexLock (&proxypp->e.lock);
|
||||
lease_renew (ddsrt_atomic_ldvoidp (&proxypp->lease), now_et ());
|
||||
ddsrt_mutex_lock (&proxypp->e.lock);
|
||||
if (proxypp->implicitly_created)
|
||||
{
|
||||
DDS_LOG(DDS_LC_DISCOVERY, " (NEW was-implicitly-created)");
|
||||
proxypp->implicitly_created = 0;
|
||||
update_proxy_participant_plist_locked (proxypp, datap, UPD_PROXYPP_SPDP, timestamp);
|
||||
}
|
||||
os_mutexUnlock (&proxypp->e.lock);
|
||||
ddsrt_mutex_unlock (&proxypp->e.lock);
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
@ -823,7 +825,7 @@ static void handle_SPDP (const struct receiver_state *rst, nn_wctime_t timestamp
|
|||
static void add_locator_to_ps (const nn_locator_t *loc, void *arg)
|
||||
{
|
||||
nn_plist_t *ps = (nn_plist_t *) arg;
|
||||
struct nn_locators_one *elem = os_malloc (sizeof (struct nn_locators_one));
|
||||
struct nn_locators_one *elem = ddsrt_malloc (sizeof (struct nn_locators_one));
|
||||
struct nn_locators *locs;
|
||||
unsigned present_flag;
|
||||
|
||||
|
@ -1075,7 +1077,7 @@ static struct proxy_participant *implicitly_create_proxypp (const nn_guid_t *ppg
|
|||
DDS_TRACE(" from-ddsi2 %x:%x:%x:%x", PGUID (privguid));
|
||||
nn_plist_init_empty (&pp_plist);
|
||||
|
||||
os_mutexLock (&privpp->e.lock);
|
||||
ddsrt_mutex_lock (&privpp->e.lock);
|
||||
as_default = ref_addrset(privpp->as_default);
|
||||
as_meta = ref_addrset(privpp->as_meta);
|
||||
/* copy just what we need */
|
||||
|
@ -1083,7 +1085,7 @@ static struct proxy_participant *implicitly_create_proxypp (const nn_guid_t *ppg
|
|||
tmp_plist.present = PP_PARTICIPANT_GUID | PP_PRISMTECH_PARTICIPANT_VERSION_INFO;
|
||||
tmp_plist.participant_guid = *ppguid;
|
||||
nn_plist_mergein_missing (&pp_plist, &tmp_plist);
|
||||
os_mutexUnlock (&privpp->e.lock);
|
||||
ddsrt_mutex_unlock (&privpp->e.lock);
|
||||
|
||||
pp_plist.prismtech_participant_version_info.flags &= ~NN_PRISMTECH_FL_PARTICIPANT_IS_DDSI2;
|
||||
new_proxy_participant (ppguid, 0, 0, &privguid, as_default, as_meta, &pp_plist, T_NEVER, vendorid, CF_IMPLICITLY_CREATED_PROXYPP | CF_PROXYPP_NO_SPDP, timestamp);
|
||||
|
@ -1197,10 +1199,10 @@ static void handle_SEDP_alive (const struct receiver_state *rst, nn_plist_t *dat
|
|||
{
|
||||
nn_etime_t never = { T_NEVER };
|
||||
DDS_LOG(DDS_LC_DISCOVERY, " %x:%x:%x:%x attach-to-DS %x:%x:%x:%x", PGUID(pp->e.guid), PGUIDPREFIX(*src_guid_prefix), pp->privileged_pp_guid.entityid.u);
|
||||
os_mutexLock (&pp->e.lock);
|
||||
ddsrt_mutex_lock (&pp->e.lock);
|
||||
pp->privileged_pp_guid.prefix = *src_guid_prefix;
|
||||
lease_set_expiry(os_atomic_ldvoidp(&pp->lease), never);
|
||||
os_mutexUnlock (&pp->e.lock);
|
||||
lease_set_expiry(ddsrt_atomic_ldvoidp(&pp->lease), never);
|
||||
ddsrt_mutex_unlock (&pp->e.lock);
|
||||
}
|
||||
DDS_LOG(DDS_LC_DISCOVERY, "\n");
|
||||
}
|
||||
|
@ -1666,7 +1668,7 @@ static int defragment (unsigned char **datap, const struct nn_rdata *fragchain,
|
|||
{
|
||||
unsigned char *buf;
|
||||
uint32_t off = 0;
|
||||
buf = os_malloc (sz);
|
||||
buf = ddsrt_malloc (sz);
|
||||
while (fragchain)
|
||||
{
|
||||
assert (fragchain->min <= off);
|
||||
|
@ -1811,7 +1813,7 @@ int builtins_dqueue_handler (const struct nn_rsample_info *sampleinfo, const str
|
|||
else
|
||||
{
|
||||
nn_parameterid_t pid;
|
||||
keyhash_payload.cdr.identifier = PLATFORM_IS_LITTLE_ENDIAN ? PL_CDR_LE : PL_CDR_BE;
|
||||
keyhash_payload.cdr.identifier = (DDSRT_ENDIAN == DDSRT_LITTLE_ENDIAN ? PL_CDR_LE : PL_CDR_BE);
|
||||
keyhash_payload.cdr.options = 0;
|
||||
switch (srcguid.entityid.u)
|
||||
{
|
||||
|
@ -1886,11 +1888,11 @@ int builtins_dqueue_handler (const struct nn_rsample_info *sampleinfo, const str
|
|||
|
||||
done_upd_deliv:
|
||||
if (needs_free)
|
||||
os_free (datap);
|
||||
ddsrt_free (datap);
|
||||
if (pwr)
|
||||
{
|
||||
/* No proxy writer for SPDP */
|
||||
os_atomic_st32 (&pwr->next_deliv_seq_lowword, (uint32_t) (sampleinfo->seq + 1));
|
||||
ddsrt_atomic_st32 (&pwr->next_deliv_seq_lowword, (uint32_t) (sampleinfo->seq + 1));
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
|
|
@ -13,28 +13,30 @@
|
|||
#include <string.h>
|
||||
#include <stddef.h>
|
||||
|
||||
#include "os/os.h"
|
||||
#include "dds/ddsrt/heap.h"
|
||||
#include "dds/ddsrt/log.h"
|
||||
#include "dds/ddsrt/sync.h"
|
||||
|
||||
#include "util/ut_avl.h"
|
||||
#include "dds/util/ut_avl.h"
|
||||
|
||||
#include "ddsi/q_entity.h"
|
||||
#include "ddsi/q_config.h"
|
||||
#include "ddsi/q_time.h"
|
||||
#include "ddsi/q_misc.h"
|
||||
#include "ddsi/q_log.h"
|
||||
#include "ddsi/q_plist.h"
|
||||
#include "ddsi/q_ephash.h"
|
||||
#include "ddsi/q_globals.h"
|
||||
#include "ddsi/q_addrset.h"
|
||||
#include "ddsi/q_radmin.h"
|
||||
#include "ddsi/q_ddsi_discovery.h"
|
||||
#include "ddsi/q_protocol.h" /* NN_ENTITYID_... */
|
||||
#include "ddsi/q_unused.h"
|
||||
#include "ddsi/q_error.h"
|
||||
#include "ddsi/q_debmon.h"
|
||||
#include "ddsi/ddsi_serdata.h"
|
||||
#include "ddsi/ddsi_tran.h"
|
||||
#include "ddsi/ddsi_tcp.h"
|
||||
#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/q_plist.h"
|
||||
#include "dds/ddsi/q_ephash.h"
|
||||
#include "dds/ddsi/q_globals.h"
|
||||
#include "dds/ddsi/q_addrset.h"
|
||||
#include "dds/ddsi/q_radmin.h"
|
||||
#include "dds/ddsi/q_ddsi_discovery.h"
|
||||
#include "dds/ddsi/q_protocol.h" /* NN_ENTITYID_... */
|
||||
#include "dds/ddsi/q_unused.h"
|
||||
#include "dds/ddsi/q_error.h"
|
||||
#include "dds/ddsi/q_debmon.h"
|
||||
#include "dds/ddsi/ddsi_serdata.h"
|
||||
#include "dds/ddsi/ddsi_tran.h"
|
||||
#include "dds/ddsi/ddsi_tcp.h"
|
||||
|
||||
#include "dds__whc.h"
|
||||
|
||||
|
@ -48,8 +50,8 @@ struct debug_monitor {
|
|||
struct thread_state1 *servts;
|
||||
ddsi_tran_factory_t tran_factory;
|
||||
ddsi_tran_listener_t servsock;
|
||||
os_mutex lock;
|
||||
os_cond cond;
|
||||
ddsrt_mutex_t lock;
|
||||
ddsrt_cond_t cond;
|
||||
struct plugin *plugins;
|
||||
int stop;
|
||||
};
|
||||
|
@ -62,11 +64,11 @@ static int cpf (ddsi_tran_conn_t conn, const char *fmt, ...)
|
|||
else
|
||||
{
|
||||
va_list ap;
|
||||
os_iovec_t iov;
|
||||
ddsrt_iovec_t iov;
|
||||
char buf[4096];
|
||||
int n;
|
||||
va_start (ap, fmt);
|
||||
n = os_vsnprintf (buf, sizeof (buf), fmt, ap);
|
||||
n = vsnprintf (buf, sizeof (buf), fmt, ap);
|
||||
va_end (ap);
|
||||
iov.iov_base = buf;
|
||||
iov.iov_len = (size_t) n;
|
||||
|
@ -126,7 +128,7 @@ static int print_any_endpoint_common (ddsi_tran_conn_t conn, const char *label,
|
|||
|
||||
static int print_endpoint_common (ddsi_tran_conn_t conn, const char *label, const struct entity_common *e, const struct endpoint_common *c, const struct nn_xqos *xqos, const struct ddsi_sertopic *topic)
|
||||
{
|
||||
OS_UNUSED_ARG (c);
|
||||
DDSRT_UNUSED_ARG (c);
|
||||
return print_any_endpoint_common (conn, label, e, xqos, topic);
|
||||
}
|
||||
|
||||
|
@ -148,9 +150,9 @@ static int print_participants (struct thread_state1 *self, ddsi_tran_conn_t conn
|
|||
ephash_enum_participant_init (&e);
|
||||
while ((p = ephash_enum_participant_next (&e)) != NULL)
|
||||
{
|
||||
os_mutexLock (&p->e.lock);
|
||||
ddsrt_mutex_lock (&p->e.lock);
|
||||
x += cpf (conn, "pp %x:%x:%x:%x %s%s\n", PGUID (p->e.guid), p->e.name, p->is_ddsi2_pp ? " [ddsi2]" : "");
|
||||
os_mutexUnlock (&p->e.lock);
|
||||
ddsrt_mutex_unlock (&p->e.lock);
|
||||
|
||||
{
|
||||
struct ephash_enum_reader er;
|
||||
|
@ -162,14 +164,14 @@ static int print_participants (struct thread_state1 *self, ddsi_tran_conn_t conn
|
|||
struct rd_pwr_match *m;
|
||||
if (r->c.pp != p)
|
||||
continue;
|
||||
os_mutexLock (&r->e.lock);
|
||||
ddsrt_mutex_lock (&r->e.lock);
|
||||
print_endpoint_common (conn, "rd", &r->e, &r->c, r->xqos, r->topic);
|
||||
#ifdef DDSI_INCLUDE_NETWORK_PARTITIONS
|
||||
x += print_addrset_if_notempty (conn, " as", r->as, "\n");
|
||||
#endif
|
||||
for (m = ut_avlIterFirst (&rd_writers_treedef, &r->writers, &writ); m; m = ut_avlIterNext (&writ))
|
||||
x += cpf (conn, " pwr %x:%x:%x:%x\n", PGUID (m->pwr_guid));
|
||||
os_mutexUnlock (&r->e.lock);
|
||||
ddsrt_mutex_unlock (&r->e.lock);
|
||||
}
|
||||
ephash_enum_reader_fini (&er);
|
||||
}
|
||||
|
@ -185,7 +187,7 @@ static int print_participants (struct thread_state1 *self, ddsi_tran_conn_t conn
|
|||
struct whc_state whcst;
|
||||
if (w->c.pp != p)
|
||||
continue;
|
||||
os_mutexLock (&w->e.lock);
|
||||
ddsrt_mutex_lock (&w->e.lock);
|
||||
print_endpoint_common (conn, "wr", &w->e, &w->c, w->xqos, w->topic);
|
||||
whc_get_state(w->whc, &whcst);
|
||||
x += cpf (conn, " whc [%lld,%lld] unacked %"PRIuSIZE"%s [%u,%u] seq %lld seq_xmit %lld cs_seq %lld\n",
|
||||
|
@ -214,7 +216,7 @@ static int print_participants (struct thread_state1 *self, ddsi_tran_conn_t conn
|
|||
x += cpf (conn, " prd %x:%x:%x:%x %s @ %lld [%lld,%lld] #nacks %u\n",
|
||||
PGUID (m->prd_guid), wr_prd_flags, m->seq, m->min_seq, m->max_seq, m->rexmit_requests);
|
||||
}
|
||||
os_mutexUnlock (&w->e.lock);
|
||||
ddsrt_mutex_unlock (&w->e.lock);
|
||||
}
|
||||
ephash_enum_writer_fini (&ew);
|
||||
}
|
||||
|
@ -233,9 +235,9 @@ static int print_proxy_participants (struct thread_state1 *self, ddsi_tran_conn_
|
|||
ephash_enum_proxy_participant_init (&e);
|
||||
while ((p = ephash_enum_proxy_participant_next (&e)) != NULL)
|
||||
{
|
||||
os_mutexLock (&p->e.lock);
|
||||
ddsrt_mutex_lock (&p->e.lock);
|
||||
x += cpf (conn, "proxypp %x:%x:%x:%x%s\n", PGUID (p->e.guid), p->is_ddsi2_pp ? " [ddsi2]" : "");
|
||||
os_mutexUnlock (&p->e.lock);
|
||||
ddsrt_mutex_unlock (&p->e.lock);
|
||||
x += print_addrset (conn, " as data", p->as_default, "");
|
||||
x += print_addrset (conn, " meta", p->as_default, "\n");
|
||||
|
||||
|
@ -249,11 +251,11 @@ static int print_proxy_participants (struct thread_state1 *self, ddsi_tran_conn_
|
|||
struct prd_wr_match *m;
|
||||
if (r->c.proxypp != p)
|
||||
continue;
|
||||
os_mutexLock (&r->e.lock);
|
||||
ddsrt_mutex_lock (&r->e.lock);
|
||||
print_proxy_endpoint_common (conn, "prd", &r->e, &r->c);
|
||||
for (m = ut_avlIterFirst (&rd_writers_treedef, &r->writers, &writ); m; m = ut_avlIterNext (&writ))
|
||||
x += cpf (conn, " wr %x:%x:%x:%x\n", PGUID (m->wr_guid));
|
||||
os_mutexUnlock (&r->e.lock);
|
||||
ddsrt_mutex_unlock (&r->e.lock);
|
||||
}
|
||||
ephash_enum_proxy_reader_fini (&er);
|
||||
}
|
||||
|
@ -268,7 +270,7 @@ static int print_proxy_participants (struct thread_state1 *self, ddsi_tran_conn_
|
|||
struct pwr_rd_match *m;
|
||||
if (w->c.proxypp != p)
|
||||
continue;
|
||||
os_mutexLock (&w->e.lock);
|
||||
ddsrt_mutex_lock (&w->e.lock);
|
||||
print_proxy_endpoint_common (conn, "pwr", &w->e, &w->c);
|
||||
x += cpf (conn, " last_seq %lld last_fragnum %u\n", w->last_seq, w->last_fragnum);
|
||||
for (m = ut_avlIterFirst (&wr_readers_treedef, &w->readers, &rdit); m; m = ut_avlIterNext (&rdit))
|
||||
|
@ -287,7 +289,7 @@ static int print_proxy_participants (struct thread_state1 *self, ddsi_tran_conn_
|
|||
break;
|
||||
}
|
||||
}
|
||||
os_mutexUnlock (&w->e.lock);
|
||||
ddsrt_mutex_unlock (&w->e.lock);
|
||||
}
|
||||
ephash_enum_proxy_writer_fini (&ew);
|
||||
}
|
||||
|
@ -300,11 +302,11 @@ static int print_proxy_participants (struct thread_state1 *self, ddsi_tran_conn_
|
|||
static uint32_t debmon_main (void *vdm)
|
||||
{
|
||||
struct debug_monitor *dm = vdm;
|
||||
os_mutexLock (&dm->lock);
|
||||
ddsrt_mutex_lock (&dm->lock);
|
||||
while (!dm->stop)
|
||||
{
|
||||
ddsi_tran_conn_t conn;
|
||||
os_mutexUnlock (&dm->lock);
|
||||
ddsrt_mutex_unlock (&dm->lock);
|
||||
if ((conn = ddsi_listener_accept (dm->servsock)) != NULL)
|
||||
{
|
||||
struct plugin *p;
|
||||
|
@ -314,22 +316,22 @@ static uint32_t debmon_main (void *vdm)
|
|||
r += print_proxy_participants (dm->servts, conn);
|
||||
|
||||
/* Note: can only add plugins (at the tail) */
|
||||
os_mutexLock (&dm->lock);
|
||||
ddsrt_mutex_lock (&dm->lock);
|
||||
p = dm->plugins;
|
||||
while (r == 0 && p != NULL)
|
||||
{
|
||||
os_mutexUnlock (&dm->lock);
|
||||
ddsrt_mutex_unlock (&dm->lock);
|
||||
r += p->fn (conn, cpf, p->arg);
|
||||
os_mutexLock (&dm->lock);
|
||||
ddsrt_mutex_lock (&dm->lock);
|
||||
p = p->next;
|
||||
}
|
||||
os_mutexUnlock (&dm->lock);
|
||||
ddsrt_mutex_unlock (&dm->lock);
|
||||
|
||||
ddsi_conn_free (conn);
|
||||
}
|
||||
os_mutexLock (&dm->lock);
|
||||
ddsrt_mutex_lock (&dm->lock);
|
||||
}
|
||||
os_mutexUnlock (&dm->lock);
|
||||
ddsrt_mutex_unlock (&dm->lock);
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
@ -343,7 +345,7 @@ struct debug_monitor *new_debug_monitor (int port)
|
|||
if (ddsi_tcp_init () < 0)
|
||||
return NULL;
|
||||
|
||||
dm = os_malloc (sizeof (*dm));
|
||||
dm = ddsrt_malloc (sizeof (*dm));
|
||||
|
||||
dm->plugins = NULL;
|
||||
if ((dm->tran_factory = ddsi_factory_find ("tcp")) == NULL)
|
||||
|
@ -362,8 +364,8 @@ struct debug_monitor *new_debug_monitor (int port)
|
|||
DDS_LOG(DDS_LC_CONFIG, "debmon at %s\n", ddsi_locator_to_string (buf, sizeof(buf), &loc));
|
||||
}
|
||||
|
||||
os_mutexInit (&dm->lock);
|
||||
os_condInit (&dm->cond, &dm->lock);
|
||||
ddsrt_mutex_init (&dm->lock);
|
||||
ddsrt_cond_init (&dm->cond);
|
||||
if (ddsi_listener_listen (dm->servsock) < 0)
|
||||
goto err_listen;
|
||||
dm->stop = 0;
|
||||
|
@ -371,28 +373,28 @@ struct debug_monitor *new_debug_monitor (int port)
|
|||
return dm;
|
||||
|
||||
err_listen:
|
||||
os_condDestroy(&dm->cond);
|
||||
os_mutexDestroy(&dm->lock);
|
||||
ddsrt_cond_destroy(&dm->cond);
|
||||
ddsrt_mutex_destroy(&dm->lock);
|
||||
ddsi_listener_free(dm->servsock);
|
||||
err_servsock:
|
||||
os_free(dm);
|
||||
ddsrt_free(dm);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
void add_debug_monitor_plugin (struct debug_monitor *dm, debug_monitor_plugin_t fn, void *arg)
|
||||
{
|
||||
struct plugin *p, **pp;
|
||||
if (dm != NULL && (p = os_malloc (sizeof (*p))) != NULL)
|
||||
if (dm != NULL && (p = ddsrt_malloc (sizeof (*p))) != NULL)
|
||||
{
|
||||
p->fn = fn;
|
||||
p->arg = arg;
|
||||
p->next = NULL;
|
||||
os_mutexLock (&dm->lock);
|
||||
ddsrt_mutex_lock (&dm->lock);
|
||||
pp = &dm->plugins;
|
||||
while (*pp)
|
||||
pp = &(*pp)->next;
|
||||
*pp = p;
|
||||
os_mutexUnlock (&dm->lock);
|
||||
ddsrt_mutex_unlock (&dm->lock);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -401,21 +403,21 @@ void free_debug_monitor (struct debug_monitor *dm)
|
|||
if (dm == NULL)
|
||||
return;
|
||||
|
||||
os_mutexLock (&dm->lock);
|
||||
ddsrt_mutex_lock (&dm->lock);
|
||||
dm->stop = 1;
|
||||
os_condBroadcast (&dm->cond);
|
||||
os_mutexUnlock (&dm->lock);
|
||||
ddsrt_cond_broadcast (&dm->cond);
|
||||
ddsrt_mutex_unlock (&dm->lock);
|
||||
ddsi_listener_unblock (dm->servsock);
|
||||
join_thread (dm->servts);
|
||||
ddsi_listener_free (dm->servsock);
|
||||
os_condDestroy (&dm->cond);
|
||||
os_mutexDestroy (&dm->lock);
|
||||
ddsrt_cond_destroy (&dm->cond);
|
||||
ddsrt_mutex_destroy (&dm->lock);
|
||||
|
||||
while (dm->plugins) {
|
||||
struct plugin *p = dm->plugins;
|
||||
dm->plugins = p->next;
|
||||
os_free (p);
|
||||
ddsrt_free (p);
|
||||
}
|
||||
os_free (dm);
|
||||
ddsrt_free (dm);
|
||||
}
|
||||
|
||||
|
|
File diff suppressed because it is too large
Load diff
|
@ -12,16 +12,15 @@
|
|||
#include <stddef.h>
|
||||
#include <assert.h>
|
||||
|
||||
#include "os/os.h"
|
||||
|
||||
#include "util/ut_hopscotch.h"
|
||||
#include "ddsi/q_ephash.h"
|
||||
#include "ddsi/q_config.h"
|
||||
#include "ddsi/q_globals.h"
|
||||
#include "ddsi/q_entity.h"
|
||||
#include "ddsi/q_gc.h"
|
||||
#include "ddsi/q_rtps.h" /* guid_t */
|
||||
#include "ddsi/q_thread.h" /* for assert(thread is awake) */
|
||||
#include "dds/ddsrt/heap.h"
|
||||
#include "dds/util/ut_hopscotch.h"
|
||||
#include "dds/ddsi/q_ephash.h"
|
||||
#include "dds/ddsi/q_config.h"
|
||||
#include "dds/ddsi/q_globals.h"
|
||||
#include "dds/ddsi/q_entity.h"
|
||||
#include "dds/ddsi/q_gc.h"
|
||||
#include "dds/ddsi/q_rtps.h" /* guid_t */
|
||||
#include "dds/ddsi/q_thread.h" /* for assert(thread is awake) */
|
||||
|
||||
struct ephash {
|
||||
struct ut_chh *hash;
|
||||
|
@ -65,7 +64,7 @@ static void gc_buckets_cb (struct gcreq *gcreq)
|
|||
{
|
||||
void *bs = gcreq->arg;
|
||||
gcreq_free (gcreq);
|
||||
os_free (bs);
|
||||
ddsrt_free (bs);
|
||||
}
|
||||
|
||||
static void gc_buckets (void *bs)
|
||||
|
@ -78,10 +77,10 @@ static void gc_buckets (void *bs)
|
|||
struct ephash *ephash_new (void)
|
||||
{
|
||||
struct ephash *ephash;
|
||||
ephash = os_malloc (sizeof (*ephash));
|
||||
ephash = ddsrt_malloc (sizeof (*ephash));
|
||||
ephash->hash = ut_chhNew (32, hash_entity_guid_wrapper, entity_guid_eq_wrapper, gc_buckets);
|
||||
if (ephash->hash == NULL) {
|
||||
os_free (ephash);
|
||||
ddsrt_free (ephash);
|
||||
return NULL;
|
||||
} else {
|
||||
return ephash;
|
||||
|
@ -92,7 +91,7 @@ void ephash_free (struct ephash *ephash)
|
|||
{
|
||||
ut_chhFree (ephash->hash);
|
||||
ephash->hash = NULL;
|
||||
os_free (ephash);
|
||||
ddsrt_free (ephash);
|
||||
}
|
||||
|
||||
static void ephash_guid_insert (struct entity_common *e)
|
||||
|
@ -335,7 +334,7 @@ struct proxy_participant *ephash_enum_proxy_participant_next (struct ephash_enum
|
|||
|
||||
void ephash_enum_fini (struct ephash_enum *st)
|
||||
{
|
||||
OS_UNUSED_ARG(st);
|
||||
DDSRT_UNUSED_ARG(st);
|
||||
}
|
||||
|
||||
void ephash_enum_writer_fini (struct ephash_enum_writer *st)
|
||||
|
|
|
@ -11,53 +11,56 @@
|
|||
*/
|
||||
#include <stddef.h>
|
||||
|
||||
#include "os/os.h"
|
||||
#include "ddsi/q_freelist.h"
|
||||
#include "dds/ddsrt/atomics.h"
|
||||
#include "dds/ddsrt/heap.h"
|
||||
#include "dds/ddsrt/sync.h"
|
||||
#include "dds/ddsrt/threads.h"
|
||||
#include "dds/ddsi/q_freelist.h"
|
||||
|
||||
#if FREELIST_TYPE == FREELIST_ATOMIC_LIFO
|
||||
|
||||
void nn_freelist_init (_Out_ struct nn_freelist *fl, uint32_t max, off_t linkoff)
|
||||
void nn_freelist_init (struct nn_freelist *fl, uint32_t max, off_t linkoff)
|
||||
{
|
||||
os_atomic_lifo_init (&fl->x);
|
||||
os_atomic_st32(&fl->count, 0);
|
||||
ddsrt_atomic_lifo_init (&fl->x);
|
||||
ddsrt_atomic_st32(&fl->count, 0);
|
||||
fl->max = (max == UINT32_MAX) ? max-1 : max;
|
||||
fl->linkoff = linkoff;
|
||||
}
|
||||
|
||||
void nn_freelist_fini (_Inout_ _Post_invalid_ struct nn_freelist *fl, _In_ void (*free) (void *elem))
|
||||
void nn_freelist_fini (struct nn_freelist *fl, void (*free) (void *elem))
|
||||
{
|
||||
void *e;
|
||||
while ((e = os_atomic_lifo_pop (&fl->x, fl->linkoff)) != NULL)
|
||||
while ((e = ddsrt_atomic_lifo_pop (&fl->x, fl->linkoff)) != NULL)
|
||||
free (e);
|
||||
}
|
||||
|
||||
_Check_return_ bool nn_freelist_push (_Inout_ struct nn_freelist *fl, _Inout_ _When_ (return != 0, _Post_invalid_) void *elem)
|
||||
bool nn_freelist_push (struct nn_freelist *fl, void *elem)
|
||||
{
|
||||
if (os_atomic_inc32_nv (&fl->count) <= fl->max)
|
||||
if (ddsrt_atomic_inc32_nv (&fl->count) <= fl->max)
|
||||
{
|
||||
os_atomic_lifo_push (&fl->x, elem, fl->linkoff);
|
||||
ddsrt_atomic_lifo_push (&fl->x, elem, fl->linkoff);
|
||||
return true;
|
||||
}
|
||||
else
|
||||
{
|
||||
os_atomic_dec32 (&fl->count);
|
||||
ddsrt_atomic_dec32 (&fl->count);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
_Check_return_ _Ret_maybenull_ void *nn_freelist_pushmany (_Inout_ struct nn_freelist *fl, _Inout_opt_ _When_ (return != 0, _Post_invalid_) void *first, _Inout_opt_ _When_ (return != 0, _Post_invalid_) void *last, uint32_t n)
|
||||
void *nn_freelist_pushmany (struct nn_freelist *fl, void *first, void *last, uint32_t n)
|
||||
{
|
||||
os_atomic_add32 (&fl->count, n);
|
||||
os_atomic_lifo_pushmany (&fl->x, first, last, fl->linkoff);
|
||||
ddsrt_atomic_add32 (&fl->count, n);
|
||||
ddsrt_atomic_lifo_pushmany (&fl->x, first, last, fl->linkoff);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
_Check_return_ _Ret_maybenull_ void *nn_freelist_pop (_Inout_ struct nn_freelist *fl)
|
||||
void *nn_freelist_pop (struct nn_freelist *fl)
|
||||
{
|
||||
void *e;
|
||||
if ((e = os_atomic_lifo_pop (&fl->x, fl->linkoff)) != NULL)
|
||||
if ((e = ddsrt_atomic_lifo_pop (&fl->x, fl->linkoff)) != NULL)
|
||||
{
|
||||
os_atomic_dec32(&fl->count);
|
||||
ddsrt_atomic_dec32(&fl->count);
|
||||
return e;
|
||||
}
|
||||
else
|
||||
|
@ -68,19 +71,19 @@ _Check_return_ _Ret_maybenull_ void *nn_freelist_pop (_Inout_ struct nn_freelist
|
|||
|
||||
#elif FREELIST_TYPE == FREELIST_DOUBLE
|
||||
|
||||
static os_threadLocal int freelist_inner_idx = -1;
|
||||
static ddsrt_thread_local int freelist_inner_idx = -1;
|
||||
|
||||
void nn_freelist_init (_Out_ struct nn_freelist *fl, uint32_t max, off_t linkoff)
|
||||
void nn_freelist_init (struct nn_freelist *fl, uint32_t max, off_t linkoff)
|
||||
{
|
||||
int i;
|
||||
os_mutexInit (&fl->lock);
|
||||
ddsrt_mutex_init (&fl->lock);
|
||||
for (i = 0; i < NN_FREELIST_NPAR; i++)
|
||||
{
|
||||
os_mutexInit (&fl->inner[i].lock);
|
||||
ddsrt_mutex_init (&fl->inner[i].lock);
|
||||
fl->inner[i].count = 0;
|
||||
fl->inner[i].m = os_malloc (sizeof (*fl->inner[i].m));
|
||||
fl->inner[i].m = ddsrt_malloc (sizeof (*fl->inner[i].m));
|
||||
}
|
||||
os_atomic_st32 (&fl->cc, 0);
|
||||
ddsrt_atomic_st32 (&fl->cc, 0);
|
||||
fl->mlist = NULL;
|
||||
fl->emlist = NULL;
|
||||
fl->count = 0;
|
||||
|
@ -93,38 +96,38 @@ static void *get_next (const struct nn_freelist *fl, const void *e)
|
|||
return *((void **) ((char *)e + fl->linkoff));
|
||||
}
|
||||
|
||||
void nn_freelist_fini (_Inout_ _Post_invalid_ struct nn_freelist *fl, _In_ void (*xfree) (void *))
|
||||
void nn_freelist_fini (struct nn_freelist *fl, void (*xfree) (void *))
|
||||
{
|
||||
int i;
|
||||
uint32_t j;
|
||||
struct nn_freelistM *m;
|
||||
os_mutexDestroy (&fl->lock);
|
||||
ddsrt_mutex_destroy (&fl->lock);
|
||||
for (i = 0; i < NN_FREELIST_NPAR; i++)
|
||||
{
|
||||
os_mutexDestroy (&fl->inner[i].lock);
|
||||
ddsrt_mutex_destroy (&fl->inner[i].lock);
|
||||
for (j = 0; j < fl->inner[i].count; j++)
|
||||
xfree (fl->inner[i].m->x[j]);
|
||||
os_free(fl->inner[i].m);
|
||||
ddsrt_free(fl->inner[i].m);
|
||||
}
|
||||
/* The compiler can't make sense of all these linked lists and doesn't
|
||||
* realize that the next pointers are always initialized here. */
|
||||
OS_WARNING_MSVC_OFF(6001);
|
||||
DDSRT_WARNING_MSVC_OFF(6001);
|
||||
while ((m = fl->mlist) != NULL)
|
||||
{
|
||||
fl->mlist = m->next;
|
||||
for (j = 0; j < NN_FREELIST_MAGSIZE; j++)
|
||||
xfree (m->x[j]);
|
||||
os_free (m);
|
||||
ddsrt_free (m);
|
||||
}
|
||||
while ((m = fl->emlist) != NULL)
|
||||
{
|
||||
fl->emlist = m->next;
|
||||
os_free (m);
|
||||
ddsrt_free (m);
|
||||
}
|
||||
OS_WARNING_MSVC_ON(6001);
|
||||
DDSRT_WARNING_MSVC_ON(6001);
|
||||
}
|
||||
|
||||
static os_atomic_uint32_t freelist_inner_idx_off = OS_ATOMIC_UINT32_INIT(0);
|
||||
static ddsrt_atomic_uint32_t freelist_inner_idx_off = DDSRT_ATOMIC_UINT32_INIT(0);
|
||||
|
||||
static int get_freelist_inner_idx (void)
|
||||
{
|
||||
|
@ -135,7 +138,7 @@ static int get_freelist_inner_idx (void)
|
|||
UINT64_C (10242350189706880077),
|
||||
};
|
||||
uintptr_t addr;
|
||||
uint64_t t = (uint64_t) ((uintptr_t) &addr) + os_atomic_ld32 (&freelist_inner_idx_off);
|
||||
uint64_t t = (uint64_t) ((uintptr_t) &addr) + ddsrt_atomic_ld32 (&freelist_inner_idx_off);
|
||||
freelist_inner_idx = (int) (((((uint32_t) t + unihashconsts[0]) * ((uint32_t) (t >> 32) + unihashconsts[1]))) >> (64 - NN_FREELIST_NPAR_LG2));
|
||||
}
|
||||
return freelist_inner_idx;
|
||||
|
@ -144,36 +147,36 @@ static int get_freelist_inner_idx (void)
|
|||
static int lock_inner (struct nn_freelist *fl)
|
||||
{
|
||||
int k = get_freelist_inner_idx();
|
||||
if (os_mutexTryLock (&fl->inner[k].lock) != os_resultSuccess)
|
||||
if (!ddsrt_mutex_trylock (&fl->inner[k].lock))
|
||||
{
|
||||
os_mutexLock (&fl->inner[k].lock);
|
||||
if (os_atomic_inc32_nv (&fl->cc) == 100)
|
||||
ddsrt_mutex_lock (&fl->inner[k].lock);
|
||||
if (ddsrt_atomic_inc32_nv (&fl->cc) == 100)
|
||||
{
|
||||
os_atomic_st32(&fl->cc, 0);
|
||||
os_atomic_inc32(&freelist_inner_idx_off);
|
||||
ddsrt_atomic_st32(&fl->cc, 0);
|
||||
ddsrt_atomic_inc32(&freelist_inner_idx_off);
|
||||
freelist_inner_idx = -1;
|
||||
}
|
||||
}
|
||||
return k;
|
||||
}
|
||||
|
||||
_Check_return_ bool nn_freelist_push (_Inout_ struct nn_freelist *fl, _Inout_ _When_ (return != 0, _Post_invalid_) void *elem)
|
||||
bool nn_freelist_push (struct nn_freelist *fl, void *elem)
|
||||
{
|
||||
int k = lock_inner (fl);
|
||||
if (fl->inner[k].count < NN_FREELIST_MAGSIZE)
|
||||
{
|
||||
fl->inner[k].m->x[fl->inner[k].count++] = elem;
|
||||
os_mutexUnlock (&fl->inner[k].lock);
|
||||
ddsrt_mutex_unlock (&fl->inner[k].lock);
|
||||
return true;
|
||||
}
|
||||
else
|
||||
{
|
||||
struct nn_freelistM *m;
|
||||
os_mutexLock (&fl->lock);
|
||||
ddsrt_mutex_lock (&fl->lock);
|
||||
if (fl->count + NN_FREELIST_MAGSIZE >= fl->max)
|
||||
{
|
||||
os_mutexUnlock (&fl->lock);
|
||||
os_mutexUnlock (&fl->inner[k].lock);
|
||||
ddsrt_mutex_unlock (&fl->lock);
|
||||
ddsrt_mutex_unlock (&fl->inner[k].lock);
|
||||
return false;
|
||||
}
|
||||
m = fl->inner[k].m;
|
||||
|
@ -182,20 +185,20 @@ _Check_return_ bool nn_freelist_push (_Inout_ struct nn_freelist *fl, _Inout_ _W
|
|||
fl->count += NN_FREELIST_MAGSIZE;
|
||||
fl->inner[k].count = 0;
|
||||
if (fl->emlist == NULL)
|
||||
fl->inner[k].m = os_malloc (sizeof (*fl->inner[k].m));
|
||||
fl->inner[k].m = ddsrt_malloc (sizeof (*fl->inner[k].m));
|
||||
else
|
||||
{
|
||||
fl->inner[k].m = fl->emlist;
|
||||
fl->emlist = fl->emlist->next;
|
||||
}
|
||||
os_mutexUnlock (&fl->lock);
|
||||
ddsrt_mutex_unlock (&fl->lock);
|
||||
fl->inner[k].m->x[fl->inner[k].count++] = elem;
|
||||
os_mutexUnlock (&fl->inner[k].lock);
|
||||
ddsrt_mutex_unlock (&fl->inner[k].lock);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
_Check_return_ _Ret_maybenull_ void *nn_freelist_pushmany (_Inout_ struct nn_freelist *fl, _Inout_opt_ _When_ (return != 0, _Post_invalid_) void *first, _Inout_opt_ _When_ (return != 0, _Post_invalid_) void *last, uint32_t n)
|
||||
void *nn_freelist_pushmany (struct nn_freelist *fl, void *first, void *last, uint32_t n)
|
||||
{
|
||||
void *m = first;
|
||||
(void)last;
|
||||
|
@ -211,22 +214,22 @@ _Check_return_ _Ret_maybenull_ void *nn_freelist_pushmany (_Inout_ struct nn_fre
|
|||
return NULL;
|
||||
}
|
||||
|
||||
_Check_return_ _Ret_maybenull_ void *nn_freelist_pop (_Inout_ struct nn_freelist *fl)
|
||||
void *nn_freelist_pop (struct nn_freelist *fl)
|
||||
{
|
||||
int k = lock_inner (fl);
|
||||
if (fl->inner[k].count > 0)
|
||||
{
|
||||
void *e = fl->inner[k].m->x[--fl->inner[k].count];
|
||||
os_mutexUnlock (&fl->inner[k].lock);
|
||||
ddsrt_mutex_unlock (&fl->inner[k].lock);
|
||||
return e;
|
||||
}
|
||||
else
|
||||
{
|
||||
os_mutexLock (&fl->lock);
|
||||
ddsrt_mutex_lock (&fl->lock);
|
||||
if (fl->mlist == NULL)
|
||||
{
|
||||
os_mutexUnlock (&fl->lock);
|
||||
os_mutexUnlock (&fl->inner[k].lock);
|
||||
ddsrt_mutex_unlock (&fl->lock);
|
||||
ddsrt_mutex_unlock (&fl->inner[k].lock);
|
||||
return NULL;
|
||||
}
|
||||
else
|
||||
|
@ -237,10 +240,10 @@ _Check_return_ _Ret_maybenull_ void *nn_freelist_pop (_Inout_ struct nn_freelist
|
|||
fl->inner[k].m = fl->mlist;
|
||||
fl->mlist = fl->mlist->next;
|
||||
fl->count -= NN_FREELIST_MAGSIZE;
|
||||
os_mutexUnlock (&fl->lock);
|
||||
ddsrt_mutex_unlock (&fl->lock);
|
||||
fl->inner[k].count = NN_FREELIST_MAGSIZE;
|
||||
e = fl->inner[k].m->x[--fl->inner[k].count];
|
||||
os_mutexUnlock (&fl->inner[k].lock);
|
||||
ddsrt_mutex_unlock (&fl->inner[k].lock);
|
||||
return e;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -13,25 +13,26 @@
|
|||
#include <stdlib.h>
|
||||
#include <stddef.h>
|
||||
|
||||
#include "os/os.h"
|
||||
#include "dds/ddsrt/heap.h"
|
||||
#include "dds/ddsrt/log.h"
|
||||
#include "dds/ddsrt/sync.h"
|
||||
#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/q_ephash.h"
|
||||
#include "dds/ddsi/q_unused.h"
|
||||
#include "dds/ddsi/q_lease.h"
|
||||
#include "dds/ddsi/q_globals.h" /* for mattr, cattr */
|
||||
|
||||
#include "ddsi/q_gc.h"
|
||||
#include "ddsi/q_log.h"
|
||||
#include "ddsi/q_config.h"
|
||||
#include "ddsi/q_time.h"
|
||||
#include "ddsi/q_thread.h"
|
||||
#include "ddsi/q_ephash.h"
|
||||
#include "ddsi/q_unused.h"
|
||||
#include "ddsi/q_lease.h"
|
||||
#include "ddsi/q_globals.h" /* for mattr, cattr */
|
||||
|
||||
#include "ddsi/q_rtps.h" /* for guid_hash */
|
||||
#include "dds/ddsi/q_rtps.h" /* for guid_hash */
|
||||
|
||||
struct gcreq_queue {
|
||||
struct gcreq *first;
|
||||
struct gcreq *last;
|
||||
os_mutex lock;
|
||||
os_cond cond;
|
||||
ddsrt_mutex_t lock;
|
||||
ddsrt_cond_t cond;
|
||||
int terminate;
|
||||
int32_t count;
|
||||
struct thread_state1 *ts;
|
||||
|
@ -80,11 +81,11 @@ static uint32_t gcreq_queue_thread (struct gcreq_queue *q)
|
|||
{
|
||||
struct thread_state1 *self = lookup_thread_state ();
|
||||
nn_mtime_t next_thread_cputime = { 0 };
|
||||
struct os_time shortsleep = { 0, 1 * T_MILLISECOND };
|
||||
dds_time_t shortsleep = 1 * T_MILLISECOND;
|
||||
int64_t delay = T_MILLISECOND; /* force evaluation after startup */
|
||||
struct gcreq *gcreq = NULL;
|
||||
int trace_shortsleep = 1;
|
||||
os_mutexLock (&q->lock);
|
||||
ddsrt_mutex_lock (&q->lock);
|
||||
while (!(q->terminate && q->count == 0))
|
||||
{
|
||||
LOG_THREAD_CPUTIME (next_thread_cputime);
|
||||
|
@ -98,17 +99,15 @@ static uint32_t gcreq_queue_thread (struct gcreq_queue *q)
|
|||
assert (trace_shortsleep);
|
||||
if (q->first == NULL)
|
||||
{
|
||||
/* FIXME: fix os_time and use absolute timeouts */
|
||||
struct os_time to;
|
||||
/* FIXME: use absolute timeouts */
|
||||
dds_time_t to;
|
||||
if (delay >= 1000 * T_SECOND) {
|
||||
/* avoid overflow */
|
||||
to.tv_sec = 1000;
|
||||
to.tv_nsec = 0;
|
||||
to = DDS_SECS(1000);
|
||||
} else {
|
||||
to.tv_sec = (os_timeSec)(delay / T_SECOND);
|
||||
to.tv_nsec = (int32_t)(delay % T_SECOND);
|
||||
to = delay;
|
||||
}
|
||||
os_condTimedWait (&q->cond, &q->lock, &to);
|
||||
ddsrt_cond_waitfor(&q->cond, &q->lock, to);
|
||||
}
|
||||
if (q->first)
|
||||
{
|
||||
|
@ -116,7 +115,7 @@ static uint32_t gcreq_queue_thread (struct gcreq_queue *q)
|
|||
q->first = q->first->next;
|
||||
}
|
||||
}
|
||||
os_mutexUnlock (&q->lock);
|
||||
ddsrt_mutex_unlock (&q->lock);
|
||||
|
||||
/* Cleanup dead proxy entities. One can argue this should be an
|
||||
independent thread, but one can also easily argue that an
|
||||
|
@ -143,7 +142,7 @@ static uint32_t gcreq_queue_thread (struct gcreq_queue *q)
|
|||
DDS_TRACE("gc %p: not yet, shortsleep\n", (void*)gcreq);
|
||||
trace_shortsleep = 0;
|
||||
}
|
||||
os_nanoSleep (shortsleep);
|
||||
dds_sleepfor (shortsleep);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -160,21 +159,21 @@ static uint32_t gcreq_queue_thread (struct gcreq_queue *q)
|
|||
}
|
||||
}
|
||||
|
||||
os_mutexLock (&q->lock);
|
||||
ddsrt_mutex_lock (&q->lock);
|
||||
}
|
||||
os_mutexUnlock (&q->lock);
|
||||
ddsrt_mutex_unlock (&q->lock);
|
||||
return 0;
|
||||
}
|
||||
|
||||
struct gcreq_queue *gcreq_queue_new (void)
|
||||
{
|
||||
struct gcreq_queue *q = os_malloc (sizeof (*q));
|
||||
struct gcreq_queue *q = ddsrt_malloc (sizeof (*q));
|
||||
|
||||
q->first = q->last = NULL;
|
||||
q->terminate = 0;
|
||||
q->count = 0;
|
||||
os_mutexInit (&q->lock);
|
||||
os_condInit (&q->cond, &q->lock);
|
||||
ddsrt_mutex_init (&q->lock);
|
||||
ddsrt_cond_init (&q->cond);
|
||||
q->ts = create_thread ("gc", (uint32_t (*) (void *)) gcreq_queue_thread, q);
|
||||
assert (q->ts);
|
||||
return q;
|
||||
|
@ -182,10 +181,10 @@ struct gcreq_queue *gcreq_queue_new (void)
|
|||
|
||||
void gcreq_queue_drain (struct gcreq_queue *q)
|
||||
{
|
||||
os_mutexLock (&q->lock);
|
||||
ddsrt_mutex_lock (&q->lock);
|
||||
while (q->count != 0)
|
||||
os_condWait (&q->cond, &q->lock);
|
||||
os_mutexUnlock (&q->lock);
|
||||
ddsrt_cond_wait (&q->cond, &q->lock);
|
||||
ddsrt_mutex_unlock (&q->lock);
|
||||
}
|
||||
|
||||
void gcreq_queue_free (struct gcreq_queue *q)
|
||||
|
@ -196,14 +195,14 @@ void gcreq_queue_free (struct gcreq_queue *q)
|
|||
gcreq = gcreq_new (q, gcreq_free);
|
||||
gcreq->nvtimes = 0;
|
||||
|
||||
os_mutexLock (&q->lock);
|
||||
ddsrt_mutex_lock (&q->lock);
|
||||
q->terminate = 1;
|
||||
/* Wait until there is only request in existence, the one we just
|
||||
allocated (this is also why we can't use "drain" here). Then
|
||||
we know the gc system is quiet. */
|
||||
while (q->count != 1)
|
||||
os_condWait (&q->cond, &q->lock);
|
||||
os_mutexUnlock (&q->lock);
|
||||
ddsrt_cond_wait (&q->cond, &q->lock);
|
||||
ddsrt_mutex_unlock (&q->lock);
|
||||
|
||||
/* Force the gc thread to wake up by enqueueing our no-op. The
|
||||
callback, gcreq_free, will be called immediately, which causes
|
||||
|
@ -213,40 +212,40 @@ void gcreq_queue_free (struct gcreq_queue *q)
|
|||
|
||||
join_thread (q->ts);
|
||||
assert (q->first == NULL);
|
||||
os_condDestroy (&q->cond);
|
||||
os_mutexDestroy (&q->lock);
|
||||
os_free (q);
|
||||
ddsrt_cond_destroy (&q->cond);
|
||||
ddsrt_mutex_destroy (&q->lock);
|
||||
ddsrt_free (q);
|
||||
}
|
||||
|
||||
struct gcreq *gcreq_new (struct gcreq_queue *q, gcreq_cb_t cb)
|
||||
{
|
||||
struct gcreq *gcreq;
|
||||
gcreq = os_malloc (offsetof (struct gcreq, vtimes) + thread_states.nthreads * sizeof (*gcreq->vtimes));
|
||||
gcreq = ddsrt_malloc (offsetof (struct gcreq, vtimes) + thread_states.nthreads * sizeof (*gcreq->vtimes));
|
||||
gcreq->cb = cb;
|
||||
gcreq->queue = q;
|
||||
threads_vtime_gather_for_wait (&gcreq->nvtimes, gcreq->vtimes);
|
||||
os_mutexLock (&q->lock);
|
||||
ddsrt_mutex_lock (&q->lock);
|
||||
q->count++;
|
||||
os_mutexUnlock (&q->lock);
|
||||
ddsrt_mutex_unlock (&q->lock);
|
||||
return gcreq;
|
||||
}
|
||||
|
||||
void gcreq_free (struct gcreq *gcreq)
|
||||
{
|
||||
struct gcreq_queue *gcreq_queue = gcreq->queue;
|
||||
os_mutexLock (&gcreq_queue->lock);
|
||||
ddsrt_mutex_lock (&gcreq_queue->lock);
|
||||
--gcreq_queue->count;
|
||||
if (gcreq_queue->count <= 1)
|
||||
os_condBroadcast (&gcreq_queue->cond);
|
||||
os_mutexUnlock (&gcreq_queue->lock);
|
||||
os_free (gcreq);
|
||||
ddsrt_cond_broadcast (&gcreq_queue->cond);
|
||||
ddsrt_mutex_unlock (&gcreq_queue->lock);
|
||||
ddsrt_free (gcreq);
|
||||
}
|
||||
|
||||
static int gcreq_enqueue_common (struct gcreq *gcreq)
|
||||
{
|
||||
struct gcreq_queue *gcreq_queue = gcreq->queue;
|
||||
int isfirst;
|
||||
os_mutexLock (&gcreq_queue->lock);
|
||||
ddsrt_mutex_lock (&gcreq_queue->lock);
|
||||
gcreq->next = NULL;
|
||||
if (gcreq_queue->first)
|
||||
{
|
||||
|
@ -260,8 +259,8 @@ static int gcreq_enqueue_common (struct gcreq *gcreq)
|
|||
}
|
||||
gcreq_queue->last = gcreq;
|
||||
if (isfirst)
|
||||
os_condBroadcast (&gcreq_queue->cond);
|
||||
os_mutexUnlock (&gcreq_queue->lock);
|
||||
ddsrt_cond_broadcast (&gcreq_queue->cond);
|
||||
ddsrt_mutex_unlock (&gcreq_queue->lock);
|
||||
return isfirst;
|
||||
}
|
||||
|
||||
|
|
|
@ -12,51 +12,55 @@
|
|||
#include <ctype.h>
|
||||
#include <stddef.h>
|
||||
|
||||
#include "os/os.h"
|
||||
#include "dds/ddsrt/heap.h"
|
||||
#include "dds/ddsrt/process.h"
|
||||
#include "dds/ddsrt/time.h"
|
||||
#include "dds/ddsrt/string.h"
|
||||
#include "dds/ddsrt/sync.h"
|
||||
|
||||
#include "util/ut_avl.h"
|
||||
#include "util/ut_thread_pool.h"
|
||||
#include "dds/util/ut_avl.h"
|
||||
#include "dds/util/ut_thread_pool.h"
|
||||
|
||||
#include "ddsi/q_md5.h"
|
||||
#include "ddsi/q_protocol.h"
|
||||
#include "ddsi/q_rtps.h"
|
||||
#include "ddsi/q_misc.h"
|
||||
#include "ddsi/q_config.h"
|
||||
#include "ddsi/q_log.h"
|
||||
#include "ddsi/q_plist.h"
|
||||
#include "ddsi/q_unused.h"
|
||||
#include "ddsi/q_bswap.h"
|
||||
#include "ddsi/q_lat_estim.h"
|
||||
#include "ddsi/q_bitset.h"
|
||||
#include "ddsi/q_xevent.h"
|
||||
#include "ddsi/q_addrset.h"
|
||||
#include "ddsi/q_ddsi_discovery.h"
|
||||
#include "ddsi/q_radmin.h"
|
||||
#include "ddsi/q_error.h"
|
||||
#include "ddsi/q_thread.h"
|
||||
#include "ddsi/q_ephash.h"
|
||||
#include "ddsi/q_lease.h"
|
||||
#include "ddsi/q_gc.h"
|
||||
#include "ddsi/q_entity.h"
|
||||
#include "ddsi/q_nwif.h"
|
||||
#include "ddsi/q_globals.h"
|
||||
#include "ddsi/q_xmsg.h"
|
||||
#include "ddsi/q_receive.h"
|
||||
#include "ddsi/q_pcap.h"
|
||||
#include "ddsi/q_feature_check.h"
|
||||
#include "ddsi/q_debmon.h"
|
||||
#include "ddsi/q_init.h"
|
||||
#include "dds/ddsi/q_md5.h"
|
||||
#include "dds/ddsi/q_protocol.h"
|
||||
#include "dds/ddsi/q_rtps.h"
|
||||
#include "dds/ddsi/q_misc.h"
|
||||
#include "dds/ddsi/q_config.h"
|
||||
#include "dds/ddsi/q_log.h"
|
||||
#include "dds/ddsi/q_plist.h"
|
||||
#include "dds/ddsi/q_unused.h"
|
||||
#include "dds/ddsi/q_bswap.h"
|
||||
#include "dds/ddsi/q_lat_estim.h"
|
||||
#include "dds/ddsi/q_bitset.h"
|
||||
#include "dds/ddsi/q_xevent.h"
|
||||
#include "dds/ddsi/q_addrset.h"
|
||||
#include "dds/ddsi/q_ddsi_discovery.h"
|
||||
#include "dds/ddsi/q_radmin.h"
|
||||
#include "dds/ddsi/q_error.h"
|
||||
#include "dds/ddsi/q_thread.h"
|
||||
#include "dds/ddsi/q_ephash.h"
|
||||
#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/q_globals.h"
|
||||
#include "dds/ddsi/q_xmsg.h"
|
||||
#include "dds/ddsi/q_receive.h"
|
||||
#include "dds/ddsi/q_pcap.h"
|
||||
#include "dds/ddsi/q_feature_check.h"
|
||||
#include "dds/ddsi/q_debmon.h"
|
||||
#include "dds/ddsi/q_init.h"
|
||||
|
||||
#include "ddsi/ddsi_tran.h"
|
||||
#include "ddsi/ddsi_udp.h"
|
||||
#include "ddsi/ddsi_tcp.h"
|
||||
#include "ddsi/ddsi_raweth.h"
|
||||
#include "ddsi/ddsi_mcgroup.h"
|
||||
#include "ddsi/ddsi_serdata_default.h"
|
||||
#include "dds/ddsi/ddsi_tran.h"
|
||||
#include "dds/ddsi/ddsi_udp.h"
|
||||
#include "dds/ddsi/ddsi_tcp.h"
|
||||
#include "dds/ddsi/ddsi_raweth.h"
|
||||
#include "dds/ddsi/ddsi_mcgroup.h"
|
||||
#include "dds/ddsi/ddsi_serdata_default.h"
|
||||
|
||||
#include "ddsi/ddsi_tkmap.h"
|
||||
#include "dds/ddsi/ddsi_tkmap.h"
|
||||
#include "dds__whc.h"
|
||||
#include "ddsi/ddsi_iid.h"
|
||||
#include "dds/ddsi/ddsi_iid.h"
|
||||
|
||||
static void add_peer_addresses (struct addrset *as, const struct config_peer_listelem *list)
|
||||
{
|
||||
|
@ -142,9 +146,9 @@ static int set_recvips (void)
|
|||
|
||||
if (config.networkRecvAddressStrings)
|
||||
{
|
||||
if (os_strcasecmp (config.networkRecvAddressStrings[0], "all") == 0)
|
||||
if (ddsrt_strcasecmp (config.networkRecvAddressStrings[0], "all") == 0)
|
||||
{
|
||||
#if OS_SOCKET_HAS_IPV6
|
||||
#if DDSRT_HAVE_IPV6
|
||||
if (gv.ipv6_link_local)
|
||||
{
|
||||
DDS_WARNING("DDSI2EService/General/MulticastRecvNetworkInterfaceAddresses: using 'preferred' instead of 'all' because of IPv6 link-local address\n");
|
||||
|
@ -156,9 +160,9 @@ static int set_recvips (void)
|
|||
gv.recvips_mode = RECVIPS_MODE_ALL;
|
||||
}
|
||||
}
|
||||
else if (os_strcasecmp (config.networkRecvAddressStrings[0], "any") == 0)
|
||||
else if (ddsrt_strcasecmp (config.networkRecvAddressStrings[0], "any") == 0)
|
||||
{
|
||||
#if OS_SOCKET_HAS_IPV6
|
||||
#if DDSRT_HAVE_IPV6
|
||||
if (gv.ipv6_link_local)
|
||||
{
|
||||
DDS_ERROR("DDSI2EService/General/MulticastRecvNetworkInterfaceAddresses: 'any' is unsupported in combination with an IPv6 link-local address\n");
|
||||
|
@ -167,15 +171,15 @@ static int set_recvips (void)
|
|||
#endif
|
||||
gv.recvips_mode = RECVIPS_MODE_ANY;
|
||||
}
|
||||
else if (os_strcasecmp (config.networkRecvAddressStrings[0], "preferred") == 0)
|
||||
else if (ddsrt_strcasecmp (config.networkRecvAddressStrings[0], "preferred") == 0)
|
||||
{
|
||||
gv.recvips_mode = RECVIPS_MODE_PREFERRED;
|
||||
}
|
||||
else if (os_strcasecmp (config.networkRecvAddressStrings[0], "none") == 0)
|
||||
else if (ddsrt_strcasecmp (config.networkRecvAddressStrings[0], "none") == 0)
|
||||
{
|
||||
gv.recvips_mode = RECVIPS_MODE_NONE;
|
||||
}
|
||||
#if OS_SOCKET_HAS_IPV6
|
||||
#if DDSRT_HAVE_IPV6
|
||||
else if (gv.ipv6_link_local)
|
||||
{
|
||||
/* If the configuration explicitly includes the selected
|
||||
|
@ -225,7 +229,7 @@ static int set_recvips (void)
|
|||
DDS_ERROR("No interface bound to requested address '%s'\n", config.networkRecvAddressStrings[i]);
|
||||
return -1;
|
||||
}
|
||||
*recvnode = os_malloc (sizeof (struct config_in_addr_node));
|
||||
*recvnode = ddsrt_malloc (sizeof (struct config_in_addr_node));
|
||||
(*recvnode)->loc = loc;
|
||||
recvnode = &(*recvnode)->next;
|
||||
*recvnode = NULL;
|
||||
|
@ -422,7 +426,7 @@ static int check_thread_properties (void)
|
|||
return ok;
|
||||
}
|
||||
|
||||
OS_WARNING_MSVC_OFF(4996);
|
||||
DDSRT_WARNING_MSVC_OFF(4996);
|
||||
int rtps_config_open (void)
|
||||
{
|
||||
int status;
|
||||
|
@ -433,12 +437,12 @@ int rtps_config_open (void)
|
|||
config.tracingOutputFile = NULL;
|
||||
status = 1;
|
||||
}
|
||||
else if (os_strcasecmp (config.tracingOutputFileName, "stdout") == 0)
|
||||
else if (ddsrt_strcasecmp (config.tracingOutputFileName, "stdout") == 0)
|
||||
{
|
||||
config.tracingOutputFile = stdout;
|
||||
status = 1;
|
||||
}
|
||||
else if (os_strcasecmp (config.tracingOutputFileName, "stderr") == 0)
|
||||
else if (ddsrt_strcasecmp (config.tracingOutputFileName, "stderr") == 0)
|
||||
{
|
||||
config.tracingOutputFile = stderr;
|
||||
status = 1;
|
||||
|
@ -458,7 +462,7 @@ int rtps_config_open (void)
|
|||
|
||||
return status;
|
||||
}
|
||||
OS_WARNING_MSVC_ON(4996);
|
||||
DDSRT_WARNING_MSVC_ON(4996);
|
||||
|
||||
int rtps_config_prep (struct cfgst *cfgst)
|
||||
{
|
||||
|
@ -542,7 +546,7 @@ int rtps_config_prep (struct cfgst *cfgst)
|
|||
while (chptr)
|
||||
{
|
||||
size_t slen = strlen (chptr->name) + 5;
|
||||
char *thread_name = os_malloc (slen);
|
||||
char *thread_name = ddsrt_malloc (slen);
|
||||
(void) snprintf (thread_name, slen, "tev.%s", chptr->name);
|
||||
|
||||
num_channels++;
|
||||
|
@ -561,7 +565,7 @@ int rtps_config_prep (struct cfgst *cfgst)
|
|||
lookup_thread_properties (thread_name))
|
||||
num_channel_threads++;
|
||||
|
||||
os_free (thread_name);
|
||||
ddsrt_free (thread_name);
|
||||
chptr = chptr->next;
|
||||
}
|
||||
if (error)
|
||||
|
@ -689,15 +693,15 @@ err_disc:
|
|||
static void rtps_term_prep (void)
|
||||
{
|
||||
/* Stop all I/O */
|
||||
os_mutexLock (&gv.lock);
|
||||
ddsrt_mutex_lock (&gv.lock);
|
||||
if (gv.rtps_keepgoing)
|
||||
{
|
||||
gv.rtps_keepgoing = 0; /* so threads will stop once they get round to checking */
|
||||
os_atomic_fence ();
|
||||
ddsrt_atomic_fence ();
|
||||
/* can't wake up throttle_writer, currently, but it'll check every few seconds */
|
||||
trigger_recv_threads ();
|
||||
}
|
||||
os_mutexUnlock (&gv.lock);
|
||||
ddsrt_mutex_unlock (&gv.lock);
|
||||
}
|
||||
|
||||
struct wait_for_receive_threads_helper_arg {
|
||||
|
@ -751,9 +755,9 @@ static struct ddsi_sertopic *make_special_topic (uint16_t enc_id, const struct d
|
|||
- initialising/freeing them here, in this manner, is not very clean
|
||||
it should be moved to somewhere in the topic implementation
|
||||
(kinda natural if they stop being "default" ones) */
|
||||
struct ddsi_sertopic_default *st = os_malloc (sizeof (*st));
|
||||
struct ddsi_sertopic_default *st = ddsrt_malloc (sizeof (*st));
|
||||
memset (st, 0, sizeof (*st));
|
||||
os_atomic_st32 (&st->c.refc, 1);
|
||||
ddsrt_atomic_st32 (&st->c.refc, 1);
|
||||
st->c.ops = &ddsi_sertopic_ops_default;
|
||||
st->c.serdata_ops = ops;
|
||||
st->c.serdata_basehash = ddsi_sertopic_compute_serdata_basehash (st->c.serdata_ops);
|
||||
|
@ -765,8 +769,8 @@ static struct ddsi_sertopic *make_special_topic (uint16_t enc_id, const struct d
|
|||
|
||||
static void make_special_topics (void)
|
||||
{
|
||||
gv.plist_topic = make_special_topic (PLATFORM_IS_LITTLE_ENDIAN ? PL_CDR_LE : PL_CDR_BE, &ddsi_serdata_ops_plist);
|
||||
gv.rawcdr_topic = make_special_topic (PLATFORM_IS_LITTLE_ENDIAN ? CDR_LE : CDR_BE, &ddsi_serdata_ops_rawcdr);
|
||||
gv.plist_topic = make_special_topic (DDSRT_ENDIAN == DDSRT_LITTLE_ENDIAN ? PL_CDR_LE : PL_CDR_BE, &ddsi_serdata_ops_plist);
|
||||
gv.rawcdr_topic = make_special_topic (DDSRT_ENDIAN == DDSRT_LITTLE_ENDIAN ? CDR_LE : CDR_BE, &ddsi_serdata_ops_rawcdr);
|
||||
}
|
||||
|
||||
static void free_special_topics (void)
|
||||
|
@ -882,11 +886,8 @@ int rtps_init (void)
|
|||
{
|
||||
int sec = (int) (gv.tstart.v / 1000000000);
|
||||
int usec = (int) (gv.tstart.v % 1000000000) / 1000;
|
||||
os_time tv;
|
||||
char str[OS_CTIME_R_BUFSIZE];
|
||||
tv.tv_sec = sec;
|
||||
tv.tv_nsec = usec * 1000;
|
||||
os_ctime_r (&tv, str, sizeof(str));
|
||||
char str[DDSRT_RFC3339STRLEN];
|
||||
ddsrt_ctime(gv.tstart.v, str, sizeof(str));
|
||||
DDS_LOG(DDS_LC_CONFIG, "started at %d.06%d -- %s\n", sec, usec, str);
|
||||
}
|
||||
|
||||
|
@ -989,12 +990,12 @@ int rtps_init (void)
|
|||
{
|
||||
static const char msgtag_fixed[] = ": partition address";
|
||||
size_t slen = strlen (np->name) + sizeof (msgtag_fixed);
|
||||
char * msgtag = os_malloc (slen);
|
||||
char * msgtag = ddsrt_malloc (slen);
|
||||
int rc;
|
||||
snprintf (msgtag, slen, "%s%s", np->name, msgtag_fixed);
|
||||
np->as = new_addrset ();
|
||||
rc = add_addresses_to_addrset (np->as, np->address_string, port, msgtag, 1);
|
||||
os_free (msgtag);
|
||||
ddsrt_free (msgtag);
|
||||
if (rc < 0)
|
||||
goto err_network_partition_addrset;
|
||||
}
|
||||
|
@ -1031,23 +1032,23 @@ int rtps_init (void)
|
|||
|
||||
make_special_topics ();
|
||||
|
||||
os_mutexInit (&gv.participant_set_lock);
|
||||
os_condInit (&gv.participant_set_cond, &gv.participant_set_lock);
|
||||
ddsrt_mutex_init (&gv.participant_set_lock);
|
||||
ddsrt_cond_init (&gv.participant_set_cond);
|
||||
lease_management_init ();
|
||||
deleted_participants_admin_init ();
|
||||
gv.guid_hash = ephash_new ();
|
||||
|
||||
os_mutexInit (&gv.privileged_pp_lock);
|
||||
ddsrt_mutex_init (&gv.privileged_pp_lock);
|
||||
gv.privileged_pp = NULL;
|
||||
|
||||
/* Template PP guid -- protected by privileged_pp_lock for simplicity */
|
||||
gv.next_ppguid.prefix.u[0] = locator_to_hopefully_unique_uint32 (&gv.ownloc);
|
||||
gv.next_ppguid.prefix.u[1] = (unsigned) os_getpid ();
|
||||
gv.next_ppguid.prefix.u[1] = (unsigned) ddsrt_getpid ();
|
||||
gv.next_ppguid.prefix.u[2] = 1;
|
||||
gv.next_ppguid.entityid.u = NN_ENTITYID_PARTICIPANT;
|
||||
|
||||
os_mutexInit (&gv.lock);
|
||||
os_mutexInit (&gv.spdp_lock);
|
||||
ddsrt_mutex_init (&gv.lock);
|
||||
ddsrt_mutex_init (&gv.spdp_lock);
|
||||
gv.spdp_defrag = nn_defrag_new (NN_DEFRAG_DROP_OLDEST, config.defrag_unreliable_maxsamples);
|
||||
gv.spdp_reorder = nn_reorder_new (NN_REORDER_MODE_ALWAYS_DELIVER, config.primary_reorder_maxsamples);
|
||||
|
||||
|
@ -1101,7 +1102,7 @@ int rtps_init (void)
|
|||
gv.pcap_fp = new_pcap_file (config.pcap_file);
|
||||
if (gv.pcap_fp)
|
||||
{
|
||||
os_mutexInit (&gv.pcap_lock);
|
||||
ddsrt_mutex_init (&gv.pcap_lock);
|
||||
}
|
||||
}
|
||||
else
|
||||
|
@ -1176,7 +1177,7 @@ int rtps_init (void)
|
|||
while (chptr)
|
||||
{
|
||||
size_t slen = strlen (chptr->name) + 5;
|
||||
char * tname = os_malloc (slen);
|
||||
char * tname = ddsrt_malloc (slen);
|
||||
(void) snprintf (tname, slen, "tev.%s", chptr->name);
|
||||
|
||||
/* Only actually create new connection if diffserv set */
|
||||
|
@ -1221,7 +1222,7 @@ int rtps_init (void)
|
|||
);
|
||||
}
|
||||
#endif
|
||||
os_free (tname);
|
||||
ddsrt_free (tname);
|
||||
chptr = chptr->next;
|
||||
}
|
||||
}
|
||||
|
@ -1272,7 +1273,7 @@ int rtps_init (void)
|
|||
gv.gcreq_queue = gcreq_queue_new ();
|
||||
|
||||
gv.rtps_keepgoing = 1;
|
||||
os_rwlockInit (&gv.qoslock);
|
||||
ddsrt_rwlock_init (&gv.qoslock);
|
||||
|
||||
{
|
||||
int r;
|
||||
|
@ -1337,7 +1338,7 @@ err_mc_conn:
|
|||
if (gv.data_conn_mc && gv.data_conn_mc != gv.disc_conn_mc)
|
||||
ddsi_conn_free (gv.data_conn_mc);
|
||||
if (gv.pcap_fp)
|
||||
os_mutexDestroy (&gv.pcap_lock);
|
||||
ddsrt_mutex_destroy (&gv.pcap_lock);
|
||||
if (gv.disc_conn_uc != gv.disc_conn_mc)
|
||||
ddsi_conn_free (gv.disc_conn_uc);
|
||||
if (gv.data_conn_uc != gv.disc_conn_uc)
|
||||
|
@ -1347,15 +1348,15 @@ err_unicast_sockets:
|
|||
ddsi_tkmap_free (gv.m_tkmap);
|
||||
nn_reorder_free (gv.spdp_reorder);
|
||||
nn_defrag_free (gv.spdp_defrag);
|
||||
os_mutexDestroy (&gv.spdp_lock);
|
||||
os_mutexDestroy (&gv.lock);
|
||||
os_mutexDestroy (&gv.privileged_pp_lock);
|
||||
ddsrt_mutex_destroy (&gv.spdp_lock);
|
||||
ddsrt_mutex_destroy (&gv.lock);
|
||||
ddsrt_mutex_destroy (&gv.privileged_pp_lock);
|
||||
ephash_free (gv.guid_hash);
|
||||
gv.guid_hash = NULL;
|
||||
deleted_participants_admin_fini ();
|
||||
lease_management_term ();
|
||||
os_condDestroy (&gv.participant_set_cond);
|
||||
os_mutexDestroy (&gv.participant_set_lock);
|
||||
ddsrt_cond_destroy (&gv.participant_set_cond);
|
||||
ddsrt_mutex_destroy (&gv.participant_set_lock);
|
||||
free_special_topics ();
|
||||
#ifdef DDSI_INCLUDE_ENCRYPTION
|
||||
if (q_security_plugin.free_decoder)
|
||||
|
@ -1385,13 +1386,13 @@ err_set_ext_address:
|
|||
{
|
||||
struct config_in_addr_node *n = gv.recvips;
|
||||
gv.recvips = n->next;
|
||||
os_free (n);
|
||||
ddsrt_free (n);
|
||||
}
|
||||
err_set_recvips:
|
||||
{
|
||||
int i;
|
||||
for (i = 0; i < gv.n_interfaces; i++)
|
||||
os_free (gv.interfaces[i].name);
|
||||
ddsrt_free (gv.interfaces[i].name);
|
||||
}
|
||||
err_find_own_ip:
|
||||
ddsi_tran_factories_fini ();
|
||||
|
@ -1402,18 +1403,18 @@ err_udp_tcp_init:
|
|||
}
|
||||
|
||||
struct dq_builtins_ready_arg {
|
||||
os_mutex lock;
|
||||
os_cond cond;
|
||||
ddsrt_mutex_t lock;
|
||||
ddsrt_cond_t cond;
|
||||
int ready;
|
||||
};
|
||||
|
||||
static void builtins_dqueue_ready_cb (void *varg)
|
||||
{
|
||||
struct dq_builtins_ready_arg *arg = varg;
|
||||
os_mutexLock (&arg->lock);
|
||||
ddsrt_mutex_lock (&arg->lock);
|
||||
arg->ready = 1;
|
||||
os_condBroadcast (&arg->cond);
|
||||
os_mutexUnlock (&arg->lock);
|
||||
ddsrt_cond_broadcast (&arg->cond);
|
||||
ddsrt_mutex_unlock (&arg->lock);
|
||||
}
|
||||
|
||||
void rtps_stop (void)
|
||||
|
@ -1454,23 +1455,23 @@ void rtps_stop (void)
|
|||
deleting them */
|
||||
{
|
||||
struct dq_builtins_ready_arg arg;
|
||||
os_mutexInit (&arg.lock);
|
||||
os_condInit (&arg.cond, &arg.lock);
|
||||
ddsrt_mutex_init (&arg.lock);
|
||||
ddsrt_cond_init (&arg.cond);
|
||||
arg.ready = 0;
|
||||
nn_dqueue_enqueue_callback(gv.builtins_dqueue, builtins_dqueue_ready_cb, &arg);
|
||||
os_mutexLock (&arg.lock);
|
||||
ddsrt_mutex_lock (&arg.lock);
|
||||
while (!arg.ready)
|
||||
os_condWait (&arg.cond, &arg.lock);
|
||||
os_mutexUnlock (&arg.lock);
|
||||
os_condDestroy (&arg.cond);
|
||||
os_mutexDestroy (&arg.lock);
|
||||
ddsrt_cond_wait (&arg.cond, &arg.lock);
|
||||
ddsrt_mutex_unlock (&arg.lock);
|
||||
ddsrt_cond_destroy (&arg.cond);
|
||||
ddsrt_mutex_destroy (&arg.lock);
|
||||
}
|
||||
|
||||
/* Once the receive threads have stopped, defragmentation and
|
||||
reorder state can't change anymore, and can be freed safely. */
|
||||
nn_reorder_free (gv.spdp_reorder);
|
||||
nn_defrag_free (gv.spdp_defrag);
|
||||
os_mutexDestroy (&gv.spdp_lock);
|
||||
ddsrt_mutex_destroy (&gv.spdp_lock);
|
||||
#ifdef DDSI_INCLUDE_ENCRYPTION
|
||||
if (q_security_plugin.free_decoder)
|
||||
{
|
||||
|
@ -1536,10 +1537,10 @@ void rtps_stop (void)
|
|||
/* Wait until all participants are really gone => by then we can be
|
||||
certain that no new GC requests will be added, short of what we
|
||||
do here */
|
||||
os_mutexLock (&gv.participant_set_lock);
|
||||
ddsrt_mutex_lock (&gv.participant_set_lock);
|
||||
while (gv.nparticipants > 0)
|
||||
os_condWait (&gv.participant_set_cond, &gv.participant_set_lock);
|
||||
os_mutexUnlock (&gv.participant_set_lock);
|
||||
ddsrt_cond_wait (&gv.participant_set_cond, &gv.participant_set_lock);
|
||||
ddsrt_mutex_unlock (&gv.participant_set_lock);
|
||||
|
||||
/* Wait until no more GC requests are outstanding -- not really
|
||||
necessary, but it allows us to claim the stack is quiescent
|
||||
|
@ -1549,7 +1550,7 @@ void rtps_stop (void)
|
|||
/* Clean up privileged_pp -- it must be NULL now (all participants
|
||||
are gone), but the lock still needs to be destroyed */
|
||||
assert (gv.privileged_pp == NULL);
|
||||
os_mutexDestroy (&gv.privileged_pp_lock);
|
||||
ddsrt_mutex_destroy (&gv.privileged_pp_lock);
|
||||
}
|
||||
|
||||
void rtps_fini (void)
|
||||
|
@ -1616,7 +1617,7 @@ void rtps_fini (void)
|
|||
|
||||
if (gv.pcap_fp)
|
||||
{
|
||||
os_mutexDestroy (&gv.pcap_lock);
|
||||
ddsrt_mutex_destroy (&gv.pcap_lock);
|
||||
fclose (gv.pcap_fp);
|
||||
}
|
||||
|
||||
|
@ -1647,8 +1648,8 @@ void rtps_fini (void)
|
|||
gv.guid_hash = NULL;
|
||||
deleted_participants_admin_fini ();
|
||||
lease_management_term ();
|
||||
os_mutexDestroy (&gv.participant_set_lock);
|
||||
os_condDestroy (&gv.participant_set_cond);
|
||||
ddsrt_mutex_destroy (&gv.participant_set_lock);
|
||||
ddsrt_cond_destroy (&gv.participant_set_cond);
|
||||
free_special_topics ();
|
||||
|
||||
nn_xqos_fini (&gv.builtin_endpoint_xqos_wr);
|
||||
|
@ -1662,23 +1663,23 @@ void rtps_fini (void)
|
|||
nn_xqos_fini (&gv.default_xqos_rd);
|
||||
nn_plist_fini (&gv.default_plist_pp);
|
||||
|
||||
os_mutexDestroy (&gv.lock);
|
||||
os_rwlockDestroy (&gv.qoslock);
|
||||
ddsrt_mutex_destroy (&gv.lock);
|
||||
ddsrt_rwlock_destroy (&gv.qoslock);
|
||||
|
||||
while (gv.recvips)
|
||||
{
|
||||
struct config_in_addr_node *n = gv.recvips;
|
||||
/* The compiler doesn't realize that n->next is always initialized. */
|
||||
OS_WARNING_MSVC_OFF(6001);
|
||||
DDSRT_WARNING_MSVC_OFF(6001);
|
||||
gv.recvips = n->next;
|
||||
OS_WARNING_MSVC_ON(6001);
|
||||
os_free (n);
|
||||
DDSRT_WARNING_MSVC_ON(6001);
|
||||
ddsrt_free (n);
|
||||
}
|
||||
|
||||
{
|
||||
int i;
|
||||
for (i = 0; i < (int) gv.n_interfaces; i++)
|
||||
os_free (gv.interfaces[i].name);
|
||||
ddsrt_free (gv.interfaces[i].name);
|
||||
}
|
||||
|
||||
ddsi_serdatapool_free (gv.serpool);
|
||||
|
|
|
@ -11,11 +11,11 @@
|
|||
*/
|
||||
#include <assert.h>
|
||||
#include <stddef.h>
|
||||
#include "os/os.h"
|
||||
#include "util/ut_avl.h"
|
||||
#include "ddsi/q_config.h"
|
||||
#include "ddsi/q_log.h"
|
||||
#include "ddsi/q_inverse_uint32_set.h"
|
||||
#include "dds/ddsrt/heap.h"
|
||||
#include "dds/util/ut_avl.h"
|
||||
#include "dds/ddsi/q_config.h"
|
||||
#include "dds/ddsi/q_log.h"
|
||||
#include "dds/ddsi/q_inverse_uint32_set.h"
|
||||
|
||||
static int uint32_t_cmp(const void *va, const void *vb);
|
||||
|
||||
|
@ -55,7 +55,7 @@ void inverse_uint32_set_init(struct inverse_uint32_set *set, uint32_t min, uint3
|
|||
set->cursor = min;
|
||||
set->min = min;
|
||||
set->max = max;
|
||||
n = os_malloc(sizeof(*n));
|
||||
n = ddsrt_malloc(sizeof(*n));
|
||||
n->min = min;
|
||||
n->max = max;
|
||||
ut_avlInsert(&inverse_uint32_set_td, &set->ids, n);
|
||||
|
@ -64,7 +64,7 @@ void inverse_uint32_set_init(struct inverse_uint32_set *set, uint32_t min, uint3
|
|||
|
||||
void inverse_uint32_set_fini(struct inverse_uint32_set *set)
|
||||
{
|
||||
ut_avlFree(&inverse_uint32_set_td, &set->ids, os_free);
|
||||
ut_avlFree(&inverse_uint32_set_td, &set->ids, ddsrt_free);
|
||||
}
|
||||
|
||||
static uint32_t inverse_uint32_set_alloc_use_min(struct inverse_uint32_set *set, struct inverse_uint32_set_node *n)
|
||||
|
@ -73,7 +73,7 @@ static uint32_t inverse_uint32_set_alloc_use_min(struct inverse_uint32_set *set,
|
|||
if (n->min == n->max)
|
||||
{
|
||||
ut_avlDelete(&inverse_uint32_set_td, &set->ids, n);
|
||||
os_free(n);
|
||||
ddsrt_free(n);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -100,7 +100,7 @@ int inverse_uint32_set_alloc(uint32_t * const id, struct inverse_uint32_set *set
|
|||
}
|
||||
else
|
||||
{
|
||||
struct inverse_uint32_set_node *n1 = os_malloc(sizeof(*n1));
|
||||
struct inverse_uint32_set_node *n1 = ddsrt_malloc(sizeof(*n1));
|
||||
assert(n->min < set->cursor && set->cursor < n->max);
|
||||
n1->min = set->cursor + 1;
|
||||
n1->max = n->max;
|
||||
|
@ -150,7 +150,7 @@ void inverse_uint32_set_free(struct inverse_uint32_set *set, uint32_t id)
|
|||
} else {
|
||||
n->max = n1->max;
|
||||
ut_avlDeleteDPath(&inverse_uint32_set_td, &set->ids, n1, &dp);
|
||||
os_free(n1);
|
||||
ddsrt_free(n1);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -161,7 +161,7 @@ void inverse_uint32_set_free(struct inverse_uint32_set *set, uint32_t id)
|
|||
else
|
||||
{
|
||||
/* no adjacent interval */
|
||||
n = os_malloc(sizeof(*n));
|
||||
n = ddsrt_malloc(sizeof(*n));
|
||||
n->min = n->max = id;
|
||||
ut_avlInsertIPath(&inverse_uint32_set_td, &set->ids, n, &ip);
|
||||
}
|
||||
|
|
|
@ -12,9 +12,9 @@
|
|||
#include <ctype.h>
|
||||
#include <stddef.h>
|
||||
|
||||
#include "ddsi/q_log.h"
|
||||
#include "ddsi/q_unused.h"
|
||||
#include "ddsi/q_lat_estim.h"
|
||||
#include "dds/ddsi/q_log.h"
|
||||
#include "dds/ddsi/q_unused.h"
|
||||
#include "dds/ddsi/q_lat_estim.h"
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
||||
|
|
|
@ -13,30 +13,31 @@
|
|||
#include <stddef.h>
|
||||
#include <assert.h>
|
||||
|
||||
#include "os/os.h"
|
||||
#include "dds/ddsrt/heap.h"
|
||||
#include "dds/ddsrt/sync.h"
|
||||
|
||||
#include "util/ut_fibheap.h"
|
||||
#include "dds/util/ut_fibheap.h"
|
||||
|
||||
#include "ddsi/ddsi_serdata_default.h"
|
||||
#include "ddsi/q_protocol.h"
|
||||
#include "ddsi/q_rtps.h"
|
||||
#include "ddsi/q_misc.h"
|
||||
#include "ddsi/q_config.h"
|
||||
#include "ddsi/q_log.h"
|
||||
#include "ddsi/q_plist.h"
|
||||
#include "ddsi/q_unused.h"
|
||||
#include "ddsi/q_xevent.h"
|
||||
#include "ddsi/q_addrset.h"
|
||||
#include "ddsi/q_ddsi_discovery.h"
|
||||
#include "ddsi/q_radmin.h"
|
||||
#include "ddsi/q_ephash.h"
|
||||
#include "ddsi/q_entity.h"
|
||||
#include "ddsi/q_globals.h"
|
||||
#include "ddsi/q_xmsg.h"
|
||||
#include "ddsi/q_bswap.h"
|
||||
#include "ddsi/q_transmit.h"
|
||||
#include "ddsi/q_lease.h"
|
||||
#include "ddsi/q_gc.h"
|
||||
#include "dds/ddsi/ddsi_serdata_default.h"
|
||||
#include "dds/ddsi/q_protocol.h"
|
||||
#include "dds/ddsi/q_rtps.h"
|
||||
#include "dds/ddsi/q_misc.h"
|
||||
#include "dds/ddsi/q_config.h"
|
||||
#include "dds/ddsi/q_log.h"
|
||||
#include "dds/ddsi/q_plist.h"
|
||||
#include "dds/ddsi/q_unused.h"
|
||||
#include "dds/ddsi/q_xevent.h"
|
||||
#include "dds/ddsi/q_addrset.h"
|
||||
#include "dds/ddsi/q_ddsi_discovery.h"
|
||||
#include "dds/ddsi/q_radmin.h"
|
||||
#include "dds/ddsi/q_ephash.h"
|
||||
#include "dds/ddsi/q_entity.h"
|
||||
#include "dds/ddsi/q_globals.h"
|
||||
#include "dds/ddsi/q_xmsg.h"
|
||||
#include "dds/ddsi/q_bswap.h"
|
||||
#include "dds/ddsi/q_transmit.h"
|
||||
#include "dds/ddsi/q_lease.h"
|
||||
#include "dds/ddsi/q_gc.h"
|
||||
|
||||
/* This is absolute bottom for signed integers, where -x = x and yet x
|
||||
!= 0 -- and note that it had better be 2's complement machine! */
|
||||
|
@ -69,9 +70,9 @@ static int compare_lease_tsched (const void *va, const void *vb)
|
|||
void lease_management_init (void)
|
||||
{
|
||||
int i;
|
||||
os_mutexInit (&gv.leaseheap_lock);
|
||||
ddsrt_mutex_init (&gv.leaseheap_lock);
|
||||
for (i = 0; i < N_LEASE_LOCKS; i++)
|
||||
os_mutexInit (&gv.lease_locks[i]);
|
||||
ddsrt_mutex_init (&gv.lease_locks[i]);
|
||||
ut_fibheapInit (&lease_fhdef, &gv.leaseheap);
|
||||
}
|
||||
|
||||
|
@ -80,11 +81,11 @@ void lease_management_term (void)
|
|||
int i;
|
||||
assert (ut_fibheapMin (&lease_fhdef, &gv.leaseheap) == NULL);
|
||||
for (i = 0; i < N_LEASE_LOCKS; i++)
|
||||
os_mutexDestroy (&gv.lease_locks[i]);
|
||||
os_mutexDestroy (&gv.leaseheap_lock);
|
||||
ddsrt_mutex_destroy (&gv.lease_locks[i]);
|
||||
ddsrt_mutex_destroy (&gv.leaseheap_lock);
|
||||
}
|
||||
|
||||
static os_mutex *lock_lease_addr (struct lease const * const l)
|
||||
static ddsrt_mutex_t *lock_lease_addr (struct lease const * const l)
|
||||
{
|
||||
uint32_t u = (uint16_t) ((uintptr_t) l >> 3);
|
||||
uint32_t v = u * 0xb4817365;
|
||||
|
@ -94,18 +95,18 @@ static os_mutex *lock_lease_addr (struct lease const * const l)
|
|||
|
||||
static void lock_lease (const struct lease *l)
|
||||
{
|
||||
os_mutexLock (lock_lease_addr (l));
|
||||
ddsrt_mutex_lock (lock_lease_addr (l));
|
||||
}
|
||||
|
||||
static void unlock_lease (const struct lease *l)
|
||||
{
|
||||
os_mutexUnlock (lock_lease_addr (l));
|
||||
ddsrt_mutex_unlock (lock_lease_addr (l));
|
||||
}
|
||||
|
||||
struct lease *lease_new (nn_etime_t texpire, int64_t tdur, struct entity_common *e)
|
||||
{
|
||||
struct lease *l;
|
||||
if ((l = os_malloc (sizeof (*l))) == NULL)
|
||||
if ((l = ddsrt_malloc (sizeof (*l))) == NULL)
|
||||
return NULL;
|
||||
DDS_TRACE("lease_new(tdur %"PRId64" guid %x:%x:%x:%x) @ %p\n", tdur, PGUID (e->guid), (void *) l);
|
||||
l->tdur = tdur;
|
||||
|
@ -118,7 +119,7 @@ struct lease *lease_new (nn_etime_t texpire, int64_t tdur, struct entity_common
|
|||
void lease_register (struct lease *l)
|
||||
{
|
||||
DDS_TRACE("lease_register(l %p guid %x:%x:%x:%x)\n", (void *) l, PGUID (l->entity->guid));
|
||||
os_mutexLock (&gv.leaseheap_lock);
|
||||
ddsrt_mutex_lock (&gv.leaseheap_lock);
|
||||
lock_lease (l);
|
||||
assert (l->tsched.v == TSCHED_NOT_ON_HEAP);
|
||||
if (l->tend.v != T_NEVER)
|
||||
|
@ -127,7 +128,7 @@ void lease_register (struct lease *l)
|
|||
ut_fibheapInsert (&lease_fhdef, &gv.leaseheap, l);
|
||||
}
|
||||
unlock_lease (l);
|
||||
os_mutexUnlock (&gv.leaseheap_lock);
|
||||
ddsrt_mutex_unlock (&gv.leaseheap_lock);
|
||||
|
||||
/* check_and_handle_lease_expiration runs on GC thread and the only way to be sure that it wakes up in time is by forcing re-evaluation (strictly speaking only needed if this is the first lease to expire, but this operation is quite rare anyway) */
|
||||
force_lease_check();
|
||||
|
@ -136,11 +137,11 @@ void lease_register (struct lease *l)
|
|||
void lease_free (struct lease *l)
|
||||
{
|
||||
DDS_TRACE("lease_free(l %p guid %x:%x:%x:%x)\n", (void *) l, PGUID (l->entity->guid));
|
||||
os_mutexLock (&gv.leaseheap_lock);
|
||||
ddsrt_mutex_lock (&gv.leaseheap_lock);
|
||||
if (l->tsched.v != TSCHED_NOT_ON_HEAP)
|
||||
ut_fibheapDelete (&lease_fhdef, &gv.leaseheap, l);
|
||||
os_mutexUnlock (&gv.leaseheap_lock);
|
||||
os_free (l);
|
||||
ddsrt_mutex_unlock (&gv.leaseheap_lock);
|
||||
ddsrt_free (l);
|
||||
|
||||
/* see lease_register() */
|
||||
force_lease_check();
|
||||
|
@ -178,7 +179,7 @@ void lease_set_expiry (struct lease *l, nn_etime_t when)
|
|||
{
|
||||
bool trigger = false;
|
||||
assert (when.v >= 0);
|
||||
os_mutexLock (&gv.leaseheap_lock);
|
||||
ddsrt_mutex_lock (&gv.leaseheap_lock);
|
||||
lock_lease (l);
|
||||
l->tend = when;
|
||||
if (l->tend.v < l->tsched.v)
|
||||
|
@ -197,7 +198,7 @@ void lease_set_expiry (struct lease *l, nn_etime_t when)
|
|||
trigger = true;
|
||||
}
|
||||
unlock_lease (l);
|
||||
os_mutexUnlock (&gv.leaseheap_lock);
|
||||
ddsrt_mutex_unlock (&gv.leaseheap_lock);
|
||||
|
||||
/* see lease_register() */
|
||||
if (trigger)
|
||||
|
@ -208,7 +209,7 @@ int64_t check_and_handle_lease_expiration (UNUSED_ARG (struct thread_state1 *sel
|
|||
{
|
||||
struct lease *l;
|
||||
int64_t delay;
|
||||
os_mutexLock (&gv.leaseheap_lock);
|
||||
ddsrt_mutex_lock (&gv.leaseheap_lock);
|
||||
while ((l = ut_fibheapMin (&lease_fhdef, &gv.leaseheap)) != NULL && l->tsched.v <= tnowE.v)
|
||||
{
|
||||
nn_guid_t g = l->entity->guid;
|
||||
|
@ -277,7 +278,7 @@ int64_t check_and_handle_lease_expiration (UNUSED_ARG (struct thread_state1 *sel
|
|||
unlock_lease (l);
|
||||
|
||||
l->tsched.v = TSCHED_NOT_ON_HEAP;
|
||||
os_mutexUnlock (&gv.leaseheap_lock);
|
||||
ddsrt_mutex_unlock (&gv.leaseheap_lock);
|
||||
|
||||
switch (k)
|
||||
{
|
||||
|
@ -301,11 +302,11 @@ int64_t check_and_handle_lease_expiration (UNUSED_ARG (struct thread_state1 *sel
|
|||
break;
|
||||
}
|
||||
|
||||
os_mutexLock (&gv.leaseheap_lock);
|
||||
ddsrt_mutex_lock (&gv.leaseheap_lock);
|
||||
}
|
||||
|
||||
delay = (l == NULL) ? T_NEVER : (l->tsched.v - tnowE.v);
|
||||
os_mutexUnlock (&gv.leaseheap_lock);
|
||||
ddsrt_mutex_unlock (&gv.leaseheap_lock);
|
||||
return delay;
|
||||
}
|
||||
|
||||
|
@ -329,7 +330,7 @@ static void debug_print_rawdata (const char *msg, const void *data, size_t len)
|
|||
void handle_PMD (UNUSED_ARG (const struct receiver_state *rst), nn_wctime_t timestamp, unsigned statusinfo, const void *vdata, unsigned len)
|
||||
{
|
||||
const struct CDRHeader *data = vdata; /* built-ins not deserialized (yet) */
|
||||
const int bswap = (data->identifier == CDR_LE) ^ PLATFORM_IS_LITTLE_ENDIAN;
|
||||
const int bswap = (data->identifier == CDR_LE) ^ (DDSRT_ENDIAN == DDSRT_LITTLE_ENDIAN);
|
||||
struct proxy_participant *pp;
|
||||
nn_guid_t ppguid;
|
||||
DDS_TRACE(" PMD ST%x", statusinfo);
|
||||
|
@ -363,7 +364,7 @@ void handle_PMD (UNUSED_ARG (const struct receiver_state *rst), nn_wctime_t time
|
|||
/* Renew lease if arrival of this message didn't already do so, also renew the lease
|
||||
of the virtual participant used for DS-discovered endpoints */
|
||||
if (!config.arrival_of_data_asserts_pp_and_ep_liveliness)
|
||||
lease_renew (os_atomic_ldvoidp (&pp->lease), now_et ());
|
||||
lease_renew (ddsrt_atomic_ldvoidp (&pp->lease), now_et ());
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
|
|
@ -63,18 +63,18 @@
|
|||
1999-05-03 lpd Original version.
|
||||
*/
|
||||
|
||||
#include "ddsi/q_md5.h"
|
||||
#include "dds/ddsi/q_md5.h"
|
||||
#include <string.h>
|
||||
#include "os/os.h" /* big or little endianness */
|
||||
#include "dds/ddsrt/endian.h" /* big or little endianness */
|
||||
|
||||
/* Byte order stuff hacked to use OSPL's macros */
|
||||
#undef BYTE_ORDER /* 1 = big-endian, -1 = little-endian, 0 = unknown */
|
||||
#if OS_ENDIANNESS == OS_BIG_ENDIAN
|
||||
#if DDSRT_ENDIAN == DDSRT_BIG_ENDIAN
|
||||
# define BYTE_ORDER 1
|
||||
#elif OS_ENDIANNESS == OS_LITTLE_ENDIAN
|
||||
#elif DDSRT_ENDIAN == DDSRT_LITTLE_ENDIAN
|
||||
# define BYTE_ORDER -1
|
||||
#else
|
||||
# error "OS_ENDIANNESS not defined"
|
||||
# error "DDSRT_ENDIAN not defined"
|
||||
#endif
|
||||
|
||||
#define T_MASK ((md5_word_t)~0)
|
||||
|
|
|
@ -11,9 +11,9 @@
|
|||
*/
|
||||
#include <string.h>
|
||||
|
||||
#include "ddsi/q_misc.h"
|
||||
#include "ddsi/q_bswap.h"
|
||||
#include "ddsi/q_md5.h"
|
||||
#include "dds/ddsi/q_misc.h"
|
||||
#include "dds/ddsi/q_bswap.h"
|
||||
#include "dds/ddsi/q_md5.h"
|
||||
|
||||
extern inline seqno_t fromSN (const nn_sequence_number_t sn);
|
||||
extern inline nn_sequence_number_t toSN (seqno_t n);
|
||||
|
|
|
@ -15,24 +15,26 @@
|
|||
#include <stdlib.h>
|
||||
#include <assert.h>
|
||||
|
||||
#include "os/os.h"
|
||||
#include "dds/ddsrt/ifaddrs.h"
|
||||
#include "dds/ddsrt/heap.h"
|
||||
#include "dds/ddsrt/string.h"
|
||||
#include "dds/ddsrt/sockets.h"
|
||||
|
||||
#include "ddsi/q_log.h"
|
||||
#include "ddsi/q_nwif.h"
|
||||
#include "ddsi/q_globals.h"
|
||||
#include "ddsi/q_config.h"
|
||||
#include "ddsi/q_unused.h"
|
||||
#include "ddsi/q_md5.h"
|
||||
#include "ddsi/q_misc.h"
|
||||
#include "ddsi/q_addrset.h" /* unspec locator */
|
||||
#include "ddsi/q_feature_check.h"
|
||||
#include "ddsi/ddsi_ipaddr.h"
|
||||
#include "util/ut_avl.h"
|
||||
#include "dds/ddsi/q_log.h"
|
||||
#include "dds/ddsi/q_nwif.h"
|
||||
#include "dds/ddsi/q_globals.h"
|
||||
#include "dds/ddsi/q_config.h"
|
||||
#include "dds/ddsi/q_unused.h"
|
||||
#include "dds/ddsi/q_md5.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/util/ut_avl.h"
|
||||
|
||||
static void print_sockerror (const char *msg)
|
||||
{
|
||||
int err = os_getErrno ();
|
||||
DDS_ERROR("SOCKET %s errno %d\n", msg, err);
|
||||
DDS_ERROR("SOCKET %s\n", msg);
|
||||
}
|
||||
|
||||
unsigned locator_to_hopefully_unique_uint32 (const nn_locator_t *src)
|
||||
|
@ -42,11 +44,11 @@ unsigned locator_to_hopefully_unique_uint32 (const nn_locator_t *src)
|
|||
memcpy (&id, src->address + 12, sizeof (id));
|
||||
else
|
||||
{
|
||||
#if OS_SOCKET_HAS_IPV6
|
||||
#if DDSRT_HAVE_IPV6
|
||||
md5_state_t st;
|
||||
md5_byte_t digest[16];
|
||||
md5_init (&st);
|
||||
md5_append (&st, (const md5_byte_t *) ((const os_sockaddr_in6 *) src)->sin6_addr.s6_addr, 16);
|
||||
md5_append (&st, (const md5_byte_t *) ((const struct sockaddr_in6 *) src)->sin6_addr.s6_addr, 16);
|
||||
md5_finish (&st, digest);
|
||||
memcpy (&id, digest, sizeof (id));
|
||||
#else
|
||||
|
@ -57,9 +59,9 @@ unsigned locator_to_hopefully_unique_uint32 (const nn_locator_t *src)
|
|||
}
|
||||
|
||||
#ifdef DDSI_INCLUDE_NETWORK_CHANNELS
|
||||
void set_socket_diffserv (os_socket sock, int diffserv)
|
||||
void set_socket_diffserv (ddsrt_socket_t sock, int diffserv)
|
||||
{
|
||||
if (os_sockSetsockopt (sock, IPPROTO_IP, IP_TOS, (char*) &diffserv, sizeof (diffserv)) != os_resultSuccess)
|
||||
if (ddsrt_setsockopt (sock, IPPROTO_IP, IP_TOS, (char*) &diffserv, sizeof (diffserv)) != DDS_RETCODE_OK)
|
||||
{
|
||||
print_sockerror ("IP_TOS");
|
||||
}
|
||||
|
@ -67,10 +69,10 @@ void set_socket_diffserv (os_socket sock, int diffserv)
|
|||
#endif
|
||||
|
||||
#ifdef SO_NOSIGPIPE
|
||||
static void set_socket_nosigpipe (os_socket sock)
|
||||
static void set_socket_nosigpipe (ddsrt_socket_t sock)
|
||||
{
|
||||
int val = 1;
|
||||
if (os_sockSetsockopt (sock, SOL_SOCKET, SO_NOSIGPIPE, (char*) &val, sizeof (val)) != os_resultSuccess)
|
||||
if (ddsrt_setsockopt (sock, SOL_SOCKET, SO_NOSIGPIPE, (char*) &val, sizeof (val)) != DDS_RETCODE_OK)
|
||||
{
|
||||
print_sockerror ("SO_NOSIGPIPE");
|
||||
}
|
||||
|
@ -78,17 +80,17 @@ static void set_socket_nosigpipe (os_socket sock)
|
|||
#endif
|
||||
|
||||
#ifdef TCP_NODELAY
|
||||
static void set_socket_nodelay (os_socket sock)
|
||||
static void set_socket_nodelay (ddsrt_socket_t sock)
|
||||
{
|
||||
int val = 1;
|
||||
if (os_sockSetsockopt (sock, IPPROTO_TCP, TCP_NODELAY, (char*) &val, sizeof (val)) != os_resultSuccess)
|
||||
if (ddsrt_setsockopt (sock, IPPROTO_TCP, TCP_NODELAY, (char*) &val, sizeof (val)) != DDS_RETCODE_OK)
|
||||
{
|
||||
print_sockerror ("TCP_NODELAY");
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
static int set_rcvbuf (os_socket socket)
|
||||
static int set_rcvbuf (ddsrt_socket_t socket)
|
||||
{
|
||||
uint32_t ReceiveBufferSize;
|
||||
uint32_t optlen = (uint32_t) sizeof (ReceiveBufferSize);
|
||||
|
@ -97,7 +99,7 @@ static int set_rcvbuf (os_socket socket)
|
|||
socket_min_rcvbuf_size = 1048576;
|
||||
else
|
||||
socket_min_rcvbuf_size = config.socket_min_rcvbuf_size.value;
|
||||
if (os_sockGetsockopt (socket, SOL_SOCKET, SO_RCVBUF, (char *) &ReceiveBufferSize, &optlen) != os_resultSuccess)
|
||||
if (ddsrt_getsockopt (socket, SOL_SOCKET, SO_RCVBUF, (char *) &ReceiveBufferSize, &optlen) != DDS_RETCODE_OK)
|
||||
{
|
||||
print_sockerror ("get SO_RCVBUF");
|
||||
return -2;
|
||||
|
@ -106,12 +108,12 @@ static int set_rcvbuf (os_socket socket)
|
|||
{
|
||||
/* make sure the receive buffersize is at least the minimum required */
|
||||
ReceiveBufferSize = socket_min_rcvbuf_size;
|
||||
(void) os_sockSetsockopt (socket, SOL_SOCKET, SO_RCVBUF, (const char *) &ReceiveBufferSize, sizeof (ReceiveBufferSize));
|
||||
(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 (os_sockGetsockopt (socket, SOL_SOCKET, SO_RCVBUF, (char *) &ReceiveBufferSize, &optlen) != os_resultSuccess)
|
||||
if (ddsrt_getsockopt (socket, SOL_SOCKET, SO_RCVBUF, (char *) &ReceiveBufferSize, &optlen) != DDS_RETCODE_OK)
|
||||
{
|
||||
print_sockerror ("get SO_RCVBUF");
|
||||
return -2;
|
||||
|
@ -132,11 +134,11 @@ static int set_rcvbuf (os_socket socket)
|
|||
return 0;
|
||||
}
|
||||
|
||||
static int set_sndbuf (os_socket socket)
|
||||
static int set_sndbuf (ddsrt_socket_t socket)
|
||||
{
|
||||
unsigned SendBufferSize;
|
||||
uint32_t optlen = (uint32_t) sizeof(SendBufferSize);
|
||||
if (os_sockGetsockopt(socket, SOL_SOCKET, SO_SNDBUF,(char *)&SendBufferSize, &optlen) != os_resultSuccess)
|
||||
if (ddsrt_getsockopt(socket, SOL_SOCKET, SO_SNDBUF,(char *)&SendBufferSize, &optlen) != DDS_RETCODE_OK)
|
||||
{
|
||||
print_sockerror ("get SO_SNDBUF");
|
||||
return -2;
|
||||
|
@ -145,7 +147,7 @@ static int set_sndbuf (os_socket socket)
|
|||
{
|
||||
/* make sure the send buffersize is at least the minimum required */
|
||||
SendBufferSize = config.socket_min_sndbuf_size;
|
||||
if (os_sockSetsockopt (socket, SOL_SOCKET, SO_SNDBUF, (const char *)&SendBufferSize, sizeof (SendBufferSize)) != os_resultSuccess)
|
||||
if (ddsrt_setsockopt (socket, SOL_SOCKET, SO_SNDBUF, (const char *)&SendBufferSize, sizeof (SendBufferSize)) != DDS_RETCODE_OK)
|
||||
{
|
||||
print_sockerror ("SO_SNDBUF");
|
||||
return -2;
|
||||
|
@ -154,15 +156,15 @@ static int set_sndbuf (os_socket socket)
|
|||
return 0;
|
||||
}
|
||||
|
||||
static int maybe_set_dont_route (os_socket socket)
|
||||
static int maybe_set_dont_route (ddsrt_socket_t socket)
|
||||
{
|
||||
if (config.dontRoute)
|
||||
{
|
||||
#if OS_SOCKET_HAS_IPV6
|
||||
#if DDSRT_HAVE_IPV6
|
||||
if (config.transport_selector == TRANS_TCP6 || config.transport_selector == TRANS_UDP6)
|
||||
{
|
||||
unsigned ipv6Flag = 1;
|
||||
if (os_sockSetsockopt (socket, IPPROTO_IPV6, IPV6_UNICAST_HOPS, &ipv6Flag, sizeof (ipv6Flag)))
|
||||
if (ddsrt_setsockopt (socket, IPPROTO_IPV6, IPV6_UNICAST_HOPS, &ipv6Flag, sizeof (ipv6Flag)) != DDS_RETCODE_OK)
|
||||
{
|
||||
print_sockerror ("IPV6_UNICAST_HOPS");
|
||||
return -2;
|
||||
|
@ -173,7 +175,7 @@ static int maybe_set_dont_route (os_socket socket)
|
|||
if (config.transport_selector == TRANS_TCP || config.transport_selector == TRANS_UDP)
|
||||
{
|
||||
int one = 1;
|
||||
if (os_sockSetsockopt (socket, SOL_SOCKET, SO_DONTROUTE, (char *) &one, sizeof (one)) != os_resultSuccess)
|
||||
if (ddsrt_setsockopt (socket, SOL_SOCKET, SO_DONTROUTE, (char *) &one, sizeof (one)) != DDS_RETCODE_OK)
|
||||
{
|
||||
print_sockerror ("SO_DONTROUTE");
|
||||
return -2;
|
||||
|
@ -183,13 +185,13 @@ static int maybe_set_dont_route (os_socket socket)
|
|||
return 0;
|
||||
}
|
||||
|
||||
static int set_reuse_options (os_socket socket)
|
||||
static int set_reuse_options (ddsrt_socket_t socket)
|
||||
{
|
||||
/* Set REUSEADDR (if available on platform) for
|
||||
multicast sockets, leave unicast sockets alone. */
|
||||
int one = 1;
|
||||
|
||||
if (os_sockSetsockopt (socket, SOL_SOCKET, SO_REUSEADDR, (char *) &one, sizeof (one)) != os_resultSuccess)
|
||||
if (ddsrt_setsockopt (socket, SOL_SOCKET, SO_REUSEADDR, (char *) &one, sizeof (one)) != DDS_RETCODE_OK)
|
||||
{
|
||||
print_sockerror ("SO_REUSEADDR");
|
||||
return -2;
|
||||
|
@ -197,22 +199,22 @@ static int set_reuse_options (os_socket socket)
|
|||
return 0;
|
||||
}
|
||||
|
||||
static int bind_socket (os_socket socket, unsigned short port)
|
||||
static int bind_socket (ddsrt_socket_t socket, unsigned short port)
|
||||
{
|
||||
os_result rc;
|
||||
dds_retcode_t rc = DDS_RETCODE_ERROR;
|
||||
|
||||
#if OS_SOCKET_HAS_IPV6
|
||||
#if DDSRT_HAVE_IPV6
|
||||
if (config.transport_selector == TRANS_TCP6 || config.transport_selector == TRANS_UDP6)
|
||||
{
|
||||
os_sockaddr_in6 socketname;
|
||||
struct sockaddr_in6 socketname;
|
||||
memset (&socketname, 0, sizeof (socketname));
|
||||
socketname.sin6_family = AF_INET6;
|
||||
socketname.sin6_port = htons (port);
|
||||
socketname.sin6_addr = os_in6addr_any;
|
||||
socketname.sin6_addr = ddsrt_in6addr_any;
|
||||
if (IN6_IS_ADDR_LINKLOCAL (&socketname.sin6_addr)) {
|
||||
socketname.sin6_scope_id = gv.interfaceNo;
|
||||
}
|
||||
rc = os_sockBind (socket, (struct sockaddr *) &socketname, sizeof (socketname));
|
||||
rc = ddsrt_bind (socket, (struct sockaddr *) &socketname, sizeof (socketname));
|
||||
}
|
||||
else
|
||||
#endif
|
||||
|
@ -222,40 +224,33 @@ static int bind_socket (os_socket socket, unsigned short port)
|
|||
socketname.sin_family = AF_INET;
|
||||
socketname.sin_port = htons (port);
|
||||
socketname.sin_addr.s_addr = htonl (INADDR_ANY);
|
||||
rc = os_sockBind (socket, (struct sockaddr *) &socketname, sizeof (socketname));
|
||||
rc = ddsrt_bind (socket, (struct sockaddr *) &socketname, sizeof (socketname));
|
||||
}
|
||||
else
|
||||
if (rc != DDS_RETCODE_OK && rc != DDS_RETCODE_PRECONDITION_NOT_MET)
|
||||
{
|
||||
rc = os_resultFail;
|
||||
print_sockerror ("bind");
|
||||
}
|
||||
if (rc != os_resultSuccess)
|
||||
{
|
||||
if (os_getErrno () != os_sockEADDRINUSE)
|
||||
{
|
||||
print_sockerror ("bind");
|
||||
}
|
||||
}
|
||||
return (rc == os_resultSuccess) ? 0 : -1;
|
||||
return (rc == DDS_RETCODE_OK) ? 0 : -1;
|
||||
}
|
||||
|
||||
#if OS_SOCKET_HAS_IPV6
|
||||
static int set_mc_options_transmit_ipv6 (os_socket socket)
|
||||
#if DDSRT_HAVE_IPV6
|
||||
static int set_mc_options_transmit_ipv6 (ddsrt_socket_t socket)
|
||||
{
|
||||
unsigned interfaceNo = gv.interfaceNo;
|
||||
unsigned ttl = (unsigned) config.multicast_ttl;
|
||||
unsigned loop;
|
||||
if (os_sockSetsockopt (socket, IPPROTO_IPV6, IPV6_MULTICAST_IF, &interfaceNo, sizeof (interfaceNo)) != os_resultSuccess)
|
||||
if (ddsrt_setsockopt (socket, IPPROTO_IPV6, IPV6_MULTICAST_IF, &interfaceNo, sizeof (interfaceNo)) != DDS_RETCODE_OK)
|
||||
{
|
||||
print_sockerror ("IPV6_MULTICAST_IF");
|
||||
return -2;
|
||||
}
|
||||
if (os_sockSetsockopt (socket, IPPROTO_IPV6, IPV6_MULTICAST_HOPS, (char *) &ttl, sizeof (ttl)) != os_resultSuccess)
|
||||
if (ddsrt_setsockopt (socket, IPPROTO_IPV6, IPV6_MULTICAST_HOPS, (char *) &ttl, sizeof (ttl)) != DDS_RETCODE_OK)
|
||||
{
|
||||
print_sockerror ("IPV6_MULTICAST_HOPS");
|
||||
return -2;
|
||||
}
|
||||
loop = (unsigned) !!config.enableMulticastLoopback;
|
||||
if (os_sockSetsockopt (socket, IPPROTO_IPV6, IPV6_MULTICAST_LOOP, &loop, sizeof (loop)) != os_resultSuccess)
|
||||
if (ddsrt_setsockopt (socket, IPPROTO_IPV6, IPV6_MULTICAST_LOOP, &loop, sizeof (loop)) != DDS_RETCODE_OK)
|
||||
{
|
||||
print_sockerror ("IPV6_MULTICAST_LOOP");
|
||||
return -2;
|
||||
|
@ -264,11 +259,11 @@ static int set_mc_options_transmit_ipv6 (os_socket socket)
|
|||
}
|
||||
#endif
|
||||
|
||||
static int set_mc_options_transmit_ipv4 (os_socket socket)
|
||||
static int set_mc_options_transmit_ipv4 (ddsrt_socket_t socket)
|
||||
{
|
||||
unsigned char ttl = (unsigned char) config.multicast_ttl;
|
||||
unsigned char loop;
|
||||
os_result ret;
|
||||
dds_retcode_t ret;
|
||||
|
||||
#if defined __linux || defined __APPLE__
|
||||
if (config.use_multicast_if_mreqn)
|
||||
|
@ -282,26 +277,26 @@ static int set_mc_options_transmit_ipv4 (os_socket socket)
|
|||
else
|
||||
mreqn.imr_address.s_addr = htonl (INADDR_ANY);
|
||||
mreqn.imr_ifindex = (int) gv.interfaceNo;
|
||||
ret = os_sockSetsockopt (socket, IPPROTO_IP, IP_MULTICAST_IF, &mreqn, sizeof (mreqn));
|
||||
ret = ddsrt_setsockopt (socket, IPPROTO_IP, IP_MULTICAST_IF, &mreqn, sizeof (mreqn));
|
||||
}
|
||||
else
|
||||
#endif
|
||||
{
|
||||
ret = os_sockSetsockopt (socket, IPPROTO_IP, IP_MULTICAST_IF, gv.ownloc.address + 12, 4);
|
||||
ret = ddsrt_setsockopt (socket, IPPROTO_IP, IP_MULTICAST_IF, gv.ownloc.address + 12, 4);
|
||||
}
|
||||
if (ret != os_resultSuccess)
|
||||
if (ret != DDS_RETCODE_OK)
|
||||
{
|
||||
print_sockerror ("IP_MULTICAST_IF");
|
||||
return -2;
|
||||
}
|
||||
if (os_sockSetsockopt (socket, IPPROTO_IP, IP_MULTICAST_TTL, (char *) &ttl, sizeof (ttl)) != os_resultSuccess)
|
||||
if (ddsrt_setsockopt (socket, IPPROTO_IP, IP_MULTICAST_TTL, (char *) &ttl, sizeof (ttl)) != DDS_RETCODE_OK)
|
||||
{
|
||||
print_sockerror ("IP_MULICAST_TTL");
|
||||
return -2;
|
||||
}
|
||||
loop = (unsigned char) config.enableMulticastLoopback;
|
||||
|
||||
if (os_sockSetsockopt (socket, IPPROTO_IP, IP_MULTICAST_LOOP, &loop, sizeof (loop)) != os_resultSuccess)
|
||||
if (ddsrt_setsockopt (socket, IPPROTO_IP, IP_MULTICAST_LOOP, &loop, sizeof (loop)) != DDS_RETCODE_OK)
|
||||
{
|
||||
print_sockerror ("IP_MULTICAST_LOOP");
|
||||
return -2;
|
||||
|
@ -309,9 +304,9 @@ static int set_mc_options_transmit_ipv4 (os_socket socket)
|
|||
return 0;
|
||||
}
|
||||
|
||||
static int set_mc_options_transmit (os_socket socket)
|
||||
static int set_mc_options_transmit (ddsrt_socket_t socket)
|
||||
{
|
||||
#if OS_SOCKET_HAS_IPV6
|
||||
#if DDSRT_HAVE_IPV6
|
||||
if (config.transport_selector == TRANS_TCP6 || config.transport_selector == TRANS_UDP6)
|
||||
{
|
||||
return set_mc_options_transmit_ipv6 (socket);
|
||||
|
@ -330,31 +325,32 @@ static int set_mc_options_transmit (os_socket socket)
|
|||
|
||||
int make_socket
|
||||
(
|
||||
os_socket * sock,
|
||||
ddsrt_socket_t * sock,
|
||||
unsigned short port,
|
||||
bool stream,
|
||||
bool reuse
|
||||
)
|
||||
{
|
||||
int rc = -2;
|
||||
dds_retcode_t ret;
|
||||
|
||||
#if OS_SOCKET_HAS_IPV6
|
||||
#if DDSRT_HAVE_IPV6
|
||||
if (config.transport_selector == TRANS_TCP6 || config.transport_selector == TRANS_UDP6)
|
||||
{
|
||||
*sock = os_sockNew (AF_INET6, stream ? SOCK_STREAM : SOCK_DGRAM);
|
||||
ret = ddsrt_socket(sock, AF_INET6, stream ? SOCK_STREAM : SOCK_DGRAM, 0);
|
||||
}
|
||||
else
|
||||
#endif
|
||||
if (config.transport_selector == TRANS_TCP || config.transport_selector == TRANS_UDP)
|
||||
{
|
||||
*sock = os_sockNew (AF_INET, stream ? SOCK_STREAM : SOCK_DGRAM);
|
||||
ret = ddsrt_socket(sock, AF_INET, stream ? SOCK_STREAM : SOCK_DGRAM, 0);
|
||||
}
|
||||
else
|
||||
{
|
||||
return -2;
|
||||
}
|
||||
|
||||
if (! OS_VALID_SOCKET (*sock))
|
||||
if (ret != DDS_RETCODE_OK)
|
||||
{
|
||||
print_sockerror ("socket");
|
||||
return rc;
|
||||
|
@ -401,24 +397,24 @@ int make_socket
|
|||
|
||||
fail:
|
||||
|
||||
os_sockFree (*sock);
|
||||
*sock = OS_INVALID_SOCKET;
|
||||
ddsrt_close(*sock);
|
||||
*sock = DDSRT_INVALID_SOCKET;
|
||||
return rc;
|
||||
}
|
||||
|
||||
static int multicast_override(const char *ifname)
|
||||
{
|
||||
char *copy = os_strdup (config.assumeMulticastCapable), *cursor = copy, *tok;
|
||||
char *copy = ddsrt_strdup (config.assumeMulticastCapable), *cursor = copy, *tok;
|
||||
int match = 0;
|
||||
if (copy != NULL)
|
||||
{
|
||||
while ((tok = os_strsep (&cursor, ",")) != NULL)
|
||||
while ((tok = ddsrt_strsep (&cursor, ",")) != NULL)
|
||||
{
|
||||
if (ddsi2_patmatch (tok, ifname))
|
||||
match = 1;
|
||||
}
|
||||
}
|
||||
os_free (copy);
|
||||
ddsrt_free (copy);
|
||||
return match;
|
||||
}
|
||||
|
||||
|
@ -433,7 +429,7 @@ int find_own_ip (const char *requested_address)
|
|||
char last_if_name[80] = "";
|
||||
int quality = -1;
|
||||
int i;
|
||||
os_ifaddrs_t *ifa, *ifa_root = NULL;
|
||||
ddsrt_ifaddrs_t *ifa, *ifa_root = NULL;
|
||||
int maxq_list[MAX_INTERFACES];
|
||||
int maxq_count = 0;
|
||||
size_t maxq_strlen = 0;
|
||||
|
@ -458,17 +454,17 @@ int find_own_ip (const char *requested_address)
|
|||
char if_name[sizeof (last_if_name)];
|
||||
int q = 0;
|
||||
|
||||
os_strlcpy(if_name, ifa->name, sizeof(if_name));
|
||||
ddsrt_strlcpy(if_name, ifa->name, sizeof(if_name));
|
||||
|
||||
if (strcmp (if_name, last_if_name))
|
||||
DDS_LOG(DDS_LC_CONFIG, "%s%s", sep, if_name);
|
||||
os_strlcpy(last_if_name, if_name, sizeof(last_if_name));
|
||||
ddsrt_strlcpy(last_if_name, if_name, sizeof(last_if_name));
|
||||
|
||||
/* interface must be up */
|
||||
if ((ifa->flags & IFF_UP) == 0) {
|
||||
DDS_LOG(DDS_LC_CONFIG, " (interface down)");
|
||||
continue;
|
||||
} else if (os_sockaddr_is_unspecified(ifa->addr)) {
|
||||
} else if (ddsrt_sockaddr_isunspecified(ifa->addr)) {
|
||||
DDS_LOG(DDS_LC_CONFIG, " (address unspecified)");
|
||||
continue;
|
||||
}
|
||||
|
@ -503,14 +499,14 @@ int find_own_ip (const char *requested_address)
|
|||
available, because the other interfaces at least in principle
|
||||
allow communicating with other machines. */
|
||||
q += 0;
|
||||
#if OS_SOCKET_HAS_IPV6
|
||||
if (!(ifa->addr->sa_family == AF_INET6 && IN6_IS_ADDR_LINKLOCAL (&((os_sockaddr_in6 *)ifa->addr)->sin6_addr)))
|
||||
#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 OS_SOCKET_HAS_IPV6
|
||||
#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
|
||||
|
@ -521,7 +517,7 @@ int find_own_ip (const char *requested_address)
|
|||
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 (&((os_sockaddr_in6 *)ifa->addr)->sin6_addr)))
|
||||
if (!(ifa->addr->sa_family == AF_INET6 && IN6_IS_ADDR_LINKLOCAL (&((struct sockaddr_in6 *)ifa->addr)->sin6_addr)))
|
||||
q += 5;
|
||||
#endif
|
||||
|
||||
|
@ -563,11 +559,11 @@ int find_own_ip (const char *requested_address)
|
|||
gv.interfaces[gv.n_interfaces].mc_capable = ((ifa->flags & IFF_MULTICAST) != 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 = os_strdup (if_name);
|
||||
gv.interfaces[gv.n_interfaces].name = ddsrt_strdup (if_name);
|
||||
gv.n_interfaces++;
|
||||
}
|
||||
DDS_LOG(DDS_LC_CONFIG, "\n");
|
||||
os_freeifaddrs (ifa_root);
|
||||
ddsrt_freeifaddrs (ifa_root);
|
||||
|
||||
if (requested_address == NULL)
|
||||
{
|
||||
|
@ -577,13 +573,13 @@ int find_own_ip (const char *requested_address)
|
|||
char *names;
|
||||
int p;
|
||||
ddsi_locator_to_string_no_port (addrbuf, sizeof(addrbuf), &gv.interfaces[idx].loc);
|
||||
names = os_malloc (maxq_strlen + 1);
|
||||
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);
|
||||
DDS_WARNING("using network interface %s (%s) selected arbitrarily from: %s\n",
|
||||
gv.interfaces[idx].name, addrbuf, names + 2);
|
||||
os_free (names);
|
||||
ddsrt_free (names);
|
||||
}
|
||||
|
||||
if (maxq_count > 0)
|
||||
|
@ -646,10 +642,10 @@ int find_own_ip (const char *requested_address)
|
|||
gv.ownloc = gv.interfaces[selected_idx].loc;
|
||||
gv.selected_interface = selected_idx;
|
||||
gv.interfaceNo = gv.interfaces[selected_idx].if_index;
|
||||
#if OS_SOCKET_HAS_IPV6
|
||||
#if DDSRT_HAVE_IPV6
|
||||
if (gv.extloc.kind == NN_LOCATOR_KIND_TCPv6 || gv.extloc.kind == NN_LOCATOR_KIND_UDPv6)
|
||||
{
|
||||
os_sockaddr_in6 addr;
|
||||
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;
|
||||
}
|
||||
|
|
|
@ -12,14 +12,13 @@
|
|||
#include <stdio.h>
|
||||
#include <assert.h>
|
||||
|
||||
#include "os/os.h"
|
||||
|
||||
#include "ddsi/q_log.h"
|
||||
#include "ddsi/q_time.h"
|
||||
#include "ddsi/q_config.h"
|
||||
#include "ddsi/q_globals.h"
|
||||
#include "ddsi/q_bswap.h"
|
||||
#include "ddsi/q_pcap.h"
|
||||
#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/q_globals.h"
|
||||
#include "dds/ddsi/q_bswap.h"
|
||||
#include "dds/ddsi/q_pcap.h"
|
||||
|
||||
/* pcap format info taken from http://wiki.wireshark.org/Development/LibpcapFileFormat */
|
||||
|
||||
|
@ -78,7 +77,7 @@ static const ipv4_hdr_t ipv4_hdr_template = {
|
|||
#define IPV4_HDR_SIZE 20
|
||||
#define UDP_HDR_SIZE 8
|
||||
|
||||
OS_WARNING_MSVC_OFF(4996);
|
||||
DDSRT_WARNING_MSVC_OFF(4996);
|
||||
FILE *new_pcap_file (const char *name)
|
||||
{
|
||||
FILE *fp;
|
||||
|
@ -101,9 +100,9 @@ FILE *new_pcap_file (const char *name)
|
|||
|
||||
return fp;
|
||||
}
|
||||
OS_WARNING_MSVC_ON(4996);
|
||||
DDSRT_WARNING_MSVC_ON(4996);
|
||||
|
||||
static void write_data (FILE *fp, const struct msghdr *msghdr, size_t sz)
|
||||
static void write_data (FILE *fp, const ddsrt_msghdr_t *msghdr, size_t sz)
|
||||
{
|
||||
size_t i, n = 0;
|
||||
for (i = 0; i < (size_t) msghdr->msg_iovlen && n < sz; i++)
|
||||
|
@ -132,8 +131,8 @@ void write_pcap_received
|
|||
(
|
||||
FILE * fp,
|
||||
nn_wctime_t tstamp,
|
||||
const os_sockaddr_storage * src,
|
||||
const os_sockaddr_storage * dst,
|
||||
const struct sockaddr_storage * src,
|
||||
const struct sockaddr_storage * dst,
|
||||
unsigned char * buf,
|
||||
size_t sz
|
||||
)
|
||||
|
@ -148,24 +147,24 @@ void write_pcap_received
|
|||
udp_hdr_t udp_hdr;
|
||||
size_t sz_ud = sz + UDP_HDR_SIZE;
|
||||
size_t sz_iud = sz_ud + IPV4_HDR_SIZE;
|
||||
os_mutexLock (&gv.pcap_lock);
|
||||
ddsrt_mutex_lock (&gv.pcap_lock);
|
||||
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;
|
||||
fwrite (&pcap_hdr, sizeof (pcap_hdr), 1, fp);
|
||||
u.ipv4_hdr = ipv4_hdr_template;
|
||||
u.ipv4_hdr.totallength = toBE2u ((unsigned short) sz_iud);
|
||||
u.ipv4_hdr.ttl = 128;
|
||||
u.ipv4_hdr.srcip = ((os_sockaddr_in*) src)->sin_addr.s_addr;
|
||||
u.ipv4_hdr.dstip = ((os_sockaddr_in*) dst)->sin_addr.s_addr;
|
||||
u.ipv4_hdr.srcip = ((struct sockaddr_in*) src)->sin_addr.s_addr;
|
||||
u.ipv4_hdr.dstip = ((struct sockaddr_in*) dst)->sin_addr.s_addr;
|
||||
u.ipv4_hdr.checksum = calc_ipv4_checksum (u.x);
|
||||
fwrite (&u.ipv4_hdr, sizeof (u.ipv4_hdr), 1, fp);
|
||||
udp_hdr.srcport = ((os_sockaddr_in*) src)->sin_port;
|
||||
udp_hdr.dstport = ((os_sockaddr_in*) dst)->sin_port;
|
||||
udp_hdr.srcport = ((struct sockaddr_in*) src)->sin_port;
|
||||
udp_hdr.dstport = ((struct sockaddr_in*) dst)->sin_port;
|
||||
udp_hdr.length = toBE2u ((unsigned short) sz_ud);
|
||||
udp_hdr.checksum = 0; /* don't have to compute a checksum for UDPv4 */
|
||||
fwrite (&udp_hdr, sizeof (udp_hdr), 1, fp);
|
||||
fwrite (buf, sz, 1, fp);
|
||||
os_mutexUnlock (&gv.pcap_lock);
|
||||
ddsrt_mutex_unlock (&gv.pcap_lock);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -173,8 +172,8 @@ void write_pcap_sent
|
|||
(
|
||||
FILE * fp,
|
||||
nn_wctime_t tstamp,
|
||||
const os_sockaddr_storage * src,
|
||||
const struct msghdr * hdr,
|
||||
const struct sockaddr_storage * src,
|
||||
const ddsrt_msghdr_t * hdr,
|
||||
size_t sz
|
||||
)
|
||||
{
|
||||
|
@ -188,23 +187,23 @@ void write_pcap_sent
|
|||
udp_hdr_t udp_hdr;
|
||||
size_t sz_ud = sz + UDP_HDR_SIZE;
|
||||
size_t sz_iud = sz_ud + IPV4_HDR_SIZE;
|
||||
os_mutexLock (&gv.pcap_lock);
|
||||
ddsrt_mutex_lock (&gv.pcap_lock);
|
||||
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;
|
||||
fwrite (&pcap_hdr, sizeof (pcap_hdr), 1, fp);
|
||||
u.ipv4_hdr = ipv4_hdr_template;
|
||||
u.ipv4_hdr.totallength = toBE2u ((unsigned short) sz_iud);
|
||||
u.ipv4_hdr.ttl = 255;
|
||||
u.ipv4_hdr.srcip = ((os_sockaddr_in*) src)->sin_addr.s_addr;
|
||||
u.ipv4_hdr.dstip = ((os_sockaddr_in*) hdr->msg_name)->sin_addr.s_addr;
|
||||
u.ipv4_hdr.srcip = ((struct sockaddr_in*) src)->sin_addr.s_addr;
|
||||
u.ipv4_hdr.dstip = ((struct sockaddr_in*) hdr->msg_name)->sin_addr.s_addr;
|
||||
u.ipv4_hdr.checksum = calc_ipv4_checksum (u.x);
|
||||
fwrite (&u.ipv4_hdr, sizeof (u.ipv4_hdr), 1, fp);
|
||||
udp_hdr.srcport = ((os_sockaddr_in*) src)->sin_port;
|
||||
udp_hdr.dstport = ((os_sockaddr_in*) hdr->msg_name)->sin_port;
|
||||
udp_hdr.srcport = ((struct sockaddr_in*) src)->sin_port;
|
||||
udp_hdr.dstport = ((struct sockaddr_in*) hdr->msg_name)->sin_port;
|
||||
udp_hdr.length = toBE2u ((unsigned short) sz_ud);
|
||||
udp_hdr.checksum = 0; /* don't have to compute a checksum for UDPv4 */
|
||||
fwrite (&udp_hdr, sizeof (udp_hdr), 1, fp);
|
||||
write_data (fp, hdr, sz);
|
||||
os_mutexUnlock (&gv.pcap_lock);
|
||||
ddsrt_mutex_unlock (&gv.pcap_lock);
|
||||
}
|
||||
}
|
||||
|
|
File diff suppressed because it is too large
Load diff
|
@ -12,10 +12,10 @@
|
|||
#include <string.h>
|
||||
#include <assert.h>
|
||||
|
||||
#include "ddsi/q_time.h"
|
||||
#include "ddsi/q_xqos.h"
|
||||
#include "ddsi/q_misc.h"
|
||||
#include "ddsi/q_qosmatch.h"
|
||||
#include "dds/ddsi/q_time.h"
|
||||
#include "dds/ddsi/q_xqos.h"
|
||||
#include "dds/ddsi/q_misc.h"
|
||||
#include "dds/ddsi/q_qosmatch.h"
|
||||
|
||||
int is_wildcard_partition (const char *str)
|
||||
{
|
||||
|
|
|
@ -22,22 +22,26 @@
|
|||
#define USE_VALGRIND 0
|
||||
#endif
|
||||
|
||||
#include "os/os.h"
|
||||
#include "dds/ddsrt/heap.h"
|
||||
#include "dds/ddsrt/threads.h"
|
||||
#include "dds/ddsrt/sync.h"
|
||||
#include "dds/ddsrt/string.h"
|
||||
#include "dds/ddsrt/log.h"
|
||||
|
||||
#include "util/ut_avl.h"
|
||||
#include "ddsi/q_protocol.h"
|
||||
#include "ddsi/q_rtps.h"
|
||||
#include "ddsi/q_misc.h"
|
||||
#include "dds/util/ut_avl.h"
|
||||
#include "dds/ddsi/q_protocol.h"
|
||||
#include "dds/ddsi/q_rtps.h"
|
||||
#include "dds/ddsi/q_misc.h"
|
||||
|
||||
#include "ddsi/q_config.h"
|
||||
#include "ddsi/q_log.h"
|
||||
#include "dds/ddsi/q_config.h"
|
||||
#include "dds/ddsi/q_log.h"
|
||||
|
||||
#include "ddsi/q_plist.h"
|
||||
#include "ddsi/q_unused.h"
|
||||
#include "ddsi/q_radmin.h"
|
||||
#include "ddsi/q_bitset.h"
|
||||
#include "ddsi/q_thread.h"
|
||||
#include "ddsi/q_globals.h" /* for mattr, cattr */
|
||||
#include "dds/ddsi/q_plist.h"
|
||||
#include "dds/ddsi/q_unused.h"
|
||||
#include "dds/ddsi/q_radmin.h"
|
||||
#include "dds/ddsi/q_bitset.h"
|
||||
#include "dds/ddsi/q_thread.h"
|
||||
#include "dds/ddsi/q_globals.h" /* for mattr, cattr */
|
||||
|
||||
/* OVERVIEW ------------------------------------------------------------
|
||||
|
||||
|
@ -276,14 +280,14 @@ struct nn_rbufpool {
|
|||
Could trivially be done lockless, except that it requires
|
||||
compare-and-swap, and we don't have that. But it hardly ever
|
||||
happens anyway. */
|
||||
os_mutex lock;
|
||||
ddsrt_mutex_t lock;
|
||||
struct nn_rbuf *current;
|
||||
uint32_t rbuf_size;
|
||||
uint32_t max_rmsg_size;
|
||||
#ifndef NDEBUG
|
||||
/* Thread that owns this pool, so we can check that no other thread
|
||||
is calling functions only the owner may use. */
|
||||
os_threadId owner_tid;
|
||||
ddsrt_thread_t owner_tid;
|
||||
#endif
|
||||
};
|
||||
|
||||
|
@ -296,7 +300,7 @@ static uint32_t align8uint32 (uint32_t x)
|
|||
}
|
||||
|
||||
#ifndef NDEBUG
|
||||
#define ASSERT_RBUFPOOL_OWNER(rbp) (assert (os_threadEqual (os_threadIdSelf (), (rbp)->owner_tid)))
|
||||
#define ASSERT_RBUFPOOL_OWNER(rbp) (assert (ddsrt_thread_equal (ddsrt_thread_self (), (rbp)->owner_tid)))
|
||||
#else
|
||||
#define ASSERT_RBUFPOOL_OWNER(rbp) ((void) (0))
|
||||
#endif
|
||||
|
@ -328,13 +332,13 @@ struct nn_rbufpool *nn_rbufpool_new (uint32_t rbuf_size, uint32_t max_rmsg_size)
|
|||
assert (max_rmsg_size > 0);
|
||||
assert (rbuf_size >= max_rmsg_size_w_hdr (max_rmsg_size));
|
||||
|
||||
if ((rbp = os_malloc (sizeof (*rbp))) == NULL)
|
||||
if ((rbp = ddsrt_malloc (sizeof (*rbp))) == NULL)
|
||||
goto fail_rbp;
|
||||
#ifndef NDEBUG
|
||||
rbp->owner_tid = os_threadIdSelf ();
|
||||
rbp->owner_tid = ddsrt_thread_self ();
|
||||
#endif
|
||||
|
||||
os_mutexInit (&rbp->lock);
|
||||
ddsrt_mutex_init (&rbp->lock);
|
||||
|
||||
rbp->rbuf_size = rbuf_size;
|
||||
rbp->max_rmsg_size = max_rmsg_size;
|
||||
|
@ -351,13 +355,13 @@ struct nn_rbufpool *nn_rbufpool_new (uint32_t rbuf_size, uint32_t max_rmsg_size)
|
|||
#if USE_VALGRIND
|
||||
VALGRIND_DESTROY_MEMPOOL (rbp);
|
||||
#endif
|
||||
os_mutexDestroy (&rbp->lock);
|
||||
os_free (rbp);
|
||||
ddsrt_mutex_destroy (&rbp->lock);
|
||||
ddsrt_free (rbp);
|
||||
fail_rbp:
|
||||
return NULL;
|
||||
}
|
||||
|
||||
void nn_rbufpool_setowner (UNUSED_ARG_NDEBUG (struct nn_rbufpool *rbp), UNUSED_ARG_NDEBUG (os_threadId tid))
|
||||
void nn_rbufpool_setowner (UNUSED_ARG_NDEBUG (struct nn_rbufpool *rbp), UNUSED_ARG_NDEBUG (ddsrt_thread_t tid))
|
||||
{
|
||||
#ifndef NDEBUG
|
||||
rbp->owner_tid = tid;
|
||||
|
@ -377,14 +381,14 @@ void nn_rbufpool_free (struct nn_rbufpool *rbp)
|
|||
#if USE_VALGRIND
|
||||
VALGRIND_DESTROY_MEMPOOL (rbp);
|
||||
#endif
|
||||
os_mutexDestroy (&rbp->lock);
|
||||
os_free (rbp);
|
||||
ddsrt_mutex_destroy (&rbp->lock);
|
||||
ddsrt_free (rbp);
|
||||
}
|
||||
|
||||
/* RBUF ---------------------------------------------------------------- */
|
||||
|
||||
struct nn_rbuf {
|
||||
os_atomic_uint32_t n_live_rmsg_chunks;
|
||||
ddsrt_atomic_uint32_t n_live_rmsg_chunks;
|
||||
uint32_t size;
|
||||
uint32_t max_rmsg_size;
|
||||
struct nn_rbufpool *rbufpool;
|
||||
|
@ -411,14 +415,14 @@ static struct nn_rbuf *nn_rbuf_alloc_new (struct nn_rbufpool *rbufpool)
|
|||
struct nn_rbuf *rb;
|
||||
ASSERT_RBUFPOOL_OWNER (rbufpool);
|
||||
|
||||
if ((rb = os_malloc (offsetof (struct nn_rbuf, u.raw) + rbufpool->rbuf_size)) == NULL)
|
||||
if ((rb = ddsrt_malloc (offsetof (struct nn_rbuf, u.raw) + rbufpool->rbuf_size)) == NULL)
|
||||
return NULL;
|
||||
#if USE_VALGRIND
|
||||
VALGRIND_MAKE_MEM_NOACCESS (rb->u.raw, rbufpool->rbuf_size);
|
||||
#endif
|
||||
|
||||
rb->rbufpool = rbufpool;
|
||||
os_atomic_st32 (&rb->n_live_rmsg_chunks, 1);
|
||||
ddsrt_atomic_st32 (&rb->n_live_rmsg_chunks, 1);
|
||||
rb->size = rbufpool->rbuf_size;
|
||||
rb->max_rmsg_size = rbufpool->max_rmsg_size;
|
||||
rb->freeptr = rb->u.raw;
|
||||
|
@ -433,10 +437,10 @@ static struct nn_rbuf *nn_rbuf_new (struct nn_rbufpool *rbufpool)
|
|||
ASSERT_RBUFPOOL_OWNER (rbufpool);
|
||||
if ((rb = nn_rbuf_alloc_new (rbufpool)) != NULL)
|
||||
{
|
||||
os_mutexLock (&rbufpool->lock);
|
||||
ddsrt_mutex_lock (&rbufpool->lock);
|
||||
nn_rbuf_release (rbufpool->current);
|
||||
rbufpool->current = rb;
|
||||
os_mutexUnlock (&rbufpool->lock);
|
||||
ddsrt_mutex_unlock (&rbufpool->lock);
|
||||
}
|
||||
return rb;
|
||||
}
|
||||
|
@ -445,10 +449,10 @@ static void nn_rbuf_release (struct nn_rbuf *rbuf)
|
|||
{
|
||||
struct nn_rbufpool *rbp = rbuf->rbufpool;
|
||||
DDS_LOG(DDS_LC_RADMIN, "rbuf_release(%p) pool %p current %p\n", (void *) rbuf, (void *) rbp, (void *) rbp->current);
|
||||
if (os_atomic_dec32_ov (&rbuf->n_live_rmsg_chunks) == 1)
|
||||
if (ddsrt_atomic_dec32_ov (&rbuf->n_live_rmsg_chunks) == 1)
|
||||
{
|
||||
DDS_LOG(DDS_LC_RADMIN, "rbuf_release(%p) free\n", (void *) rbuf);
|
||||
os_free (rbuf);
|
||||
ddsrt_free (rbuf);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -464,7 +468,7 @@ static void nn_rbuf_release (struct nn_rbuf *rbuf)
|
|||
#define RMSG_REFCOUNT_UNCOMMITTED_BIAS (1u << 31)
|
||||
#define RMSG_REFCOUNT_RDATA_BIAS (1u << 20)
|
||||
#ifndef NDEBUG
|
||||
#define ASSERT_RMSG_UNCOMMITTED(rmsg) (assert (os_atomic_ld32 (&(rmsg)->refcount) >= RMSG_REFCOUNT_UNCOMMITTED_BIAS))
|
||||
#define ASSERT_RMSG_UNCOMMITTED(rmsg) (assert (ddsrt_atomic_ld32 (&(rmsg)->refcount) >= RMSG_REFCOUNT_UNCOMMITTED_BIAS))
|
||||
#else
|
||||
#define ASSERT_RMSG_UNCOMMITTED(rmsg) ((void) 0)
|
||||
#endif
|
||||
|
@ -503,7 +507,7 @@ static void init_rmsg_chunk (struct nn_rmsg_chunk *chunk, struct nn_rbuf *rbuf)
|
|||
chunk->rbuf = rbuf;
|
||||
chunk->next = NULL;
|
||||
chunk->size = 0;
|
||||
os_atomic_inc32 (&rbuf->n_live_rmsg_chunks);
|
||||
ddsrt_atomic_inc32 (&rbuf->n_live_rmsg_chunks);
|
||||
}
|
||||
|
||||
struct nn_rmsg *nn_rmsg_new (struct nn_rbufpool *rbufpool)
|
||||
|
@ -517,7 +521,7 @@ struct nn_rmsg *nn_rmsg_new (struct nn_rbufpool *rbufpool)
|
|||
return NULL;
|
||||
|
||||
/* Reference to this rmsg, undone by rmsg_commit(). */
|
||||
os_atomic_st32 (&rmsg->refcount, RMSG_REFCOUNT_UNCOMMITTED_BIAS);
|
||||
ddsrt_atomic_st32 (&rmsg->refcount, RMSG_REFCOUNT_UNCOMMITTED_BIAS);
|
||||
/* Initial chunk */
|
||||
init_rmsg_chunk (&rmsg->chunk, rbufpool->current);
|
||||
rmsg->lastchunk = &rmsg->chunk;
|
||||
|
@ -533,7 +537,7 @@ void nn_rmsg_setsize (struct nn_rmsg *rmsg, uint32_t size)
|
|||
DDS_LOG(DDS_LC_RADMIN, "rmsg_setsize(%p, %u => %u)\n", (void *) rmsg, size, size8);
|
||||
ASSERT_RBUFPOOL_OWNER (rmsg->chunk.rbuf->rbufpool);
|
||||
ASSERT_RMSG_UNCOMMITTED (rmsg);
|
||||
assert (os_atomic_ld32 (&rmsg->refcount) == RMSG_REFCOUNT_UNCOMMITTED_BIAS);
|
||||
assert (ddsrt_atomic_ld32 (&rmsg->refcount) == RMSG_REFCOUNT_UNCOMMITTED_BIAS);
|
||||
assert (rmsg->chunk.size == 0);
|
||||
assert (size8 <= rmsg->chunk.rbuf->max_rmsg_size);
|
||||
assert (rmsg->lastchunk == &rmsg->chunk);
|
||||
|
@ -554,7 +558,7 @@ void nn_rmsg_free (struct nn_rmsg *rmsg)
|
|||
compare-and-swap for this. */
|
||||
struct nn_rmsg_chunk *c;
|
||||
DDS_LOG(DDS_LC_RADMIN, "rmsg_free(%p)\n", (void *) rmsg);
|
||||
assert (os_atomic_ld32 (&rmsg->refcount) == 0);
|
||||
assert (ddsrt_atomic_ld32 (&rmsg->refcount) == 0);
|
||||
c = &rmsg->chunk;
|
||||
while (c)
|
||||
{
|
||||
|
@ -567,7 +571,7 @@ void nn_rmsg_free (struct nn_rmsg *rmsg)
|
|||
VALGRIND_MEMPOOL_FREE (rbuf->rbufpool, c);
|
||||
}
|
||||
#endif
|
||||
assert (os_atomic_ld32 (&rbuf->n_live_rmsg_chunks) > 0);
|
||||
assert (ddsrt_atomic_ld32 (&rbuf->n_live_rmsg_chunks) > 0);
|
||||
nn_rbuf_release (rbuf);
|
||||
c = c1;
|
||||
}
|
||||
|
@ -597,11 +601,11 @@ void nn_rmsg_commit (struct nn_rmsg *rmsg)
|
|||
ASSERT_RMSG_UNCOMMITTED (rmsg);
|
||||
assert (chunk->size <= chunk->rbuf->max_rmsg_size);
|
||||
assert ((chunk->size % 8) == 0);
|
||||
assert (os_atomic_ld32 (&rmsg->refcount) >= RMSG_REFCOUNT_UNCOMMITTED_BIAS);
|
||||
assert (os_atomic_ld32 (&rmsg->chunk.rbuf->n_live_rmsg_chunks) > 0);
|
||||
assert (os_atomic_ld32 (&chunk->rbuf->n_live_rmsg_chunks) > 0);
|
||||
assert (ddsrt_atomic_ld32 (&rmsg->refcount) >= RMSG_REFCOUNT_UNCOMMITTED_BIAS);
|
||||
assert (ddsrt_atomic_ld32 (&rmsg->chunk.rbuf->n_live_rmsg_chunks) > 0);
|
||||
assert (ddsrt_atomic_ld32 (&chunk->rbuf->n_live_rmsg_chunks) > 0);
|
||||
assert (chunk->rbuf->rbufpool->current == chunk->rbuf);
|
||||
if (os_atomic_sub32_nv (&rmsg->refcount, RMSG_REFCOUNT_UNCOMMITTED_BIAS) == 0)
|
||||
if (ddsrt_atomic_sub32_nv (&rmsg->refcount, RMSG_REFCOUNT_UNCOMMITTED_BIAS) == 0)
|
||||
nn_rmsg_free (rmsg);
|
||||
else
|
||||
{
|
||||
|
@ -623,7 +627,7 @@ static void nn_rmsg_addbias (struct nn_rmsg *rmsg)
|
|||
DDS_LOG(DDS_LC_RADMIN, "rmsg_addbias(%p)\n", (void *) rmsg);
|
||||
ASSERT_RBUFPOOL_OWNER (rmsg->chunk.rbuf->rbufpool);
|
||||
ASSERT_RMSG_UNCOMMITTED (rmsg);
|
||||
os_atomic_add32 (&rmsg->refcount, RMSG_REFCOUNT_RDATA_BIAS);
|
||||
ddsrt_atomic_add32 (&rmsg->refcount, RMSG_REFCOUNT_RDATA_BIAS);
|
||||
}
|
||||
|
||||
static void nn_rmsg_rmbias_and_adjust (struct nn_rmsg *rmsg, int adjust)
|
||||
|
@ -637,8 +641,8 @@ static void nn_rmsg_rmbias_and_adjust (struct nn_rmsg *rmsg, int adjust)
|
|||
assert (adjust >= 0);
|
||||
assert ((uint32_t) adjust < RMSG_REFCOUNT_RDATA_BIAS);
|
||||
sub = RMSG_REFCOUNT_RDATA_BIAS - (uint32_t) adjust;
|
||||
assert (os_atomic_ld32 (&rmsg->refcount) >= sub);
|
||||
if (os_atomic_sub32_nv (&rmsg->refcount, sub) == 0)
|
||||
assert (ddsrt_atomic_ld32 (&rmsg->refcount) >= sub);
|
||||
if (ddsrt_atomic_sub32_nv (&rmsg->refcount, sub) == 0)
|
||||
nn_rmsg_free (rmsg);
|
||||
}
|
||||
|
||||
|
@ -647,15 +651,15 @@ static void nn_rmsg_rmbias_anythread (struct nn_rmsg *rmsg)
|
|||
/* For removing garbage when freeing a nn_defrag. */
|
||||
uint32_t sub = RMSG_REFCOUNT_RDATA_BIAS;
|
||||
DDS_LOG(DDS_LC_RADMIN, "rmsg_rmbias_anythread(%p)\n", (void *) rmsg);
|
||||
assert (os_atomic_ld32 (&rmsg->refcount) >= sub);
|
||||
if (os_atomic_sub32_nv (&rmsg->refcount, sub) == 0)
|
||||
assert (ddsrt_atomic_ld32 (&rmsg->refcount) >= sub);
|
||||
if (ddsrt_atomic_sub32_nv (&rmsg->refcount, sub) == 0)
|
||||
nn_rmsg_free (rmsg);
|
||||
}
|
||||
static void nn_rmsg_unref (struct nn_rmsg *rmsg)
|
||||
{
|
||||
DDS_LOG(DDS_LC_RADMIN, "rmsg_unref(%p)\n", (void *) rmsg);
|
||||
assert (os_atomic_ld32 (&rmsg->refcount) > 0);
|
||||
if (os_atomic_dec32_ov (&rmsg->refcount) == 1)
|
||||
assert (ddsrt_atomic_ld32 (&rmsg->refcount) > 0);
|
||||
if (ddsrt_atomic_dec32_ov (&rmsg->refcount) == 1)
|
||||
nn_rmsg_free (rmsg);
|
||||
}
|
||||
|
||||
|
@ -715,7 +719,7 @@ struct nn_rdata *nn_rdata_new (struct nn_rmsg *rmsg, uint32_t start, uint32_t en
|
|||
d->submsg_zoff = (uint16_t) NN_OFF_TO_ZOFF (submsg_offset);
|
||||
d->payload_zoff = (uint16_t) NN_OFF_TO_ZOFF (payload_offset);
|
||||
#ifndef NDEBUG
|
||||
os_atomic_st32 (&d->refcount_bias_added, 0);
|
||||
ddsrt_atomic_st32 (&d->refcount_bias_added, 0);
|
||||
#endif
|
||||
DDS_LOG(DDS_LC_RADMIN, "rdata_new(%p, bytes [%u,%u), submsg @ %u, payload @ %u) = %p\n", (void *) rmsg, start, endp1, NN_RDATA_SUBMSG_OFF (d), NN_RDATA_PAYLOAD_OFF (d), (void *) d);
|
||||
return d;
|
||||
|
@ -726,7 +730,7 @@ static void nn_rdata_addbias (struct nn_rdata *rdata)
|
|||
DDS_LOG(DDS_LC_RADMIN, "rdata_addbias(%p)\n", (void *) rdata);
|
||||
#ifndef NDEBUG
|
||||
ASSERT_RBUFPOOL_OWNER (rdata->rmsg->chunk.rbuf->rbufpool);
|
||||
if (os_atomic_inc32_nv (&rdata->refcount_bias_added) != 1)
|
||||
if (ddsrt_atomic_inc32_nv (&rdata->refcount_bias_added) != 1)
|
||||
abort ();
|
||||
#endif
|
||||
nn_rmsg_addbias (rdata->rmsg);
|
||||
|
@ -736,7 +740,7 @@ static void nn_rdata_rmbias_and_adjust (struct nn_rdata *rdata, int adjust)
|
|||
{
|
||||
DDS_LOG(DDS_LC_RADMIN, "rdata_rmbias_and_adjust(%p, %d)\n", (void *) rdata, adjust);
|
||||
#ifndef NDEBUG
|
||||
if (os_atomic_dec32_ov (&rdata->refcount_bias_added) != 1)
|
||||
if (ddsrt_atomic_dec32_ov (&rdata->refcount_bias_added) != 1)
|
||||
abort ();
|
||||
#endif
|
||||
nn_rmsg_rmbias_and_adjust (rdata->rmsg, adjust);
|
||||
|
@ -746,7 +750,7 @@ static void nn_rdata_rmbias_anythread (struct nn_rdata *rdata)
|
|||
{
|
||||
DDS_LOG(DDS_LC_RADMIN, "rdata_rmbias_anythread(%p)\n", (void *) rdata);
|
||||
#ifndef NDEBUG
|
||||
if (os_atomic_dec32_ov (&rdata->refcount_bias_added) != 1)
|
||||
if (ddsrt_atomic_dec32_ov (&rdata->refcount_bias_added) != 1)
|
||||
abort ();
|
||||
#endif
|
||||
nn_rmsg_rmbias_anythread (rdata->rmsg);
|
||||
|
@ -878,7 +882,7 @@ struct nn_defrag *nn_defrag_new (enum nn_defrag_drop_mode drop_mode, uint32_t ma
|
|||
{
|
||||
struct nn_defrag *d;
|
||||
assert (max_samples >= 1);
|
||||
if ((d = os_malloc (sizeof (*d))) == NULL)
|
||||
if ((d = ddsrt_malloc (sizeof (*d))) == NULL)
|
||||
return NULL;
|
||||
ut_avlInit (&defrag_sampletree_treedef, &d->sampletree);
|
||||
d->drop_mode = drop_mode;
|
||||
|
@ -942,7 +946,7 @@ void nn_defrag_free (struct nn_defrag *defrag)
|
|||
s = ut_avlFindMin (&defrag_sampletree_treedef, &defrag->sampletree);
|
||||
}
|
||||
assert (defrag->n_samples == 0);
|
||||
os_free (defrag);
|
||||
ddsrt_free (defrag);
|
||||
}
|
||||
|
||||
static int defrag_try_merge_with_succ (struct nn_rsample_defrag *sample, struct nn_defrag_iv *node)
|
||||
|
@ -1635,7 +1639,7 @@ static const ut_avlTreedef_t reorder_sampleivtree_treedef =
|
|||
struct nn_reorder *nn_reorder_new (enum nn_reorder_mode mode, uint32_t max_samples)
|
||||
{
|
||||
struct nn_reorder *r;
|
||||
if ((r = os_malloc (sizeof (*r))) == NULL)
|
||||
if ((r = ddsrt_malloc (sizeof (*r))) == NULL)
|
||||
return NULL;
|
||||
ut_avlInit (&reorder_sampleivtree_treedef, &r->sampleivtree);
|
||||
r->max_sampleiv = NULL;
|
||||
|
@ -1675,7 +1679,7 @@ void nn_reorder_free (struct nn_reorder *r)
|
|||
}
|
||||
iv = ut_avlFindMin (&reorder_sampleivtree_treedef, &r->sampleivtree);
|
||||
}
|
||||
os_free (r);
|
||||
ddsrt_free (r);
|
||||
}
|
||||
|
||||
static void reorder_add_rsampleiv (struct nn_reorder *reorder, struct nn_rsample *rsample)
|
||||
|
@ -2359,8 +2363,8 @@ seqno_t nn_reorder_next_seq (const struct nn_reorder *reorder)
|
|||
/* DQUEUE -------------------------------------------------------------- */
|
||||
|
||||
struct nn_dqueue {
|
||||
os_mutex lock;
|
||||
os_cond cond;
|
||||
ddsrt_mutex_t lock;
|
||||
ddsrt_cond_t cond;
|
||||
nn_dqueue_handler_t handler;
|
||||
void *handler_arg;
|
||||
|
||||
|
@ -2369,7 +2373,7 @@ struct nn_dqueue {
|
|||
struct thread_state1 *ts;
|
||||
char *name;
|
||||
uint32_t max_samples;
|
||||
os_atomic_uint32_t nof_samples;
|
||||
ddsrt_atomic_uint32_t nof_samples;
|
||||
};
|
||||
|
||||
enum dqueue_elem_kind {
|
||||
|
@ -2379,7 +2383,7 @@ enum dqueue_elem_kind {
|
|||
};
|
||||
|
||||
enum nn_dqueue_bubble_kind {
|
||||
NN_DQBK_STOP, /* _not_ os_malloc()ed! */
|
||||
NN_DQBK_STOP, /* _not_ ddsrt_malloc()ed! */
|
||||
NN_DQBK_CALLBACK,
|
||||
NN_DQBK_RDGUID
|
||||
};
|
||||
|
@ -2421,7 +2425,7 @@ static uint32_t dqueue_thread (struct nn_dqueue *q)
|
|||
nn_guid_t rdguid, *prdguid = NULL;
|
||||
uint32_t rdguid_count = 0;
|
||||
|
||||
os_mutexLock (&q->lock);
|
||||
ddsrt_mutex_lock (&q->lock);
|
||||
while (keepgoing)
|
||||
{
|
||||
struct nn_rsample_chain sc;
|
||||
|
@ -2429,18 +2433,18 @@ static uint32_t dqueue_thread (struct nn_dqueue *q)
|
|||
LOG_THREAD_CPUTIME (next_thread_cputime);
|
||||
|
||||
if (q->sc.first == NULL)
|
||||
os_condWait (&q->cond, &q->lock);
|
||||
ddsrt_cond_wait (&q->cond, &q->lock);
|
||||
sc = q->sc;
|
||||
q->sc.first = q->sc.last = NULL;
|
||||
os_mutexUnlock (&q->lock);
|
||||
ddsrt_mutex_unlock (&q->lock);
|
||||
|
||||
while (sc.first)
|
||||
{
|
||||
struct nn_rsample_chain_elem *e = sc.first;
|
||||
int ret;
|
||||
sc.first = e->next;
|
||||
if (os_atomic_dec32_ov (&q->nof_samples) == 1) {
|
||||
os_condBroadcast (&q->cond);
|
||||
if (ddsrt_atomic_dec32_ov (&q->nof_samples) == 1) {
|
||||
ddsrt_cond_broadcast (&q->cond);
|
||||
}
|
||||
thread_state_awake (self);
|
||||
switch (dqueue_elem_kind (e))
|
||||
|
@ -2487,7 +2491,7 @@ static uint32_t dqueue_thread (struct nn_dqueue *q)
|
|||
prdguid = &rdguid;
|
||||
break;
|
||||
}
|
||||
os_free (b);
|
||||
ddsrt_free (b);
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
@ -2495,9 +2499,9 @@ static uint32_t dqueue_thread (struct nn_dqueue *q)
|
|||
thread_state_asleep (self);
|
||||
}
|
||||
|
||||
os_mutexLock (&q->lock);
|
||||
ddsrt_mutex_lock (&q->lock);
|
||||
}
|
||||
os_mutexUnlock (&q->lock);
|
||||
ddsrt_mutex_unlock (&q->lock);
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
@ -2507,36 +2511,36 @@ struct nn_dqueue *nn_dqueue_new (const char *name, uint32_t max_samples, nn_dque
|
|||
char *thrname;
|
||||
size_t thrnamesz;
|
||||
|
||||
if ((q = os_malloc (sizeof (*q))) == NULL)
|
||||
if ((q = ddsrt_malloc (sizeof (*q))) == NULL)
|
||||
goto fail_q;
|
||||
if ((q->name = os_strdup (name)) == NULL)
|
||||
if ((q->name = ddsrt_strdup (name)) == NULL)
|
||||
goto fail_name;
|
||||
q->max_samples = max_samples;
|
||||
os_atomic_st32 (&q->nof_samples, 0);
|
||||
ddsrt_atomic_st32 (&q->nof_samples, 0);
|
||||
q->handler = handler;
|
||||
q->handler_arg = arg;
|
||||
q->sc.first = q->sc.last = NULL;
|
||||
|
||||
os_mutexInit (&q->lock);
|
||||
os_condInit (&q->cond, &q->lock);
|
||||
ddsrt_mutex_init (&q->lock);
|
||||
ddsrt_cond_init (&q->cond);
|
||||
|
||||
thrnamesz = 3 + strlen (name) + 1;
|
||||
if ((thrname = os_malloc (thrnamesz)) == NULL)
|
||||
if ((thrname = ddsrt_malloc (thrnamesz)) == NULL)
|
||||
goto fail_thrname;
|
||||
snprintf (thrname, thrnamesz, "dq.%s", name);
|
||||
if ((q->ts = create_thread (thrname, (uint32_t (*) (void *)) dqueue_thread, q)) == NULL)
|
||||
goto fail_thread;
|
||||
os_free (thrname);
|
||||
ddsrt_free (thrname);
|
||||
return q;
|
||||
|
||||
fail_thread:
|
||||
os_free (thrname);
|
||||
ddsrt_free (thrname);
|
||||
fail_thrname:
|
||||
os_condDestroy (&q->cond);
|
||||
os_mutexDestroy (&q->lock);
|
||||
os_free (q->name);
|
||||
ddsrt_cond_destroy (&q->cond);
|
||||
ddsrt_mutex_destroy (&q->lock);
|
||||
ddsrt_free (q->name);
|
||||
fail_name:
|
||||
os_free (q);
|
||||
ddsrt_free (q);
|
||||
fail_q:
|
||||
return NULL;
|
||||
}
|
||||
|
@ -2563,11 +2567,11 @@ void nn_dqueue_enqueue (struct nn_dqueue *q, struct nn_rsample_chain *sc, nn_reo
|
|||
assert (rres > 0);
|
||||
assert (sc->first);
|
||||
assert (sc->last->next == NULL);
|
||||
os_mutexLock (&q->lock);
|
||||
os_atomic_add32 (&q->nof_samples, (uint32_t) rres);
|
||||
ddsrt_mutex_lock (&q->lock);
|
||||
ddsrt_atomic_add32 (&q->nof_samples, (uint32_t) rres);
|
||||
if (nn_dqueue_enqueue_locked (q, sc))
|
||||
os_condBroadcast (&q->cond);
|
||||
os_mutexUnlock (&q->lock);
|
||||
ddsrt_cond_broadcast (&q->cond);
|
||||
ddsrt_mutex_unlock (&q->lock);
|
||||
}
|
||||
|
||||
static int nn_dqueue_enqueue_bubble_locked (struct nn_dqueue *q, struct nn_dqueue_bubble *b)
|
||||
|
@ -2582,17 +2586,17 @@ static int nn_dqueue_enqueue_bubble_locked (struct nn_dqueue *q, struct nn_dqueu
|
|||
|
||||
static void nn_dqueue_enqueue_bubble (struct nn_dqueue *q, struct nn_dqueue_bubble *b)
|
||||
{
|
||||
os_mutexLock (&q->lock);
|
||||
os_atomic_inc32 (&q->nof_samples);
|
||||
ddsrt_mutex_lock (&q->lock);
|
||||
ddsrt_atomic_inc32 (&q->nof_samples);
|
||||
if (nn_dqueue_enqueue_bubble_locked (q, b))
|
||||
os_condBroadcast (&q->cond);
|
||||
os_mutexUnlock (&q->lock);
|
||||
ddsrt_cond_broadcast (&q->cond);
|
||||
ddsrt_mutex_unlock (&q->lock);
|
||||
}
|
||||
|
||||
void nn_dqueue_enqueue_callback (struct nn_dqueue *q, nn_dqueue_callback_t cb, void *arg)
|
||||
{
|
||||
struct nn_dqueue_bubble *b;
|
||||
b = os_malloc (sizeof (*b));
|
||||
b = ddsrt_malloc (sizeof (*b));
|
||||
b->kind = NN_DQBK_CALLBACK;
|
||||
b->u.cb.cb = cb;
|
||||
b->u.cb.arg = arg;
|
||||
|
@ -2603,7 +2607,7 @@ void nn_dqueue_enqueue1 (struct nn_dqueue *q, const nn_guid_t *rdguid, struct nn
|
|||
{
|
||||
struct nn_dqueue_bubble *b;
|
||||
|
||||
b = os_malloc (sizeof (*b));
|
||||
b = ddsrt_malloc (sizeof (*b));
|
||||
b->kind = NN_DQBK_RDGUID;
|
||||
b->u.rdguid.rdguid = *rdguid;
|
||||
b->u.rdguid.count = (uint32_t) rres;
|
||||
|
@ -2612,12 +2616,12 @@ void nn_dqueue_enqueue1 (struct nn_dqueue *q, const nn_guid_t *rdguid, struct nn
|
|||
assert (rdguid != NULL);
|
||||
assert (sc->first);
|
||||
assert (sc->last->next == NULL);
|
||||
os_mutexLock (&q->lock);
|
||||
os_atomic_add32 (&q->nof_samples, 1 + (uint32_t) rres);
|
||||
ddsrt_mutex_lock (&q->lock);
|
||||
ddsrt_atomic_add32 (&q->nof_samples, 1 + (uint32_t) rres);
|
||||
if (nn_dqueue_enqueue_bubble_locked (q, b))
|
||||
os_condBroadcast (&q->cond);
|
||||
ddsrt_cond_broadcast (&q->cond);
|
||||
nn_dqueue_enqueue_locked (q, sc);
|
||||
os_mutexUnlock (&q->lock);
|
||||
ddsrt_mutex_unlock (&q->lock);
|
||||
}
|
||||
|
||||
int nn_dqueue_is_full (struct nn_dqueue *q)
|
||||
|
@ -2629,19 +2633,19 @@ int nn_dqueue_is_full (struct nn_dqueue *q)
|
|||
don't mind the occasional extra sample in the queue (we don't),
|
||||
and survive the occasional decision to not queue when it
|
||||
could've been queued (we do), it should be ok. */
|
||||
const uint32_t count = os_atomic_ld32 (&q->nof_samples);
|
||||
const uint32_t count = ddsrt_atomic_ld32 (&q->nof_samples);
|
||||
return (count >= q->max_samples);
|
||||
}
|
||||
|
||||
void nn_dqueue_wait_until_empty_if_full (struct nn_dqueue *q)
|
||||
{
|
||||
const uint32_t count = os_atomic_ld32 (&q->nof_samples);
|
||||
const uint32_t count = ddsrt_atomic_ld32 (&q->nof_samples);
|
||||
if (count >= q->max_samples)
|
||||
{
|
||||
os_mutexLock (&q->lock);
|
||||
while (os_atomic_ld32 (&q->nof_samples) > 0)
|
||||
os_condWait (&q->cond, &q->lock);
|
||||
os_mutexUnlock (&q->lock);
|
||||
ddsrt_mutex_lock (&q->lock);
|
||||
while (ddsrt_atomic_ld32 (&q->nof_samples) > 0)
|
||||
ddsrt_cond_wait (&q->cond, &q->lock);
|
||||
ddsrt_mutex_unlock (&q->lock);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -2658,8 +2662,8 @@ void nn_dqueue_free (struct nn_dqueue *q)
|
|||
|
||||
join_thread (q->ts);
|
||||
assert (q->sc.first == NULL);
|
||||
os_condDestroy (&q->cond);
|
||||
os_mutexDestroy (&q->lock);
|
||||
os_free (q->name);
|
||||
os_free (q);
|
||||
ddsrt_cond_destroy (&q->cond);
|
||||
ddsrt_mutex_destroy (&q->lock);
|
||||
ddsrt_free (q->name);
|
||||
ddsrt_free (q);
|
||||
}
|
||||
|
|
|
@ -14,43 +14,46 @@
|
|||
#include <stdlib.h>
|
||||
#include <stddef.h>
|
||||
|
||||
#include "os/os.h"
|
||||
#include "dds/ddsrt/heap.h"
|
||||
#include "dds/ddsrt/sync.h"
|
||||
#include "dds/ddsrt/string.h"
|
||||
#include "dds/ddsrt/log.h"
|
||||
|
||||
#include "ddsi/q_md5.h"
|
||||
#include "util/ut_avl.h"
|
||||
#include "dds/ddsi/q_md5.h"
|
||||
#include "dds/util/ut_avl.h"
|
||||
#include "dds__stream.h"
|
||||
#include "ddsi/q_protocol.h"
|
||||
#include "ddsi/q_rtps.h"
|
||||
#include "ddsi/q_misc.h"
|
||||
#include "ddsi/q_config.h"
|
||||
#include "ddsi/q_log.h"
|
||||
#include "ddsi/q_plist.h"
|
||||
#include "ddsi/q_unused.h"
|
||||
#include "ddsi/q_bswap.h"
|
||||
#include "ddsi/q_lat_estim.h"
|
||||
#include "ddsi/q_bitset.h"
|
||||
#include "ddsi/q_xevent.h"
|
||||
#include "ddsi/q_addrset.h"
|
||||
#include "ddsi/q_ddsi_discovery.h"
|
||||
#include "ddsi/q_radmin.h"
|
||||
#include "ddsi/q_error.h"
|
||||
#include "ddsi/q_thread.h"
|
||||
#include "ddsi/q_ephash.h"
|
||||
#include "ddsi/q_lease.h"
|
||||
#include "ddsi/q_gc.h"
|
||||
#include "ddsi/q_entity.h"
|
||||
#include "ddsi/q_xmsg.h"
|
||||
#include "ddsi/q_receive.h"
|
||||
#include "ddsi/q_transmit.h"
|
||||
#include "ddsi/q_globals.h"
|
||||
#include "ddsi/q_static_assert.h"
|
||||
#include "ddsi/q_init.h"
|
||||
#include "ddsi/ddsi_tkmap.h"
|
||||
#include "ddsi/ddsi_mcgroup.h"
|
||||
#include "ddsi/ddsi_serdata.h"
|
||||
#include "ddsi/ddsi_serdata_default.h" /* FIXME: get rid of this */
|
||||
#include "dds/ddsi/q_protocol.h"
|
||||
#include "dds/ddsi/q_rtps.h"
|
||||
#include "dds/ddsi/q_misc.h"
|
||||
#include "dds/ddsi/q_config.h"
|
||||
#include "dds/ddsi/q_log.h"
|
||||
#include "dds/ddsi/q_plist.h"
|
||||
#include "dds/ddsi/q_unused.h"
|
||||
#include "dds/ddsi/q_bswap.h"
|
||||
#include "dds/ddsi/q_lat_estim.h"
|
||||
#include "dds/ddsi/q_bitset.h"
|
||||
#include "dds/ddsi/q_xevent.h"
|
||||
#include "dds/ddsi/q_addrset.h"
|
||||
#include "dds/ddsi/q_ddsi_discovery.h"
|
||||
#include "dds/ddsi/q_radmin.h"
|
||||
#include "dds/ddsi/q_error.h"
|
||||
#include "dds/ddsi/q_thread.h"
|
||||
#include "dds/ddsi/q_ephash.h"
|
||||
#include "dds/ddsi/q_lease.h"
|
||||
#include "dds/ddsi/q_gc.h"
|
||||
#include "dds/ddsi/q_entity.h"
|
||||
#include "dds/ddsi/q_xmsg.h"
|
||||
#include "dds/ddsi/q_receive.h"
|
||||
#include "dds/ddsi/q_transmit.h"
|
||||
#include "dds/ddsi/q_globals.h"
|
||||
#include "dds/ddsi/q_static_assert.h"
|
||||
#include "dds/ddsi/q_init.h"
|
||||
#include "dds/ddsi/ddsi_tkmap.h"
|
||||
#include "dds/ddsi/ddsi_mcgroup.h"
|
||||
#include "dds/ddsi/ddsi_serdata.h"
|
||||
#include "dds/ddsi/ddsi_serdata_default.h" /* FIXME: get rid of this */
|
||||
|
||||
#include "ddsi/sysdeps.h"
|
||||
#include "dds/ddsi/sysdeps.h"
|
||||
#include "dds__whc.h"
|
||||
|
||||
/*
|
||||
|
@ -415,13 +418,13 @@ static int valid_Data (const struct receiver_state *rst, struct nn_rmsg *rmsg, D
|
|||
case CDR_BE:
|
||||
case PL_CDR_BE:
|
||||
{
|
||||
sampleinfo->bswap = PLATFORM_IS_LITTLE_ENDIAN ? 1 : 0;
|
||||
sampleinfo->bswap = (DDSRT_ENDIAN == DDSRT_LITTLE_ENDIAN ? 1 : 0);
|
||||
break;
|
||||
}
|
||||
case CDR_LE:
|
||||
case PL_CDR_LE:
|
||||
{
|
||||
sampleinfo->bswap = PLATFORM_IS_LITTLE_ENDIAN ? 0 : 1;
|
||||
sampleinfo->bswap = (DDSRT_ENDIAN == DDSRT_LITTLE_ENDIAN ? 0 : 1);
|
||||
break;
|
||||
}
|
||||
default:
|
||||
|
@ -554,13 +557,13 @@ static int valid_DataFrag (const struct receiver_state *rst, struct nn_rmsg *rms
|
|||
case CDR_BE:
|
||||
case PL_CDR_BE:
|
||||
{
|
||||
sampleinfo->bswap = PLATFORM_IS_LITTLE_ENDIAN ? 1 : 0;
|
||||
sampleinfo->bswap = (DDSRT_ENDIAN == DDSRT_LITTLE_ENDIAN ? 1 : 0);
|
||||
break;
|
||||
}
|
||||
case CDR_LE:
|
||||
case PL_CDR_LE:
|
||||
{
|
||||
sampleinfo->bswap = PLATFORM_IS_LITTLE_ENDIAN ? 0 : 1;
|
||||
sampleinfo->bswap = (DDSRT_ENDIAN == DDSRT_LITTLE_ENDIAN ? 0 : 1);
|
||||
break;
|
||||
}
|
||||
default:
|
||||
|
@ -754,7 +757,7 @@ static int handle_AckNack (struct receiver_state *rst, nn_etime_t tnow, const Ac
|
|||
|
||||
/* liveliness is still only implemented partially (with all set to AUTOMATIC, BY_PARTICIPANT, &c.), so we simply renew the proxy participant's lease. */
|
||||
if (prd->assert_pp_lease)
|
||||
lease_renew (os_atomic_ldvoidp (&prd->c.proxypp->lease), tnow);
|
||||
lease_renew (ddsrt_atomic_ldvoidp (&prd->c.proxypp->lease), tnow);
|
||||
|
||||
if (!wr->reliable) /* note: reliability can't be changed */
|
||||
{
|
||||
|
@ -762,7 +765,7 @@ static int handle_AckNack (struct receiver_state *rst, nn_etime_t tnow, const Ac
|
|||
return 1;
|
||||
}
|
||||
|
||||
os_mutexLock (&wr->e.lock);
|
||||
ddsrt_mutex_lock (&wr->e.lock);
|
||||
if ((rn = ut_avlLookup (&wr_readers_treedef, &wr->readers, &src)) == NULL)
|
||||
{
|
||||
DDS_TRACE(" %x:%x:%x:%x -> %x:%x:%x:%x not a connection)", PGUID (src), PGUID (dst));
|
||||
|
@ -1066,7 +1069,7 @@ static int handle_AckNack (struct receiver_state *rst, nn_etime_t tnow, const Ac
|
|||
force_heartbeat_to_peer (wr, &whcst, prd, 0);
|
||||
DDS_TRACE(")");
|
||||
out:
|
||||
os_mutexUnlock (&wr->e.lock);
|
||||
ddsrt_mutex_unlock (&wr->e.lock);
|
||||
whc_free_deferred_free_list (wr->whc, deferred_free_list);
|
||||
return 1;
|
||||
}
|
||||
|
@ -1226,11 +1229,11 @@ static int handle_Heartbeat (struct receiver_state *rst, nn_etime_t tnow, struct
|
|||
|
||||
/* liveliness is still only implemented partially (with all set to AUTOMATIC, BY_PARTICIPANT, &c.), so we simply renew the proxy participant's lease. */
|
||||
if (pwr->assert_pp_lease)
|
||||
lease_renew (os_atomic_ldvoidp (&pwr->c.proxypp->lease), tnow);
|
||||
lease_renew (ddsrt_atomic_ldvoidp (&pwr->c.proxypp->lease), tnow);
|
||||
|
||||
DDS_TRACE("%x:%x:%x:%x -> %x:%x:%x:%x:", PGUID (src), PGUID (dst));
|
||||
|
||||
os_mutexLock (&pwr->e.lock);
|
||||
ddsrt_mutex_lock (&pwr->e.lock);
|
||||
|
||||
if (!pwr->have_seen_heartbeat)
|
||||
{
|
||||
|
@ -1323,7 +1326,7 @@ static int handle_Heartbeat (struct receiver_state *rst, nn_etime_t tnow, struct
|
|||
handle_forall_destinations (&dst, pwr, (ut_avlWalk_t) handle_Heartbeat_helper, &arg);
|
||||
DDS_TRACE(")");
|
||||
|
||||
os_mutexUnlock (&pwr->e.lock);
|
||||
ddsrt_mutex_unlock (&pwr->e.lock);
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
@ -1354,10 +1357,10 @@ static int handle_HeartbeatFrag (struct receiver_state *rst, UNUSED_ARG(nn_etime
|
|||
|
||||
/* liveliness is still only implemented partially (with all set to AUTOMATIC, BY_PARTICIPANT, &c.), so we simply renew the proxy participant's lease. */
|
||||
if (pwr->assert_pp_lease)
|
||||
lease_renew (os_atomic_ldvoidp (&pwr->c.proxypp->lease), tnow);
|
||||
lease_renew (ddsrt_atomic_ldvoidp (&pwr->c.proxypp->lease), tnow);
|
||||
|
||||
DDS_TRACE(" %x:%x:%x:%x -> %x:%x:%x:%x", PGUID (src), PGUID (dst));
|
||||
os_mutexLock (&pwr->e.lock);
|
||||
ddsrt_mutex_lock (&pwr->e.lock);
|
||||
|
||||
if (seq > pwr->last_seq)
|
||||
{
|
||||
|
@ -1434,7 +1437,7 @@ static int handle_HeartbeatFrag (struct receiver_state *rst, UNUSED_ARG(nn_etime
|
|||
}
|
||||
}
|
||||
DDS_TRACE(")");
|
||||
os_mutexUnlock (&pwr->e.lock);
|
||||
ddsrt_mutex_unlock (&pwr->e.lock);
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
@ -1482,7 +1485,7 @@ static int handle_NackFrag (struct receiver_state *rst, nn_etime_t tnow, const N
|
|||
|
||||
/* liveliness is still only implemented partially (with all set to AUTOMATIC, BY_PARTICIPANT, &c.), so we simply renew the proxy participant's lease. */
|
||||
if (prd->assert_pp_lease)
|
||||
lease_renew (os_atomic_ldvoidp (&prd->c.proxypp->lease), tnow);
|
||||
lease_renew (ddsrt_atomic_ldvoidp (&prd->c.proxypp->lease), tnow);
|
||||
|
||||
if (!wr->reliable) /* note: reliability can't be changed */
|
||||
{
|
||||
|
@ -1490,7 +1493,7 @@ static int handle_NackFrag (struct receiver_state *rst, nn_etime_t tnow, const N
|
|||
return 1;
|
||||
}
|
||||
|
||||
os_mutexLock (&wr->e.lock);
|
||||
ddsrt_mutex_lock (&wr->e.lock);
|
||||
if ((rn = ut_avlLookup (&wr_readers_treedef, &wr->readers, &src)) == NULL)
|
||||
{
|
||||
DDS_TRACE(" %x:%x:%x:%x -> %x:%x:%x:%x not a connection", PGUID (src), PGUID (dst));
|
||||
|
@ -1557,7 +1560,7 @@ static int handle_NackFrag (struct receiver_state *rst, nn_etime_t tnow, const N
|
|||
}
|
||||
|
||||
out:
|
||||
os_mutexUnlock (&wr->e.lock);
|
||||
ddsrt_mutex_unlock (&wr->e.lock);
|
||||
DDS_TRACE(")");
|
||||
return 1;
|
||||
}
|
||||
|
@ -1730,13 +1733,13 @@ static int handle_Gap (struct receiver_state *rst, nn_etime_t tnow, struct nn_rm
|
|||
|
||||
/* liveliness is still only implemented partially (with all set to AUTOMATIC, BY_PARTICIPANT, &c.), so we simply renew the proxy participant's lease. */
|
||||
if (pwr->assert_pp_lease)
|
||||
lease_renew (os_atomic_ldvoidp (&pwr->c.proxypp->lease), tnow);
|
||||
lease_renew (ddsrt_atomic_ldvoidp (&pwr->c.proxypp->lease), tnow);
|
||||
|
||||
os_mutexLock (&pwr->e.lock);
|
||||
ddsrt_mutex_lock (&pwr->e.lock);
|
||||
if ((wn = ut_avlLookup (&pwr_readers_treedef, &pwr->readers, &dst)) == NULL)
|
||||
{
|
||||
DDS_TRACE("%x:%x:%x:%x -> %x:%x:%x:%x not a connection)", PGUID (src), PGUID (dst));
|
||||
os_mutexUnlock (&pwr->e.lock);
|
||||
ddsrt_mutex_unlock (&pwr->e.lock);
|
||||
return 1;
|
||||
}
|
||||
DDS_TRACE("%x:%x:%x:%x -> %x:%x:%x:%x", PGUID (src), PGUID (dst));
|
||||
|
@ -1790,7 +1793,7 @@ static int handle_Gap (struct receiver_state *rst, nn_etime_t tnow, struct nn_rm
|
|||
pwr->last_fragnum_reset = 0;
|
||||
}
|
||||
DDS_TRACE(")");
|
||||
os_mutexUnlock (&pwr->e.lock);
|
||||
ddsrt_mutex_unlock (&pwr->e.lock);
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
@ -2029,7 +2032,7 @@ static int deliver_user_data (const struct nn_rsample_info *sampleinfo, const st
|
|||
(with late acknowledgement of sample and nack). */
|
||||
retry:
|
||||
|
||||
os_mutexLock (&pwr->rdary.rdary_lock);
|
||||
ddsrt_mutex_lock (&pwr->rdary.rdary_lock);
|
||||
if (pwr->rdary.fastpath_ok)
|
||||
{
|
||||
struct reader ** const rdary = pwr->rdary.rdary;
|
||||
|
@ -2039,14 +2042,14 @@ retry:
|
|||
DDS_TRACE("reader %x:%x:%x:%x\n", PGUID (rdary[i]->e.guid));
|
||||
if (! (ddsi_plugin.rhc_plugin.rhc_store_fn) (rdary[i]->rhc, &pwr_info, payload, tk))
|
||||
{
|
||||
if (pwr_locked) os_mutexUnlock (&pwr->e.lock);
|
||||
os_mutexUnlock (&pwr->rdary.rdary_lock);
|
||||
if (pwr_locked) ddsrt_mutex_unlock (&pwr->e.lock);
|
||||
ddsrt_mutex_unlock (&pwr->rdary.rdary_lock);
|
||||
dds_sleepfor (DDS_MSECS (10));
|
||||
if (pwr_locked) os_mutexLock (&pwr->e.lock);
|
||||
if (pwr_locked) ddsrt_mutex_lock (&pwr->e.lock);
|
||||
goto retry;
|
||||
}
|
||||
}
|
||||
os_mutexUnlock (&pwr->rdary.rdary_lock);
|
||||
ddsrt_mutex_unlock (&pwr->rdary.rdary_lock);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -2060,8 +2063,8 @@ retry:
|
|||
reliable samples that are rejected are simply discarded. */
|
||||
ut_avlIter_t it;
|
||||
struct pwr_rd_match *m;
|
||||
os_mutexUnlock (&pwr->rdary.rdary_lock);
|
||||
if (!pwr_locked) os_mutexLock (&pwr->e.lock);
|
||||
ddsrt_mutex_unlock (&pwr->rdary.rdary_lock);
|
||||
if (!pwr_locked) ddsrt_mutex_lock (&pwr->e.lock);
|
||||
for (m = ut_avlIterFirst (&pwr_readers_treedef, &pwr->readers, &it); m != NULL; m = ut_avlIterNext (&it))
|
||||
{
|
||||
struct reader *rd;
|
||||
|
@ -2071,10 +2074,10 @@ retry:
|
|||
(void) (ddsi_plugin.rhc_plugin.rhc_store_fn) (rd->rhc, &pwr_info, payload, tk);
|
||||
}
|
||||
}
|
||||
if (!pwr_locked) os_mutexUnlock (&pwr->e.lock);
|
||||
if (!pwr_locked) ddsrt_mutex_unlock (&pwr->e.lock);
|
||||
}
|
||||
|
||||
os_atomic_st32 (&pwr->next_deliv_seq_lowword, (uint32_t) (sampleinfo->seq + 1));
|
||||
ddsrt_atomic_st32 (&pwr->next_deliv_seq_lowword, (uint32_t) (sampleinfo->seq + 1));
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -2082,9 +2085,9 @@ retry:
|
|||
DDS_TRACE(" %"PRId64"=>%x:%x:%x:%x%s\n", sampleinfo->seq, PGUID (*rdguid), rd ? "" : "?");
|
||||
while (rd && ! (ddsi_plugin.rhc_plugin.rhc_store_fn) (rd->rhc, &pwr_info, payload, tk) && ephash_lookup_proxy_writer_guid (&pwr->e.guid))
|
||||
{
|
||||
if (pwr_locked) os_mutexUnlock (&pwr->e.lock);
|
||||
if (pwr_locked) ddsrt_mutex_unlock (&pwr->e.lock);
|
||||
dds_sleepfor (DDS_MSECS (1));
|
||||
if (pwr_locked) os_mutexLock (&pwr->e.lock);
|
||||
if (pwr_locked) ddsrt_mutex_lock (&pwr->e.lock);
|
||||
}
|
||||
}
|
||||
ddsi_tkmap_instance_unref (tk);
|
||||
|
@ -2164,14 +2167,14 @@ static void handle_regular (struct receiver_state *rst, nn_etime_t tnow, struct
|
|||
participant's lease. */
|
||||
if (pwr->assert_pp_lease)
|
||||
{
|
||||
lease_renew (os_atomic_ldvoidp (&pwr->c.proxypp->lease), tnow);
|
||||
lease_renew (ddsrt_atomic_ldvoidp (&pwr->c.proxypp->lease), tnow);
|
||||
}
|
||||
|
||||
/* Shouldn't lock the full writer, but will do so for now */
|
||||
os_mutexLock (&pwr->e.lock);
|
||||
ddsrt_mutex_lock (&pwr->e.lock);
|
||||
if (ut_avlIsEmpty (&pwr->readers) || pwr->local_matching_inprogress)
|
||||
{
|
||||
os_mutexUnlock (&pwr->e.lock);
|
||||
ddsrt_mutex_unlock (&pwr->e.lock);
|
||||
DDS_TRACE(" %x:%x:%x:%x -> %x:%x:%x:%x: no readers", PGUID (pwr->e.guid), PGUID (dst));
|
||||
return;
|
||||
}
|
||||
|
@ -2285,7 +2288,7 @@ static void handle_regular (struct receiver_state *rst, nn_etime_t tnow, struct
|
|||
#endif
|
||||
nn_fragchain_adjust_refcount (fragchain, refc_adjust);
|
||||
}
|
||||
os_mutexUnlock (&pwr->e.lock);
|
||||
ddsrt_mutex_unlock (&pwr->e.lock);
|
||||
nn_dqueue_wait_until_empty_if_full (pwr->dqueue);
|
||||
}
|
||||
|
||||
|
@ -2296,12 +2299,12 @@ static int handle_SPDP (const struct nn_rsample_info *sampleinfo, struct nn_rdat
|
|||
struct nn_rdata *fragchain;
|
||||
nn_reorder_result_t rres;
|
||||
int refc_adjust = 0;
|
||||
os_mutexLock (&gv.spdp_lock);
|
||||
ddsrt_mutex_lock (&gv.spdp_lock);
|
||||
rsample = nn_defrag_rsample (gv.spdp_defrag, rdata, sampleinfo);
|
||||
fragchain = nn_rsample_fragchain (rsample);
|
||||
if ((rres = nn_reorder_rsample (&sc, gv.spdp_reorder, rsample, &refc_adjust, nn_dqueue_is_full (gv.builtins_dqueue))) > 0)
|
||||
nn_dqueue_enqueue (gv.builtins_dqueue, &sc, rres);
|
||||
os_mutexUnlock (&gv.spdp_lock);
|
||||
ddsrt_mutex_unlock (&gv.spdp_lock);
|
||||
nn_fragchain_adjust_refcount (fragchain, refc_adjust);
|
||||
return 0;
|
||||
}
|
||||
|
@ -2336,10 +2339,10 @@ static void drop_oversize (struct receiver_state *rst, struct nn_rmsg *rmsg, con
|
|||
dst.prefix = rst->dst_guid_prefix;
|
||||
dst.entityid = msg->readerId;
|
||||
|
||||
os_mutexLock (&pwr->e.lock);
|
||||
ddsrt_mutex_lock (&pwr->e.lock);
|
||||
wn = ut_avlLookup (&pwr_readers_treedef, &pwr->readers, &dst);
|
||||
gap_was_valuable = handle_one_gap (pwr, wn, sampleinfo->seq, sampleinfo->seq+1, gap, &refc_adjust);
|
||||
os_mutexUnlock (&pwr->e.lock);
|
||||
ddsrt_mutex_unlock (&pwr->e.lock);
|
||||
nn_fragchain_adjust_refcount (gap, refc_adjust);
|
||||
|
||||
if (gap_was_valuable)
|
||||
|
@ -2687,11 +2690,11 @@ static int handle_submsg_sequence
|
|||
|
||||
if (sm->smhdr.flags & SMFLAG_ENDIANNESS)
|
||||
{
|
||||
byteswap = ! PLATFORM_IS_LITTLE_ENDIAN;
|
||||
byteswap = !(DDSRT_ENDIAN == DDSRT_LITTLE_ENDIAN);
|
||||
}
|
||||
else
|
||||
{
|
||||
byteswap = PLATFORM_IS_LITTLE_ENDIAN;
|
||||
byteswap = (DDSRT_ENDIAN == DDSRT_LITTLE_ENDIAN);
|
||||
}
|
||||
if (byteswap)
|
||||
{
|
||||
|
@ -2986,11 +2989,11 @@ static bool do_packet
|
|||
|
||||
if (ml->smhdr.flags & SMFLAG_ENDIANNESS)
|
||||
{
|
||||
swap = ! PLATFORM_IS_LITTLE_ENDIAN;
|
||||
swap = !(DDSRT_ENDIAN == DDSRT_LITTLE_ENDIAN);
|
||||
}
|
||||
else
|
||||
{
|
||||
swap = PLATFORM_IS_LITTLE_ENDIAN;
|
||||
swap = (DDSRT_ENDIAN == DDSRT_LITTLE_ENDIAN);
|
||||
}
|
||||
if (swap)
|
||||
{
|
||||
|
@ -3066,8 +3069,8 @@ static int local_participant_cmp (const void *va, const void *vb)
|
|||
{
|
||||
const struct local_participant_desc *a = va;
|
||||
const struct local_participant_desc *b = vb;
|
||||
os_socket h1 = ddsi_conn_handle (a->m_conn);
|
||||
os_socket h2 = ddsi_conn_handle (b->m_conn);
|
||||
ddsrt_socket_t h1 = ddsi_conn_handle (a->m_conn);
|
||||
ddsrt_socket_t h2 = ddsi_conn_handle (b->m_conn);
|
||||
return (h1 == h2) ? 0 : (h1 < h2) ? -1 : 1;
|
||||
}
|
||||
|
||||
|
@ -3106,12 +3109,12 @@ static void local_participant_set_init (struct local_participant_set *lps)
|
|||
{
|
||||
lps->ps = NULL;
|
||||
lps->nps = 0;
|
||||
lps->gen = os_atomic_ld32 (&gv.participant_set_generation) - 1;
|
||||
lps->gen = ddsrt_atomic_ld32 (&gv.participant_set_generation) - 1;
|
||||
}
|
||||
|
||||
static void local_participant_set_fini (struct local_participant_set *lps)
|
||||
{
|
||||
os_free (lps->ps);
|
||||
ddsrt_free (lps->ps);
|
||||
}
|
||||
|
||||
static void rebuild_local_participant_set (struct thread_state1 *self, struct local_participant_set *lps)
|
||||
|
@ -3119,17 +3122,17 @@ static void rebuild_local_participant_set (struct thread_state1 *self, struct lo
|
|||
struct ephash_enum_participant est;
|
||||
struct participant *pp;
|
||||
unsigned nps_alloc;
|
||||
DDS_TRACE("pp set gen changed: local %u global %"PRIu32"\n", lps->gen, os_atomic_ld32(&gv.participant_set_generation));
|
||||
DDS_TRACE("pp set gen changed: local %u global %"PRIu32"\n", lps->gen, ddsrt_atomic_ld32(&gv.participant_set_generation));
|
||||
thread_state_awake (self);
|
||||
restart:
|
||||
lps->gen = os_atomic_ld32 (&gv.participant_set_generation);
|
||||
lps->gen = ddsrt_atomic_ld32 (&gv.participant_set_generation);
|
||||
/* Actual local set of participants may never be older than the
|
||||
local generation count => membar to guarantee the ordering */
|
||||
os_atomic_fence_acq ();
|
||||
ddsrt_atomic_fence_acq ();
|
||||
nps_alloc = gv.nparticipants;
|
||||
os_free (lps->ps);
|
||||
ddsrt_free (lps->ps);
|
||||
lps->nps = 0;
|
||||
lps->ps = (nps_alloc == 0) ? NULL : os_malloc (nps_alloc * sizeof (*lps->ps));
|
||||
lps->ps = (nps_alloc == 0) ? NULL : ddsrt_malloc (nps_alloc * sizeof (*lps->ps));
|
||||
ephash_enum_participant_init (&est);
|
||||
while ((pp = ephash_enum_participant_next (&est)) != NULL)
|
||||
{
|
||||
|
@ -3147,7 +3150,7 @@ static void rebuild_local_participant_set (struct thread_state1 *self, struct lo
|
|||
{
|
||||
lps->ps[lps->nps].m_conn = pp->m_conn;
|
||||
lps->ps[lps->nps].guid_prefix = pp->e.guid.prefix;
|
||||
DDS_TRACE(" pp %x:%x:%x:%x handle %"PRIsock"\n", PGUID (pp->e.guid), ddsi_conn_handle (pp->m_conn));
|
||||
DDS_TRACE(" pp %x:%x:%x:%x handle %"PRIdSOCK"\n", PGUID (pp->e.guid), ddsi_conn_handle (pp->m_conn));
|
||||
lps->nps++;
|
||||
}
|
||||
}
|
||||
|
@ -3159,8 +3162,8 @@ static void rebuild_local_participant_set (struct thread_state1 *self, struct lo
|
|||
participant guid prefix for a directed packet without an
|
||||
explicit destination. Membar because we must have completed
|
||||
the loop before testing the generation again. */
|
||||
os_atomic_fence_acq ();
|
||||
if (lps->gen != os_atomic_ld32 (&gv.participant_set_generation))
|
||||
ddsrt_atomic_fence_acq ();
|
||||
if (lps->gen != ddsrt_atomic_ld32 (&gv.participant_set_generation))
|
||||
{
|
||||
DDS_TRACE(" set changed - restarting\n");
|
||||
goto restart;
|
||||
|
@ -3313,7 +3316,7 @@ void trigger_recv_threads (void)
|
|||
char buf[DDSI_LOCSTRLEN];
|
||||
char dummy = 0;
|
||||
const nn_locator_t *dst = gv.recv_threads[i].arg.u.single.loc;
|
||||
os_iovec_t iov;
|
||||
ddsrt_iovec_t iov;
|
||||
iov.iov_base = &dummy;
|
||||
iov.iov_len = 1;
|
||||
DDS_TRACE("trigger_recv_threads: %d single %s\n", i, ddsi_locator_to_string (buf, sizeof (buf), dst));
|
||||
|
@ -3337,7 +3340,7 @@ uint32_t recv_thread (void *vrecv_thread_arg)
|
|||
os_sockWaitset waitset = recv_thread_arg->mode == RTM_MANY ? recv_thread_arg->u.many.ws : NULL;
|
||||
nn_mtime_t next_thread_cputime = { 0 };
|
||||
|
||||
nn_rbufpool_setowner (rbpool, os_threadIdSelf ());
|
||||
nn_rbufpool_setowner (rbpool, ddsrt_thread_self ());
|
||||
if (waitset == NULL)
|
||||
{
|
||||
while (gv.rtps_keepgoing)
|
||||
|
@ -3383,7 +3386,7 @@ uint32_t recv_thread (void *vrecv_thread_arg)
|
|||
{
|
||||
/* no other sockets to check */
|
||||
}
|
||||
else if (os_atomic_ld32 (&gv.participant_set_generation) != lps.gen)
|
||||
else if (ddsrt_atomic_ld32 (&gv.participant_set_generation) != lps.gen)
|
||||
{
|
||||
rebuildws = 1;
|
||||
}
|
||||
|
|
|
@ -11,10 +11,10 @@
|
|||
*/
|
||||
#ifdef DDSI_INCLUDE_ENCRYPTION
|
||||
|
||||
#include "ddsi/q_security.h"
|
||||
#include "ddsi/q_config.h"
|
||||
#include "ddsi/q_log.h"
|
||||
#include "ddsi/q_error.h"
|
||||
#include "dds/ddsi/q_security.h"
|
||||
#include "dds/ddsi/q_config.h"
|
||||
#include "dds/ddsi/q_log.h"
|
||||
#include "dds/ddsi/q_error.h"
|
||||
#include "os/os_stdlib.h"
|
||||
#include "os/os_process.h"
|
||||
#include "os/os_thread.h"
|
||||
|
@ -539,7 +539,7 @@ static c_bool q_securityResolveCipherKeyFromUri
|
|||
const char *justPath =
|
||||
(char *)(uriStr + strlen(URI_FILESCHEMA));
|
||||
|
||||
filename = os_strdup (justPath);
|
||||
filename = ddsrt_strdup (justPath);
|
||||
file = fopen(filename, "r");
|
||||
if (file) {
|
||||
/* read at most 255 chars from file, this should suffice if the
|
||||
|
@ -561,7 +561,7 @@ static c_bool q_securityResolveCipherKeyFromUri
|
|||
DDS_ERROR("q_securityResolveCipherKeyFromUri: Could not open %s",uriStr);
|
||||
}
|
||||
|
||||
os_free(filename);
|
||||
ddsrt_free(filename);
|
||||
|
||||
} else if (uriStr != NULL) {
|
||||
/* seems to be a hex string */
|
||||
|
@ -600,34 +600,34 @@ static c_bool q_securityCipherTypeFromString(const char* cipherName,
|
|||
return FALSE;
|
||||
}
|
||||
|
||||
if (os_strcasecmp(cipherName, "null") == 0) {
|
||||
if (ddsrt_strcasecmp(cipherName, "null") == 0) {
|
||||
*cipherType = Q_CIPHER_NULL;
|
||||
} else if (os_strcasecmp(cipherName, "blowfish") == 0 ||
|
||||
os_strcasecmp(cipherName, "blowfish-sha1") == 0) {
|
||||
} else if (ddsrt_strcasecmp(cipherName, "blowfish") == 0 ||
|
||||
ddsrt_strcasecmp(cipherName, "blowfish-sha1") == 0) {
|
||||
*cipherType = Q_CIPHER_BLOWFISH;
|
||||
} else if (os_strcasecmp(cipherName, "aes128") == 0 ||
|
||||
os_strcasecmp(cipherName, "aes128-sha1") == 0) {
|
||||
} else if (ddsrt_strcasecmp(cipherName, "aes128") == 0 ||
|
||||
ddsrt_strcasecmp(cipherName, "aes128-sha1") == 0) {
|
||||
*cipherType = Q_CIPHER_AES128;
|
||||
} else if (os_strcasecmp(cipherName, "aes192") == 0 ||
|
||||
os_strcasecmp(cipherName, "aes192-sha1") == 0) {
|
||||
} else if (ddsrt_strcasecmp(cipherName, "aes192") == 0 ||
|
||||
ddsrt_strcasecmp(cipherName, "aes192-sha1") == 0) {
|
||||
*cipherType = Q_CIPHER_AES192;
|
||||
} else if (os_strcasecmp(cipherName, "aes256") == 0 ||
|
||||
os_strcasecmp(cipherName, "aes256-sha1") == 0) {
|
||||
} else if (ddsrt_strcasecmp(cipherName, "aes256") == 0 ||
|
||||
ddsrt_strcasecmp(cipherName, "aes256-sha1") == 0) {
|
||||
*cipherType = Q_CIPHER_AES256;
|
||||
#if 0
|
||||
} else if (os_strcasecmp(cipherName, "rsa-null") == 0) {
|
||||
} else if (ddsrt_strcasecmp(cipherName, "rsa-null") == 0) {
|
||||
*cipherType = Q_CIPHER_RSA_WITH_NULL;
|
||||
} else if (os_strcasecmp(cipherName, "rsa-blowfish") == 0 ||
|
||||
os_strcasecmp(cipherName, "rsa-blowfish-sha1") == 0) {
|
||||
} else if (ddsrt_strcasecmp(cipherName, "rsa-blowfish") == 0 ||
|
||||
ddsrt_strcasecmp(cipherName, "rsa-blowfish-sha1") == 0) {
|
||||
*cipherType = Q_CIPHER_RSA_WITH_BLOWFISH;
|
||||
} else if (os_strcasecmp(cipherName, "rsa-aes128") == 0 ||
|
||||
os_strcasecmp(cipherName, "rsa-aes128-sha1") == 0) {
|
||||
} else if (ddsrt_strcasecmp(cipherName, "rsa-aes128") == 0 ||
|
||||
ddsrt_strcasecmp(cipherName, "rsa-aes128-sha1") == 0) {
|
||||
*cipherType = Q_CIPHER_RSA_WITH_AES128;
|
||||
} else if (os_strcasecmp(cipherName, "rsa-aes192") == 0 ||
|
||||
os_strcasecmp(cipherName, "rsa-aes192-sha1") == 0) {
|
||||
} else if (ddsrt_strcasecmp(cipherName, "rsa-aes192") == 0 ||
|
||||
ddsrt_strcasecmp(cipherName, "rsa-aes192-sha1") == 0) {
|
||||
*cipherType = Q_CIPHER_RSA_WITH_AES192;
|
||||
} else if (os_strcasecmp(cipherName, "rsa-aes256") == 0 ||
|
||||
os_strcasecmp(cipherName, "rsa-aes256-sha1") == 0) {
|
||||
} else if (ddsrt_strcasecmp(cipherName, "rsa-aes256") == 0 ||
|
||||
ddsrt_strcasecmp(cipherName, "rsa-aes256-sha1") == 0) {
|
||||
*cipherType = Q_CIPHER_RSA_WITH_AES256;
|
||||
#endif
|
||||
} else {
|
||||
|
@ -668,8 +668,10 @@ static os_uint32 cipherTypeToHeaderSize(q_cipherType cipherType) {
|
|||
static
|
||||
void q_securityRNGSeed (void)
|
||||
{
|
||||
os_time time=os_timeGetMonotonic();
|
||||
RAND_seed((const void *)&time.tv_nsec,sizeof(time.tv_nsec));
|
||||
int32_t nsec;
|
||||
dds_time_t time = ddsrt_time_monotonic();
|
||||
nsec = time % DDS_NSECS_IN_SEC;
|
||||
RAND_seed(nsec,sizeof(nsec));
|
||||
}
|
||||
|
||||
static
|
||||
|
@ -947,7 +949,7 @@ static q_securityEncoderSet q_securityEncoderSetNew (void)
|
|||
const os_uint32 nofPartitions = config.nof_networkPartitions;
|
||||
|
||||
q_securityEncoderSet result =
|
||||
os_malloc(sizeof(C_STRUCT(q_securityEncoderSet)));
|
||||
ddsrt_malloc(sizeof(C_STRUCT(q_securityEncoderSet)));
|
||||
|
||||
if (!result) {
|
||||
return NULL;
|
||||
|
@ -958,7 +960,7 @@ static q_securityEncoderSet q_securityEncoderSetNew (void)
|
|||
if (nofPartitions == 0) {
|
||||
result->encoders = NULL;
|
||||
} else {
|
||||
result->encoders = os_malloc(sizeof(C_STRUCT(q_securityPartitionEncoder)) * nofPartitions);
|
||||
result->encoders = ddsrt_malloc(sizeof(C_STRUCT(q_securityPartitionEncoder)) * nofPartitions);
|
||||
memset(result->encoders,
|
||||
0,
|
||||
sizeof(C_STRUCT(q_securityPartitionEncoder)) *
|
||||
|
@ -1037,11 +1039,11 @@ static q_securityDecoderSet q_securityDecoderSetNew (void)
|
|||
return NULL;
|
||||
}
|
||||
|
||||
result = os_malloc (sizeof(C_STRUCT(q_securityDecoderSet)));
|
||||
result = ddsrt_malloc (sizeof(C_STRUCT(q_securityDecoderSet)));
|
||||
result->nofPartitions = 0;
|
||||
|
||||
result->decoders =
|
||||
os_malloc(sizeof(C_STRUCT(q_securityPartitionDecoder)) * nofPartitions);
|
||||
ddsrt_malloc(sizeof(C_STRUCT(q_securityPartitionDecoder)) * nofPartitions);
|
||||
|
||||
/* init the memory region */
|
||||
memset(result->decoders,
|
||||
|
@ -1115,8 +1117,8 @@ static c_bool q_securityEncoderSetFree (q_securityEncoderSet codec)
|
|||
|
||||
q_securityPartitionEncoderFini(currentEncoder);
|
||||
}
|
||||
os_free(codec->encoders);
|
||||
os_free(codec);
|
||||
ddsrt_free(codec->encoders);
|
||||
ddsrt_free(codec);
|
||||
|
||||
return 1; /* true */
|
||||
}
|
||||
|
@ -1137,8 +1139,8 @@ static c_bool q_securityDecoderSetFree (q_securityDecoderSet codec)
|
|||
|
||||
q_securityPartitionDecoderFini(currentDecoder);
|
||||
}
|
||||
os_free(codec->decoders);
|
||||
os_free(codec);
|
||||
ddsrt_free(codec->decoders);
|
||||
ddsrt_free(codec);
|
||||
|
||||
return TRUE; /* true */
|
||||
}
|
||||
|
@ -1674,7 +1676,7 @@ static os_ssize_t q_security_sendmsg
|
|||
}
|
||||
else
|
||||
{
|
||||
buf = os_malloc (sz);
|
||||
buf = ddsrt_malloc (sz);
|
||||
}
|
||||
/* ... then copy data into buffer */
|
||||
data_size = 0;
|
||||
|
@ -1715,7 +1717,7 @@ static os_ssize_t q_security_sendmsg
|
|||
|
||||
if (buf != stbuf)
|
||||
{
|
||||
os_free (buf);
|
||||
ddsrt_free (buf);
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
|
|
@ -11,24 +11,24 @@
|
|||
*/
|
||||
#include <assert.h>
|
||||
|
||||
#include "os/os.h"
|
||||
#include "dds/ddsrt/heap.h"
|
||||
#include "dds/ddsrt/sync.h"
|
||||
#include "dds/ddsrt/threads.h"
|
||||
|
||||
#include "ddsi/q_servicelease.h"
|
||||
#include "ddsi/q_config.h"
|
||||
#include "ddsi/q_log.h"
|
||||
#include "ddsi/q_thread.h"
|
||||
#include "ddsi/q_time.h"
|
||||
#include "ddsi/q_unused.h"
|
||||
#include "ddsi/q_error.h"
|
||||
#include "ddsi/q_globals.h" /* for mattr, cattr */
|
||||
#include "ddsi/q_receive.h"
|
||||
#include "dds/ddsi/q_servicelease.h"
|
||||
#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/q_error.h"
|
||||
#include "dds/ddsi/q_globals.h" /* for mattr, cattr */
|
||||
#include "dds/ddsi/q_receive.h"
|
||||
|
||||
#include "ddsi/sysdeps.h" /* for getrusage() */
|
||||
|
||||
static void nn_retrieve_lease_settings (os_time *sleepTime)
|
||||
static dds_time_t nn_retrieve_lease_settings (void)
|
||||
{
|
||||
const float leaseSec = config.servicelease_expiry_time;
|
||||
float sleepSec = leaseSec * config.servicelease_update_factor;
|
||||
const double leaseSec = config.servicelease_expiry_time;
|
||||
double sleepSec = leaseSec * config.servicelease_update_factor;
|
||||
|
||||
/* Run at no less than 1Hz: internal liveliness monitoring is slaved
|
||||
to this interval as well. 1Hz lease renewals and liveliness
|
||||
|
@ -36,10 +36,10 @@ static void nn_retrieve_lease_settings (os_time *sleepTime)
|
|||
a second is a lot more useful than doing it once every few
|
||||
seconds. Besides -- we're now also gathering CPU statistics. */
|
||||
if (sleepSec > 1.0f)
|
||||
sleepSec = 1.0f;
|
||||
return DDS_NSECS_IN_SEC;
|
||||
|
||||
sleepTime->tv_sec = (int32_t) sleepSec;
|
||||
sleepTime->tv_nsec = (int32_t) ((sleepSec - (float) sleepTime->tv_sec) * 1e9f);
|
||||
return ((dds_time_t)(sleepSec * DDS_NSECS_IN_SEC)) +
|
||||
((dds_time_t)(sleepSec * (double)DDS_NSECS_IN_SEC) % DDS_NSECS_IN_SEC);
|
||||
}
|
||||
|
||||
struct alive_wd {
|
||||
|
@ -48,14 +48,14 @@ struct alive_wd {
|
|||
};
|
||||
|
||||
struct nn_servicelease {
|
||||
os_time sleepTime;
|
||||
dds_time_t sleepTime;
|
||||
int keepgoing;
|
||||
struct alive_wd *av_ary;
|
||||
void (*renew_cb) (void *arg);
|
||||
void *renew_arg;
|
||||
|
||||
os_mutex lock;
|
||||
os_cond cond;
|
||||
ddsrt_mutex_t lock;
|
||||
ddsrt_cond_t cond;
|
||||
struct thread_state1 *ts;
|
||||
};
|
||||
|
||||
|
@ -76,7 +76,7 @@ static uint32_t lease_renewal_thread (struct nn_servicelease *sl)
|
|||
sl->av_ary[i].alive = 1;
|
||||
sl->av_ary[i].wd = thread_states.ts[i].watchdog - 1;
|
||||
}
|
||||
os_mutexLock (&sl->lock);
|
||||
ddsrt_mutex_lock (&sl->lock);
|
||||
while (sl->keepgoing)
|
||||
{
|
||||
unsigned n_alive = 0;
|
||||
|
@ -144,26 +144,22 @@ static uint32_t lease_renewal_thread (struct nn_servicelease *sl)
|
|||
was_alive = 0;
|
||||
}
|
||||
|
||||
#if SYSDEPS_HAVE_GETRUSAGE
|
||||
/* If getrusage() is available, use it to log CPU and memory
|
||||
statistics to the trace. Getrusage() can't fail if the
|
||||
parameters are valid, and these are by the book. Still we
|
||||
check. */
|
||||
if (dds_get_log_mask() & DDS_LC_TIMING)
|
||||
{
|
||||
struct rusage u;
|
||||
if (getrusage (RUSAGE_SELF, &u) == 0)
|
||||
ddsrt_rusage_t u;
|
||||
if (ddsrt_getrusage (DDSRT_RUSAGE_SELF, &u) == DDS_RETCODE_OK)
|
||||
{
|
||||
DDS_LOG(DDS_LC_TIMING,
|
||||
"rusage: utime %d.%06d stime %d.%06d maxrss %ld data %ld vcsw %ld ivcsw %ld\n",
|
||||
(int) u.ru_utime.tv_sec, (int) u.ru_utime.tv_usec,
|
||||
(int) u.ru_stime.tv_sec, (int) u.ru_stime.tv_usec,
|
||||
u.ru_maxrss, u.ru_idrss, u.ru_nvcsw, u.ru_nivcsw);
|
||||
"rusage: utime %d.%09d stime %d.%09d maxrss %ld data %ld vcsw %ld ivcsw %ld\n",
|
||||
(int) u.utime / DDS_NSECS_IN_SEC,
|
||||
(int) u.utime % DDS_NSECS_IN_SEC,
|
||||
(int) u.stime / DDS_NSECS_IN_SEC,
|
||||
(int) u.stime % DDS_NSECS_IN_SEC,
|
||||
u.maxrss, u.idrss, u.nvcsw, u.nivcsw);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
os_condTimedWait (&sl->cond, &sl->lock, &sl->sleepTime);
|
||||
ddsrt_cond_waitfor (&sl->cond, &sl->lock, sl->sleepTime);
|
||||
|
||||
/* We are never active in a way that matters for the garbage
|
||||
collection of old writers, &c. */
|
||||
|
@ -175,7 +171,7 @@ static uint32_t lease_renewal_thread (struct nn_servicelease *sl)
|
|||
if (gv.deaf)
|
||||
trigger_recv_threads ();
|
||||
}
|
||||
os_mutexUnlock (&sl->lock);
|
||||
ddsrt_mutex_unlock (&sl->lock);
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
@ -187,32 +183,32 @@ struct nn_servicelease *nn_servicelease_new (void (*renew_cb) (void *arg), void
|
|||
{
|
||||
struct nn_servicelease *sl;
|
||||
|
||||
sl = os_malloc (sizeof (*sl));
|
||||
nn_retrieve_lease_settings (&sl->sleepTime);
|
||||
sl = ddsrt_malloc (sizeof (*sl));
|
||||
sl->sleepTime = nn_retrieve_lease_settings ();
|
||||
sl->keepgoing = -1;
|
||||
sl->renew_cb = renew_cb ? renew_cb : dummy_renew_cb;
|
||||
sl->renew_arg = renew_arg;
|
||||
sl->ts = NULL;
|
||||
|
||||
if ((sl->av_ary = os_malloc (thread_states.nthreads * sizeof (*sl->av_ary))) == NULL)
|
||||
if ((sl->av_ary = ddsrt_malloc (thread_states.nthreads * sizeof (*sl->av_ary))) == NULL)
|
||||
goto fail_vtimes;
|
||||
/* service lease update thread initializes av_ary */
|
||||
|
||||
os_mutexInit (&sl->lock);
|
||||
os_condInit (&sl->cond, &sl->lock);
|
||||
ddsrt_mutex_init (&sl->lock);
|
||||
ddsrt_cond_init (&sl->cond);
|
||||
return sl;
|
||||
|
||||
fail_vtimes:
|
||||
os_free (sl);
|
||||
ddsrt_free (sl);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
int nn_servicelease_start_renewing (struct nn_servicelease *sl)
|
||||
{
|
||||
os_mutexLock (&sl->lock);
|
||||
ddsrt_mutex_lock (&sl->lock);
|
||||
assert (sl->keepgoing == -1);
|
||||
sl->keepgoing = 1;
|
||||
os_mutexUnlock (&sl->lock);
|
||||
ddsrt_mutex_unlock (&sl->lock);
|
||||
|
||||
sl->ts = create_thread ("lease", (uint32_t (*) (void *)) lease_renewal_thread, sl);
|
||||
if (sl->ts == NULL)
|
||||
|
@ -226,26 +222,27 @@ int nn_servicelease_start_renewing (struct nn_servicelease *sl)
|
|||
|
||||
void nn_servicelease_statechange_barrier (struct nn_servicelease *sl)
|
||||
{
|
||||
os_mutexLock (&sl->lock);
|
||||
os_mutexUnlock (&sl->lock);
|
||||
ddsrt_mutex_lock (&sl->lock);
|
||||
ddsrt_mutex_unlock (&sl->lock);
|
||||
}
|
||||
|
||||
void nn_servicelease_stop_renewing (struct nn_servicelease *sl)
|
||||
{
|
||||
if (sl->keepgoing != -1)
|
||||
{
|
||||
os_mutexLock (&sl->lock);
|
||||
ddsrt_mutex_lock (&sl->lock);
|
||||
sl->keepgoing = 0;
|
||||
os_condSignal (&sl->cond);
|
||||
os_mutexUnlock (&sl->lock);
|
||||
ddsrt_cond_signal (&sl->cond);
|
||||
ddsrt_mutex_unlock (&sl->lock);
|
||||
join_thread (sl->ts);
|
||||
}
|
||||
}
|
||||
|
||||
void nn_servicelease_free (struct nn_servicelease *sl)
|
||||
{
|
||||
os_condDestroy (&sl->cond);
|
||||
os_mutexDestroy (&sl->lock);
|
||||
os_free (sl->av_ary);
|
||||
os_free (sl);
|
||||
ddsrt_cond_destroy (&sl->cond);
|
||||
ddsrt_mutex_destroy (&sl->lock);
|
||||
ddsrt_free (sl->av_ary);
|
||||
ddsrt_free (sl);
|
||||
}
|
||||
|
||||
|
|
Some files were not shown because too many files have changed in this diff Show more
Loading…
Add table
Add a link
Reference in a new issue