From cdb2e0e3b42203202e80744095e987c7930db18f Mon Sep 17 00:00:00 2001 From: Rolf Ahrenberg Date: Sat, 29 Nov 2014 14:44:30 +0200 Subject: [PATCH] Added logging of maximum processing time in cPoller(). --- msearch.c | 5 +++++ msearch.h | 1 + poller.c | 11 ++++++++++- pollerif.h | 1 + rtcp.c | 5 +++++ rtcp.h | 1 + rtp.c | 5 +++++ rtp.h | 1 + 8 files changed, 29 insertions(+), 1 deletion(-) diff --git a/msearch.c b/msearch.c index 6152cda..6aa920c 100644 --- a/msearch.c +++ b/msearch.c @@ -92,3 +92,8 @@ void cSatipMsearch::Process(void) } } } + +cString cSatipMsearch::ToString(void) const +{ + return "MSearch"; +} diff --git a/msearch.h b/msearch.h index 3b78e1a..87e730f 100644 --- a/msearch.h +++ b/msearch.h @@ -32,6 +32,7 @@ public: public: virtual int GetFd(void); virtual void Process(void); + virtual cString ToString(void) const; }; #endif /* __SATIP_MSEARCH_H_ */ diff --git a/poller.c b/poller.c index 10cd01a..ded4980 100644 --- a/poller.c +++ b/poller.c @@ -69,6 +69,7 @@ void cSatipPoller::Action(void) { debug("cSatipPoller::%s(): entering", __FUNCTION__); struct epoll_event events[eMaxFileDescriptors]; + int maxElapsed = 0; // Increase priority SetPriority(-1); // Do the thread loop @@ -77,8 +78,16 @@ void cSatipPoller::Action(void) ERROR_IF_FUNC((nfds == -1), "epoll_wait() failed", break, ;); for (int i = 0; i < nfds; ++i) { cSatipPollerIf* poll = reinterpret_cast(events[i].data.ptr); - if (poll) + if (poll) { + int elapsed; + cTimeMs processing(0); poll->Process(); + elapsed = processing.Elapsed(); + if (elapsed > maxElapsed) { + maxElapsed = elapsed; + debug("cSatipPoller::%s(): Processing %s took %d ms", __FUNCTION__, *(poll->ToString()), maxElapsed); + } + } } } debug("cSatipPoller::%s(): exiting", __FUNCTION__); diff --git a/pollerif.h b/pollerif.h index 02be97a..79d4a96 100644 --- a/pollerif.h +++ b/pollerif.h @@ -14,6 +14,7 @@ public: virtual ~cSatipPollerIf() {} virtual int GetFd(void) = 0; virtual void Process(void) = 0; + virtual cString ToString(void) const = 0; private: cSatipPollerIf(const cSatipPollerIf&); diff --git a/rtcp.c b/rtcp.c index 2695e8e..e3f3f79 100644 --- a/rtcp.c +++ b/rtcp.c @@ -91,3 +91,8 @@ void cSatipRtcp::Process(void) error("Error %d reading from RTCP socket [device %d]", errno, tunerM.GetId()); } } + +cString cSatipRtcp::ToString(void) const +{ + return cString::sprintf("RTCP [device %d]", tunerM.GetId()); +} diff --git a/rtcp.h b/rtcp.h index eb1296b..30d5532 100644 --- a/rtcp.h +++ b/rtcp.h @@ -27,6 +27,7 @@ public: public: virtual int GetFd(void); virtual void Process(void); + virtual cString ToString(void) const; }; #endif /* __SATIP_RTCP_H_ */ diff --git a/rtp.c b/rtp.c index 754306c..d3a51b5 100644 --- a/rtp.c +++ b/rtp.c @@ -121,3 +121,8 @@ void cSatipRtp::Process(void) error("Error %d reading from RTP socket [device %d]", errno, tunerM.GetId()); } } + +cString cSatipRtp::ToString(void) const +{ + return cString::sprintf("RTP [device %d]", tunerM.GetId()); +} diff --git a/rtp.h b/rtp.h index 101c36b..45ebf95 100644 --- a/rtp.h +++ b/rtp.h @@ -34,6 +34,7 @@ public: public: virtual int GetFd(void); virtual void Process(void); + virtual cString ToString(void) const; }; #endif /* __SATIP_RTP_H_ */