Skip to content

Commit

Permalink
Removed the unnecessary lock.
Browse files Browse the repository at this point in the history
  • Loading branch information
yallie committed Jan 10, 2025
1 parent f5106c8 commit f8ca295
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 19 deletions.
10 changes: 5 additions & 5 deletions CoreRemoting.Tests/SessionTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -100,11 +100,11 @@ public void Client_Connect_should_throw_exception_on_invalid_auth_credentials()
ConnectionTimeout = 0,
ServerPort = server.Config.NetworkPort,
MessageEncryption = false,
Credentials = new []
{
new Credential() { Name = "User", Value = "tester" },
new Credential() {Name = "Password", Value = password }
}
Credentials =
[
new() { Name = "User", Value = "tester" },
new() { Name = "Password", Value = password }
]
});

if (shouldThrow)
Expand Down
24 changes: 10 additions & 14 deletions CoreRemoting/RemotingClient.cs
Original file line number Diff line number Diff line change
Expand Up @@ -121,18 +121,14 @@ public RemotingClient(ClientConfig config) : this()

private void OnDisconnected()
{
Dictionary<Guid, ClientRpcContext> activeCalls;
lock (_syncObject)
{
if (_activeCalls == null)
return;

activeCalls = _activeCalls;
_activeCalls = null;
}
var activeCalls = _activeCalls;
_activeCalls = null;

_goodbyeCompletedTaskSource.TrySetResult(true);

if (activeCalls == null)
return;

foreach (var activeCall in activeCalls)
{
activeCall.Value.Error = true;
Expand Down Expand Up @@ -486,9 +482,9 @@ private WireMessage TryDeserialize(byte[] rawMessage)
{
Data = rawMessage,
Error = true,
Iv = Array.Empty<byte>(),
Iv = [],
MessageType = "invalid",
UniqueCallKey = Array.Empty<byte>(),
UniqueCallKey = [],
};
}
}
Expand Down Expand Up @@ -567,7 +563,7 @@ private void ProcessAuthenticationResponseMessage(WireMessage message)
/// <param name="message">Deserialized WireMessage that contains a RemoteDelegateInvocationMessage</param>
private void ProcessRemoteDelegateInvocationMessage(WireMessage message)
{
byte[] sharedSecret = SharedSecret();
var sharedSecret = SharedSecret();

var delegateInvocationMessage =
Serializer
Expand Down Expand Up @@ -685,7 +681,7 @@ private void ProcessRpcResultMessage(WireMessage message)
/// <returns>Results of the remote method invocation</returns>
internal async Task<ClientRpcContext> InvokeRemoteMethod(MethodCallMessage methodCallMessage, bool oneWay = false)
{
byte[] sharedSecret = SharedSecret();
var sharedSecret = SharedSecret();

lock (_syncObject)
{
Expand Down Expand Up @@ -717,7 +713,7 @@ internal async Task<ClientRpcContext> InvokeRemoteMethod(MethodCallMessage metho
keyPair: _keyPair,
uniqueCallKey: clientRpcContext.UniqueCallKey.ToByteArray());

byte[] rawData = Serializer.Serialize(wireMessage);
var rawData = Serializer.Serialize(wireMessage);

_rawMessageTransport.LastException = null;

Expand Down

0 comments on commit f8ca295

Please sign in to comment.