From a9615869e337392cddc1411ed35a5adfde2f3d85 Mon Sep 17 00:00:00 2001 From: Erik Hofman Date: Fri, 12 Mar 2021 10:48:12 +0100 Subject: [PATCH] If a reader is detected there is no need to test it further, just set a boolean. --- simgear/io/SGDataDistributionService.cxx | 24 +++++++++++++----------- simgear/io/SGDataDistributionService.hxx | 5 +---- 2 files changed, 14 insertions(+), 15 deletions(-) diff --git a/simgear/io/SGDataDistributionService.cxx b/simgear/io/SGDataDistributionService.cxx index 69b2f256..7a2339a2 100644 --- a/simgear/io/SGDataDistributionService.cxx +++ b/simgear/io/SGDataDistributionService.cxx @@ -157,17 +157,19 @@ SG_DDS::write( const char *buf, const int length ) return 0; } - dds_return_t rc; - uint32_t status = 0; - rc = dds_get_status_changes(writer, &status); - if (rc != DDS_RETCODE_OK) { - SG_LOG(SG_IO, SG_ALERT, "dds_get_status_changes: " - << dds_strretcode(-rc)); - return 0; - } - if (!(status & DDS_PUBLICATION_MATCHED_STATUS)) { - SG_LOG(SG_IO, SG_INFO, "DDS skipping write: no readers."); - return length; // no readers yet. + if (!status) + { + dds_return_t rc = dds_get_status_changes(writer, &status); + if (rc != DDS_RETCODE_OK) { + SG_LOG(SG_IO, SG_ALERT, "dds_get_status_changes: " + << dds_strretcode(-rc)); + return 0; + } + + if (!(status & DDS_PUBLICATION_MATCHED_STATUS)) { + SG_LOG(SG_IO, SG_INFO, "DDS skipping write: no readers."); + return length; // no readers yet. + } } result = dds_write(writer, buf); diff --git a/simgear/io/SGDataDistributionService.hxx b/simgear/io/SGDataDistributionService.hxx index 8aa0f864..c570d9f6 100644 --- a/simgear/io/SGDataDistributionService.hxx +++ b/simgear/io/SGDataDistributionService.hxx @@ -45,7 +45,7 @@ private: const dds_topic_descriptor_t *descriptor = nullptr; size_t packet_size = 0; - int timeout = 0; + uint32_t status = 0; dds_entity_t participant = -1; dds_entity_t topic = -1; @@ -75,9 +75,6 @@ public: // close the participant. bool close(); - - // set timeout (default: 0) - inline void set_timeout(int i) { timeout = i; } };