Skip to content

Commit

Permalink
Close some kinds of misbehaving connections during shutdown (#6684) (#…
Browse files Browse the repository at this point in the history
  • Loading branch information
ReubenBond authored Aug 18, 2020
1 parent b56da8f commit e466b07
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions src/Orleans.Core/Networking/Connection.cs
Original file line number Diff line number Diff line change
Expand Up @@ -135,6 +135,16 @@ public void Close()
// Stop processing incoming messages first.
// This signals the outgoing message processor to exit gracefully and terminate the connection.
this.outgoingMessageWriter.TryComplete();

lock (this.lockObj)
{
if (_processIncomingTask is null || _processOutgoingTask is null)
{
// Connection has not started processing yet and may be stuck in a preparatory stage (eg, due to a misbehaved client).
// This is not yet a functioning connection, so we should close it ungracefully.
this.CloseInternal(new ConnectionAbortedException("Connection is being closed before handshake has completed"));
}
}
}

private void CloseInternal(Exception exception)
Expand Down

0 comments on commit e466b07

Please sign in to comment.