Commit f130981c authored by Wez's avatar Wez Committed by Commit Bot

Add FDIO_EVT_PEER_CLOSED to WatchFileDescriptor(WATCH_READ) events.

WatchFileDescriptor(WATCH_READ) should result in
OnFileCanReadWithoutBlocking() if the descriptor is at end-of-stream
when it is invoked, to wake the caller to detect that by attempting to
read and receiving zero bytes.

Bug: 898938, 706592, 884299
Change-Id: I77662fe77eb8fb988089640a75a60d470770b78f
Reviewed-on: https://chromium-review.googlesource.com/c/1316672
Commit-Queue: Wez <wez@chromium.org>
Reviewed-by: default avatarSergey Ulanov <sergeyu@chromium.org>
Cr-Commit-Position: refs/heads/master@{#605154}
parent ec2dbf94
...@@ -125,7 +125,7 @@ void MessagePumpFuchsia::FdWatchController::OnZxHandleSignalled( ...@@ -125,7 +125,7 @@ void MessagePumpFuchsia::FdWatchController::OnZxHandleSignalled(
bool* was_stopped = was_stopped_; bool* was_stopped = was_stopped_;
if (events & FDIO_EVT_WRITABLE) if (events & FDIO_EVT_WRITABLE)
watcher_->OnFileCanWriteWithoutBlocking(fd_); watcher_->OnFileCanWriteWithoutBlocking(fd_);
if (!*was_stopped && (events & FDIO_EVT_READABLE)) if (!*was_stopped && (events & (FDIO_EVT_READABLE | FDIO_EVT_PEER_CLOSED)))
watcher_->OnFileCanReadWithoutBlocking(fd_); watcher_->OnFileCanReadWithoutBlocking(fd_);
// Don't add additional work here without checking |*was_stopped_| again. // Don't add additional work here without checking |*was_stopped_| again.
...@@ -192,13 +192,14 @@ bool MessagePumpFuchsia::WatchFileDescriptor(int fd, ...@@ -192,13 +192,14 @@ bool MessagePumpFuchsia::WatchFileDescriptor(int fd,
switch (mode) { switch (mode) {
case WATCH_READ: case WATCH_READ:
controller->desired_events_ = FDIO_EVT_READABLE; controller->desired_events_ = FDIO_EVT_READABLE | FDIO_EVT_PEER_CLOSED;
break; break;
case WATCH_WRITE: case WATCH_WRITE:
controller->desired_events_ = FDIO_EVT_WRITABLE; controller->desired_events_ = FDIO_EVT_WRITABLE;
break; break;
case WATCH_READ_WRITE: case WATCH_READ_WRITE:
controller->desired_events_ = FDIO_EVT_READABLE | FDIO_EVT_WRITABLE; controller->desired_events_ =
FDIO_EVT_READABLE | FDIO_EVT_PEER_CLOSED | FDIO_EVT_WRITABLE;
break; break;
default: default:
NOTREACHED() << "unexpected mode: " << mode; NOTREACHED() << "unexpected mode: " << mode;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment