Commit 2aa51e52 authored by Tamir Duberstein's avatar Tamir Duberstein Committed by Commit Bot

[fuchsia] avoid masking bits passed to FDIO

We can do our masking later, avoiding violating FDIO's assumptions.

Change-Id: Ia28b74b9d7fadae6512af51df18e39935e3e90d0
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1697140Reviewed-by: default avatarJames Robinson <jamesr@chromium.org>
Reviewed-by: default avatarSergey Ulanov <sergeyu@chromium.org>
Commit-Queue: Fabrice de Gans-Riberi <fdegans@chromium.org>
Cr-Commit-Position: refs/heads/master@{#676612}
parent 01911906
......@@ -92,14 +92,6 @@ void MessagePumpFuchsia::ZxHandleWatchController::HandleSignal(
controller->handler = nullptr;
// |signal| can include other spurious things, in particular, that an fd
// is writable, when we only asked to know when it was readable. In that
// case, we don't want to call both the CanWrite and CanRead callback,
// when the caller asked for only, for example, readable callbacks. So,
// mask with the events that we actually wanted to know about.
zx_signals_t signals = signal->trigger & signal->observed;
DCHECK_NE(0u, signals);
// In the case of a persistent Watch, the Watch may be stopped and
// potentially deleted by the caller within the callback, in which case
// |controller| should not be accessed again, and we mustn't continue the
......@@ -108,7 +100,7 @@ void MessagePumpFuchsia::ZxHandleWatchController::HandleSignal(
bool was_stopped = false;
controller->was_stopped_ = &was_stopped;
controller->watcher_->OnZxHandleSignalled(wait->object, signals);
controller->watcher_->OnZxHandleSignalled(wait->object, signal->observed);
if (was_stopped)
return;
......@@ -125,6 +117,14 @@ void MessagePumpFuchsia::FdWatchController::OnZxHandleSignalled(
uint32_t events;
fdio_unsafe_wait_end(io_, signals, &events);
// |events| can include other spurious things, in particular, that an fd
// is writable, when we only asked to know when it was readable. In that
// case, we don't want to call both the CanWrite and CanRead callback,
// when the caller asked for only, for example, readable callbacks. So,
// mask with the events that we actually wanted to know about.
events &= desired_events_;
DCHECK_NE(0u, events);
// Each |watcher_| callback we invoke may stop or delete |this|. The pump has
// set |was_stopped_| to point to a safe location on the calling stack, so we
// can use that to detect being stopped mid-callback and avoid doing further
......
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