Skip to content

Commit

Permalink
Avoid race in GatewaySender.Send (#6655)
Browse files Browse the repository at this point in the history
  • Loading branch information
ReubenBond authored Jul 21, 2020
1 parent 8b597c2 commit dc76212
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions src/Orleans.Runtime/Messaging/Gateway.cs
Original file line number Diff line number Diff line change
Expand Up @@ -436,16 +436,19 @@ private void Drain(ClientState clientState)

private bool Send(Message msg, ClientState client)
{
var connection = client.Connection;
if (connection is null) return false;

try
{
client.Connection.Send(msg);
connection.Send(msg);
gatewaySends.Increment();
return true;
}
catch (Exception exception)
{
gateway.RecordClosedConnection(client.Connection);
client.Connection.Abort(new ConnectionAbortedException("Exception posting a message to sender. See InnerException for details.", exception));
gateway.RecordClosedConnection(connection);
connection.Abort(new ConnectionAbortedException("Exception posting a message to sender. See InnerException for details.", exception));
return false;
}
}
Expand Down

0 comments on commit dc76212

Please sign in to comment.