If I am reading this correctly, Mojo::IOLoop::Stream just ignores write 
errors (and continues attempting to write on the closed socket).

What are the "timing problems" which are avoided by not handling write 
errors? Is there a better way of avoiding those problems?

...
sub _write {
  my $self = shift;

  # Handle errors only when reading (to avoid timing problems)
  my $handle = $self->{handle};
  if (length $self->{buffer}) {
    return unless defined(my $written = 
$handle->syswrite($self->{buffer}));
    $self->emit(write => substr($self->{buffer}, 0, $written, 
''))->_again;
  }

  $self->emit('drain') unless length $self->{buffer};
  return if $self->is_writing;
  return $self->close if $self->{graceful};
  $self->reactor->watch($handle, !$self->{paused}, 0) if $self->{handle};
}
...

On Fri, 27 Apr 2018, Charlie Brady wrote:

> 
> I have a controller producing a response with a write_chunk() loop. I want 
> to take a different action if the client does not read the full response - 
> e.g. when a user hits Cancel in a file save dialog.
> 
> In a previous version of my code which ran in CGI mode SIGPIPE told me 
> that information. Is there anything in Mojolicious which will relay the 
> socket write error back to the controller?
> 
> Thanks
> 

Reply via email to