Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Removed the unnecessary lock. #111

Merged
merged 1 commit into from
Jan 10, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading