From 137936b6d160f9a28b8a10b4523e23ab931d0ce6 Mon Sep 17 00:00:00 2001 From: randomdan Date: Fri, 3 Jan 2014 11:31:11 +0000 Subject: Log exceptions in scan frequency found handler Only set connection proxy for non-local calls Force indirect proxy use (for async) in demux send, add log on demux read error, fix use of poll() --- p2pvr/lib/tuner.cpp | 34 ++++++++++++++++++++++++++-------- 1 file changed, 26 insertions(+), 8 deletions(-) diff --git a/p2pvr/lib/tuner.cpp b/p2pvr/lib/tuner.cpp index b5c280a..1095667 100644 --- a/p2pvr/lib/tuner.cpp +++ b/p2pvr/lib/tuner.cpp @@ -13,6 +13,7 @@ #include #include "fileHandle.h" #include "siParsers/table.h" +#include class FrontendNotSupported : public NotSupported { public: @@ -95,7 +96,14 @@ Tuner::ScanAndSendNetworkInformation(const P2PVR::RawDataClientPrx & client, con try { return (SendPID(0x10, client, ice) > 0); } + catch (const std::exception & ex) { + char * buf = __cxxabiv1::__cxa_demangle(typeid(ex).name(), NULL, NULL, NULL); + Logger()->messagebf(LOG_DEBUG, "%s: frequency scan lock event failed %s:%s", __PRETTY_FUNCTION__, buf, ex.what()); + free(buf); + return false; + } catch (...) { + Logger()->messagebf(LOG_DEBUG, "%s: frequency scan lock event failed", __PRETTY_FUNCTION__); return false; } }); @@ -143,7 +151,9 @@ Tuner::SendPID(int pid, const P2PVR::RawDataClientPrx & client, const Ice::Curre time(&lastUsedTime); Logger()->messagebf(LOG_DEBUG, "%s: pid = 0x%x", __PRETTY_FUNCTION__, pid); - ice.con->createProxy(client->ice_getIdentity()); + if (ice.con) { + ice.con->createProxy(client->ice_getIdentity()); + } FileHandle demux(OpenDemux()); RequestPID(pid, demux); return ReadDemuxAndSend(demux, client); @@ -164,27 +174,35 @@ Tuner::RequestPID(int pid, int demux) } uint64_t -Tuner::ReadDemuxAndSend(int demux, const P2PVR::RawDataClientPrx & client) const +Tuner::ReadDemuxAndSend(int demux, const P2PVR::RawDataClientPrx & _client) const { Logger()->messagebf(LOG_DEBUG, "%s: begin", __PRETTY_FUNCTION__); std::vector asyncs; struct pollfd ufd; + memset(&ufd, 0, sizeof(pollfd)); + ufd.fd = demux; + ufd.events = POLLIN | POLLPRI; uint64_t packetsSent = 0; bool exitFlag = false; + auto client = _client->ice_collocationOptimized(false); do { // Wait for data to appear - memset(&ufd, 0, sizeof(pollfd)); - ufd.fd = demux; - ufd.events = POLLIN; - if (poll(&ufd, 1, DemuxReadTimeout) < 1) { - Logger()->messagebf(LOG_DEBUG, "%s: Timed out waiting for data", __PRETTY_FUNCTION__); - break; + switch (poll(&ufd, 1, DemuxReadTimeout)) { + case -1: + Logger()->messagebf(LOG_DEBUG, "%s: poll error reading demux (%d:%s)", __PRETTY_FUNCTION__, errno, strerror(errno)); + throw P2PVR::DeviceError("demux", strerror(errno), errno); + case 0: + auto status = frontend->GetStatus(); + Logger()->messagebf(LOG_DEBUG, "%s: Timed out waiting for data (device status 0x%02x)", __PRETTY_FUNCTION__, status); + throw P2PVR::DeviceError("demux", "timeout", 0); } // Read it P2PVR::Data buf(1 << 12); int nr = read(demux, &buf.front(), buf.size()); if (nr < 0) { + Logger()->messagebf(LOG_DEBUG, "%s: error reading demux (%d:%s) status 0x%02x", + __PRETTY_FUNCTION__, errno, strerror(errno), frontend->GetStatus()); throw P2PVR::DeviceError("demux", strerror(errno), errno); } size_t n = nr; -- cgit v1.2.3