Ignore handlers without any data.

This commit is contained in:
Alexander Pipelka 2017-10-04 10:52:01 +02:00
parent 0a9bb96dd4
commit f4454b0f0d
1 changed files with 11 additions and 11 deletions

View File

@ -274,34 +274,34 @@ cSatipSectionFilterHandler::~cSatipSectionFilterHandler()
void cSatipSectionFilterHandler::SendAll(void) void cSatipSectionFilterHandler::SendAll(void)
{ {
cMutexLock MutexLock(&mutexM); cMutexLock MutexLock(&mutexM);
bool retry; bool pendingData;
do { do {
retry = false; pendingData = false;
// zero polling structures // zero polling structures
memset(pollFdsM, 0, sizeof(pollFdsM)); memset(pollFdsM, 0, sizeof(pollFdsM));
// assemble all handlers to poll // assemble all handlers to poll (use -1 to ignore handlers)
for (unsigned int i = 0; i < eMaxSecFilterCount; ++i) { for (unsigned int i = 0; i < eMaxSecFilterCount; ++i) {
if (filtersM[i] && filtersM[i]->Available() != 0) { if (filtersM[i] && filtersM[i]->Available() != 0) {
pollFdsM[i].fd = filtersM[i]->GetFd(); pollFdsM[i].fd = filtersM[i]->GetFd();
pollFdsM[i].events = POLLOUT; pollFdsM[i].events = POLLOUT;
pendingData = true;
} }
else
pollFdsM[i].fd = -1;
} }
// anyone ready for writing // exit if there isn't any pending data or we time out
if (poll(pollFdsM, eMaxSecFilterCount, eSecFilterSendTimeoutMs) <= 0) if (!pendingData || poll(pollFdsM, eMaxSecFilterCount, eSecFilterSendTimeoutMs) <= 0)
return; return;
// send data // send data (if available)
for (unsigned int i = 0; i < eMaxSecFilterCount; ++i) { for (unsigned int i = 0; i < eMaxSecFilterCount && pendingData; ++i) {
if (pollFdsM[i].revents & POLLOUT) if (pollFdsM[i].revents & POLLOUT)
filtersM[i]->Send(); filtersM[i]->Send();
if (!retry && filtersM[i] && filtersM[i]->Available() != 0)
retry = true;
} }
} while (retry); } while (pendingData);
} }
void cSatipSectionFilterHandler::Action(void) void cSatipSectionFilterHandler::Action(void)