summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorrandomdan <randomdan@localhost>2014-01-03 11:31:11 +0000
committerrandomdan <randomdan@localhost>2014-01-03 11:31:11 +0000
commit137936b6d160f9a28b8a10b4523e23ab931d0ce6 (patch)
tree7e447782ae86280ab5f40f13d6aada4b1fc56e3a
parentCatch all exceptions in scheduled update thread (diff)
downloadp2pvr-137936b6d160f9a28b8a10b4523e23ab931d0ce6.tar.bz2
p2pvr-137936b6d160f9a28b8a10b4523e23ab931d0ce6.tar.xz
p2pvr-137936b6d160f9a28b8a10b4523e23ab931d0ce6.zip
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()
-rw-r--r--p2pvr/lib/tuner.cpp34
1 files 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 <boost/tuple/tuple.hpp>
#include "fileHandle.h"
#include "siParsers/table.h"
+#include <cxxabi.h>
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<Ice::AsyncResultPtr> 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;