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

[Server] [Performance] Reduce locking in CustomNodeManager2 #2895

Closed
Closed
29 changes: 15 additions & 14 deletions Applications/Quickstarts.Servers/Alarms/AlarmNodeManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@

using System;
using System.Collections.Generic;
using System.Globalization;
using System.Threading;
using Opc.Ua;
using Opc.Ua.Server;
Expand Down Expand Up @@ -143,7 +144,7 @@ public override void CreateAddressSpace(IDictionary<NodeId, IList<IReference>> e

Type alarmControllerType = Type.GetType("Alarms.AlarmController");
int interval = 1000;
string intervalString = interval.ToString();
string intervalString = interval.ToString(CultureInfo.InvariantCulture);

int conditionTypeIndex = 0;
#endregion
Expand Down Expand Up @@ -762,23 +763,23 @@ public override void Call(

MethodState method = null;

lock (Lock)
{
// check for valid handle.
NodeHandle initialHandle = GetManagerHandle(systemContext, methodToCall.ObjectId, operationCache);
// check for valid handle.
NodeHandle initialHandle = GetManagerHandle(systemContext, methodToCall.ObjectId, operationCache);

if (initialHandle == null)
if (initialHandle == null)
{
if (ackConfirmMethod)
{
romanett marked this conversation as resolved.
Show resolved Hide resolved
if (ackConfirmMethod)
{
// Mantis 6944
errors[ii] = StatusCodes.BadNodeIdUnknown;
methodToCall.Processed = true;
}

continue;
// Mantis 6944
errors[ii] = StatusCodes.BadNodeIdUnknown;
methodToCall.Processed = true;
}

continue;
}

lock (Lock)
{
// owned by this node manager.
methodToCall.Processed = true;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -187,8 +187,7 @@ public override void CreateAddressSpace(IDictionary<NodeId, IList<IReference>> e

foreach (NodeState node in PredefinedNodes.Values)
{
ConditionState condition = node as ConditionState;
if (condition != null && !Object.ReferenceEquals(condition.Parent, conditionsFolder))
if (node is ConditionState condition && !ReferenceEquals(condition.Parent, conditionsFolder))
{
condition.AddNotifier(SystemContext, null, true, conditionsFolder);
conditionsFolder.AddNotifier(SystemContext, null, false, condition);
Expand Down
2 changes: 1 addition & 1 deletion Libraries/Opc.Ua.Client/Session/TraceableSession.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1300,7 +1300,7 @@ public void ManagedBrowse(RequestHeader requestHeader, ViewDescription view, ILi
{
using (Activity activity = ActivitySource.StartActivity())
{
return await m_session.ManagedBrowseAsync(requestHeader, view, nodesToBrowse, maxResultsToReturn, browseDirection, referenceTypeId, includeSubtypes, nodeClassMask, ct);
return await m_session.ManagedBrowseAsync(requestHeader, view, nodesToBrowse, maxResultsToReturn, browseDirection, referenceTypeId, includeSubtypes, nodeClassMask, ct).ConfigureAwait(false);
romanett marked this conversation as resolved.
Show resolved Hide resolved
}
}

Expand Down
Loading
Loading