summaryrefslogtreecommitdiff
path: root/vdr-vdrmanager/select.cpp
diff options
context:
space:
mode:
authorlado <herrlado@gmail.com>2013-04-03 09:58:02 +0200
committerlado <herrlado@gmail.com>2013-04-03 09:58:02 +0200
commit17c8d505c9bb272c520a778b58d3e8a579f89fab (patch)
treea2a6abe974854a27e5fcf9f2f62d07ac047354d8 /vdr-vdrmanager/select.cpp
parent10164a068cead3c4b64e01b09faf2c418adc8ea2 (diff)
downloadvdr-manager-17c8d505c9bb272c520a778b58d3e8a579f89fab.tar.gz
vdr-manager-17c8d505c9bb272c520a778b58d3e8a579f89fab.tar.bz2
current changes
Diffstat (limited to 'vdr-vdrmanager/select.cpp')
-rw-r--r--vdr-vdrmanager/select.cpp26
1 files changed, 13 insertions, 13 deletions
diff --git a/vdr-vdrmanager/select.cpp b/vdr-vdrmanager/select.cpp
index 06d9103..c569f42 100644
--- a/vdr-vdrmanager/select.cpp
+++ b/vdr-vdrmanager/select.cpp
@@ -108,9 +108,8 @@ bool cSelect::Action() {
}
void cSelect::CreatePollfds() {
- // construct pollfd array
- // we need one pollfd for the eventpipe,
- // the serversocket and each clientsocket
+
+ // we poll for the server socket and for each client socket
pollfds = new struct pollfd[clientsocketcount + 1];
pollfds[0].fd = serversocket->GetSocket();
pollfds[0].events = POLLIN;
@@ -119,9 +118,10 @@ void cSelect::CreatePollfds() {
int i = 1;
while (curnode) {
pollfds[i].fd = curnode->socket->GetSocket();
- pollfds[i].events = POLLIN;
- if (curnode->socket->WritePending())
+ pollfds[i].events = POLLIN | POLLHUP;
+ if (curnode->socket->WritePending()) {
pollfds[i].events |= POLLOUT;
+ }
pollfds[i++].revents = 0;
curnode = curnode->next;
}
@@ -149,17 +149,17 @@ bool cSelect::Poll() {
for (int i = 1; i < clientsocketcount + 1; i++) {
cVdrmanagerClientSocket * sock = GetClientSocket(pollfds[i].fd);
if (sock) {
- if (pollfds[i].revents & (POLLIN | POLLHUP)) {
+ if (pollfds[i].revents & POLLOUT) {
+ // possibly outstanding writes
+ sock->Flush();
+ } else if (pollfds[i].revents & (POLLIN | POLLHUP)) {
// client request
handler->HandleClientRequest(sock);
+ }
- // disconnect?
- if (sock->Disconnected()) {
- RemoveClientSocket(sock);
- }
- } else if (pollfds[i].revents & POLLOUT) {
- // possibly outstanding writes
- sock->Flush();
+ // disconnect?
+ if (sock->Disconnected()) {
+ RemoveClientSocket(sock);
}
}
}