Skip to content

Commit cb51153

Browse files
committed
Rework dispose of ServerInternalData
1 parent 8871598 commit cb51153

File tree

2 files changed

+14
-17
lines changed

2 files changed

+14
-17
lines changed

Libraries/Opc.Ua.Server/Server/ServerInternalData.cs

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,9 +30,7 @@
3030
using System;
3131
using System.Collections.Generic;
3232
using System.Globalization;
33-
using System.Security.Cryptography.X509Certificates;
3433
using Opc.Ua.Configuration;
35-
using Opc.Ua.Security.Certificates;
3634

3735
#pragma warning disable 0618
3836

@@ -88,13 +86,22 @@ protected virtual void Dispose(bool disposing)
8886
{
8987
if (disposing)
9088
{
89+
Initialized = false;
90+
9191
Utils.SilentDispose(m_resourceManager);
9292
Utils.SilentDispose(m_requestManager);
9393
Utils.SilentDispose(m_aggregateManager);
9494
Utils.SilentDispose(m_nodeManager);
9595
Utils.SilentDispose(m_sessionManager);
9696
Utils.SilentDispose(m_subscriptionManager);
9797
Utils.SilentDispose(m_monitoredItemQueueFactory);
98+
99+
m_endpointAddresses?.Clear();
100+
m_endpointAddresses = null;
101+
m_typeTree?.Clear();
102+
m_typeTree = null;
103+
m_serverUris = null;
104+
m_defaultSystemContext = null;
98105
}
99106
}
100107
#endregion

Libraries/Opc.Ua.Server/Server/StandardServer.cs

Lines changed: 5 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -56,9 +56,9 @@ public StandardServer(
5656
IServerInternal serverInternal,
5757
IMainNodeManagerFactory mainNodeManagerFactory)
5858
{
59-
m_applicationInstance = applicationInstance;
60-
m_serverInternal = serverInternal;
61-
m_mainNodeManagerFactory = mainNodeManagerFactory;
59+
m_applicationInstance = applicationInstance ?? throw new ArgumentNullException(nameof(applicationInstance));
60+
m_serverInternal = serverInternal ?? throw new ArgumentNullException(nameof(serverInternal));
61+
m_mainNodeManagerFactory = mainNodeManagerFactory ?? throw new ArgumentNullException(nameof(mainNodeManagerFactory)); ;
6262
}
6363
#endregion
6464

@@ -88,12 +88,7 @@ protected override void Dispose(bool disposing)
8888
m_configurationWatcher = null;
8989
}
9090

91-
// close the server.
92-
//if (m_serverInternal != null)
93-
//{
94-
// Utils.SilentDispose(m_serverInternal);
95-
// m_serverInternal = null;
96-
//}
91+
Utils.SilentDispose(m_serverInternal);
9792
}
9893

9994
base.Dispose(disposing);
@@ -3203,12 +3198,7 @@ protected override void OnServerStopping()
32033198
}
32043199
finally
32053200
{
3206-
// ensure that everything is cleaned up.
3207-
//if (m_serverInternal != null)
3208-
//{
3209-
// Utils.SilentDispose(m_serverInternal);
3210-
// m_serverInternal = null;
3211-
//}
3201+
Utils.SilentDispose(m_serverInternal);
32123202
}
32133203
}
32143204

0 commit comments

Comments
 (0)