From cfe0e77aaf87a0590ceea42f6afa62b0c7d95e80 Mon Sep 17 00:00:00 2001 From: Aleksandar Donchev Date: Mon, 25 Sep 2017 17:01:18 +0200 Subject: Timer fd is closed at the beginning of the next iteration + some unit tests. Signed-off-by: Christian Linke Change-Id: I8c5d3c436ac9fad62c76a26145c731b538abb1e7 --- AudioManagerUtilities/include/CAmSocketHandler.h | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) (limited to 'AudioManagerUtilities/include/CAmSocketHandler.h') diff --git a/AudioManagerUtilities/include/CAmSocketHandler.h b/AudioManagerUtilities/include/CAmSocketHandler.h index 717f792..7baa496 100644 --- a/AudioManagerUtilities/include/CAmSocketHandler.h +++ b/AudioManagerUtilities/include/CAmSocketHandler.h @@ -244,10 +244,11 @@ class CAmSocketHandler sh_timer_s() : handle(0) #ifdef WITH_TIMERFD - , fd(0) + , fd(-1) #endif , countdown(), callback(), userData(0) {} + }; struct sh_signal_s @@ -291,7 +292,11 @@ class CAmSocketHandler VectorListPoll_t mListPoll; //! mListTimer; //! mListActiveTimer; //! mListRemovedTimers; +#endif sh_identifier_s mSetSignalhandlerKeys; //!A set of all used signal handler keys VectorSignalHandlers_t mSignalHandlers; bool mRecreatePollfds; //! Date: Tue, 26 Sep 2017 16:07:00 +0200 Subject: A filedescriptor removal will set an invalidation flag which will prevent calls on the invalidated objects in the current iteration. Signed-off-by: Christian Linke Change-Id: I9d5d3c434ac9fad62c76a76145c731b538aeb1e3 # Conflicts: # AudioManagerUtilities/src/CAmSocketHandler.cpp --- AudioManagerUtilities/include/CAmSocketHandler.h | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) (limited to 'AudioManagerUtilities/include/CAmSocketHandler.h') diff --git a/AudioManagerUtilities/include/CAmSocketHandler.h b/AudioManagerUtilities/include/CAmSocketHandler.h index 7baa496..d14c1a3 100644 --- a/AudioManagerUtilities/include/CAmSocketHandler.h +++ b/AudioManagerUtilities/include/CAmSocketHandler.h @@ -217,6 +217,7 @@ class CAmSocketHandler { struct sh_poll_s //! prepareCB; //preperation callback @@ -226,7 +227,7 @@ class CAmSocketHandler void* userData; sh_poll_s() : - handle(0), pollfdValue(), prepareCB(), firedCB(), checkCB(), dispatchCB(), userData(0) + isValid(true), handle(0), pollfdValue(), prepareCB(), firedCB(), checkCB(), dispatchCB(), userData(0) {} }; @@ -302,9 +303,11 @@ class CAmSocketHandler bool mRecreatePollfds; //! Date: Wed, 27 Sep 2017 11:51:13 +0200 Subject: Runtime check for calls to the sockethandler from other threads Signed-off-by: Christian Linke Change-Id: I9d9d3c424ac9fad62c76a76545c731b518bdb1e2 --- AudioManagerUtilities/include/CAmSocketHandler.h | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'AudioManagerUtilities/include/CAmSocketHandler.h') diff --git a/AudioManagerUtilities/include/CAmSocketHandler.h b/AudioManagerUtilities/include/CAmSocketHandler.h index d14c1a3..6163b3c 100644 --- a/AudioManagerUtilities/include/CAmSocketHandler.h +++ b/AudioManagerUtilities/include/CAmSocketHandler.h @@ -27,6 +27,7 @@ #include #include #include +#include #include #include #include "audiomanagertypes.h" @@ -309,6 +310,9 @@ class CAmSocketHandler #endif private: + + static void checkCallerThreadId(void); + bool fdIsValid(const int fd) const; timespec* insertTime(timespec& buffertime); @@ -496,6 +500,8 @@ public: void exit_mainloop(); bool fatalErrorOccurred(); + + static const std::thread::id SOCKETHANDLER_THREAD_ID; }; } /* namespace am */ -- cgit v1.2.1 From 6b6342f5381138aeecea93e153de021e42db8283 Mon Sep 17 00:00:00 2001 From: Aleksandar Donchev Date: Thu, 28 Sep 2017 17:09:28 +0200 Subject: * All methods in CAPI wrapper with connectionID parameter are deprecated because CommonAPI creates new filedescriptor per connection which isn't needed. * revents flag is passed to the CommonAPI watcher instead events * revents set to 0 in Sockethandler Signed-off-by: Christian Linke Change-Id: I9d9d2c424ac9fad62c76a66545c731c518adb2e4 --- AudioManagerUtilities/include/CAmSocketHandler.h | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) (limited to 'AudioManagerUtilities/include/CAmSocketHandler.h') diff --git a/AudioManagerUtilities/include/CAmSocketHandler.h b/AudioManagerUtilities/include/CAmSocketHandler.h index 6163b3c..8809a30 100644 --- a/AudioManagerUtilities/include/CAmSocketHandler.h +++ b/AudioManagerUtilities/include/CAmSocketHandler.h @@ -305,14 +305,13 @@ class CAmSocketHandler internal_codes_t mInternalCodes; sh_pollHandle_t mSignalFdHandle; VectorListPoll_t mListActivePolls; + const std::thread::id mThreadID; //!< Socket handler thread id used to check if the calls come from the same thread #ifndef WITH_TIMERFD timespec mStartTime; //! Date: Thu, 12 Oct 2017 13:02:09 +0200 Subject: Real time scheduler added, capi wrapper timeout return value considered in registerTimeout, only requested revent passed from within the camsockethandler instead of all Signed-off-by: Christian Linke Change-Id: I2d9d2c424ac3fac62c76a66545a531c518edb2e8 --- AudioManagerUtilities/include/CAmSocketHandler.h | 7 ------- 1 file changed, 7 deletions(-) (limited to 'AudioManagerUtilities/include/CAmSocketHandler.h') diff --git a/AudioManagerUtilities/include/CAmSocketHandler.h b/AudioManagerUtilities/include/CAmSocketHandler.h index 8809a30..53010ba 100644 --- a/AudioManagerUtilities/include/CAmSocketHandler.h +++ b/AudioManagerUtilities/include/CAmSocketHandler.h @@ -421,13 +421,6 @@ private: */ inline static void fire(const sh_poll_s* a); - /** - * functor to return all fired events - * @param a - * @return - */ - inline static bool eventFired(const pollfd& a); - /** * functor to help find the items that do not need dispatching * @param a -- cgit v1.2.1 From d6481481d86408a5b1c74162012167ed57ac6ee9 Mon Sep 17 00:00:00 2001 From: Aleksandar Donchev Date: Mon, 27 Nov 2017 15:39:53 +0100 Subject: Cmake parameters for real-time scheduler's priority and policy and throw runtime error if read fails. Signed-off-by: Christian Linke Change-Id: I6a7a2c424bc8fac62c76a66545a231c518edb2e1 --- AudioManagerUtilities/include/CAmSocketHandler.h | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) (limited to 'AudioManagerUtilities/include/CAmSocketHandler.h') diff --git a/AudioManagerUtilities/include/CAmSocketHandler.h b/AudioManagerUtilities/include/CAmSocketHandler.h index 53010ba..2fd5c42 100644 --- a/AudioManagerUtilities/include/CAmSocketHandler.h +++ b/AudioManagerUtilities/include/CAmSocketHandler.h @@ -492,7 +492,29 @@ public: void exit_mainloop(); bool fatalErrorOccurred(); +#ifdef WITH_REALTIME_SCHEDULER + /** + * Set scheduling algorithm and/or parameters for a thread whose ID is specified in pid. + * If pid equals zero, the scheduling policy and parameters of the calling thread will be set. + * @param pid_t pid thread id + * @param int policy equals specified policies in sched_setscheduler documentation + * @param int priority between 1 and 99 + * @return on success 0 and on error -1 + */ + static int setRuntimeScheduler(const pid_t pid, const int policy, const int priority); +#endif }; +#ifdef WITH_REALTIME_SCHEDULER +#define SET_REALTIME_SCHEDULER()\ + if ( CAmSocketHandler::setRuntimeScheduler(0, AM_REALTIME_POLICY, AM_PROCESS_PRIORITY) != 0 )\ + {\ + std::cerr <<"sched_setscheduler:"< Date: Wed, 7 Feb 2018 10:51:17 +0100 Subject: The real-time scheduler removed. Signed-off-by: Christian Linke Change-Id: I7c8a2c474bc8fac62c76a46545a231c518edb2a8 --- AudioManagerUtilities/include/CAmSocketHandler.h | 22 ---------------------- 1 file changed, 22 deletions(-) (limited to 'AudioManagerUtilities/include/CAmSocketHandler.h') diff --git a/AudioManagerUtilities/include/CAmSocketHandler.h b/AudioManagerUtilities/include/CAmSocketHandler.h index 2fd5c42..53010ba 100644 --- a/AudioManagerUtilities/include/CAmSocketHandler.h +++ b/AudioManagerUtilities/include/CAmSocketHandler.h @@ -492,29 +492,7 @@ public: void exit_mainloop(); bool fatalErrorOccurred(); -#ifdef WITH_REALTIME_SCHEDULER - /** - * Set scheduling algorithm and/or parameters for a thread whose ID is specified in pid. - * If pid equals zero, the scheduling policy and parameters of the calling thread will be set. - * @param pid_t pid thread id - * @param int policy equals specified policies in sched_setscheduler documentation - * @param int priority between 1 and 99 - * @return on success 0 and on error -1 - */ - static int setRuntimeScheduler(const pid_t pid, const int policy, const int priority); -#endif }; -#ifdef WITH_REALTIME_SCHEDULER -#define SET_REALTIME_SCHEDULER()\ - if ( CAmSocketHandler::setRuntimeScheduler(0, AM_REALTIME_POLICY, AM_PROCESS_PRIORITY) != 0 )\ - {\ - std::cerr <<"sched_setscheduler:"<