Skip to content

Commit

Permalink
Prevent Poller from spinning on socket EOF
Browse files Browse the repository at this point in the history
  • Loading branch information
gbitzes committed Nov 17, 2016
1 parent 3ae3c6d commit 450e356
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions src/Poller.cc
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
#include "Poller.hh"
#include "RedisParser.hh"
#include <sys/socket.h>
#include <sys/ioctl.h>
#include <poll.h>

#include <sys/types.h>
Expand Down Expand Up @@ -115,6 +116,15 @@ void Poller::worker(int fd, Dispatcher *dispatcher) {
// time to quit?
if(shutdown) break;

// EOF?
if(polls[0].revents & POLLIN) {
int count = -1;
ioctl(fd, FIONREAD, &count);
if(count == 0) {
break;
}
}

while(true) {
LinkStatus status = parser.fetch(currentRequest);
if(status <= 0) break;
Expand Down

0 comments on commit 450e356

Please sign in to comment.