summaryrefslogtreecommitdiff
path: root/AudioManagerUtilities/include/CAmSocketHandler.h
diff options
context:
space:
mode:
authorJens Lorenz <jlorenz@de.adit-jv.com>2018-06-07 18:04:03 +0200
committerJens Lorenz <jlorenz@de.adit-jv.com>2018-06-12 08:39:48 +0200
commitfc50c62104b3019ff4de9e4fcc5b6f04b74a664a (patch)
treede6c86d62087e27f318f5a9e97d8972b6c40154e /AudioManagerUtilities/include/CAmSocketHandler.h
parent27c9983421494ce9f5b82027f4b2e7f72369dced (diff)
downloadaudiomanager-fc50c62104b3019ff4de9e4fcc5b6f04b74a664a.tar.gz
AMUtil: Fix inconsistent fdPollingArray
In case someone removed a fd and closed it opened a new one and added it to the socket handler the container state of the object in map was changed from either REMOVE/CLOSE to UNINIT. This leads to the emplace call in the fdPollingArray vector and the fd is maintained twice. Over the entire runtime there will be zombie fds provided to ppoll functions which will race a POLLERR revent leading to 100% cpu load. Also the CLOSE state is now removed because only the application is aware if a fd has to be closed. For instance calling add/remove in a loop were start_listenting is not running will turn to a system issue were no fds can be provided by the operation system. Signed-off-by: Jens Lorenz <jlorenz@de.adit-jv.com>
Diffstat (limited to 'AudioManagerUtilities/include/CAmSocketHandler.h')
-rw-r--r--AudioManagerUtilities/include/CAmSocketHandler.h20
1 files changed, 10 insertions, 10 deletions
diff --git a/AudioManagerUtilities/include/CAmSocketHandler.h b/AudioManagerUtilities/include/CAmSocketHandler.h
index 797551d..db3207e 100644
--- a/AudioManagerUtilities/include/CAmSocketHandler.h
+++ b/AudioManagerUtilities/include/CAmSocketHandler.h
@@ -50,7 +50,6 @@ namespace am
typedef uint16_t sh_pollHandle_t; //!<this is a handle for a filedescriptor to be used with the SocketHandler
typedef sh_pollHandle_t sh_timerHandle_t; //!<this is a handle for a timer to be used with the SocketHandler
-typedef enum:uint8_t { RMV_ONLY, RMV_N_CLS } sh_rmv_e;
/**
* prototype for poll prepared callback
@@ -218,11 +217,11 @@ class CAmSocketHandler
{
typedef enum:uint8_t
{
- UNINIT = 0u, // new, uninitialized element which needs to be inserted to ppoll array
- VALID = 1u, // it is a valid element in ppoll array
- UPDATE = 2u, // update of event information therefore update ppoll array
- REMOVE = 3u, // remove from ppoll array and internal map
- CLOSE = 4u // close and remove from ppoll array and internal map
+ ADD = 0u, // new, uninitialized element which needs to be added to ppoll array
+ UPDATE = 1u, // update of event information therefore update ppoll array
+ VALID = 2u, // it is a valid element in ppoll array
+ REMOVE = 3u, // remove from ppoll array and internal map
+ INVALID = 4u // uninit element requested to be removed from internal map only
} poll_states_e;
struct sh_poll_s //!<struct that holds information about polls
@@ -237,7 +236,7 @@ class CAmSocketHandler
poll_states_e state;
sh_poll_s() :
- handle(0), pollfdValue(), prepareCB(), firedCB(), checkCB(), dispatchCB(), userData(0), state(UNINIT)
+ handle(0), pollfdValue(), prepareCB(), firedCB(), checkCB(), dispatchCB(), userData(0), state(ADD)
{}
};
@@ -288,8 +287,9 @@ class CAmSocketHandler
typedef enum:uint8_t
{
- NO_ERROR = 0u, // OK
- FD_ERROR = 1u, // Invalid file descriptor
+ NO_ERROR = 0u, // OK
+ FD_ERROR = 1u, // Invalid file descriptor
+ MT_ERROR = 2u // Multi-thread issue
} internal_codes_e;
typedef uint8_t internal_codes_t;
@@ -463,7 +463,7 @@ public:
std::function<bool(const sh_pollHandle_t handle, void* userData)> check, std::function<bool(const sh_pollHandle_t handle, void* userData)> dispatch, void* userData, sh_pollHandle_t& handle);
am_Error_e addFDPoll(const int fd, const short event, IAmShPollPrepare *prepare, IAmShPollFired *fired, IAmShPollCheck *check, IAmShPollDispatch *dispatch, void* userData, sh_pollHandle_t& handle);
- am_Error_e removeFDPoll(const sh_pollHandle_t handle, const sh_rmv_e rmv = RMV_ONLY);
+ am_Error_e removeFDPoll(const sh_pollHandle_t handle);
am_Error_e updateEventFlags(const sh_pollHandle_t handle, const short events);
am_Error_e addSignalHandler(std::function<void(const sh_pollHandle_t handle, const signalfd_siginfo & info, void* userData)> callback, sh_pollHandle_t& handle, void * userData);
am_Error_e removeSignalHandler(const sh_pollHandle_t handle);