From c683a12d4d480c8f7277c574edf492d0157a0769 Mon Sep 17 00:00:00 2001 From: bju Date: Wed, 3 Apr 2013 01:29:28 +0200 Subject: Bug #1325 --- vdr-vdrmanager/select.cpp | 26 +++++++++++++------------- vdr-vdrmanager/sock.cpp | 2 +- 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() { -- cgit v1.2.3