summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGuerra Mattia <mguerra@de.adit-jv.com>2017-09-28 15:09:56 +0200
committerJens Lorenz <jlorenz@de.adit-jv.com>2017-09-29 11:42:01 +0200
commitc7f1fd1a0b14686d06043be27f0ac03265aac16f (patch)
tree0e9cdaa4ce2d2667bf99ca2690176b42261613e4
parent4e72bcb91edee76ad1b1b622c84586a487797339 (diff)
downloadaudiomanager-c7f1fd1a0b14686d06043be27f0ac03265aac16f.tar.gz
AMUtil: fix missed copy in list Poll
When copying the list of Poll fd, also the revents have to be copied. This is very important for AM Plugins which rely on revents in order to consume data. Without updating the revents, there's concrete risk of endless poll and general stuck situation. Signed-off-by: Guerra Mattia <mguerra@de.adit-jv.com>
-rw-r--r--AudioManagerUtilities/src/CAmSocketHandler.cpp31
1 files changed, 18 insertions, 13 deletions
diff --git a/AudioManagerUtilities/src/CAmSocketHandler.cpp b/AudioManagerUtilities/src/CAmSocketHandler.cpp
index 7b0fc5d..fad60e5 100644
--- a/AudioManagerUtilities/src/CAmSocketHandler.cpp
+++ b/AudioManagerUtilities/src/CAmSocketHandler.cpp
@@ -69,10 +69,13 @@ CAmSocketHandler::CAmSocketHandler() :
short event = 0;
sh_pollHandle_t handle;
event |= POLLIN;
- if (addFDPoll(mPipe[0], event, NULL, [](const pollfd pollfd, const sh_pollHandle_t, void*)
- {}, [](const sh_pollHandle_t, void*)
- { return (false);}, NULL, NULL, handle) != E_OK)
+ if (addFDPoll(mPipe[0], event, NULL,
+ [](const pollfd, const sh_pollHandle_t, void*){},
+ [](const sh_pollHandle_t, void*) { return (false); },
+ NULL, NULL, handle) != E_OK)
+ {
mInternalCodes |= internal_codes_e::FD_ERROR;
+ }
}
CAmSocketHandler::~CAmSocketHandler()
@@ -99,10 +102,8 @@ void CAmSocketHandler::start_listenting()
#endif
timespec buffertime;
- std::list<sh_poll_s> listPoll;
VectorListPoll_t cloneListPoll;
VectorListPoll_t::iterator listmPollIt;
- VectorListPollfd_t::iterator itMfdPollingArray;
VectorListPollfd_t fdPollingArray; //!<the polling array for ppoll
auto preparePollfd = [&](const sh_poll_s& row)
@@ -151,19 +152,23 @@ void CAmSocketHandler::start_listenting()
if (pollStatus != 0) //only check filedescriptors if there was a change
{
+ std::list<sh_poll_s> listPoll;
//todo: here could be a timer that makes sure naughty plugins return!
- listPoll.clear();
//stage 0+1, call firedCB
- for (itMfdPollingArray = fdPollingArray.begin(); itMfdPollingArray != fdPollingArray.end(); itMfdPollingArray++)
+ listmPollIt = cloneListPoll.begin();
+ for (auto it : fdPollingArray)
{
- if (CAmSocketHandler::eventFired(*itMfdPollingArray))
- {
- listmPollIt = cloneListPoll.begin();
- std::advance(listmPollIt, std::distance(fdPollingArray.begin(), itMfdPollingArray));
-
+ if (CAmSocketHandler::eventFired(it))
+ {
+ listmPollIt->pollfdValue.revents = it.revents;
listPoll.push_back(*listmPollIt);
CAmSocketHandler::fire(*listmPollIt);
}
+ else
+ {
+ listmPollIt->pollfdValue.revents = 0;
+ }
+ listmPollIt++;
}
//stage 2, lets ask around if some dispatching is necessary, the ones who need stay on the list
@@ -395,7 +400,7 @@ am::am_Error_e CAmSocketHandler::addFDPoll(const int fd, const short event, IAmS
{
std::function<void(const sh_pollHandle_t handle, void* userData)> prepareCB; //preperation callback
- std::function<void(const pollfd pollfd, const sh_pollHandle_t handle, void* userData)> firedCB; //fired callback
+ std::function<void(const pollfd poll, const sh_pollHandle_t handle, void* userData)> firedCB; //fired callback
std::function<bool(const sh_pollHandle_t handle, void* userData)> checkCB; //check callback
std::function<bool(const sh_pollHandle_t handle, void* userData)> dispatchCB; //check callback