summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--vdr-vdrmanager/select.cpp26
-rw-r--r--vdr-vdrmanager/sock.cpp2
2 files changed, 14 insertions, 14 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);
}
}
}
diff --git a/vdr-vdrmanager/sock.cpp b/vdr-vdrmanager/sock.cpp
index 2102c36..a860b53 100644
--- a/vdr-vdrmanager/sock.cpp
+++ b/vdr-vdrmanager/sock.cpp
@@ -303,7 +303,7 @@ int cVdrmanagerClientSocket::GetClientId() {
}
bool cVdrmanagerClientSocket::WritePending() {
- return sendoffset < sendsize;
+ return sendsize > 0;
}
bool cVdrmanagerClientSocket::IsLoggedIn() {