If a reader is detected there is no need to test it further, just set a boolean.

This commit is contained in:
Erik Hofman 2021-03-12 10:48:12 +01:00
parent 878b742558
commit a9615869e3
2 changed files with 14 additions and 15 deletions

View File

@ -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);

View File

@ -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; }
};