Skip to content

Commit

Permalink
loop_once handle read/write in one loop
Browse files Browse the repository at this point in the history
  • Loading branch information
yedongfu committed Feb 11, 2019
1 parent fa892ea commit 1b5001c
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions handy/poller.cc
Original file line number Diff line number Diff line change
Expand Up @@ -92,13 +92,15 @@ void PollerEpoll::loop_once(int waitMs) {
Channel *ch = (Channel *) activeEvs_[i].data.ptr;
int events = activeEvs_[i].events;
if (ch) {
if (events & kWriteEvent) {
trace("channel %lld fd %d handle write", (long long) ch->id(), ch->fd());
ch->handleWrite();
}
if (events & (kReadEvent | POLLERR)) {
trace("channel %lld fd %d handle read", (long long) ch->id(), ch->fd());
ch->handleRead();
} else if (events & kWriteEvent) {
trace("channel %lld fd %d handle write", (long long) ch->id(), ch->fd());
ch->handleWrite();
} else {
}
if (!(events & (kReadEvent | kWriteEvent | POLLERR))){
fatal("unexpected poller events");
}
}
Expand Down

0 comments on commit 1b5001c

Please sign in to comment.