From 46a197d8f85b99cebc0145925cd760fc2fbd4692 Mon Sep 17 00:00:00 2001 From: Alexander Pipelka Date: Thu, 28 Sep 2017 10:25:16 +0200 Subject: [PATCH] Moved send loop one level down. --- sectionfilter.c | 41 +++++++++++++++++++++-------------------- sectionfilter.h | 2 +- 2 files changed, 22 insertions(+), 21 deletions(-) diff --git a/sectionfilter.c b/sectionfilter.c index 3936372..026efbd 100644 --- a/sectionfilter.c +++ b/sectionfilter.c @@ -271,29 +271,30 @@ cSatipSectionFilterHandler::~cSatipSectionFilterHandler() Delete(i); } -bool cSatipSectionFilterHandler::Send(void) +void cSatipSectionFilterHandler::SendAll(void) { - // zero polling structures - memset(pollFdsM, 0, sizeof(pollFdsM)); + while (true) { + // zero polling structures + memset(pollFdsM, 0, sizeof(pollFdsM)); - // assemble all handlers to poll - for (unsigned int i = 0; i < eMaxSecFilterCount; ++i) { - if (filtersM[i] && filtersM[i]->Available() != 0) { - pollFdsM[i].fd = filtersM[i]->GetFd(); - pollFdsM[i].events = POLLOUT; - } - } + // assemble all handlers to poll + for (unsigned int i = 0; i < eMaxSecFilterCount; ++i) { + if (filtersM[i] && filtersM[i]->Available() != 0) { + pollFdsM[i].fd = filtersM[i]->GetFd(); + pollFdsM[i].events = POLLOUT; + } + } - // anyone ready for writing - if (poll(pollFdsM, eMaxSecFilterCount, eSecFilterSendTimeoutMs) <= 0) - return false; + // anyone ready for writing + if (poll(pollFdsM, eMaxSecFilterCount, eSecFilterSendTimeoutMs) <= 0) + return; - // send data - for (unsigned int i = 0; i < eMaxSecFilterCount; ++i) { - if (pollFdsM[i].revents & POLLOUT) - filtersM[i]->Send(); - } - return true; + // send data + for (unsigned int i = 0; i < eMaxSecFilterCount; ++i) { + if (pollFdsM[i].revents & POLLOUT) + filtersM[i]->Send(); + } + } } void cSatipSectionFilterHandler::Action(void) @@ -330,7 +331,7 @@ void cSatipSectionFilterHandler::Action(void) // Send demuxed section packets through all filters mutexM.Lock(); - while (Send()) ; + SendAll(); mutexM.Unlock(); } debug1("%s Exiting [device %d]", __PRETTY_FUNCTION__, deviceIndexM); diff --git a/sectionfilter.h b/sectionfilter.h index c0ea1d6..e5573d3 100644 --- a/sectionfilter.h +++ b/sectionfilter.h @@ -76,7 +76,7 @@ private: bool Delete(unsigned int indexP); bool IsBlackListed(u_short pidP, u_char tidP, u_char maskP) const; - bool Send(void); + void SendAll(void); protected: virtual void Action(void);