Skip to content
This repository has been archived by the owner on Dec 18, 2018. It is now read-only.

Commit

Permalink
Dispose socket if writer is completed with any error.
Browse files Browse the repository at this point in the history
  • Loading branch information
Cesar Blum Silveira committed Jul 7, 2017
1 parent 5023f94 commit 093a6fe
Showing 1 changed file with 4 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ public LibuvOutputConsumer(
_connectionId = connectionId;
_log = log;

_pipe.OnWriterCompleted(DisposeSocket, this);
_pipe.OnWriterCompleted(OnWriterCompleted, this);
}

public async Task WriteOutputAsync()
Expand Down Expand Up @@ -88,11 +88,10 @@ public async Task WriteOutputAsync()
}
}

private static void DisposeSocket(Exception ex, object state)
private static void OnWriterCompleted(Exception ex, object state)
{
// If the pipe writer was closed with a TimeoutException, a write timed out.
// Disposing the socket will cancel the pending UvWriteReq.
if (ex is TimeoutException)
// Cut off writes if the writer is completed with an error.
if (ex != null)
{
var libuvOutputConsumer = (LibuvOutputConsumer)state;
libuvOutputConsumer._socket.Dispose();
Expand Down

0 comments on commit 093a6fe

Please sign in to comment.