summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEnrico Scholz <enrico.scholz@informatik.tu-chemnitz.de>2013-01-04 19:36:23 +0100
committerEnrico Scholz <enrico.scholz@informatik.tu-chemnitz.de>2013-01-04 19:36:23 +0100
commit3465c47441008b4a7e968cd1dbc4d7f29c8e41f0 (patch)
tree4094334ace449e62b26b2fe87a1ad1813ff62875
parentf5389f0183cdde1b04cf68e475376c8fc7e448f5 (diff)
downloadvdr-plugin-inputdev-3465c47441008b4a7e968cd1dbc4d7f29c8e41f0.tar.gz
vdr-plugin-inputdev-3465c47441008b4a7e968cd1dbc4d7f29c8e41f0.tar.bz2
fixup! refactored epoll event handling
-rw-r--r--inputdev.cc15
-rw-r--r--inputdev.h2
2 files changed, 13 insertions, 4 deletions
diff --git a/inputdev.cc b/inputdev.cc
index 5342c0c..6de02c8 100644
--- a/inputdev.cc
+++ b/inputdev.cc
@@ -390,7 +390,7 @@ bool cInputDevice::start(int efd)
char const *dev_path = dev_path_;
ev.events = EPOLLIN;
- ev.data.ptr = this;
+ ev.data.ptr = static_cast<cEpollHandler *>(this);
rc = ioctl(fd_, EVIOCGRAB, 1);
if (rc < 0) {
@@ -625,7 +625,7 @@ bool cInputDeviceController::open_generic(int fd_udev)
}
ev.events = EPOLLIN;
- ev.data.ptr = this;
+ ev.data.ptr = static_cast<cEpollHandler *>(this);
rc = epoll_ctl(fd_epoll, EPOLL_CTL_ADD, fd_udev, &ev);
if (rc < 0) {
@@ -640,6 +640,7 @@ bool cInputDeviceController::open_generic(int fd_udev)
goto err;
}
+ ev.data.ptr = NULL;
rc = epoll_ctl(fd_epoll, EPOLL_CTL_ADD, fd_alive_[0], &ev);
if (rc < 0) {
esyslog("%s: epoll_ctl(ADD, <alive#%d>) failed: %s\n",
@@ -769,10 +770,16 @@ void cInputDeviceController::Action(void)
class cEpollHandler *dev =
static_cast<class cEpollHandler *>(events[i].data.ptr);
- if ((ev & (EPOLLHUP|EPOLLIN)) == EPOLLHUP)
+ if (!dev)
+ esyslog("%s: internal error; got event from keep-alive pipe\n",
+ plugin_.Name());
+ else if ((ev & (EPOLLHUP|EPOLLIN)) == EPOLLHUP)
dev->handle_hup();
- else
+ else if (ev & EPOLLIN)
dev->handle_pollin();
+ else
+ esyslog("%s: unexpected event %04x@%p\n",
+ plugin_.Name(), ev, dev);
}
cleanup_devices();
diff --git a/inputdev.h b/inputdev.h
index 72692f2..5d4a2ed 100644
--- a/inputdev.h
+++ b/inputdev.h
@@ -22,6 +22,8 @@
class cEpollHandler {
public:
+ virtual ~cEpollHandler() {}
+
virtual void handle_hup() = 0;
virtual void handle_pollin() = 0;
};