From f4824b0b5d724577aff75aff93a8ed30ee7bfdbe Mon Sep 17 00:00:00 2001 From: Erik Boasson Date: Wed, 18 Jul 2018 16:24:29 +0200 Subject: [PATCH] replace temporary hack that is dds_writecdr by a better but nonetheless still temporary hack Signed-off-by: Erik Boasson --- src/core/ddsc/include/ddsc/dds.h | 8 +++---- src/core/ddsc/src/dds__entity.h | 4 ++++ src/core/ddsc/src/dds__write.h | 4 +--- src/core/ddsc/src/dds_entity.c | 6 ++++++ src/core/ddsc/src/dds_write.c | 37 +++++++++----------------------- 5 files changed, 25 insertions(+), 34 deletions(-) diff --git a/src/core/ddsc/include/ddsc/dds.h b/src/core/ddsc/include/ddsc/dds.h index ce5c6d6..e94a2ac 100644 --- a/src/core/ddsc/include/ddsc/dds.h +++ b/src/core/ddsc/include/ddsc/dds.h @@ -55,6 +55,9 @@ typedef _Return_type_success_(return > 0) int32_t dds_entity_t; extern "C" { #endif +/* FIXME: rename serdata, abstract it properly, etc */ +struct serdata; + /** * @brief Returns the default domain identifier. * @@ -1707,8 +1710,7 @@ _Pre_satisfies_((writer & DDS_ENTITY_KIND_MASK) == DDS_KIND_WRITER) DDS_EXPORT int dds_writecdr( dds_entity_t writer, - const void *cdr, - size_t size); + struct serdata *serdata); /** * @brief Write the value of a data instance along with the source timestamp passed. @@ -2717,8 +2719,6 @@ dds_take_mask_wl( _In_ uint32_t maxs, _In_ uint32_t mask); -struct serdata; - DDS_EXPORT int dds_takecdr( dds_entity_t reader_or_condition, diff --git a/src/core/ddsc/src/dds__entity.h b/src/core/ddsc/src/dds__entity.h index 2b62c14..872278f 100644 --- a/src/core/ddsc/src/dds__entity.h +++ b/src/core/ddsc/src/dds__entity.h @@ -108,6 +108,10 @@ const char * dds__entity_kind_str( _In_ dds_entity_t e); +dds_domain * +dds__entity_domain( + _In_ dds_entity* e); + #if defined (__cplusplus) } #endif diff --git a/src/core/ddsc/src/dds__write.h b/src/core/ddsc/src/dds__write.h index 149f950..c12d99f 100644 --- a/src/core/ddsc/src/dds__write.h +++ b/src/core/ddsc/src/dds__write.h @@ -39,12 +39,10 @@ dds_write_impl( int dds_writecdr_impl( _In_ dds_writer *wr, - _In_ const void *cdr, - _In_ size_t sz, + _Inout_ struct serdata *d, _In_ dds_time_t tstamp, _In_ dds_write_action action); - #if defined (__cplusplus) } #endif diff --git a/src/core/ddsc/src/dds_entity.c b/src/core/ddsc/src/dds_entity.c index 2b3cd12..926850d 100644 --- a/src/core/ddsc/src/dds_entity.c +++ b/src/core/ddsc/src/dds_entity.c @@ -46,6 +46,12 @@ dds_entity_add_ref(_In_ dds_entity * e) os_mutexUnlock (&e->m_mutex); } +dds_domain * +dds__entity_domain(_In_ dds_entity* e) +{ + return e->m_domain; +} + static void dds_set_explicit( _In_ dds_entity_t entity); diff --git a/src/core/ddsc/src/dds_write.c b/src/core/ddsc/src/dds_write.c index 2cc92c1..8c9e8c2 100644 --- a/src/core/ddsc/src/dds_write.c +++ b/src/core/ddsc/src/dds_write.c @@ -26,7 +26,6 @@ #include "ddsi/q_radmin.h" #include - _Pre_satisfies_((writer & DDS_ENTITY_KIND_MASK) == DDS_KIND_WRITER) dds_return_t dds_write( @@ -58,16 +57,15 @@ _Pre_satisfies_((writer & DDS_ENTITY_KIND_MASK) == DDS_KIND_WRITER) int dds_writecdr( dds_entity_t writer, - const void *cdr, - size_t size) + struct serdata *serdata) { dds_return_t ret; dds__retcode_t rc; dds_writer *wr; - if (cdr != NULL) { + if (serdata != NULL) { rc = dds_writer_lock(writer, &wr); if (rc == DDS_RETCODE_OK) { - ret = dds_writecdr_impl (wr, cdr, size, dds_time (), 0); + ret = dds_writecdr_impl (wr, serdata, dds_time (), 0); dds_writer_unlock(wr); } else { ret = DDS_ERRNO(rc, "Error occurred on locking writer"); @@ -257,24 +255,21 @@ filtered: int dds_writecdr_impl( - _In_ dds_writer *wr, - _In_ const void *cdr, - _In_ size_t sz, - _In_ dds_time_t tstamp, - _In_ dds_write_action action) + _In_ dds_writer *wr, + _Inout_ serdata_t d, + _In_ dds_time_t tstamp, + _In_ dds_write_action action) { int ret = DDS_RETCODE_OK; int w_rc; assert (wr); - assert (cdr); 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; - serdata_t d; /* Check for topic filter */ if (ddsi_wr->topic->filter_fn && ! writekey) { @@ -285,22 +280,10 @@ dds_writecdr_impl( thread_state_awake (thr); } - /* Serialize and write data or key */ - { - serstate_t st = ddsi_serstate_new (ddsi_wr->topic); - dds_stream_t is; - ddsi_serstate_append_blob(st, 1, sz, cdr); - d = ddsi_serstate_fix(st); - assert(d->v.keyhash.m_flags == 0); - assert(!d->v.bswap); - dds_stream_from_serstate (&is, d->v.st); - d->v.st->kind = writekey ? STK_KEY : STK_DATA; - dds_stream_read_keyhash (&is, &d->v.keyhash, ddsi_wr->topic->status_cb_entity->m_descriptor, d->v.st->kind == STK_KEY); - } - /* 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.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; os_mutexLock (&wr->m_call_lock); ddsi_serdata_ref(d);