Postpone reader detection to the write call and skip writing if there is no reader yet.

This commit is contained in:
Erik Hofman 2021-03-10 16:14:30 +01:00
parent c0205f7eb2
commit b6c80f2e6a

View File

@ -116,19 +116,6 @@ SG_DDS::open( SGProtocolDir direction )
<< dds_strretcode(-rc));
return false;
}
uint32_t status = 0;
while(!(status & DDS_PUBLICATION_MATCHED_STATUS))
{
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));
}
/* Polling sleep. */
dds_sleepfor(DDS_MSECS(20));
}
}
return true;
@ -170,6 +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.
}
result = dds_write(writer, buf);
if(result != DDS_RETCODE_OK)
{