abstract the internal representation of a sample
besides the old state being in dire need of cleaning up, this also paves the way for having any number of different sample representations in the system Signed-off-by: Erik Boasson <eb@ilities.com>
This commit is contained in:
		
							parent
							
								
									6e1df4c564
								
							
						
					
					
						commit
						a25f683bcf
					
				
					 52 changed files with 1400 additions and 1125 deletions
				
			
		| 
						 | 
				
			
			@ -21,7 +21,6 @@ PREPEND(srcs_ddsc "${CMAKE_CURRENT_LIST_DIR}/src"
 | 
			
		|||
    dds_publisher.c
 | 
			
		||||
    dds_rhc.c
 | 
			
		||||
    dds_time.c
 | 
			
		||||
    q_osplser.c
 | 
			
		||||
    dds_domain.c
 | 
			
		||||
    dds_instance.c
 | 
			
		||||
    dds_qos.c
 | 
			
		||||
| 
						 | 
				
			
			@ -82,7 +81,6 @@ PREPEND(hdrs_private_ddsc "${CMAKE_CURRENT_LIST_DIR}/src"
 | 
			
		|||
    dds__write.h
 | 
			
		||||
    dds__writer.h
 | 
			
		||||
    dds__whc.h
 | 
			
		||||
    q__osplser.h
 | 
			
		||||
)
 | 
			
		||||
 | 
			
		||||
configure_file(
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -55,8 +55,7 @@ typedef _Return_type_success_(return >  0) int32_t dds_entity_t;
 | 
			
		|||
extern "C" {
 | 
			
		||||
#endif
 | 
			
		||||
 | 
			
		||||
/* FIXME: rename serdata, abstract it properly, etc */
 | 
			
		||||
struct serdata;
 | 
			
		||||
struct ddsi_serdata;
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
 * @brief Returns the default domain identifier.
 | 
			
		||||
| 
						 | 
				
			
			@ -1710,7 +1709,7 @@ _Pre_satisfies_((writer & DDS_ENTITY_KIND_MASK) == DDS_KIND_WRITER)
 | 
			
		|||
DDS_EXPORT int
 | 
			
		||||
dds_writecdr(
 | 
			
		||||
        dds_entity_t writer,
 | 
			
		||||
        struct serdata *serdata);
 | 
			
		||||
        struct ddsi_serdata *serdata);
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
 * @brief Write the value of a data instance along with the source timestamp passed.
 | 
			
		||||
| 
						 | 
				
			
			@ -2722,7 +2721,7 @@ dds_take_mask_wl(
 | 
			
		|||
DDS_EXPORT int
 | 
			
		||||
dds_takecdr(
 | 
			
		||||
        dds_entity_t reader_or_condition,
 | 
			
		||||
        struct serdata **buf,
 | 
			
		||||
        struct ddsi_serdata **buf,
 | 
			
		||||
        uint32_t maxs,
 | 
			
		||||
        dds_sample_info_t *si,
 | 
			
		||||
        uint32_t mask);
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -56,7 +56,7 @@ dds_key_descriptor_t;
 | 
			
		|||
 | 
			
		||||
typedef struct dds_topic_descriptor
 | 
			
		||||
{
 | 
			
		||||
  const size_t m_size;                 /* Size of topic type */
 | 
			
		||||
  const uint32_t m_size;               /* Size of topic type */
 | 
			
		||||
  const uint32_t m_align;              /* Alignment of topic type */
 | 
			
		||||
  const uint32_t m_flagset;            /* Flags */
 | 
			
		||||
  const uint32_t m_nkeys;              /* Number of keys (can be 0) */
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -45,8 +45,8 @@ dds_uptr_t;
 | 
			
		|||
typedef struct dds_stream
 | 
			
		||||
{
 | 
			
		||||
  dds_uptr_t m_buffer;  /* Union of pointers to start of buffer */
 | 
			
		||||
  size_t m_size;      /* Buffer size */
 | 
			
		||||
  size_t m_index;     /* Read/write offset from start of buffer */
 | 
			
		||||
  uint32_t m_size;      /* Buffer size */
 | 
			
		||||
  uint32_t m_index;     /* Read/write offset from start of buffer */
 | 
			
		||||
  bool m_endian;        /* Endian: big (false) or little (true) */
 | 
			
		||||
  bool m_failed;        /* Attempt made to read beyond end of buffer */
 | 
			
		||||
}
 | 
			
		||||
| 
						 | 
				
			
			@ -55,13 +55,13 @@ dds_stream_t;
 | 
			
		|||
#define DDS_STREAM_BE false
 | 
			
		||||
#define DDS_STREAM_LE true
 | 
			
		||||
 | 
			
		||||
DDS_EXPORT dds_stream_t * dds_stream_create (size_t size);
 | 
			
		||||
DDS_EXPORT dds_stream_t * dds_stream_create (uint32_t size);
 | 
			
		||||
DDS_EXPORT dds_stream_t * dds_stream_from_buffer (const void *buf, size_t sz, int bswap);
 | 
			
		||||
DDS_EXPORT void dds_stream_delete (dds_stream_t * st);
 | 
			
		||||
DDS_EXPORT void dds_stream_fini (dds_stream_t * st);
 | 
			
		||||
DDS_EXPORT void dds_stream_reset (dds_stream_t * st);
 | 
			
		||||
DDS_EXPORT void dds_stream_init (dds_stream_t * st, size_t size);
 | 
			
		||||
DDS_EXPORT void dds_stream_grow (dds_stream_t * st, size_t size);
 | 
			
		||||
DDS_EXPORT void dds_stream_init (dds_stream_t * st, uint32_t size);
 | 
			
		||||
DDS_EXPORT void dds_stream_grow (dds_stream_t * st, uint32_t size);
 | 
			
		||||
DDS_EXPORT bool dds_stream_endian (void);
 | 
			
		||||
 | 
			
		||||
struct dds_topic_descriptor;
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -23,11 +23,11 @@ extern "C" {
 | 
			
		|||
 | 
			
		||||
struct rhc;
 | 
			
		||||
struct nn_xqos;
 | 
			
		||||
struct serdata;
 | 
			
		||||
struct ddsi_serdata;
 | 
			
		||||
struct tkmap_instance;
 | 
			
		||||
struct proxy_writer_info;
 | 
			
		||||
 | 
			
		||||
struct rhc * dds_rhc_new (dds_reader * reader, const struct sertopic * topic);
 | 
			
		||||
struct rhc * dds_rhc_new (dds_reader * reader, const struct ddsi_sertopic * topic);
 | 
			
		||||
void dds_rhc_free (struct rhc * rhc);
 | 
			
		||||
void dds_rhc_fini (struct rhc * rhc);
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			@ -36,7 +36,7 @@ uint32_t dds_rhc_lock_samples (struct rhc * rhc);
 | 
			
		|||
DDS_EXPORT bool dds_rhc_store
 | 
			
		||||
(
 | 
			
		||||
  struct rhc * __restrict rhc, const struct proxy_writer_info * __restrict pwr_info,
 | 
			
		||||
  struct serdata * __restrict sample, struct tkmap_instance * __restrict tk
 | 
			
		||||
  struct ddsi_serdata * __restrict sample, struct tkmap_instance * __restrict tk
 | 
			
		||||
);
 | 
			
		||||
void dds_rhc_unregister_wr (struct rhc * __restrict rhc, const struct proxy_writer_info * __restrict pwr_info);
 | 
			
		||||
void dds_rhc_relinquish_ownership (struct rhc * __restrict rhc, const uint64_t wr_iid);
 | 
			
		||||
| 
						 | 
				
			
			@ -72,7 +72,7 @@ int dds_rhc_remove_waitset (dds_readcond * cond, dds_waitset * waitset);
 | 
			
		|||
 | 
			
		||||
int dds_rhc_takecdr
 | 
			
		||||
(
 | 
			
		||||
  struct rhc *rhc, bool lock, struct serdata **values, dds_sample_info_t *info_seq,
 | 
			
		||||
  struct rhc *rhc, bool lock, struct ddsi_serdata **values, dds_sample_info_t *info_seq,
 | 
			
		||||
  uint32_t max_samples, unsigned sample_states,
 | 
			
		||||
  unsigned view_states, unsigned instance_states,
 | 
			
		||||
  dds_instance_handle_t handle
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -12,7 +12,8 @@
 | 
			
		|||
#ifndef _DDS_STREAM_H_
 | 
			
		||||
#define _DDS_STREAM_H_
 | 
			
		||||
 | 
			
		||||
#include "ddsi/ddsi_ser.h"
 | 
			
		||||
#include "ddsi/ddsi_serdata.h"
 | 
			
		||||
#include "ddsi/ddsi_serdata_default.h"
 | 
			
		||||
 | 
			
		||||
#if defined (__cplusplus)
 | 
			
		||||
extern "C" {
 | 
			
		||||
| 
						 | 
				
			
			@ -22,25 +23,20 @@ void dds_stream_write_sample
 | 
			
		|||
(
 | 
			
		||||
  dds_stream_t * os,
 | 
			
		||||
  const void * data,
 | 
			
		||||
  const struct sertopic * topic
 | 
			
		||||
  const struct ddsi_sertopic_default * topic
 | 
			
		||||
);
 | 
			
		||||
void dds_stream_read_sample
 | 
			
		||||
(
 | 
			
		||||
  dds_stream_t * is,
 | 
			
		||||
  void * data,
 | 
			
		||||
  const struct sertopic * topic
 | 
			
		||||
  const struct ddsi_sertopic_default * topic
 | 
			
		||||
);
 | 
			
		||||
 | 
			
		||||
size_t dds_stream_check_optimize (_In_ const dds_topic_descriptor_t * desc);
 | 
			
		||||
void dds_stream_from_serstate (_Out_ dds_stream_t * s, _In_ const serstate_t st);
 | 
			
		||||
void dds_stream_add_to_serstate (_Inout_ dds_stream_t * s, _Inout_ serstate_t st);
 | 
			
		||||
void dds_stream_from_serdata_default (dds_stream_t * s, const struct ddsi_serdata_default *d);
 | 
			
		||||
void dds_stream_add_to_serdata_default (dds_stream_t * s, struct ddsi_serdata_default **d);
 | 
			
		||||
 | 
			
		||||
void dds_stream_write_key
 | 
			
		||||
(
 | 
			
		||||
  dds_stream_t * os,
 | 
			
		||||
  const char * sample,
 | 
			
		||||
  const dds_topic_descriptor_t * desc
 | 
			
		||||
);
 | 
			
		||||
void dds_stream_write_key (dds_stream_t * os, const char * sample, const struct ddsi_sertopic_default * topic);
 | 
			
		||||
void dds_stream_read_key
 | 
			
		||||
(
 | 
			
		||||
  dds_stream_t * is,
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -20,12 +20,12 @@ extern "C" {
 | 
			
		|||
#endif
 | 
			
		||||
 | 
			
		||||
struct tkmap;
 | 
			
		||||
struct serdata;
 | 
			
		||||
struct ddsi_serdata;
 | 
			
		||||
struct dds_topic;
 | 
			
		||||
 | 
			
		||||
struct tkmap_instance
 | 
			
		||||
{
 | 
			
		||||
  struct serdata * m_sample;
 | 
			
		||||
  struct ddsi_serdata * m_sample;
 | 
			
		||||
  struct tkmap * m_map;
 | 
			
		||||
  uint64_t m_iid;
 | 
			
		||||
  os_atomic_uint32_t m_refc;
 | 
			
		||||
| 
						 | 
				
			
			@ -35,15 +35,15 @@ struct tkmap_instance
 | 
			
		|||
struct tkmap * dds_tkmap_new (void);
 | 
			
		||||
void dds_tkmap_free (_Inout_ _Post_invalid_ struct tkmap *tkmap);
 | 
			
		||||
void dds_tkmap_instance_ref (_In_ struct tkmap_instance *tk);
 | 
			
		||||
uint64_t dds_tkmap_lookup (_In_ struct tkmap *tkmap, _In_ const struct serdata *serdata);
 | 
			
		||||
uint64_t dds_tkmap_lookup (_In_ struct tkmap *tkmap, _In_ const struct ddsi_serdata *serdata);
 | 
			
		||||
_Check_return_ bool dds_tkmap_get_key (_In_ struct tkmap * map, _In_ uint64_t iid, _Out_ void * sample);
 | 
			
		||||
_Check_return_ struct tkmap_instance * dds_tkmap_find(
 | 
			
		||||
        _In_ struct serdata * sd,
 | 
			
		||||
        _In_ struct ddsi_serdata * sd,
 | 
			
		||||
        _In_ const bool rd,
 | 
			
		||||
        _In_ const bool create);
 | 
			
		||||
_Check_return_ struct tkmap_instance * dds_tkmap_find_by_id (_In_ struct tkmap * map, _In_ uint64_t iid);
 | 
			
		||||
 | 
			
		||||
DDS_EXPORT _Check_return_ struct tkmap_instance * dds_tkmap_lookup_instance_ref (_In_ struct serdata * sd);
 | 
			
		||||
DDS_EXPORT _Check_return_ struct tkmap_instance * dds_tkmap_lookup_instance_ref (_In_ struct ddsi_serdata * sd);
 | 
			
		||||
DDS_EXPORT void dds_tkmap_instance_unref (_In_ struct tkmap_instance * tk);
 | 
			
		||||
 | 
			
		||||
#if defined (__cplusplus)
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -21,8 +21,8 @@ extern "C" {
 | 
			
		|||
#define dds_topic_lock(hdl, obj) dds_entity_lock(hdl, DDS_KIND_TOPIC, (dds_entity**)obj)
 | 
			
		||||
#define dds_topic_unlock(obj)    dds_entity_unlock((dds_entity*)obj);
 | 
			
		||||
 | 
			
		||||
extern struct sertopic * dds_topic_lookup (dds_domain * domain, const char * name);
 | 
			
		||||
extern void dds_topic_free (dds_domainid_t domainid, struct sertopic * st);
 | 
			
		||||
extern struct ddsi_sertopic * dds_topic_lookup (dds_domain * domain, const char * name);
 | 
			
		||||
extern void dds_topic_free (dds_domainid_t domainid, struct ddsi_sertopic * st);
 | 
			
		||||
 | 
			
		||||
#ifndef DDS_TOPIC_INTERN_FILTER_FN_DEFINED
 | 
			
		||||
#define DDS_TOPIC_INTERN_FILTER_FN_DEFINED
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -38,7 +38,7 @@ struct dds_readcond;
 | 
			
		|||
struct dds_guardcond;
 | 
			
		||||
struct dds_statuscond;
 | 
			
		||||
 | 
			
		||||
struct sertopic;
 | 
			
		||||
struct ddsi_sertopic;
 | 
			
		||||
struct rhc;
 | 
			
		||||
 | 
			
		||||
/* Internal entity status flags */
 | 
			
		||||
| 
						 | 
				
			
			@ -203,7 +203,7 @@ dds_writer;
 | 
			
		|||
typedef struct dds_topic
 | 
			
		||||
{
 | 
			
		||||
  struct dds_entity m_entity;
 | 
			
		||||
  struct sertopic * m_stopic;
 | 
			
		||||
  struct ddsi_sertopic * m_stopic;
 | 
			
		||||
  const dds_topic_descriptor_t * m_descriptor;
 | 
			
		||||
 | 
			
		||||
  /* Status metrics */
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -20,6 +20,8 @@ extern "C" {
 | 
			
		|||
#define DDS_WR_DISPOSE_BIT 0x02
 | 
			
		||||
#define DDS_WR_UNREGISTER_BIT 0x04
 | 
			
		||||
 | 
			
		||||
struct ddsi_serdata;
 | 
			
		||||
 | 
			
		||||
typedef enum
 | 
			
		||||
{
 | 
			
		||||
  DDS_WR_ACTION_WRITE = 0,
 | 
			
		||||
| 
						 | 
				
			
			@ -39,7 +41,7 @@ dds_write_impl(
 | 
			
		|||
int
 | 
			
		||||
dds_writecdr_impl(
 | 
			
		||||
        _In_ dds_writer *wr,
 | 
			
		||||
        _Inout_ struct serdata *d,
 | 
			
		||||
        _Inout_ struct ddsi_serdata *d,
 | 
			
		||||
        _In_ dds_time_t tstamp,
 | 
			
		||||
        _In_ dds_write_action action);
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -15,7 +15,6 @@
 | 
			
		|||
#include "ddsi/q_thread.h"
 | 
			
		||||
#include "ddsi/q_config.h"
 | 
			
		||||
#include "ddsi/q_builtin_topic.h"
 | 
			
		||||
#include "q__osplser.h"
 | 
			
		||||
#include "dds__init.h"
 | 
			
		||||
#include "dds__qos.h"
 | 
			
		||||
#include "dds__domain.h"
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -22,7 +22,7 @@
 | 
			
		|||
#include "dds__err.h"
 | 
			
		||||
#include "dds__builtin.h"
 | 
			
		||||
#include "dds__report.h"
 | 
			
		||||
#include "ddsi/ddsi_ser.h"
 | 
			
		||||
#include "ddsi/ddsi_serdata.h"
 | 
			
		||||
#include "ddsi/q_servicelease.h"
 | 
			
		||||
#include "ddsi/q_entity.h"
 | 
			
		||||
#include <ddsi/q_config.h>
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -18,10 +18,9 @@
 | 
			
		|||
#include "dds__rhc.h"
 | 
			
		||||
#include "dds__tkmap.h"
 | 
			
		||||
#include "dds__err.h"
 | 
			
		||||
#include "ddsi/ddsi_ser.h"
 | 
			
		||||
#include "ddsi/ddsi_serdata.h"
 | 
			
		||||
#include "ddsi/q_entity.h"
 | 
			
		||||
#include "ddsi/q_thread.h"
 | 
			
		||||
#include "q__osplser.h"
 | 
			
		||||
#include "dds__report.h"
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			@ -70,7 +69,7 @@ dds_instance_find(
 | 
			
		|||
        _In_ const void *data,
 | 
			
		||||
        _In_ const bool create)
 | 
			
		||||
{
 | 
			
		||||
    serdata_t sd = serialize_key (topic->m_stopic, data);
 | 
			
		||||
    struct ddsi_serdata *sd = ddsi_serdata_from_sample (topic->m_stopic, SDK_KEY, data);
 | 
			
		||||
    struct tkmap_instance * inst = dds_tkmap_find (sd, false, create);
 | 
			
		||||
    ddsi_serdata_unref (sd);
 | 
			
		||||
    return inst;
 | 
			
		||||
| 
						 | 
				
			
			@ -407,7 +406,7 @@ dds_instance_lookup(
 | 
			
		|||
    dds_instance_handle_t ih = DDS_HANDLE_NIL;
 | 
			
		||||
    const dds_topic * topic;
 | 
			
		||||
    struct tkmap * map = gv.m_tkmap;
 | 
			
		||||
    serdata_t sd;
 | 
			
		||||
    struct ddsi_serdata *sd;
 | 
			
		||||
    dds_return_t ret;
 | 
			
		||||
 | 
			
		||||
    DDS_REPORT_STACK();
 | 
			
		||||
| 
						 | 
				
			
			@ -419,7 +418,7 @@ dds_instance_lookup(
 | 
			
		|||
 | 
			
		||||
    topic = dds_instance_info_by_hdl (entity);
 | 
			
		||||
    if (topic) {
 | 
			
		||||
        sd = serialize_key (topic->m_stopic, data);
 | 
			
		||||
        sd = ddsi_serdata_from_sample (topic->m_stopic, SDK_KEY, data);
 | 
			
		||||
        ih = dds_tkmap_lookup (map, sd);
 | 
			
		||||
        ddsi_serdata_unref (sd);
 | 
			
		||||
        ret = DDS_RETCODE_OK;
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -13,7 +13,7 @@
 | 
			
		|||
#include <string.h>
 | 
			
		||||
#include "dds__key.h"
 | 
			
		||||
#include "dds__stream.h"
 | 
			
		||||
#include "ddsi/ddsi_ser.h"
 | 
			
		||||
#include "ddsi/ddsi_serdata.h"
 | 
			
		||||
#include "ddsi/q_bswap.h"
 | 
			
		||||
#include "ddsi/q_md5.h"
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -13,7 +13,6 @@
 | 
			
		|||
#include "ddsi/q_entity.h"
 | 
			
		||||
#include "ddsi/q_thread.h"
 | 
			
		||||
#include "ddsi/q_config.h"
 | 
			
		||||
#include "q__osplser.h"
 | 
			
		||||
#include "dds__init.h"
 | 
			
		||||
#include "dds__qos.h"
 | 
			
		||||
#include "dds__domain.h"
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -16,7 +16,8 @@
 | 
			
		|||
#include "dds__querycond.h"
 | 
			
		||||
#include "dds__readcond.h"
 | 
			
		||||
#include "dds__err.h"
 | 
			
		||||
#include "ddsi/ddsi_ser.h"
 | 
			
		||||
#include "ddsi/ddsi_serdata.h"
 | 
			
		||||
#include "ddsi/ddsi_sertopic.h"
 | 
			
		||||
#include "dds__report.h"
 | 
			
		||||
 | 
			
		||||
_Pre_satisfies_((reader & DDS_ENTITY_KIND_MASK) == DDS_KIND_READER)
 | 
			
		||||
| 
						 | 
				
			
			@ -44,9 +45,12 @@ dds_create_querycondition(
 | 
			
		|||
        dds_reader_unlock(r);
 | 
			
		||||
        rc = dds_topic_lock(topic, &t);
 | 
			
		||||
        if (rc == DDS_RETCODE_OK) {
 | 
			
		||||
            abort();
 | 
			
		||||
#if 0
 | 
			
		||||
            if (t->m_stopic->filter_sample == NULL) {
 | 
			
		||||
                t->m_stopic->filter_sample = dds_alloc(t->m_descriptor->m_size);
 | 
			
		||||
            }
 | 
			
		||||
#endif
 | 
			
		||||
            dds_topic_unlock(t);
 | 
			
		||||
        } else {
 | 
			
		||||
            (void)dds_delete(hdl);
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -188,7 +188,7 @@ static dds_return_t
 | 
			
		|||
dds_readcdr_impl(
 | 
			
		||||
        _In_  bool take,
 | 
			
		||||
        _In_  dds_entity_t reader_or_condition,
 | 
			
		||||
        _Out_ struct serdata ** buf,
 | 
			
		||||
        _Out_ struct ddsi_serdata ** buf,
 | 
			
		||||
        _In_  uint32_t maxs,
 | 
			
		||||
        _Out_ dds_sample_info_t * si,
 | 
			
		||||
        _In_  uint32_t mask,
 | 
			
		||||
| 
						 | 
				
			
			@ -630,7 +630,7 @@ dds_take_mask_wl(
 | 
			
		|||
int
 | 
			
		||||
dds_takecdr(
 | 
			
		||||
        dds_entity_t rd_or_cnd,
 | 
			
		||||
        struct serdata **buf,
 | 
			
		||||
        struct ddsi_serdata **buf,
 | 
			
		||||
        uint32_t maxs,
 | 
			
		||||
        dds_sample_info_t *si,
 | 
			
		||||
        uint32_t mask)
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -31,11 +31,12 @@
 | 
			
		|||
#include "ddsi/q_xqos.h"
 | 
			
		||||
#include "ddsi/q_error.h"
 | 
			
		||||
#include "ddsi/q_unused.h"
 | 
			
		||||
#include "q__osplser.h"
 | 
			
		||||
#include "ddsi/q_config.h"
 | 
			
		||||
#include "ddsi/q_globals.h"
 | 
			
		||||
#include "ddsi/q_radmin.h" /* sampleinfo */
 | 
			
		||||
#include "ddsi/q_entity.h" /* proxy_writer_info */
 | 
			
		||||
#include "ddsi/ddsi_serdata.h"
 | 
			
		||||
#include "ddsi/ddsi_serdata_default.h"
 | 
			
		||||
#include "ddsi/sysdeps.h"
 | 
			
		||||
#include "dds__report.h"
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			@ -223,7 +224,7 @@ void lwregs_dump (struct lwregs *rt)
 | 
			
		|||
 | 
			
		||||
struct rhc_sample
 | 
			
		||||
{
 | 
			
		||||
  struct serdata *sample;      /* serialised data (either just_key or real data) */
 | 
			
		||||
  struct ddsi_serdata *sample; /* serialised data (either just_key or real data) */
 | 
			
		||||
  struct rhc_sample *next;     /* next sample in time ordering, or oldest sample if most recent */
 | 
			
		||||
  uint64_t wr_iid;             /* unique id for writer of this sample (perhaps better in serdata) */
 | 
			
		||||
  bool isread;                 /* READ or NOT_READ sample state */
 | 
			
		||||
| 
						 | 
				
			
			@ -293,7 +294,7 @@ struct rhc
 | 
			
		|||
  bool reliable;                    /* true if reliability RELIABLE */
 | 
			
		||||
 | 
			
		||||
  dds_reader * reader;              /* reader */
 | 
			
		||||
  const struct sertopic * topic;    /* topic description */
 | 
			
		||||
  const struct ddsi_sertopic * topic;    /* topic description */
 | 
			
		||||
  unsigned history_depth;           /* depth, 1 for KEEP_LAST_1, 2**32-1 for KEEP_ALL */
 | 
			
		||||
 | 
			
		||||
  os_mutex lock;
 | 
			
		||||
| 
						 | 
				
			
			@ -319,7 +320,7 @@ struct trigger_info
 | 
			
		|||
#define INST_HAS_UNREAD(i) (INST_NREAD (i) < INST_NSAMPLES (i))
 | 
			
		||||
 | 
			
		||||
static unsigned qmask_of_inst (const struct rhc_instance *inst);
 | 
			
		||||
static bool update_conditions_locked (struct rhc *rhc, const struct trigger_info *pre, const struct trigger_info *post, const struct serdata *sample);
 | 
			
		||||
static bool update_conditions_locked (struct rhc *rhc, const struct trigger_info *pre, const struct trigger_info *post, const struct ddsi_serdata *sample);
 | 
			
		||||
#ifndef NDEBUG
 | 
			
		||||
static int rhc_check_counts_locked (struct rhc *rhc, bool check_conds);
 | 
			
		||||
#endif
 | 
			
		||||
| 
						 | 
				
			
			@ -389,7 +390,7 @@ static void remove_inst_from_nonempty_list (struct rhc *rhc, struct rhc_instance
 | 
			
		|||
  rhc->n_nonempty_instances--;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
struct rhc * dds_rhc_new (dds_reader * reader, const struct sertopic * topic)
 | 
			
		||||
struct rhc * dds_rhc_new (dds_reader * reader, const struct ddsi_sertopic * topic)
 | 
			
		||||
{
 | 
			
		||||
  struct rhc * rhc = dds_alloc (sizeof (*rhc));
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			@ -578,7 +579,7 @@ static bool add_sample
 | 
			
		|||
  struct rhc * rhc,
 | 
			
		||||
  struct rhc_instance * inst,
 | 
			
		||||
  const struct proxy_writer_info * pwr_info,
 | 
			
		||||
  const struct serdata * sample,
 | 
			
		||||
  const struct ddsi_serdata * sample,
 | 
			
		||||
  status_cb_data_t * cb_data
 | 
			
		||||
)
 | 
			
		||||
{
 | 
			
		||||
| 
						 | 
				
			
			@ -652,7 +653,7 @@ static bool add_sample
 | 
			
		|||
    rhc->n_vsamples++;
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
  s->sample = ddsi_serdata_ref ((serdata_t) sample); /* drops const (tho refcount does change) */
 | 
			
		||||
  s->sample = ddsi_serdata_ref ((struct ddsi_serdata *) sample); /* drops const (tho refcount does change) */
 | 
			
		||||
  s->wr_iid = pwr_info->iid;
 | 
			
		||||
  s->isread = false;
 | 
			
		||||
  s->disposed_gen = inst->disposed_gen;
 | 
			
		||||
| 
						 | 
				
			
			@ -662,15 +663,16 @@ static bool add_sample
 | 
			
		|||
  return true;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
static bool content_filter_accepts (const struct sertopic * topic, const struct serdata *sample)
 | 
			
		||||
static bool content_filter_accepts (const struct ddsi_sertopic * topic, const struct ddsi_serdata *sample)
 | 
			
		||||
{
 | 
			
		||||
  bool ret = true;
 | 
			
		||||
 | 
			
		||||
#if 0 /* FIXME: content filter */
 | 
			
		||||
  if (topic->filter_fn)
 | 
			
		||||
  {
 | 
			
		||||
    deserialize_into ((char*) topic->filter_sample, sample);
 | 
			
		||||
    ret = (topic->filter_fn) (topic->filter_sample, topic->filter_ctx);
 | 
			
		||||
  }
 | 
			
		||||
#endif
 | 
			
		||||
  return ret;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			@ -683,16 +685,16 @@ static int inst_accepts_sample
 | 
			
		|||
(
 | 
			
		||||
  const struct rhc *rhc, const struct rhc_instance *inst,
 | 
			
		||||
  const struct proxy_writer_info *pwr_info,
 | 
			
		||||
  const struct serdata *sample, const bool has_data
 | 
			
		||||
  const struct ddsi_serdata *sample, const bool has_data
 | 
			
		||||
)
 | 
			
		||||
{
 | 
			
		||||
  if (rhc->by_source_ordering)
 | 
			
		||||
  {
 | 
			
		||||
    if (sample->v.msginfo.timestamp.v > inst->tstamp.v)
 | 
			
		||||
    if (sample->timestamp.v > inst->tstamp.v)
 | 
			
		||||
    {
 | 
			
		||||
      /* ok */
 | 
			
		||||
    }
 | 
			
		||||
    else if (sample->v.msginfo.timestamp.v < inst->tstamp.v)
 | 
			
		||||
    else if (sample->timestamp.v < inst->tstamp.v)
 | 
			
		||||
    {
 | 
			
		||||
      return 0;
 | 
			
		||||
    }
 | 
			
		||||
| 
						 | 
				
			
			@ -1019,7 +1021,7 @@ static void dds_rhc_unregister
 | 
			
		|||
static struct rhc_instance * alloc_new_instance
 | 
			
		||||
(
 | 
			
		||||
  const struct proxy_writer_info *pwr_info,
 | 
			
		||||
  struct serdata *serdata,
 | 
			
		||||
  struct ddsi_serdata *serdata,
 | 
			
		||||
  struct tkmap_instance *tk
 | 
			
		||||
)
 | 
			
		||||
{
 | 
			
		||||
| 
						 | 
				
			
			@ -1029,8 +1031,8 @@ static struct rhc_instance * alloc_new_instance
 | 
			
		|||
  inst = dds_alloc (sizeof (*inst));
 | 
			
		||||
  inst->iid = tk->m_iid;
 | 
			
		||||
  inst->tk = tk;
 | 
			
		||||
  inst->wrcount = (serdata->v.msginfo.statusinfo & NN_STATUSINFO_UNREGISTER) ? 0 : 1;
 | 
			
		||||
  inst->isdisposed = (serdata->v.msginfo.statusinfo & NN_STATUSINFO_DISPOSE);
 | 
			
		||||
  inst->wrcount = (serdata->statusinfo & NN_STATUSINFO_UNREGISTER) ? 0 : 1;
 | 
			
		||||
  inst->isdisposed = (serdata->statusinfo & NN_STATUSINFO_DISPOSE);
 | 
			
		||||
  inst->isnew = 1;
 | 
			
		||||
  inst->inv_exists = 0;
 | 
			
		||||
  inst->inv_isread = 0; /* don't care */
 | 
			
		||||
| 
						 | 
				
			
			@ -1038,7 +1040,7 @@ static struct rhc_instance * alloc_new_instance
 | 
			
		|||
  inst->wr_iid = pwr_info->iid;
 | 
			
		||||
  inst->wr_iid_islive = (inst->wrcount != 0);
 | 
			
		||||
  inst->wr_guid = pwr_info->guid;
 | 
			
		||||
  inst->tstamp = serdata->v.msginfo.timestamp;
 | 
			
		||||
  inst->tstamp = serdata->timestamp;
 | 
			
		||||
  inst->strength = pwr_info->ownership_strength;
 | 
			
		||||
  return inst;
 | 
			
		||||
}
 | 
			
		||||
| 
						 | 
				
			
			@ -1048,7 +1050,7 @@ static rhc_store_result_t rhc_store_new_instance
 | 
			
		|||
  struct trigger_info * post,
 | 
			
		||||
  struct rhc *rhc,
 | 
			
		||||
  const struct proxy_writer_info *pwr_info,
 | 
			
		||||
  struct serdata *sample,
 | 
			
		||||
  struct ddsi_serdata *sample,
 | 
			
		||||
  struct tkmap_instance *tk,
 | 
			
		||||
  const bool has_data,
 | 
			
		||||
  status_cb_data_t * cb_data
 | 
			
		||||
| 
						 | 
				
			
			@ -1121,12 +1123,12 @@ static rhc_store_result_t rhc_store_new_instance
 | 
			
		|||
bool dds_rhc_store
 | 
			
		||||
(
 | 
			
		||||
  struct rhc * __restrict rhc, const struct proxy_writer_info * __restrict pwr_info,
 | 
			
		||||
  struct serdata * __restrict sample, struct tkmap_instance * __restrict tk
 | 
			
		||||
  struct ddsi_serdata * __restrict sample, struct tkmap_instance * __restrict tk
 | 
			
		||||
)
 | 
			
		||||
{
 | 
			
		||||
  const uint64_t wr_iid = pwr_info->iid;
 | 
			
		||||
  const unsigned statusinfo = sample->v.msginfo.statusinfo;
 | 
			
		||||
  const bool has_data = (sample->v.st->kind == STK_DATA);
 | 
			
		||||
  const unsigned statusinfo = sample->statusinfo;
 | 
			
		||||
  const bool has_data = (sample->kind == SDK_DATA);
 | 
			
		||||
  const int is_dispose = (statusinfo & NN_STATUSINFO_DISPOSE) != 0;
 | 
			
		||||
  struct rhc_instance dummy_instance;
 | 
			
		||||
  struct rhc_instance *inst;
 | 
			
		||||
| 
						 | 
				
			
			@ -1193,7 +1195,7 @@ bool dds_rhc_store
 | 
			
		|||
    }
 | 
			
		||||
    if (statusinfo & NN_STATUSINFO_UNREGISTER)
 | 
			
		||||
    {
 | 
			
		||||
      dds_rhc_unregister (&post, rhc, inst, pwr_info, sample->v.msginfo.timestamp);
 | 
			
		||||
      dds_rhc_unregister (&post, rhc, inst, pwr_info, sample->timestamp);
 | 
			
		||||
    }
 | 
			
		||||
    else
 | 
			
		||||
    {
 | 
			
		||||
| 
						 | 
				
			
			@ -1282,7 +1284,7 @@ bool dds_rhc_store
 | 
			
		|||
      if (inst_became_disposed && (inst->latest == NULL ))
 | 
			
		||||
        inst_set_invsample (rhc, inst);
 | 
			
		||||
 | 
			
		||||
      update_inst (rhc, inst, pwr_info, true, sample->v.msginfo.timestamp);
 | 
			
		||||
      update_inst (rhc, inst, pwr_info, true, sample->timestamp);
 | 
			
		||||
 | 
			
		||||
      /* Can only add samples => only need to give special treatment
 | 
			
		||||
         to instances that were empty before.  It is, however, not
 | 
			
		||||
| 
						 | 
				
			
			@ -1326,7 +1328,7 @@ bool dds_rhc_store
 | 
			
		|||
         mean an application reading "x" after the write and reading it
 | 
			
		||||
         again after the unregister will see a change in the
 | 
			
		||||
         no_writers_generation field? */
 | 
			
		||||
      dds_rhc_unregister (&post, rhc, inst, pwr_info, sample->v.msginfo.timestamp);
 | 
			
		||||
      dds_rhc_unregister (&post, rhc, inst, pwr_info, sample->timestamp);
 | 
			
		||||
    }
 | 
			
		||||
    else
 | 
			
		||||
    {
 | 
			
		||||
| 
						 | 
				
			
			@ -1582,7 +1584,7 @@ static void set_sample_info (dds_sample_info_t *si, const struct rhc_instance *i
 | 
			
		|||
  si->generation_rank = 0; /* __/ */
 | 
			
		||||
  si->absolute_generation_rank = (inst->disposed_gen + inst->no_writers_gen) - (sample->disposed_gen + sample->no_writers_gen);
 | 
			
		||||
  si->valid_data = true;
 | 
			
		||||
  si->source_timestamp = sample->sample->v.msginfo.timestamp.v;
 | 
			
		||||
  si->source_timestamp = sample->sample->timestamp.v;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
static void set_sample_info_invsample (dds_sample_info_t *si, const struct rhc_instance *inst)
 | 
			
		||||
| 
						 | 
				
			
			@ -1626,7 +1628,12 @@ static int dds_rhc_read_w_qminv
 | 
			
		|||
{
 | 
			
		||||
  bool trigger_waitsets = false;
 | 
			
		||||
  uint32_t n = 0;
 | 
			
		||||
#if 0
 | 
			
		||||
  const struct dds_topic_descriptor * desc = (const struct dds_topic_descriptor *) rhc->topic->type;
 | 
			
		||||
#else /* FIXME: hack hack -- deserialize_into */
 | 
			
		||||
  const struct ddsi_sertopic_default *sertopic_def = (const struct ddsi_sertopic_default *)rhc->topic;
 | 
			
		||||
  const struct dds_topic_descriptor * desc = sertopic_def->type;
 | 
			
		||||
#endif
 | 
			
		||||
 | 
			
		||||
  if (lock)
 | 
			
		||||
  {
 | 
			
		||||
| 
						 | 
				
			
			@ -1664,7 +1671,7 @@ static int dds_rhc_read_w_qminv
 | 
			
		|||
              {
 | 
			
		||||
                /* sample state matches too */
 | 
			
		||||
                set_sample_info (info_seq + n, inst, sample);
 | 
			
		||||
                deserialize_into ((char*) values[n], sample->sample);
 | 
			
		||||
                ddsi_serdata_to_sample (sample->sample, values[n], 0, 0);
 | 
			
		||||
                if (cond == NULL
 | 
			
		||||
                    || (dds_entity_kind(cond->m_entity.m_hdl) != DDS_KIND_COND_QUERY)
 | 
			
		||||
                    || (cond->m_query.m_filter != NULL && cond->m_query.m_filter(values[n])))
 | 
			
		||||
| 
						 | 
				
			
			@ -1696,7 +1703,7 @@ static int dds_rhc_read_w_qminv
 | 
			
		|||
          if (inst->inv_exists && n < max_samples && (QMASK_OF_INVSAMPLE (inst) & qminv) == 0)
 | 
			
		||||
          {
 | 
			
		||||
            set_sample_info_invsample (info_seq + n, inst);
 | 
			
		||||
            deserialize_into ((char*) values[n], inst->tk->m_sample);
 | 
			
		||||
            ddsi_serdata_to_sample (inst->tk->m_sample, values[n], 0, 0);
 | 
			
		||||
            if (!inst->inv_isread)
 | 
			
		||||
            {
 | 
			
		||||
              inst->inv_isread = 1;
 | 
			
		||||
| 
						 | 
				
			
			@ -1754,7 +1761,12 @@ static int dds_rhc_take_w_qminv
 | 
			
		|||
  bool trigger_waitsets = false;
 | 
			
		||||
  uint64_t iid;
 | 
			
		||||
  uint32_t n = 0;
 | 
			
		||||
#if 0
 | 
			
		||||
  const struct dds_topic_descriptor * desc = (const struct dds_topic_descriptor *) rhc->topic->type;
 | 
			
		||||
#else /* FIXME: hack hack -- deserialize_into */
 | 
			
		||||
  const struct ddsi_sertopic_default *sertopic_def = (const struct ddsi_sertopic_default *)rhc->topic;
 | 
			
		||||
  const struct dds_topic_descriptor * desc = sertopic_def->type;
 | 
			
		||||
#endif
 | 
			
		||||
 | 
			
		||||
  if (lock)
 | 
			
		||||
  {
 | 
			
		||||
| 
						 | 
				
			
			@ -1799,7 +1811,7 @@ static int dds_rhc_take_w_qminv
 | 
			
		|||
              else
 | 
			
		||||
              {
 | 
			
		||||
                set_sample_info (info_seq + n, inst, sample);
 | 
			
		||||
                deserialize_into ((char*) values[n], sample->sample);
 | 
			
		||||
                ddsi_serdata_to_sample (sample->sample, values[n], 0, 0);
 | 
			
		||||
                if (cond == NULL
 | 
			
		||||
                    || (dds_entity_kind(cond->m_entity.m_hdl) != DDS_KIND_COND_QUERY)
 | 
			
		||||
                    || ( cond->m_query.m_filter != NULL && cond->m_query.m_filter(values[n])))
 | 
			
		||||
| 
						 | 
				
			
			@ -1843,7 +1855,7 @@ static int dds_rhc_take_w_qminv
 | 
			
		|||
          if (inst->inv_exists && n < max_samples && (QMASK_OF_INVSAMPLE (inst) & qminv) == 0)
 | 
			
		||||
          {
 | 
			
		||||
            set_sample_info_invsample (info_seq + n, inst);
 | 
			
		||||
            deserialize_into ((char*) values[n], inst->tk->m_sample);
 | 
			
		||||
            ddsi_serdata_to_sample (inst->tk->m_sample, values[n], 0, 0);
 | 
			
		||||
            inst_clear_invsample (rhc, inst);
 | 
			
		||||
            ++n;
 | 
			
		||||
          }
 | 
			
		||||
| 
						 | 
				
			
			@ -1912,7 +1924,7 @@ static int dds_rhc_take_w_qminv
 | 
			
		|||
 | 
			
		||||
static int dds_rhc_takecdr_w_qminv
 | 
			
		||||
(
 | 
			
		||||
 struct rhc *rhc, bool lock, struct serdata ** values, dds_sample_info_t *info_seq,
 | 
			
		||||
 struct rhc *rhc, bool lock, struct ddsi_serdata ** values, dds_sample_info_t *info_seq,
 | 
			
		||||
 uint32_t max_samples, unsigned qminv, dds_instance_handle_t handle, dds_readcond *cond
 | 
			
		||||
 )
 | 
			
		||||
{
 | 
			
		||||
| 
						 | 
				
			
			@ -2159,7 +2171,7 @@ static bool update_conditions_locked
 | 
			
		|||
(
 | 
			
		||||
  struct rhc *rhc, const struct trigger_info *pre,
 | 
			
		||||
  const struct trigger_info *post,
 | 
			
		||||
  const struct serdata *sample
 | 
			
		||||
  const struct ddsi_serdata *sample
 | 
			
		||||
)
 | 
			
		||||
{
 | 
			
		||||
  /* Pre: rhc->lock held; returns 1 if triggering required, else 0. */
 | 
			
		||||
| 
						 | 
				
			
			@ -2167,7 +2179,9 @@ static bool update_conditions_locked
 | 
			
		|||
  dds_readcond * iter;
 | 
			
		||||
  int m_pre;
 | 
			
		||||
  int m_post;
 | 
			
		||||
#if 0 /* FIXME: content filter, query cond */
 | 
			
		||||
  bool deserialised = (rhc->topic->filter_fn != NULL);
 | 
			
		||||
#endif
 | 
			
		||||
 | 
			
		||||
  TRACE (("update_conditions_locked(%p) - inst %u nonempty %u disp %u nowr %u new %u samples %u read %u\n",
 | 
			
		||||
          (void *) rhc, rhc->n_instances, rhc->n_nonempty_instances, rhc->n_not_alive_disposed,
 | 
			
		||||
| 
						 | 
				
			
			@ -2210,6 +2224,7 @@ static bool update_conditions_locked
 | 
			
		|||
    }
 | 
			
		||||
    else if (m_pre < m_post)
 | 
			
		||||
    {
 | 
			
		||||
#if 0 /* FIXME: content filter, query cond */
 | 
			
		||||
      if (sample && !deserialised && (dds_entity_kind(iter->m_entity.m_hdl) == DDS_KIND_COND_QUERY))
 | 
			
		||||
      {
 | 
			
		||||
        deserialize_into ((char*)rhc->topic->filter_sample, sample);
 | 
			
		||||
| 
						 | 
				
			
			@ -2229,6 +2244,18 @@ static bool update_conditions_locked
 | 
			
		|||
          trigger = true;
 | 
			
		||||
        }
 | 
			
		||||
      }
 | 
			
		||||
#else
 | 
			
		||||
      assert (dds_entity_kind(iter->m_entity.m_hdl) != DDS_KIND_COND_QUERY);
 | 
			
		||||
      if (sample == NULL)
 | 
			
		||||
      {
 | 
			
		||||
        TRACE (("now matches"));
 | 
			
		||||
        if (iter->m_entity.m_trigger++ == 0)
 | 
			
		||||
        {
 | 
			
		||||
          TRACE ((" (cond now triggers)"));
 | 
			
		||||
          trigger = true;
 | 
			
		||||
        }
 | 
			
		||||
      }
 | 
			
		||||
#endif
 | 
			
		||||
    }
 | 
			
		||||
    else
 | 
			
		||||
    {
 | 
			
		||||
| 
						 | 
				
			
			@ -2286,7 +2313,7 @@ dds_rhc_take(
 | 
			
		|||
 | 
			
		||||
int dds_rhc_takecdr
 | 
			
		||||
(
 | 
			
		||||
 struct rhc *rhc, bool lock, struct serdata ** values, dds_sample_info_t *info_seq, uint32_t max_samples,
 | 
			
		||||
 struct rhc *rhc, bool lock, struct ddsi_serdata ** values, dds_sample_info_t *info_seq, uint32_t max_samples,
 | 
			
		||||
 unsigned sample_states, unsigned view_states, unsigned instance_states, dds_instance_handle_t handle)
 | 
			
		||||
{
 | 
			
		||||
  unsigned qminv = qmask_from_dcpsquery (sample_states, view_states, instance_states);
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -147,7 +147,7 @@ size_t dds_stream_check_optimize (_In_ const dds_topic_descriptor_t * desc)
 | 
			
		|||
  void * sample = dds_alloc (desc->m_size);
 | 
			
		||||
  uint8_t * ptr1;
 | 
			
		||||
  uint8_t * ptr2;
 | 
			
		||||
  size_t size = desc->m_size;
 | 
			
		||||
  uint32_t size = desc->m_size;
 | 
			
		||||
  uint8_t val = 1;
 | 
			
		||||
 | 
			
		||||
  dds_stream_init (&os, size);
 | 
			
		||||
| 
						 | 
				
			
			@ -169,7 +169,7 @@ size_t dds_stream_check_optimize (_In_ const dds_topic_descriptor_t * desc)
 | 
			
		|||
  return size;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
dds_stream_t * dds_stream_create (size_t size)
 | 
			
		||||
dds_stream_t * dds_stream_create (uint32_t size)
 | 
			
		||||
{
 | 
			
		||||
  dds_stream_t * stream = (dds_stream_t*) dds_alloc (sizeof (*stream));
 | 
			
		||||
  dds_stream_init (stream, size);
 | 
			
		||||
| 
						 | 
				
			
			@ -190,7 +190,7 @@ void dds_stream_fini (dds_stream_t * st)
 | 
			
		|||
  }
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
void dds_stream_init (dds_stream_t * st, size_t size)
 | 
			
		||||
void dds_stream_init (dds_stream_t * st, uint32_t size)
 | 
			
		||||
{
 | 
			
		||||
  memset (st, 0, sizeof (*st));
 | 
			
		||||
  DDS_CDR_REINIT (st, size);
 | 
			
		||||
| 
						 | 
				
			
			@ -201,13 +201,13 @@ void dds_stream_reset (dds_stream_t * st)
 | 
			
		|||
  DDS_CDR_RESET (st);
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
void dds_stream_grow (dds_stream_t * st, size_t size)
 | 
			
		||||
void dds_stream_grow (dds_stream_t * st, uint32_t size)
 | 
			
		||||
{
 | 
			
		||||
  size_t needed = size + st->m_index;
 | 
			
		||||
  uint32_t needed = size + st->m_index;
 | 
			
		||||
 | 
			
		||||
  /* Reallocate on 4k boundry */
 | 
			
		||||
 | 
			
		||||
  size_t newSize = (needed & ~(size_t)0xfff) + 0x1000;
 | 
			
		||||
  uint32_t newSize = (needed & ~(uint32_t)0xfff) + 0x1000;
 | 
			
		||||
  uint8_t * old = st->m_buffer.p8;
 | 
			
		||||
 | 
			
		||||
  st->m_buffer.p8 = dds_realloc (old, newSize);
 | 
			
		||||
| 
						 | 
				
			
			@ -378,21 +378,17 @@ void dds_stream_read_buffer (dds_stream_t * is, uint8_t * buffer, uint32_t len)
 | 
			
		|||
  }
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
void dds_stream_read_sample (dds_stream_t * is, void * data, const struct sertopic * topic)
 | 
			
		||||
void dds_stream_read_sample (dds_stream_t * is, void * data, const struct ddsi_sertopic_default * topic)
 | 
			
		||||
{
 | 
			
		||||
  const struct dds_topic_descriptor * desc = (const struct dds_topic_descriptor *) topic->type;
 | 
			
		||||
 | 
			
		||||
  /* Check if can copy directly from stream buffer */
 | 
			
		||||
  if (topic->opt_size && DDS_IS_OK (is, desc->m_size) && (is->m_endian == DDS_ENDIAN))
 | 
			
		||||
  {
 | 
			
		||||
    /* Check if can copy directly from stream buffer */
 | 
			
		||||
 | 
			
		||||
    if (topic->opt_size && DDS_IS_OK (is, desc->m_size) && (is->m_endian == DDS_ENDIAN))
 | 
			
		||||
    {
 | 
			
		||||
      DDS_IS_GET_BYTES (is, data, desc->m_size);
 | 
			
		||||
    }
 | 
			
		||||
    else
 | 
			
		||||
    {
 | 
			
		||||
      dds_stream_read (is, data, desc->m_ops);
 | 
			
		||||
    }
 | 
			
		||||
    DDS_IS_GET_BYTES (is, data, desc->m_size);
 | 
			
		||||
  }
 | 
			
		||||
  else
 | 
			
		||||
  {
 | 
			
		||||
    dds_stream_read (is, data, desc->m_ops);
 | 
			
		||||
  }
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			@ -1162,7 +1158,7 @@ static void dds_stream_read (dds_stream_t * is, char * data, const uint32_t * op
 | 
			
		|||
#endif
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
void dds_stream_write_sample (dds_stream_t * os, const void * data, const struct sertopic * topic)
 | 
			
		||||
void dds_stream_write_sample (dds_stream_t * os, const void * data, const struct ddsi_sertopic_default * topic)
 | 
			
		||||
{
 | 
			
		||||
  const struct dds_topic_descriptor * desc = (const struct dds_topic_descriptor *) topic->type;
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			@ -1176,16 +1172,16 @@ void dds_stream_write_sample (dds_stream_t * os, const void * data, const struct
 | 
			
		|||
  }
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
void dds_stream_from_serstate (_Out_ dds_stream_t * s, _In_ const serstate_t st)
 | 
			
		||||
void dds_stream_from_serdata_default (_Out_ dds_stream_t * s, _In_ const struct ddsi_serdata_default *d)
 | 
			
		||||
{
 | 
			
		||||
  s->m_failed = false;
 | 
			
		||||
  s->m_buffer.p8 = (uint8_t*) st->data;
 | 
			
		||||
  s->m_size = st->size + offsetof (struct serdata, data);
 | 
			
		||||
  s->m_index = offsetof (struct serdata, data);
 | 
			
		||||
  s->m_endian = (st->data->v.bswap) ? (! DDS_ENDIAN) : DDS_ENDIAN;
 | 
			
		||||
  s->m_buffer.p8 = (uint8_t*) d;
 | 
			
		||||
  s->m_index = (uint32_t) offsetof (struct ddsi_serdata_default, data);
 | 
			
		||||
  s->m_size = d->size + s->m_index;
 | 
			
		||||
  s->m_endian = (d->bswap) ? (! DDS_ENDIAN) : DDS_ENDIAN;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
void dds_stream_add_to_serstate (_Inout_ dds_stream_t * s, _Inout_ serstate_t st)
 | 
			
		||||
void dds_stream_add_to_serdata_default (dds_stream_t * s, struct ddsi_serdata_default **d)
 | 
			
		||||
{
 | 
			
		||||
  /* DDSI requires 4 byte alignment */
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			@ -1193,18 +1189,14 @@ void dds_stream_add_to_serstate (_Inout_ dds_stream_t * s, _Inout_ serstate_t st
 | 
			
		|||
 | 
			
		||||
  /* Reset data pointer as stream may have reallocated */
 | 
			
		||||
 | 
			
		||||
  st->data = s->m_buffer.pv;
 | 
			
		||||
  st->pos += (s->m_index - offsetof (struct serdata, data));
 | 
			
		||||
  st->size = (s->m_size - offsetof(struct serdata, data));
 | 
			
		||||
  (*d) = s->m_buffer.pv;
 | 
			
		||||
  (*d)->pos = (s->m_index - (uint32_t)offsetof (struct ddsi_serdata_default, data));
 | 
			
		||||
  (*d)->size = (s->m_size - (uint32_t)offsetof(struct ddsi_serdata_default, data));
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
void dds_stream_write_key
 | 
			
		||||
(
 | 
			
		||||
  dds_stream_t * os,
 | 
			
		||||
  const char * sample,
 | 
			
		||||
  const dds_topic_descriptor_t * desc
 | 
			
		||||
)
 | 
			
		||||
void dds_stream_write_key (dds_stream_t * os, const char * sample, const struct ddsi_sertopic_default * topic)
 | 
			
		||||
{
 | 
			
		||||
  const struct dds_topic_descriptor * desc = (const struct dds_topic_descriptor *) topic->type;
 | 
			
		||||
  uint32_t i;
 | 
			
		||||
  const char * src;
 | 
			
		||||
  const uint32_t * op;
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -22,7 +22,7 @@
 | 
			
		|||
#include "util/ut_hopscotch.h"
 | 
			
		||||
#include "dds__stream.h"
 | 
			
		||||
#include "os/os.h"
 | 
			
		||||
#include "q__osplser.h"
 | 
			
		||||
#include "ddsi/ddsi_serdata.h"
 | 
			
		||||
 | 
			
		||||
#define REFC_DELETE 0x80000000
 | 
			
		||||
#define REFC_MASK   0x0fffffff
 | 
			
		||||
| 
						 | 
				
			
			@ -62,68 +62,9 @@ static void gc_tkmap_instance (struct tkmap_instance *tk)
 | 
			
		|||
  gcreq_enqueue (gcreq);
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
/* Fixed seed and length */
 | 
			
		||||
 | 
			
		||||
#define DDS_MH3_LEN 16
 | 
			
		||||
#define DDS_MH3_SEED 0
 | 
			
		||||
 | 
			
		||||
#define DDS_MH3_ROTL32(x,r) (((x) << (r)) | ((x) >> (32 - (r))))
 | 
			
		||||
 | 
			
		||||
/* Really
 | 
			
		||||
 http://code.google.com/p/smhasher/source/browse/trunk/MurmurHash3.cpp,
 | 
			
		||||
 MurmurHash3_x86_32
 | 
			
		||||
*/
 | 
			
		||||
 | 
			
		||||
static uint32_t dds_mh3 (const void * key)
 | 
			
		||||
{
 | 
			
		||||
  const uint8_t *data = (const uint8_t *) key;
 | 
			
		||||
  const intptr_t nblocks = (intptr_t) (DDS_MH3_LEN / 4);
 | 
			
		||||
  const uint32_t c1 = 0xcc9e2d51;
 | 
			
		||||
  const uint32_t c2 = 0x1b873593;
 | 
			
		||||
 | 
			
		||||
  uint32_t h1 = DDS_MH3_SEED;
 | 
			
		||||
 | 
			
		||||
  const uint32_t *blocks = (const uint32_t *) (data + nblocks * 4);
 | 
			
		||||
  register intptr_t i;
 | 
			
		||||
 | 
			
		||||
  for (i = -nblocks; i; i++)
 | 
			
		||||
  {
 | 
			
		||||
    uint32_t k1 = blocks[i];
 | 
			
		||||
 | 
			
		||||
    k1 *= c1;
 | 
			
		||||
    k1 = DDS_MH3_ROTL32 (k1, 15);
 | 
			
		||||
    k1 *= c2;
 | 
			
		||||
 | 
			
		||||
    h1 ^= k1;
 | 
			
		||||
    h1 = DDS_MH3_ROTL32 (h1, 13);
 | 
			
		||||
    h1 = h1 * 5+0xe6546b64;
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
  /* finalization */
 | 
			
		||||
 | 
			
		||||
  h1 ^= DDS_MH3_LEN;
 | 
			
		||||
  h1 ^= h1 >> 16;
 | 
			
		||||
  h1 *= 0x85ebca6b;
 | 
			
		||||
  h1 ^= h1 >> 13;
 | 
			
		||||
  h1 *= 0xc2b2ae35;
 | 
			
		||||
  h1 ^= h1 >> 16;
 | 
			
		||||
 | 
			
		||||
  return h1;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
static uint32_t dds_tk_hash (const struct tkmap_instance * inst)
 | 
			
		||||
{
 | 
			
		||||
  volatile struct serdata * sd = (volatile struct serdata *) inst->m_sample;
 | 
			
		||||
 | 
			
		||||
  if (! sd->v.hash_valid)
 | 
			
		||||
  {
 | 
			
		||||
    const uint32_t * k = (const uint32_t *) sd->v.keyhash.m_hash;
 | 
			
		||||
    const uint32_t hash0 = sd->v.st->topic ? sd->v.st->topic->hash : 0;
 | 
			
		||||
    sd->v.hash = ((sd->v.keyhash.m_flags & DDS_KEY_IS_HASH) ? dds_mh3 (k) : (*k)) ^ hash0;
 | 
			
		||||
    sd->v.hash_valid = 1;
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
  return sd->v.hash;
 | 
			
		||||
  return inst->m_sample->hash;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
static uint32_t dds_tk_hash_void (const void * inst)
 | 
			
		||||
| 
						 | 
				
			
			@ -133,7 +74,7 @@ static uint32_t dds_tk_hash_void (const void * inst)
 | 
			
		|||
 | 
			
		||||
static int dds_tk_equals (const struct tkmap_instance *a, const struct tkmap_instance *b)
 | 
			
		||||
{
 | 
			
		||||
  return serdata_cmp (a->m_sample, b->m_sample) == 0;
 | 
			
		||||
  return (a->m_sample->ops == b->m_sample->ops) ? ddsi_serdata_eqkey (a->m_sample, b->m_sample) : 0;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
static int dds_tk_equals_void (const void *a, const void *b)
 | 
			
		||||
| 
						 | 
				
			
			@ -166,11 +107,11 @@ void dds_tkmap_free (_Inout_ _Post_invalid_ struct tkmap * map)
 | 
			
		|||
  dds_free (map);
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
uint64_t dds_tkmap_lookup (_In_ struct tkmap * map, _In_ const struct serdata * sd)
 | 
			
		||||
uint64_t dds_tkmap_lookup (_In_ struct tkmap * map, _In_ const struct ddsi_serdata * sd)
 | 
			
		||||
{
 | 
			
		||||
  struct tkmap_instance dummy;
 | 
			
		||||
  struct tkmap_instance * tk;
 | 
			
		||||
  dummy.m_sample = (struct serdata *) sd;
 | 
			
		||||
  dummy.m_sample = (struct ddsi_serdata *) sd;
 | 
			
		||||
  tk = ut_chhLookup (map->m_hh, &dummy);
 | 
			
		||||
  return (tk) ? tk->m_iid : DDS_HANDLE_NIL;
 | 
			
		||||
}
 | 
			
		||||
| 
						 | 
				
			
			@ -189,7 +130,7 @@ static void dds_tkmap_get_key_fn (void * vtk, void * varg)
 | 
			
		|||
  tkmap_get_key_arg * arg = (tkmap_get_key_arg*) varg;
 | 
			
		||||
  if (tk->m_iid == arg->m_iid)
 | 
			
		||||
  {
 | 
			
		||||
    deserialize_into (arg->m_sample, tk->m_sample);
 | 
			
		||||
    ddsi_serdata_to_sample (tk->m_sample, arg->m_sample, 0, 0);
 | 
			
		||||
    arg->m_ret = true;
 | 
			
		||||
  }
 | 
			
		||||
}
 | 
			
		||||
| 
						 | 
				
			
			@ -243,7 +184,7 @@ struct tkmap_instance * dds_tkmap_find_by_id (_In_ struct tkmap * map, _In_ uint
 | 
			
		|||
 | 
			
		||||
_Check_return_
 | 
			
		||||
struct tkmap_instance * dds_tkmap_find(
 | 
			
		||||
        _In_ struct serdata * sd,
 | 
			
		||||
        _In_ struct ddsi_serdata * sd,
 | 
			
		||||
        _In_ const bool rd,
 | 
			
		||||
        _In_ const bool create)
 | 
			
		||||
{
 | 
			
		||||
| 
						 | 
				
			
			@ -251,7 +192,10 @@ struct tkmap_instance * dds_tkmap_find(
 | 
			
		|||
  struct tkmap_instance * tk;
 | 
			
		||||
  struct tkmap * map = gv.m_tkmap;
 | 
			
		||||
 | 
			
		||||
  /* FIXME: check this */
 | 
			
		||||
#if 0
 | 
			
		||||
  assert(sd->v.keyhash.m_flags & DDS_KEY_HASH_SET);
 | 
			
		||||
#endif
 | 
			
		||||
  dummy.m_sample = sd;
 | 
			
		||||
 | 
			
		||||
retry:
 | 
			
		||||
| 
						 | 
				
			
			@ -300,7 +244,7 @@ retry:
 | 
			
		|||
}
 | 
			
		||||
 | 
			
		||||
_Check_return_
 | 
			
		||||
struct tkmap_instance * dds_tkmap_lookup_instance_ref (_In_ struct serdata * sd)
 | 
			
		||||
struct tkmap_instance * dds_tkmap_lookup_instance_ref (_In_ struct ddsi_serdata * sd)
 | 
			
		||||
{
 | 
			
		||||
  assert (vtime_awake_p (lookup_thread_state ()->vtime));
 | 
			
		||||
#if 0
 | 
			
		||||
| 
						 | 
				
			
			@ -337,7 +281,9 @@ void dds_tkmap_instance_unref (_In_ struct tkmap_instance * tk)
 | 
			
		|||
    struct tkmap *map = tk->m_map;
 | 
			
		||||
 | 
			
		||||
    /* Remove from hash table */
 | 
			
		||||
    (void)ut_chhRemove(map->m_hh, tk);
 | 
			
		||||
    int removed = ut_chhRemove(map->m_hh, tk);
 | 
			
		||||
    assert (removed);
 | 
			
		||||
    (void)removed;
 | 
			
		||||
 | 
			
		||||
    /* Signal any threads blocked in their retry loops in lookup */
 | 
			
		||||
    os_mutexLock(&map->m_lock);
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -21,19 +21,19 @@
 | 
			
		|||
#include "dds__err.h"
 | 
			
		||||
#include "ddsi/q_entity.h"
 | 
			
		||||
#include "ddsi/q_thread.h"
 | 
			
		||||
#include "q__osplser.h"
 | 
			
		||||
#include "ddsi/ddsi_sertopic.h"
 | 
			
		||||
#include "ddsi/q_ddsi_discovery.h"
 | 
			
		||||
#include "os/os_atomics.h"
 | 
			
		||||
#include "dds__report.h"
 | 
			
		||||
 | 
			
		||||
#include "dds__iid.h"
 | 
			
		||||
 | 
			
		||||
#define DDS_TOPIC_STATUS_MASK                                    \
 | 
			
		||||
                        DDS_INCONSISTENT_TOPIC_STATUS
 | 
			
		||||
 | 
			
		||||
const ut_avlTreedef_t dds_topictree_def = UT_AVL_TREEDEF_INITIALIZER_INDKEY
 | 
			
		||||
(
 | 
			
		||||
  offsetof (struct sertopic, avlnode),
 | 
			
		||||
  offsetof (struct sertopic, name_typename),
 | 
			
		||||
  offsetof (struct ddsi_sertopic, avlnode),
 | 
			
		||||
  offsetof (struct ddsi_sertopic, name_typename),
 | 
			
		||||
  (int (*) (const void *, const void *)) strcmp,
 | 
			
		||||
  0
 | 
			
		||||
);
 | 
			
		||||
| 
						 | 
				
			
			@ -151,12 +151,12 @@ dds_topic_status_cb(
 | 
			
		|||
    DDS_REPORT_FLUSH(rc != DDS_RETCODE_OK);
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
sertopic_t
 | 
			
		||||
struct ddsi_sertopic *
 | 
			
		||||
dds_topic_lookup_locked(
 | 
			
		||||
        dds_domain *domain,
 | 
			
		||||
        const char *name)
 | 
			
		||||
{
 | 
			
		||||
    sertopic_t st = NULL;
 | 
			
		||||
    struct ddsi_sertopic *st = NULL;
 | 
			
		||||
    ut_avlIter_t iter;
 | 
			
		||||
 | 
			
		||||
    assert (domain);
 | 
			
		||||
| 
						 | 
				
			
			@ -172,12 +172,12 @@ dds_topic_lookup_locked(
 | 
			
		|||
    return st;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
sertopic_t
 | 
			
		||||
struct ddsi_sertopic *
 | 
			
		||||
dds_topic_lookup(
 | 
			
		||||
        dds_domain *domain,
 | 
			
		||||
        const char *name)
 | 
			
		||||
{
 | 
			
		||||
    sertopic_t st;
 | 
			
		||||
    struct ddsi_sertopic *st;
 | 
			
		||||
    os_mutexLock (&dds_global.m_mutex);
 | 
			
		||||
    st = dds_topic_lookup_locked(domain, name);
 | 
			
		||||
    os_mutexUnlock (&dds_global.m_mutex);
 | 
			
		||||
| 
						 | 
				
			
			@ -187,7 +187,7 @@ dds_topic_lookup(
 | 
			
		|||
void
 | 
			
		||||
dds_topic_free(
 | 
			
		||||
        dds_domainid_t domainid,
 | 
			
		||||
        struct sertopic *st)
 | 
			
		||||
        struct ddsi_sertopic *st)
 | 
			
		||||
{
 | 
			
		||||
    dds_domain *domain;
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			@ -200,13 +200,13 @@ dds_topic_free(
 | 
			
		|||
    }
 | 
			
		||||
    os_mutexUnlock (&dds_global.m_mutex);
 | 
			
		||||
    st->status_cb_entity = NULL;
 | 
			
		||||
    sertopic_free (st);
 | 
			
		||||
    ddsi_sertopic_unref (st);
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
static void
 | 
			
		||||
dds_topic_add_locked(
 | 
			
		||||
        dds_domainid_t id,
 | 
			
		||||
        sertopic_t st)
 | 
			
		||||
        struct ddsi_sertopic *st)
 | 
			
		||||
{
 | 
			
		||||
    dds_domain * dom;
 | 
			
		||||
    dom = dds_domain_find_locked (id);
 | 
			
		||||
| 
						 | 
				
			
			@ -222,7 +222,7 @@ dds_find_topic(
 | 
			
		|||
{
 | 
			
		||||
    dds_entity_t tp;
 | 
			
		||||
    dds_entity *p = NULL;
 | 
			
		||||
    sertopic_t st;
 | 
			
		||||
    struct ddsi_sertopic *st;
 | 
			
		||||
    dds__retcode_t rc;
 | 
			
		||||
 | 
			
		||||
    DDS_REPORT_STACK();
 | 
			
		||||
| 
						 | 
				
			
			@ -307,7 +307,7 @@ dds_topic_qos_set(
 | 
			
		|||
    return ret;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
static bool dupdef_qos_ok(const dds_qos_t *qos, const struct sertopic *st)
 | 
			
		||||
static bool dupdef_qos_ok(const dds_qos_t *qos, const struct ddsi_sertopic *st)
 | 
			
		||||
{
 | 
			
		||||
    if ((qos == NULL) != (st->status_cb_entity->m_entity.m_qos == NULL)) {
 | 
			
		||||
        return false;
 | 
			
		||||
| 
						 | 
				
			
			@ -327,10 +327,9 @@ dds_create_topic(
 | 
			
		|||
        _In_opt_ const dds_qos_t *qos,
 | 
			
		||||
        _In_opt_ const dds_listener_t *listener)
 | 
			
		||||
{
 | 
			
		||||
    static uint32_t next_topicid = 0;
 | 
			
		||||
 | 
			
		||||
    char *key = NULL;
 | 
			
		||||
    sertopic_t st;
 | 
			
		||||
    struct ddsi_sertopic *stgeneric;
 | 
			
		||||
    struct ddsi_sertopic_default *st;
 | 
			
		||||
    const char *typename;
 | 
			
		||||
    dds__retcode_t rc;
 | 
			
		||||
    dds_entity *par;
 | 
			
		||||
| 
						 | 
				
			
			@ -378,16 +377,17 @@ dds_create_topic(
 | 
			
		|||
 | 
			
		||||
    /* Check if topic already exists with same name */
 | 
			
		||||
    os_mutexLock (&dds_global.m_mutex);
 | 
			
		||||
    if ((st = dds_topic_lookup_locked (par->m_domain, name)) != NULL) {
 | 
			
		||||
    if ((stgeneric = dds_topic_lookup_locked (par->m_domain, name)) != NULL) {
 | 
			
		||||
        st = (struct ddsi_sertopic_default *)stgeneric;
 | 
			
		||||
        if (st->type != desc) {
 | 
			
		||||
            /* FIXME: should copy the type, perhaps? but then the pointers will no longer be the same */
 | 
			
		||||
            hdl = DDS_ERRNO(DDS_RETCODE_PRECONDITION_NOT_MET, "Create topic with mismatching type.");
 | 
			
		||||
        } else if (!dupdef_qos_ok(qos, st)) {
 | 
			
		||||
        } else if (!dupdef_qos_ok(qos, stgeneric)) {
 | 
			
		||||
            /* FIXME: should copy the type, perhaps? but then the pointers will no longer be the same */
 | 
			
		||||
            hdl = DDS_ERRNO(DDS_RETCODE_INCONSISTENT_POLICY, "Create topic with mismatching qos.");
 | 
			
		||||
        } else {
 | 
			
		||||
            dds_entity_add_ref (&st->status_cb_entity->m_entity);
 | 
			
		||||
            hdl = st->status_cb_entity->m_entity.m_hdl;
 | 
			
		||||
            dds_entity_add_ref (&st->c.status_cb_entity->m_entity);
 | 
			
		||||
            hdl = st->c.status_cb_entity->m_entity.m_hdl;
 | 
			
		||||
        }
 | 
			
		||||
        os_mutexUnlock (&dds_global.m_mutex);
 | 
			
		||||
    } else {
 | 
			
		||||
| 
						 | 
				
			
			@ -413,34 +413,33 @@ dds_create_topic(
 | 
			
		|||
        top->m_entity.m_deriver.validate_status = dds_topic_status_validate;
 | 
			
		||||
 | 
			
		||||
        st = dds_alloc (sizeof (*st));
 | 
			
		||||
 | 
			
		||||
        os_atomic_st32 (&st->c.refc, 1);
 | 
			
		||||
        st->c.iid = dds_iid_gen ();
 | 
			
		||||
        st->c.status_cb = dds_topic_status_cb;
 | 
			
		||||
        st->c.status_cb_entity = top;
 | 
			
		||||
        st->c.name_typename = key;
 | 
			
		||||
        st->c.name = dds_alloc (strlen (name) + 1);
 | 
			
		||||
        strcpy (st->c.name, name);
 | 
			
		||||
        st->c.typename = dds_alloc (strlen (typename) + 1);
 | 
			
		||||
        strcpy (st->c.typename, typename);
 | 
			
		||||
        st->c.ops = &ddsi_sertopic_ops_default;
 | 
			
		||||
        st->c.serdata_ops = &ddsi_serdata_ops_cdr;
 | 
			
		||||
        st->native_encoding_identifier = (PLATFORM_IS_LITTLE_ENDIAN ? CDR_LE : CDR_BE);
 | 
			
		||||
 | 
			
		||||
        st->type = (void*) desc;
 | 
			
		||||
        os_atomic_st32 (&st->refcount, 1);
 | 
			
		||||
        st->status_cb = dds_topic_status_cb;
 | 
			
		||||
        st->status_cb_entity = top;
 | 
			
		||||
        st->name_typename = key;
 | 
			
		||||
        st->name = dds_alloc (strlen (name) + 1);
 | 
			
		||||
        strcpy (st->name, name);
 | 
			
		||||
        st->typename = dds_alloc (strlen (typename) + 1);
 | 
			
		||||
        strcpy (st->typename, typename);
 | 
			
		||||
        st->nkeys = desc->m_nkeys;
 | 
			
		||||
        st->keys = desc->m_keys;
 | 
			
		||||
        st->id = next_topicid++;
 | 
			
		||||
 | 
			
		||||
#ifdef VXWORKS_RTP
 | 
			
		||||
        st->hash = (uint32_t)((st->id * UINT64_C (12844332200329132887UL)) >> 32);
 | 
			
		||||
#else
 | 
			
		||||
        st->hash = (uint32_t)((st->id * UINT64_C (12844332200329132887)) >> 32);
 | 
			
		||||
#endif
 | 
			
		||||
 | 
			
		||||
        /* Check if topic cannot be optimised (memcpy marshal) */
 | 
			
		||||
 | 
			
		||||
        if ((desc->m_flagset & DDS_TOPIC_NO_OPTIMIZE) == 0) {
 | 
			
		||||
            st->opt_size = dds_stream_check_optimize (desc);
 | 
			
		||||
        }
 | 
			
		||||
        top->m_stopic = st;
 | 
			
		||||
        top->m_stopic = &st->c;
 | 
			
		||||
 | 
			
		||||
        /* Add topic to extent */
 | 
			
		||||
        dds_topic_add_locked (par->m_domainid, st);
 | 
			
		||||
        dds_topic_add_locked (par->m_domainid, &st->c);
 | 
			
		||||
        os_mutexUnlock (&dds_global.m_mutex);
 | 
			
		||||
 | 
			
		||||
        nn_plist_init_empty (&plist);
 | 
			
		||||
| 
						 | 
				
			
			@ -449,8 +448,8 @@ dds_create_topic(
 | 
			
		|||
        }
 | 
			
		||||
 | 
			
		||||
        /* Set Topic meta data (for SEDP publication) */
 | 
			
		||||
        plist.qos.topic_name = dds_string_dup (st->name);
 | 
			
		||||
        plist.qos.type_name = dds_string_dup (st->typename);
 | 
			
		||||
        plist.qos.topic_name = dds_string_dup (st->c.name);
 | 
			
		||||
        plist.qos.type_name = dds_string_dup (st->c.typename);
 | 
			
		||||
        plist.qos.present |= (QP_TOPIC_NAME | QP_TYPE_NAME);
 | 
			
		||||
        if (desc->m_meta) {
 | 
			
		||||
            plist.type_description = dds_string_dup (desc->m_meta);
 | 
			
		||||
| 
						 | 
				
			
			@ -503,6 +502,7 @@ dds_topic_mod_filter(
 | 
			
		|||
        void **ctx,
 | 
			
		||||
        bool set)
 | 
			
		||||
{
 | 
			
		||||
#if 0 /* FIXME: content filter */
 | 
			
		||||
    dds_topic *t;
 | 
			
		||||
    if (dds_topic_lock(topic, &t) == DDS_RETCODE_OK) {
 | 
			
		||||
        if (set) {
 | 
			
		||||
| 
						 | 
				
			
			@ -523,6 +523,7 @@ dds_topic_mod_filter(
 | 
			
		|||
        *filter = 0;
 | 
			
		||||
        *ctx = NULL;
 | 
			
		||||
    }
 | 
			
		||||
#endif
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
_Pre_satisfies_((topic & DDS_ENTITY_KIND_MASK) == DDS_KIND_TOPIC)
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -14,10 +14,9 @@
 | 
			
		|||
#include <string.h>
 | 
			
		||||
 | 
			
		||||
#include "os/os.h"
 | 
			
		||||
#include "ddsi/ddsi_ser.h"
 | 
			
		||||
#include "ddsi/ddsi_serdata.h"
 | 
			
		||||
#include "ddsi/q_unused.h"
 | 
			
		||||
#include "ddsi/q_config.h"
 | 
			
		||||
#include "q__osplser.h"
 | 
			
		||||
#include "dds__whc.h"
 | 
			
		||||
#include "dds__tkmap.h"
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			@ -42,7 +41,7 @@ struct whc_node {
 | 
			
		|||
  unsigned borrowed: 1; /* at most one can borrow it at any time */
 | 
			
		||||
  nn_mtime_t last_rexmit_ts;
 | 
			
		||||
  unsigned rexmit_count;
 | 
			
		||||
  struct serdata *serdata;
 | 
			
		||||
  struct ddsi_serdata *serdata;
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
struct whc_intvnode {
 | 
			
		||||
| 
						 | 
				
			
			@ -143,10 +142,10 @@ static void get_state_locked(const struct whc_impl *whc, struct whc_state *st);
 | 
			
		|||
static unsigned whc_remove_acked_messages (struct whc *whc, seqno_t max_drop_seq, struct whc_state *whcst, struct whc_node **deferred_free_list);
 | 
			
		||||
static void whc_free_deferred_free_list (struct whc *whc, struct whc_node *deferred_free_list);
 | 
			
		||||
static void whc_get_state(const struct whc *whc, struct whc_state *st);
 | 
			
		||||
static int whc_insert (struct whc *whc, seqno_t max_drop_seq, seqno_t seq, struct nn_plist *plist, serdata_t serdata, struct tkmap_instance *tk);
 | 
			
		||||
static int whc_insert (struct whc *whc, seqno_t max_drop_seq, seqno_t seq, struct nn_plist *plist, struct ddsi_serdata *serdata, struct tkmap_instance *tk);
 | 
			
		||||
static seqno_t whc_next_seq (const struct whc *whc, seqno_t seq);
 | 
			
		||||
static bool whc_borrow_sample (const struct whc *whc, seqno_t seq, struct whc_borrowed_sample *sample);
 | 
			
		||||
static bool whc_borrow_sample_key (const struct whc *whc, const struct serdata *serdata_key, struct whc_borrowed_sample *sample);
 | 
			
		||||
static bool whc_borrow_sample_key (const struct whc *whc, const struct ddsi_serdata *serdata_key, struct whc_borrowed_sample *sample);
 | 
			
		||||
static void whc_return_sample (struct whc *whc, struct whc_borrowed_sample *sample, bool update_retransmit_info);
 | 
			
		||||
static unsigned whc_downgrade_to_volatile (struct whc *whc, struct whc_state *st);
 | 
			
		||||
static void whc_sample_iter_init (const struct whc *whc, struct whc_sample_iter *opaque_it);
 | 
			
		||||
| 
						 | 
				
			
			@ -331,7 +330,7 @@ static struct whc_node *whc_findseq (const struct whc_impl *whc, seqno_t seq)
 | 
			
		|||
#endif
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
static struct whc_node *whc_findkey (const struct whc_impl *whc, const struct serdata *serdata_key)
 | 
			
		||||
static struct whc_node *whc_findkey (const struct whc_impl *whc, const struct ddsi_serdata *serdata_key)
 | 
			
		||||
{
 | 
			
		||||
  union {
 | 
			
		||||
    struct whc_idxnode idxn;
 | 
			
		||||
| 
						 | 
				
			
			@ -1035,7 +1034,7 @@ static unsigned whc_remove_acked_messages (struct whc *whc_generic, seqno_t max_
 | 
			
		|||
  return cnt;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
static struct whc_node *whc_insert_seq (struct whc_impl *whc, seqno_t max_drop_seq, seqno_t seq, struct nn_plist *plist, serdata_t serdata)
 | 
			
		||||
static struct whc_node *whc_insert_seq (struct whc_impl *whc, seqno_t max_drop_seq, seqno_t seq, struct nn_plist *plist, struct ddsi_serdata *serdata)
 | 
			
		||||
{
 | 
			
		||||
  struct whc_node *newn = NULL;
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			@ -1096,7 +1095,7 @@ static struct whc_node *whc_insert_seq (struct whc_impl *whc, seqno_t max_drop_s
 | 
			
		|||
  return newn;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
static int whc_insert (struct whc *whc_generic, seqno_t max_drop_seq, seqno_t seq, struct nn_plist *plist, serdata_t serdata, struct tkmap_instance *tk)
 | 
			
		||||
static int whc_insert (struct whc *whc_generic, seqno_t max_drop_seq, seqno_t seq, struct nn_plist *plist, struct ddsi_serdata *serdata, struct tkmap_instance *tk)
 | 
			
		||||
{
 | 
			
		||||
  struct whc_impl * const whc = (struct whc_impl *)whc_generic;
 | 
			
		||||
  struct whc_node *newn = NULL;
 | 
			
		||||
| 
						 | 
				
			
			@ -1113,7 +1112,7 @@ static int whc_insert (struct whc *whc_generic, seqno_t max_drop_seq, seqno_t se
 | 
			
		|||
  {
 | 
			
		||||
    struct whc_state whcst;
 | 
			
		||||
    get_state_locked(whc, &whcst);
 | 
			
		||||
    TRACE_WHC(("whc_insert(%p max_drop_seq %"PRId64" seq %"PRId64" plist %p serdata %p:%x)\n", (void *)whc, max_drop_seq, seq, (void*)plist, (void*)serdata, *(unsigned *)serdata->v.keyhash.m_hash));
 | 
			
		||||
    TRACE_WHC(("whc_insert(%p max_drop_seq %"PRId64" seq %"PRId64" plist %p serdata %p:%"PRIx32")\n", (void *)whc, max_drop_seq, seq, (void*)plist, (void*)serdata, serdata->hash));
 | 
			
		||||
    TRACE_WHC(("  whc: [%"PRId64",%"PRId64"] max_drop_seq %"PRId64" h %u tl %u\n",
 | 
			
		||||
               whcst.min_seq, whcst.max_seq, whc->max_drop_seq, whc->hdepth, whc->tldepth));
 | 
			
		||||
  }
 | 
			
		||||
| 
						 | 
				
			
			@ -1132,7 +1131,7 @@ static int whc_insert (struct whc *whc_generic, seqno_t max_drop_seq, seqno_t se
 | 
			
		|||
  TRACE_WHC(("  whcn %p:", (void*)newn));
 | 
			
		||||
 | 
			
		||||
  /* Special case of empty data (such as commit messages) can't go into index, and if we're not maintaining an index, we're done, too */
 | 
			
		||||
  if (ddsi_serdata_is_empty(serdata) || whc->idxdepth == 0)
 | 
			
		||||
  if (serdata->kind == SDK_EMPTY || whc->idxdepth == 0)
 | 
			
		||||
  {
 | 
			
		||||
    TRACE_WHC((" empty or no hist\n"));
 | 
			
		||||
    os_mutexUnlock (&whc->lock);
 | 
			
		||||
| 
						 | 
				
			
			@ -1144,7 +1143,7 @@ static int whc_insert (struct whc *whc_generic, seqno_t max_drop_seq, seqno_t se
 | 
			
		|||
  {
 | 
			
		||||
    /* Unregisters cause deleting of index entry, non-unregister of adding/overwriting in history */
 | 
			
		||||
    TRACE_WHC((" idxn %p", (void *)idxn));
 | 
			
		||||
    if (serdata->v.msginfo.statusinfo & NN_STATUSINFO_UNREGISTER)
 | 
			
		||||
    if (serdata->statusinfo & NN_STATUSINFO_UNREGISTER)
 | 
			
		||||
    {
 | 
			
		||||
      TRACE_WHC((" unreg:delete\n"));
 | 
			
		||||
      delete_one_instance_from_idx (whc, max_drop_seq, idxn);
 | 
			
		||||
| 
						 | 
				
			
			@ -1200,7 +1199,7 @@ static int whc_insert (struct whc *whc_generic, seqno_t max_drop_seq, seqno_t se
 | 
			
		|||
  {
 | 
			
		||||
    TRACE_WHC((" newkey"));
 | 
			
		||||
    /* Ignore unregisters, but insert everything else */
 | 
			
		||||
    if (!(serdata->v.msginfo.statusinfo & NN_STATUSINFO_UNREGISTER))
 | 
			
		||||
    if (!(serdata->statusinfo & NN_STATUSINFO_UNREGISTER))
 | 
			
		||||
    {
 | 
			
		||||
      unsigned i;
 | 
			
		||||
      idxn = os_malloc (sizeof (*idxn) + whc->idxdepth * sizeof (idxn->hist[0]));
 | 
			
		||||
| 
						 | 
				
			
			@ -1264,7 +1263,7 @@ static bool whc_borrow_sample (const struct whc *whc_generic, seqno_t seq, struc
 | 
			
		|||
  return found;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
static bool whc_borrow_sample_key (const struct whc *whc_generic, const struct serdata *serdata_key, struct whc_borrowed_sample *sample)
 | 
			
		||||
static bool whc_borrow_sample_key (const struct whc *whc_generic, const struct ddsi_serdata *serdata_key, struct whc_borrowed_sample *sample)
 | 
			
		||||
{
 | 
			
		||||
  const struct whc_impl * const whc = (const struct whc_impl *)whc_generic;
 | 
			
		||||
  struct whc_node *whcn;
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -15,7 +15,8 @@
 | 
			
		|||
#include "dds__tkmap.h"
 | 
			
		||||
#include "ddsi/q_error.h"
 | 
			
		||||
#include "ddsi/q_thread.h"
 | 
			
		||||
#include "q__osplser.h"
 | 
			
		||||
#include "ddsi/q_xmsg.h"
 | 
			
		||||
#include "ddsi/ddsi_serdata.h"
 | 
			
		||||
#include "dds__stream.h"
 | 
			
		||||
#include "dds__err.h"
 | 
			
		||||
#include "ddsi/q_transmit.h"
 | 
			
		||||
| 
						 | 
				
			
			@ -57,7 +58,7 @@ _Pre_satisfies_((writer & DDS_ENTITY_KIND_MASK) == DDS_KIND_WRITER)
 | 
			
		|||
int
 | 
			
		||||
dds_writecdr(
 | 
			
		||||
        dds_entity_t writer,
 | 
			
		||||
        struct serdata *serdata)
 | 
			
		||||
        struct ddsi_serdata *serdata)
 | 
			
		||||
{
 | 
			
		||||
    dds_return_t ret;
 | 
			
		||||
    dds__retcode_t rc;
 | 
			
		||||
| 
						 | 
				
			
			@ -112,7 +113,7 @@ err:
 | 
			
		|||
static int
 | 
			
		||||
deliver_locally(
 | 
			
		||||
        _In_ struct writer *wr,
 | 
			
		||||
        _In_ serdata_t payload,
 | 
			
		||||
        _In_ struct ddsi_serdata *payload,
 | 
			
		||||
        _In_ struct tkmap_instance *tk)
 | 
			
		||||
{
 | 
			
		||||
    dds_return_t ret = DDS_RETCODE_OK;
 | 
			
		||||
| 
						 | 
				
			
			@ -191,34 +192,32 @@ dds_write_impl(
 | 
			
		|||
    dds_writer * writer = (dds_writer*) wr;
 | 
			
		||||
    struct writer * ddsi_wr = writer->m_wr;
 | 
			
		||||
    struct tkmap_instance * tk;
 | 
			
		||||
    serdata_t d;
 | 
			
		||||
    struct ddsi_serdata *d;
 | 
			
		||||
 | 
			
		||||
    if (data == NULL) {
 | 
			
		||||
        return DDS_ERRNO(DDS_RETCODE_BAD_PARAMETER, "No data buffer provided");
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
#if 0 /* FIXME: content filter */
 | 
			
		||||
    /* Check for topic filter */
 | 
			
		||||
    if (ddsi_wr->topic->filter_fn && ! writekey) {
 | 
			
		||||
        if (!(ddsi_wr->topic->filter_fn) (data, ddsi_wr->topic->filter_ctx)) {
 | 
			
		||||
            goto filtered;
 | 
			
		||||
            return DDS_RECTODE_OK;
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
#endif
 | 
			
		||||
 | 
			
		||||
    if (asleep) {
 | 
			
		||||
        thread_state_awake (thr);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    /* Serialize and write data or key */
 | 
			
		||||
    if (writekey) {
 | 
			
		||||
        d = serialize_key (ddsi_wr->topic, data);
 | 
			
		||||
    } else {
 | 
			
		||||
        d = serialize (ddsi_wr->topic, data);
 | 
			
		||||
    }
 | 
			
		||||
    d = ddsi_serdata_from_sample (ddsi_wr->topic, writekey ? SDK_KEY : SDK_DATA, data);
 | 
			
		||||
 | 
			
		||||
    /* Set if disposing or unregistering */
 | 
			
		||||
    d->v.msginfo.statusinfo = ((action & DDS_WR_DISPOSE_BIT   ) ? NN_STATUSINFO_DISPOSE    : 0) |
 | 
			
		||||
                              ((action & DDS_WR_UNREGISTER_BIT) ? NN_STATUSINFO_UNREGISTER : 0) ;
 | 
			
		||||
    d->v.msginfo.timestamp.v = tstamp;
 | 
			
		||||
    d->statusinfo = ((action & DDS_WR_DISPOSE_BIT   ) ? NN_STATUSINFO_DISPOSE    : 0) |
 | 
			
		||||
                    ((action & DDS_WR_UNREGISTER_BIT) ? NN_STATUSINFO_UNREGISTER : 0) ;
 | 
			
		||||
    d->timestamp.v = tstamp;
 | 
			
		||||
    ddsi_serdata_ref(d);
 | 
			
		||||
    tk = (ddsi_plugin.rhc_plugin.rhc_lookup_fn) (d);
 | 
			
		||||
    w_rc = write_sample_gc (writer->m_xp, ddsi_wr, d, tk);
 | 
			
		||||
| 
						 | 
				
			
			@ -246,14 +245,13 @@ dds_write_impl(
 | 
			
		|||
        thread_state_asleep (thr);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
filtered:
 | 
			
		||||
    return ret;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
int
 | 
			
		||||
dds_writecdr_impl(
 | 
			
		||||
    _In_ dds_writer *wr,
 | 
			
		||||
    _Inout_ serdata_t d,
 | 
			
		||||
    _Inout_ struct ddsi_serdata *d,
 | 
			
		||||
    _In_ dds_time_t tstamp,
 | 
			
		||||
    _In_ dds_write_action action)
 | 
			
		||||
{
 | 
			
		||||
| 
						 | 
				
			
			@ -264,24 +262,25 @@ dds_writecdr_impl(
 | 
			
		|||
 | 
			
		||||
    struct thread_state1 * const thr = lookup_thread_state ();
 | 
			
		||||
    const bool asleep = !vtime_awake_p (thr->vtime);
 | 
			
		||||
    const bool writekey = action & DDS_WR_KEY_BIT;
 | 
			
		||||
    struct writer * ddsi_wr = wr->m_wr;
 | 
			
		||||
    struct tkmap_instance * tk;
 | 
			
		||||
 | 
			
		||||
#if 0 /* FIXME: content filter */
 | 
			
		||||
    /* Check for topic filter */
 | 
			
		||||
    if (ddsi_wr->topic->filter_fn && ! writekey) {
 | 
			
		||||
        abort();
 | 
			
		||||
    }
 | 
			
		||||
#endif
 | 
			
		||||
 | 
			
		||||
    if (asleep) {
 | 
			
		||||
        thread_state_awake (thr);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    /* Set if disposing or unregistering */
 | 
			
		||||
    d->v.msginfo.statusinfo =
 | 
			
		||||
    d->statusinfo =
 | 
			
		||||
        ((action & DDS_WR_DISPOSE_BIT   ) ? NN_STATUSINFO_DISPOSE    : 0) |
 | 
			
		||||
        ((action & DDS_WR_UNREGISTER_BIT) ? NN_STATUSINFO_UNREGISTER : 0) ;
 | 
			
		||||
    d->v.msginfo.timestamp.v = tstamp;
 | 
			
		||||
    d->timestamp.v = tstamp;
 | 
			
		||||
    ddsi_serdata_ref(d);
 | 
			
		||||
    tk = (ddsi_plugin.rhc_plugin.rhc_lookup_fn) (d);
 | 
			
		||||
    w_rc = write_sample_gc (wr->m_xp, ddsi_wr, d, tk);
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -14,7 +14,7 @@
 | 
			
		|||
#include "ddsi/q_config.h"
 | 
			
		||||
#include "ddsi/q_entity.h"
 | 
			
		||||
#include "ddsi/q_thread.h"
 | 
			
		||||
#include "q__osplser.h"
 | 
			
		||||
#include "ddsi/q_xmsg.h"
 | 
			
		||||
#include "dds__writer.h"
 | 
			
		||||
#include "dds__listener.h"
 | 
			
		||||
#include "dds__qos.h"
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -1,39 +0,0 @@
 | 
			
		|||
/*
 | 
			
		||||
 * Copyright(c) 2006 to 2018 ADLINK Technology Limited and others
 | 
			
		||||
 *
 | 
			
		||||
 * This program and the accompanying materials are made available under the
 | 
			
		||||
 * terms of the Eclipse Public License v. 2.0 which is available at
 | 
			
		||||
 * http://www.eclipse.org/legal/epl-2.0, or the Eclipse Distribution License
 | 
			
		||||
 * v. 1.0 which is available at
 | 
			
		||||
 * http://www.eclipse.org/org/documents/edl-v10.php.
 | 
			
		||||
 *
 | 
			
		||||
 * SPDX-License-Identifier: EPL-2.0 OR BSD-3-Clause
 | 
			
		||||
 */
 | 
			
		||||
#ifndef DDS_OSPLSER_H
 | 
			
		||||
#define DDS_OSPLSER_H
 | 
			
		||||
 | 
			
		||||
#include "ddsi/ddsi_ser.h"
 | 
			
		||||
#include "ddsi/q_xmsg.h"
 | 
			
		||||
 | 
			
		||||
#if defined (__cplusplus)
 | 
			
		||||
extern "C" {
 | 
			
		||||
#endif
 | 
			
		||||
 | 
			
		||||
int serdata_cmp (const struct serdata * a, const struct serdata * b);
 | 
			
		||||
uint32_t serdata_hash (const struct serdata *a);
 | 
			
		||||
 | 
			
		||||
serdata_t serialize (const struct sertopic * tp, const void * sample);
 | 
			
		||||
serdata_t serialize_key (const struct sertopic * tp, const void * sample);
 | 
			
		||||
 | 
			
		||||
void deserialize_into (void *sample, const struct serdata *serdata);
 | 
			
		||||
void free_deserialized (const struct serdata *serdata, void *vx);
 | 
			
		||||
 | 
			
		||||
void sertopic_free (struct sertopic * tp);
 | 
			
		||||
void serstate_set_key (serstate_t st, int justkey, const void *key);
 | 
			
		||||
void serstate_init (serstate_t st, const struct sertopic * topic);
 | 
			
		||||
void serstate_free (serstate_t st);
 | 
			
		||||
 | 
			
		||||
#if defined (__cplusplus)
 | 
			
		||||
}
 | 
			
		||||
#endif
 | 
			
		||||
#endif
 | 
			
		||||
| 
						 | 
				
			
			@ -1,142 +0,0 @@
 | 
			
		|||
/*
 | 
			
		||||
 * Copyright(c) 2006 to 2018 ADLINK Technology Limited and others
 | 
			
		||||
 *
 | 
			
		||||
 * This program and the accompanying materials are made available under the
 | 
			
		||||
 * terms of the Eclipse Public License v. 2.0 which is available at
 | 
			
		||||
 * http://www.eclipse.org/legal/epl-2.0, or the Eclipse Distribution License
 | 
			
		||||
 * v. 1.0 which is available at
 | 
			
		||||
 * http://www.eclipse.org/org/documents/edl-v10.php.
 | 
			
		||||
 *
 | 
			
		||||
 * SPDX-License-Identifier: EPL-2.0 OR BSD-3-Clause
 | 
			
		||||
 */
 | 
			
		||||
#include <assert.h>
 | 
			
		||||
#include <string.h>
 | 
			
		||||
#include "os/os.h"
 | 
			
		||||
#include "dds__key.h"
 | 
			
		||||
#include "dds__tkmap.h"
 | 
			
		||||
#include "dds__stream.h"
 | 
			
		||||
#include "ddsi/q_bswap.h"
 | 
			
		||||
#include "q__osplser.h"
 | 
			
		||||
 | 
			
		||||
serdata_t serialize (const struct sertopic * tp, const void * sample)
 | 
			
		||||
{
 | 
			
		||||
  dds_stream_t os;
 | 
			
		||||
  serstate_t st = ddsi_serstate_new (tp);
 | 
			
		||||
  dds_key_gen ((const dds_topic_descriptor_t*) tp->type, &st->data->v.keyhash, (char*) sample);
 | 
			
		||||
  dds_stream_from_serstate (&os, st);
 | 
			
		||||
  dds_stream_write_sample (&os, sample, tp);
 | 
			
		||||
  dds_stream_add_to_serstate (&os, st);
 | 
			
		||||
  return st->data;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
int serdata_cmp (const struct serdata *a, const struct serdata *b)
 | 
			
		||||
{
 | 
			
		||||
  /* First compare on topic */
 | 
			
		||||
 | 
			
		||||
  if (a->v.st->topic != b->v.st->topic)
 | 
			
		||||
  {
 | 
			
		||||
    return a->v.st->topic < b->v.st->topic ? -1 : 1;
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
  /* Samples with a keyless topic map to the default instance */
 | 
			
		||||
 | 
			
		||||
  if 
 | 
			
		||||
  (
 | 
			
		||||
    (a->v.st->topic) &&
 | 
			
		||||
    (((dds_topic_descriptor_t*) a->v.st->topic->type)->m_keys == 0)
 | 
			
		||||
  )
 | 
			
		||||
  {
 | 
			
		||||
    return 0;
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
  /* Check key has been hashed */
 | 
			
		||||
 | 
			
		||||
  assert (a->v.keyhash.m_flags & DDS_KEY_HASH_SET);
 | 
			
		||||
 | 
			
		||||
  /* Compare by hash */
 | 
			
		||||
 | 
			
		||||
  return memcmp (a->v.keyhash.m_hash, b->v.keyhash.m_hash, 16);
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
serdata_t serialize_key (const struct sertopic * tp, const void * sample)
 | 
			
		||||
{
 | 
			
		||||
  serdata_t sd;
 | 
			
		||||
  dds_stream_t os;
 | 
			
		||||
  dds_topic_descriptor_t * desc = (dds_topic_descriptor_t*) tp->type;
 | 
			
		||||
  serstate_t st = ddsi_serstate_new (tp);
 | 
			
		||||
  dds_key_gen (desc, &st->data->v.keyhash, (char*) sample);
 | 
			
		||||
  dds_stream_from_serstate (&os, st);
 | 
			
		||||
  dds_stream_write_key (&os, sample, desc);
 | 
			
		||||
  dds_stream_add_to_serstate (&os, st);
 | 
			
		||||
  sd = st->data;
 | 
			
		||||
  sd->v.st->kind = STK_KEY;
 | 
			
		||||
  return sd;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
void deserialize_into (void * sample, const struct serdata * serdata)
 | 
			
		||||
{
 | 
			
		||||
  const serstate_t st = serdata->v.st;
 | 
			
		||||
  dds_stream_t is;
 | 
			
		||||
 | 
			
		||||
  dds_stream_from_serstate (&is, st);
 | 
			
		||||
  if (st->kind == STK_KEY)
 | 
			
		||||
  {
 | 
			
		||||
    dds_stream_read_key (&is, sample, (const dds_topic_descriptor_t*) st->topic->type);
 | 
			
		||||
  }
 | 
			
		||||
  else
 | 
			
		||||
  {
 | 
			
		||||
    dds_stream_read_sample (&is, sample, st->topic);
 | 
			
		||||
  }
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
void serstate_set_key (serstate_t st, int justkey, const void *key)
 | 
			
		||||
{
 | 
			
		||||
  st->kind = justkey ? STK_KEY : STK_DATA;
 | 
			
		||||
  memcpy (&st->data->v.keyhash.m_hash, key, 16);
 | 
			
		||||
  st->data->v.keyhash.m_flags = DDS_KEY_SET | DDS_KEY_HASH_SET | DDS_KEY_IS_HASH;
 | 
			
		||||
  st->data->v.keyhash.m_key_len = 16;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
void serstate_init (serstate_t st, const struct sertopic * topic)
 | 
			
		||||
{
 | 
			
		||||
  st->pos = 0;
 | 
			
		||||
  st->topic = topic;
 | 
			
		||||
  st->kind = STK_DATA;
 | 
			
		||||
  st->twrite.v = -1;
 | 
			
		||||
  os_atomic_st32 (&st->refcount, 1);
 | 
			
		||||
 | 
			
		||||
  if (topic)
 | 
			
		||||
  {
 | 
			
		||||
    os_atomic_inc32 (&(((struct sertopic *) topic)->refcount));
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
  st->data->hdr.identifier = topic ? 
 | 
			
		||||
    (PLATFORM_IS_LITTLE_ENDIAN ? CDR_LE : CDR_BE) : 
 | 
			
		||||
    (PLATFORM_IS_LITTLE_ENDIAN ? PL_CDR_LE : PL_CDR_BE);
 | 
			
		||||
 | 
			
		||||
  st->data->v.hash_valid = (topic == NULL || topic->nkeys) ? 0 : 1;
 | 
			
		||||
  st->data->v.hash = 0;
 | 
			
		||||
  st->data->v.bswap = false;
 | 
			
		||||
  memset (st->data->v.keyhash.m_hash, 0, sizeof (st->data->v.keyhash.m_hash));
 | 
			
		||||
  st->data->v.keyhash.m_key_len = 0;
 | 
			
		||||
  st->data->v.keyhash.m_flags = 0;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
void serstate_free (serstate_t st)
 | 
			
		||||
{
 | 
			
		||||
  dds_free (st->data->v.keyhash.m_key_buff);
 | 
			
		||||
  dds_free (st->data);
 | 
			
		||||
  dds_free (st);
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
void sertopic_free (struct sertopic * tp)
 | 
			
		||||
{
 | 
			
		||||
  if (tp && (os_atomic_dec32_nv (&tp->refcount) == 0))
 | 
			
		||||
  {
 | 
			
		||||
    dds_free (tp->name);
 | 
			
		||||
    dds_free (tp->typename);
 | 
			
		||||
    dds_free (tp->name_typename);
 | 
			
		||||
    dds_sample_free (tp->filter_sample, (const struct dds_topic_descriptor *) tp->type, DDS_FREE_ALL);
 | 
			
		||||
    dds_free (tp);
 | 
			
		||||
  }
 | 
			
		||||
}
 | 
			
		||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue