diff --git a/services/network/socket_data_pump.cc b/services/network/socket_data_pump.cc index 35c3689b3aa3a..c3afdd9c91278 100644 --- a/services/network/socket_data_pump.cc +++ b/services/network/socket_data_pump.cc @@ -251,7 +251,12 @@ void SocketDataPump::ShutdownSend() { } void SocketDataPump::MaybeNotifyDelegate() { - if (!delegate_ || send_stream_.is_valid() || !receive_is_shutdown_) { + // While a Write() is pending, BeginRead() has moved the consumer handle out + // of `send_stream_` and into `pending_send_buffer_`. Check both so we don't + // signal idle (and let the delegate destroy us, unmapping the ring buffer) + // while SocketPosix::write_buf_ still holds a span into that buffer. + if (!delegate_ || send_stream_.is_valid() || pending_send_buffer_ || + !receive_is_shutdown_) { return; } delegate_->OnShutdown();