< Summary

Information
Class: Ice.Internal.Instance
Assembly: Ice
File(s): /_/csharp/src/Ice/Internal/Instance.cs
Tag: 91_21789722663
Line coverage
73%
Covered lines: 434
Uncovered lines: 159
Coverable lines: 593
Total lines: 1438
Line coverage: 73.1%
Branch coverage
71%
Covered branches: 201
Total branches: 282
Branch coverage: 71.2%
Method coverage
89%
Covered methods: 52
Total methods: 58
Method coverage: 89.6%

Metrics

MethodBranch coverage Crap Score Cyclomatic complexity Line coverage
.ctor(...)100%11100%
updateConnectionObservers()100%11100%
updateThreadObservers()100%11100%
initializationData()100%11100%
traceLevels()100%11100%
defaultsAndOverrides()100%11100%
routerManager()50%2.03280%
locatorManager()50%2.03280%
referenceFactory()100%22100%
outgoingConnectionFactory()50%2.03280%
objectAdapterFactory()100%22100%
protocolSupport()100%11100%
preferIPv6()100%11100%
networkProxy()100%11100%
clientThreadPool()100%22100%
serverThreadPool()66.67%6.29680%
endpointHostResolver()50%2.03280%
retryQueue()50%2.03280%
timer()50%2.03280%
endpointFactoryManager()50%2.03280%
pluginManager()50%2.03280%
messageSizeMax()100%11100%
batchAutoFlushSize()100%11100%
classGraphDepthMax()100%11100%
toStringMode()100%11100%
cacheMessageBuffers()100%11100%
getImplicitContext()100%11100%
createAdmin(...)56.25%481650%
getAdmin()80%11.561075%
addAdminFacet(...)90%10.11090%
removeAdminFacet(...)87.5%8.03892.31%
findAdminFacet(...)87.5%8.04891.67%
findAllAdminFacets()87.5%8.05890.91%
setDefaultLocator(...)50%2.02283.33%
setDefaultRouter(...)50%2.02283.33%
setLogger(...)0%620%
setThreadHook(...)100%210%
addSliceLoader(...)100%210%
initialize(...)70%152.896070.45%
finishSetup(...)87.5%61.244882.09%
destroy()69.57%52.874685.19%
getBufSizeWarn(...)0%620%
setSndBufSizeWarn(...)100%210%
setRcvBufSizeWarn(...)100%210%
updateConnectionObservers()100%1.04166.67%
updateThreadObservers()62.5%8.7877.78%
addAllAdminFacets()83.33%6.05688.89%
setServerProcessProxy(...)25%85.731220%
serverConnectionOptions(...)100%11100%
get_sliceLoader()100%11100%
get_clientConnectionOptions()100%11100%
set_clientConnectionOptions(...)100%11100%
get_retryIntervals()100%11100%
set_retryIntervals(...)100%11100%
createNetworkProxy(...)83.33%6.04690%
readConnectionOptions(...)100%11100%
.cctor()100%11100%
.ctor()100%11100%

File(s)

/_/csharp/src/Ice/Internal/Instance.cs

#LineLine coverage
 1// Copyright (c) ZeroC, Inc.
 2
 3using System.Diagnostics;
 4using System.Globalization;
 5using System.Text;
 6
 7namespace Ice.Internal;
 8
 9public sealed class BufSizeWarnInfo
 10{
 11    // Whether send size warning has been emitted
 12    public bool sndWarn;
 13
 14    // The send size for which the warning was emitted
 15    public int sndSize;
 16
 17    // Whether receive size warning has been emitted
 18    public bool rcvWarn;
 19
 20    // The receive size for which the warning was emitted
 21    public int rcvSize;
 22}
 23
 24public sealed class Instance
 25{
 26    private class ObserverUpdaterI : Ice.Instrumentation.ObserverUpdater
 27    {
 128        public ObserverUpdaterI(Instance instance) => _instance = instance;
 29
 130        public void updateConnectionObservers() => _instance.updateConnectionObservers();
 31
 132        public void updateThreadObservers() => _instance.updateThreadObservers();
 33
 34        private readonly Instance _instance;
 35    }
 36
 37    public Ice.InitializationData initializationData() =>
 38        //
 39        // No check for destruction. It must be possible to access the
 40        // initialization data after destruction.
 41        //
 42        // No mutex lock, immutable.
 43        //
 144        _initData;
 45
 46    public TraceLevels traceLevels()
 47    {
 48        // No mutex lock, immutable.
 49        Debug.Assert(_traceLevels != null);
 150        return _traceLevels;
 51    }
 52
 53    public DefaultsAndOverrides defaultsAndOverrides()
 54    {
 55        // No mutex lock, immutable.
 56        Debug.Assert(_defaultsAndOverrides != null);
 157        return _defaultsAndOverrides;
 58    }
 59
 60    public RouterManager routerManager()
 61    {
 162        lock (_mutex)
 63        {
 164            if (_state == StateDestroyed)
 65            {
 066                throw new Ice.CommunicatorDestroyedException();
 67            }
 68
 69            Debug.Assert(_routerManager != null);
 170            return _routerManager;
 71        }
 172    }
 73
 74    public LocatorManager locatorManager()
 75    {
 176        lock (_mutex)
 77        {
 178            if (_state == StateDestroyed)
 79            {
 080                throw new Ice.CommunicatorDestroyedException();
 81            }
 82
 83            Debug.Assert(_locatorManager != null);
 184            return _locatorManager;
 85        }
 186    }
 87
 88    internal ReferenceFactory referenceFactory()
 89    {
 190        lock (_mutex)
 91        {
 192            if (_state == StateDestroyed)
 93            {
 194                throw new Ice.CommunicatorDestroyedException();
 95            }
 96
 97            Debug.Assert(_referenceFactory != null);
 198            return _referenceFactory;
 99        }
 1100    }
 101
 102    internal OutgoingConnectionFactory outgoingConnectionFactory()
 103    {
 1104        lock (_mutex)
 105        {
 1106            if (_state == StateDestroyed)
 107            {
 0108                throw new Ice.CommunicatorDestroyedException();
 109            }
 110
 111            Debug.Assert(_outgoingConnectionFactory != null);
 1112            return _outgoingConnectionFactory;
 113        }
 1114    }
 115
 116    public ObjectAdapterFactory objectAdapterFactory()
 117    {
 1118        lock (_mutex)
 119        {
 1120            if (_state == StateDestroyed)
 121            {
 1122                throw new Ice.CommunicatorDestroyedException();
 123            }
 124
 125            Debug.Assert(_objectAdapterFactory != null);
 1126            return _objectAdapterFactory;
 127        }
 1128    }
 129
 1130    public int protocolSupport() => _protocolSupport;
 131
 1132    public bool preferIPv6() => _preferIPv6;
 133
 1134    public NetworkProxy networkProxy() => _networkProxy;
 135
 136    public ThreadPool clientThreadPool()
 137    {
 1138        lock (_mutex)
 139        {
 1140            if (_state == StateDestroyed)
 141            {
 1142                throw new Ice.CommunicatorDestroyedException();
 143            }
 144
 145            Debug.Assert(_clientThreadPool != null);
 1146            return _clientThreadPool;
 147        }
 1148    }
 149
 150    public ThreadPool serverThreadPool()
 151    {
 1152        lock (_mutex)
 153        {
 1154            if (_state == StateDestroyed)
 155            {
 0156                throw new Ice.CommunicatorDestroyedException();
 157            }
 158
 1159            if (_serverThreadPool == null) // Lazy initialization.
 160            {
 1161                if (_state == StateDestroyInProgress)
 162                {
 0163                    throw new Ice.CommunicatorDestroyedException();
 164                }
 1165                int timeout = _initData.properties.getIcePropertyAsInt("Ice.ServerIdleTime");
 1166                _serverThreadPool = new ThreadPool(this, "Ice.ThreadPool.Server", timeout);
 167            }
 168
 1169            return _serverThreadPool;
 170        }
 1171    }
 172
 173    public EndpointHostResolver endpointHostResolver()
 174    {
 1175        lock (_mutex)
 176        {
 1177            if (_state == StateDestroyed)
 178            {
 0179                throw new Ice.CommunicatorDestroyedException();
 180            }
 181
 182            Debug.Assert(_endpointHostResolver != null);
 1183            return _endpointHostResolver;
 184        }
 1185    }
 186
 187    public RetryQueue
 188    retryQueue()
 189    {
 1190        lock (_mutex)
 191        {
 1192            if (_state == StateDestroyed)
 193            {
 0194                throw new Ice.CommunicatorDestroyedException();
 195            }
 196
 197            Debug.Assert(_retryQueue != null);
 1198            return _retryQueue;
 199        }
 1200    }
 201
 202    public Timer
 203    timer()
 204    {
 1205        lock (_mutex)
 206        {
 1207            if (_state == StateDestroyed)
 208            {
 0209                throw new Ice.CommunicatorDestroyedException();
 210            }
 211
 212            Debug.Assert(_timer != null);
 1213            return _timer;
 214        }
 1215    }
 216
 217    public EndpointFactoryManager endpointFactoryManager()
 218    {
 1219        lock (_mutex)
 220        {
 1221            if (_state == StateDestroyed)
 222            {
 0223                throw new Ice.CommunicatorDestroyedException();
 224            }
 225
 226            Debug.Assert(_endpointFactoryManager != null);
 1227            return _endpointFactoryManager;
 228        }
 1229    }
 230
 231    public Ice.PluginManager pluginManager()
 232    {
 1233        lock (_mutex)
 234        {
 1235            if (_state == StateDestroyed)
 236            {
 0237                throw new Ice.CommunicatorDestroyedException();
 238            }
 239
 240            Debug.Assert(_pluginManager != null);
 1241            return _pluginManager;
 242        }
 1243    }
 244
 245    public int messageSizeMax() =>
 246        // No mutex lock, immutable.
 1247        _messageSizeMax;
 248
 249    public int batchAutoFlushSize() =>
 250        // No mutex lock, immutable.
 1251        _batchAutoFlushSize;
 252
 253    public int classGraphDepthMax() =>
 254        // No mutex lock, immutable.
 1255        _classGraphDepthMax;
 256
 257    public Ice.ToStringMode
 258    toStringMode() =>
 259        // No mutex lock, immutable
 1260        _toStringMode;
 261
 262    public int cacheMessageBuffers() =>
 263        // No mutex lock, immutable.
 1264        _cacheMessageBuffers;
 265
 1266    public Ice.ImplicitContextI getImplicitContext() => _implicitContext;
 267
 268    public Ice.ObjectPrx createAdmin(Ice.ObjectAdapter adminAdapter, Ice.Identity adminIdentity)
 269    {
 1270        bool createAdapter = adminAdapter == null;
 271
 1272        lock (_mutex)
 273        {
 1274            if (_state == StateDestroyed)
 275            {
 0276                throw new Ice.CommunicatorDestroyedException();
 277            }
 278
 1279            if (adminIdentity == null || adminIdentity.name.Length == 0)
 280            {
 0281                throw new ArgumentException("The admin identity is not valid", nameof(adminIdentity));
 282            }
 283
 1284            if (_adminAdapter != null)
 285            {
 0286                throw new Ice.InitializationException("Admin already created");
 287            }
 288
 1289            if (!_adminEnabled)
 290            {
 0291                throw new Ice.InitializationException("Admin is disabled");
 292            }
 293
 1294            if (createAdapter)
 295            {
 1296                if (_initData.properties.getIceProperty("Ice.Admin.Endpoints").Length > 0)
 297                {
 0298                    adminAdapter = _objectAdapterFactory.createObjectAdapter(
 0299                        "Ice.Admin",
 0300                        router: null,
 0301                        serverAuthenticationOptions: null);
 302                }
 303                else
 304                {
 1305                    throw new Ice.InitializationException("Ice.Admin.Endpoints is not set");
 306                }
 307            }
 308
 1309            _adminIdentity = adminIdentity;
 1310            _adminAdapter = adminAdapter;
 1311            addAllAdminFacets();
 1312        }
 313
 1314        if (createAdapter)
 315        {
 316            try
 317            {
 0318                adminAdapter.activate();
 0319            }
 0320            catch (Ice.LocalException)
 321            {
 322                //
 323                // We cleanup _adminAdapter, however this error is not recoverable
 324                // (can't call again getAdmin() after fixing the problem)
 325                // since all the facets (servants) in the adapter are lost
 326                //
 0327                adminAdapter.destroy();
 0328                lock (_mutex)
 329                {
 0330                    _adminAdapter = null;
 0331                }
 0332                throw;
 333            }
 334        }
 1335        setServerProcessProxy(adminAdapter, adminIdentity);
 1336        return adminAdapter.createProxy(adminIdentity);
 337    }
 338
 339    public Ice.ObjectPrx
 340    getAdmin()
 341    {
 342        Ice.ObjectAdapter adminAdapter;
 343        Ice.Identity adminIdentity;
 344
 1345        lock (_mutex)
 346        {
 1347            if (_state == StateDestroyed)
 348            {
 0349                throw new Ice.CommunicatorDestroyedException();
 350            }
 351
 1352            if (_adminAdapter != null)
 353            {
 1354                return _adminAdapter.createProxy(_adminIdentity);
 355            }
 1356            else if (_adminEnabled)
 357            {
 1358                if (_initData.properties.getIceProperty("Ice.Admin.Endpoints").Length > 0)
 359                {
 1360                    adminAdapter = _objectAdapterFactory.createObjectAdapter(
 1361                        "Ice.Admin",
 1362                        router: null,
 1363                        serverAuthenticationOptions: null);
 364                }
 365                else
 366                {
 1367                    return null;
 368                }
 1369                adminIdentity = new Ice.Identity(
 1370                    "admin",
 1371                    _initData.properties.getIceProperty("Ice.Admin.InstanceName"));
 1372                if (adminIdentity.category.Length == 0)
 373                {
 0374                    adminIdentity.category = System.Guid.NewGuid().ToString();
 375                }
 376
 1377                _adminIdentity = adminIdentity;
 1378                _adminAdapter = adminAdapter;
 1379                addAllAdminFacets();
 380                // continue below outside synchronization
 381            }
 382            else
 383            {
 1384                return null;
 385            }
 386        }
 387
 388        try
 389        {
 1390            adminAdapter.activate();
 1391        }
 0392        catch (Ice.LocalException)
 393        {
 394            //
 395            // We cleanup _adminAdapter, however this error is not recoverable
 396            // (can't call again getAdmin() after fixing the problem)
 397            // since all the facets (servants) in the adapter are lost
 398            //
 0399            adminAdapter.destroy();
 0400            lock (_mutex)
 401            {
 0402                _adminAdapter = null;
 0403            }
 0404            throw;
 405        }
 406
 1407        setServerProcessProxy(adminAdapter, adminIdentity);
 1408        return adminAdapter.createProxy(adminIdentity);
 1409    }
 410
 411    public void
 412    addAdminFacet(Ice.Object servant, string facet)
 413    {
 1414        lock (_mutex)
 415        {
 1416            if (_state == StateDestroyed)
 417            {
 0418                throw new Ice.CommunicatorDestroyedException();
 419            }
 420
 1421            if (_adminAdapter == null || (_adminFacetFilter.Count > 0 && !_adminFacetFilter.Contains(facet)))
 422            {
 1423                if (_adminFacets.ContainsKey(facet))
 424                {
 1425                    throw new Ice.AlreadyRegisteredException("facet", facet);
 426                }
 1427                _adminFacets.Add(facet, servant);
 428            }
 429            else
 430            {
 1431                _adminAdapter.addFacet(servant, _adminIdentity, facet);
 432            }
 1433        }
 1434    }
 435
 436    public Ice.Object
 437    removeAdminFacet(string facet)
 438    {
 1439        lock (_mutex)
 440        {
 1441            if (_state == StateDestroyed)
 442            {
 0443                throw new Ice.CommunicatorDestroyedException();
 444            }
 445
 1446            Ice.Object result = null;
 1447            if (_adminAdapter == null || (_adminFacetFilter.Count > 0 && !_adminFacetFilter.Contains(facet)))
 448            {
 449                try
 450                {
 1451                    result = _adminFacets[facet];
 1452                }
 1453                catch (KeyNotFoundException)
 454                {
 1455                    throw new Ice.NotRegisteredException("facet", facet);
 456                }
 457
 1458                _adminFacets.Remove(facet);
 459            }
 460            else
 461            {
 1462                result = _adminAdapter.removeFacet(_adminIdentity, facet);
 463            }
 1464            return result;
 465        }
 1466    }
 467
 468    public Ice.Object
 469    findAdminFacet(string facet)
 470    {
 1471        lock (_mutex)
 472        {
 1473            if (_state == StateDestroyed)
 474            {
 0475                throw new Ice.CommunicatorDestroyedException();
 476            }
 477
 1478            Ice.Object result = null;
 1479            if (_adminAdapter == null || (_adminFacetFilter.Count > 0 && !_adminFacetFilter.Contains(facet)))
 480            {
 481                try
 482                {
 1483                    result = _adminFacets[facet];
 1484                }
 1485                catch (KeyNotFoundException)
 486                {
 1487                }
 488            }
 489            else
 490            {
 1491                result = _adminAdapter.findFacet(_adminIdentity, facet);
 492            }
 1493            return result;
 494        }
 1495    }
 496
 497    public Dictionary<string, Ice.Object>
 498    findAllAdminFacets()
 499    {
 1500        lock (_mutex)
 501        {
 1502            if (_state == StateDestroyed)
 503            {
 0504                throw new Ice.CommunicatorDestroyedException();
 505            }
 506
 1507            if (_adminAdapter == null)
 508            {
 1509                return new Dictionary<string, Ice.Object>(_adminFacets);
 510            }
 511            else
 512            {
 1513                Dictionary<string, Ice.Object> result = _adminAdapter.findAllFacets(_adminIdentity);
 1514                if (_adminFacets.Count > 0)
 515                {
 1516                    foreach (KeyValuePair<string, Ice.Object> p in _adminFacets)
 517                    {
 1518                        result.Add(p.Key, p.Value);
 519                    }
 520                }
 1521                return result;
 522            }
 523        }
 1524    }
 525
 526    public void
 527    setDefaultLocator(Ice.LocatorPrx locator)
 528    {
 1529        lock (_mutex)
 530        {
 1531            if (_state == StateDestroyed)
 532            {
 0533                throw new Ice.CommunicatorDestroyedException();
 534            }
 535
 1536            _referenceFactory = _referenceFactory.setDefaultLocator(locator);
 1537        }
 1538    }
 539
 540    public void
 541    setDefaultRouter(Ice.RouterPrx router)
 542    {
 1543        lock (_mutex)
 544        {
 1545            if (_state == StateDestroyed)
 546            {
 0547                throw new Ice.CommunicatorDestroyedException();
 548            }
 549
 1550            _referenceFactory = _referenceFactory.setDefaultRouter(router);
 1551        }
 1552    }
 553
 554    internal void setLogger(Logger logger)
 555    {
 556        // Only called by the LoggerPlugin constructor, so no need to lock.
 0557        if (_ownLogger)
 558        {
 0559            _initData.logger!.Dispose();
 560        }
 0561        _initData.logger = logger;
 0562        _ownLogger = true;
 0563    }
 564
 565    public void
 566    setThreadHook(System.Action threadStart, System.Action threadStop)
 567    {
 568        //
 569        // No locking, as it can only be called during plug-in loading
 570        //
 0571        _initData.threadStart = threadStart;
 0572        _initData.threadStop = threadStop;
 0573    }
 574
 0575    internal void addSliceLoader(SliceLoader loader) => _applicationSliceLoader.add(loader);
 576
 577    //
 578    // Only for use by Ice.Communicator
 579    //
 580    internal void initialize(Ice.Communicator communicator, Ice.InitializationData initData)
 581    {
 1582        _state = StateActive;
 1583        _initData = initData;
 584
 585        try
 586        {
 1587            _initData.properties ??= new Properties();
 588
 1589            string programName = _initData.properties.getIceProperty("Ice.ProgramName");
 1590            if (programName.Length == 0)
 591            {
 1592                _initData.properties.setProperty("Ice.ProgramName", AppDomain.CurrentDomain.FriendlyName);
 593                // Re-read it to mark it as used.
 1594                programName = _initData.properties.getIceProperty("Ice.ProgramName");
 595            }
 596
 1597            lock (_staticLock)
 598            {
 1599                if (!_oneOffDone)
 600                {
 1601                    string stdOut = _initData.properties.getIceProperty("Ice.StdOut");
 1602                    string stdErr = _initData.properties.getIceProperty("Ice.StdErr");
 603
 1604                    System.IO.StreamWriter outStream = null;
 605
 1606                    if (stdOut.Length > 0)
 607                    {
 608                        try
 609                        {
 0610                            outStream = System.IO.File.AppendText(stdOut);
 0611                        }
 0612                        catch (IOException ex)
 613                        {
 0614                            throw new FileException($"Cannot append to '{stdOut}'", ex);
 615                        }
 0616                        outStream.AutoFlush = true;
 0617                        Console.Out.Close();
 0618                        Console.SetOut(outStream);
 619                    }
 1620                    if (stdErr.Length > 0)
 621                    {
 0622                        if (stdErr.Equals(stdOut, StringComparison.Ordinal))
 623                        {
 0624                            Console.SetError(outStream);
 625                        }
 626                        else
 627                        {
 0628                            System.IO.StreamWriter errStream = null;
 629                            try
 630                            {
 0631                                errStream = System.IO.File.AppendText(stdErr);
 0632                            }
 0633                            catch (IOException ex)
 634                            {
 0635                                throw new FileException($"Cannot append to '{stdErr}'", ex);
 636                            }
 0637                            errStream.AutoFlush = true;
 0638                            Console.Error.Close();
 0639                            Console.SetError(errStream);
 640                        }
 641                    }
 642
 1643                    _oneOffDone = true;
 644                }
 1645            }
 646
 1647            if (_initData.logger is null)
 648            {
 1649                string logfile = _initData.properties.getIceProperty("Ice.LogFile");
 1650                if (logfile.Length != 0)
 651                {
 1652                    _initData.logger = new FileLoggerI(programName, logfile);
 1653                    _ownLogger = true;
 654                }
 1655                else if (Ice.Util.getProcessLogger() is LoggerI)
 656                {
 657                    //
 658                    // Ice.ConsoleListener is enabled by default.
 659                    //
 1660                    bool console = _initData.properties.getIcePropertyAsInt("Ice.ConsoleListener") > 0;
 1661                    _initData.logger = new TraceLoggerI(programName, console);
 1662                    _ownLogger = true;
 663                }
 664                else
 665                {
 0666                    _initData.logger = Ice.Util.getProcessLogger();
 667                    // _ownLogger remains false
 668                }
 669            }
 670            // else _ownLogger remains false
 671
 1672            _traceLevels = new TraceLevels(_initData.properties);
 673
 1674            _defaultsAndOverrides = new DefaultsAndOverrides(_initData.properties, _initData.logger);
 675
 1676            clientConnectionOptions = readConnectionOptions("Ice.Connection.Client");
 1677            _serverConnectionOptions = readConnectionOptions("Ice.Connection.Server");
 678
 679            // The maximum size of an Ice protocol message in bytes. This is limited to 0x7fffffff, which corresponds to
 680            // the maximum value of a 32-bit signed integer (int).
 681            const int messageSizeMaxUpperLimit = int.MaxValue;
 1682            int messageSizeMax = _initData.properties.getIcePropertyAsInt("Ice.MessageSizeMax");
 1683            if (messageSizeMax > messageSizeMaxUpperLimit / 1024)
 684            {
 0685                throw new Ice.InitializationException(
 0686                    $"Ice.MessageSizeMax '{messageSizeMax}' is too large, it must be less than or equal to '{messageSize
 687            }
 1688            else if (messageSizeMax < 1)
 689            {
 0690                _messageSizeMax = messageSizeMaxUpperLimit;
 691            }
 692            else
 693            {
 694                // The property is specified in kibibytes (KiB); _messageSizeMax is stored in bytes.
 1695                _messageSizeMax = messageSizeMax * 1024;
 696            }
 697
 1698            int batchAutoFlushSize = _initData.properties.getIcePropertyAsInt("Ice.BatchAutoFlushSize");
 1699            if (batchAutoFlushSize > messageSizeMaxUpperLimit / 1024)
 700            {
 0701                throw new Ice.InitializationException(
 0702                    $"Ice.BatchAutoFlushSize '{batchAutoFlushSize}' is too large, it must be less than or equal to '{mes
 703            }
 1704            else if (batchAutoFlushSize < 1)
 705            {
 0706                _batchAutoFlushSize = messageSizeMaxUpperLimit;
 707            }
 708            else
 709            {
 710                // The property is specified in kibibytes (KiB); _batchAutoFlushSize is stored in bytes.
 1711                _batchAutoFlushSize = batchAutoFlushSize * 1024;
 712            }
 713
 1714            int classGraphDepthMax = _initData.properties.getIcePropertyAsInt("Ice.ClassGraphDepthMax");
 1715            if (classGraphDepthMax < 1)
 716            {
 0717                _classGraphDepthMax = 0x7fffffff;
 718            }
 719            else
 720            {
 1721                _classGraphDepthMax = classGraphDepthMax;
 722            }
 723
 724            // Update _initData.sliceLoader
 725
 1726            if (_initData.sliceLoader is not null)
 727            {
 1728                _applicationSliceLoader.add(_initData.sliceLoader);
 729            }
 730
 731            // We create a lazy Slice loader that searches assemblies the first time we unmarshal a class or
 732            // exception. At that time, all the assemblies should have been loaded.
 1733            var lazySliceLoader = new LazySliceLoader(
 1734                () => SliceLoader.fromAssemblies(AppDomain.CurrentDomain.GetAssemblies()));
 735
 1736            _initData.sliceLoader = new CompositeSliceLoader(_applicationSliceLoader, lazySliceLoader);
 737
 1738            string toStringModeStr = _initData.properties.getIceProperty("Ice.ToStringMode");
 1739            if (toStringModeStr == "Unicode")
 740            {
 1741                _toStringMode = Ice.ToStringMode.Unicode;
 742            }
 0743            else if (toStringModeStr == "ASCII")
 744            {
 0745                _toStringMode = Ice.ToStringMode.ASCII;
 746            }
 0747            else if (toStringModeStr == "Compat")
 748            {
 0749                _toStringMode = Ice.ToStringMode.Compat;
 750            }
 751            else
 752            {
 0753                throw new Ice.InitializationException(
 0754                    "The value for Ice.ToStringMode must be Unicode, ASCII or Compat");
 755            }
 756
 1757            _cacheMessageBuffers = _initData.properties.getIcePropertyAsInt("Ice.CacheMessageBuffers");
 758
 1759            _implicitContext = Ice.ImplicitContextI.create(_initData.properties.getIceProperty("Ice.ImplicitContext"));
 1760            _routerManager = new RouterManager();
 761
 1762            _locatorManager = new LocatorManager(_initData.properties);
 763
 1764            _referenceFactory = new ReferenceFactory(this, communicator);
 765
 1766            bool isIPv6Supported = Network.isIPv6Supported();
 1767            bool ipv4 = _initData.properties.getIcePropertyAsInt("Ice.IPv4") > 0;
 1768            bool ipv6 = isIPv6Supported && _initData.properties.getIcePropertyAsInt("Ice.IPv6") > 0;
 1769            if (!ipv4 && !ipv6)
 770            {
 0771                throw new Ice.InitializationException("Both IPV4 and IPv6 support cannot be disabled.");
 772            }
 1773            else if (ipv4 && ipv6)
 774            {
 1775                _protocolSupport = Network.EnableBoth;
 776            }
 1777            else if (ipv4)
 778            {
 1779                _protocolSupport = Network.EnableIPv4;
 780            }
 781            else
 782            {
 1783                _protocolSupport = Network.EnableIPv6;
 784            }
 1785            _preferIPv6 = _initData.properties.getIcePropertyAsInt("Ice.PreferIPv6Address") > 0;
 786
 1787            _networkProxy = createNetworkProxy(_initData.properties, _protocolSupport);
 788
 1789            _sslEngine = new Ice.SSL.SSLEngine(communicator);
 790
 1791            _endpointFactoryManager = new EndpointFactoryManager(this);
 792
 1793            var tcpInstance = new ProtocolInstance(this, Ice.TCPEndpointType.value, "tcp", false);
 1794            _endpointFactoryManager.add(new TcpEndpointFactory(tcpInstance));
 795
 1796            var udpInstance = new ProtocolInstance(this, Ice.UDPEndpointType.value, "udp", false);
 1797            _endpointFactoryManager.add(new UdpEndpointFactory(udpInstance));
 798
 1799            var wsInstance = new ProtocolInstance(this, Ice.WSEndpointType.value, "ws", false);
 1800            _endpointFactoryManager.add(new WSEndpointFactory(wsInstance, Ice.TCPEndpointType.value));
 801
 1802            var sslInstance = new Ice.SSL.Instance(_sslEngine, Ice.SSLEndpointType.value, "ssl");
 1803            _endpointFactoryManager.add(new Ice.SSL.EndpointFactoryI(sslInstance, Ice.TCPEndpointType.value));
 804
 1805            var wssInstance = new ProtocolInstance(this, Ice.WSSEndpointType.value, "wss", true);
 1806            _endpointFactoryManager.add(new WSEndpointFactory(wssInstance, Ice.SSLEndpointType.value));
 807
 1808            _pluginManager = new Ice.PluginManagerI(communicator);
 809
 1810            _outgoingConnectionFactory = new OutgoingConnectionFactory(this);
 811
 1812            _objectAdapterFactory = new ObjectAdapterFactory(this, communicator);
 813
 1814            _retryQueue = new RetryQueue(this);
 815
 1816            string[] retryValues = _initData.properties.getIcePropertyAsList("Ice.RetryIntervals");
 1817            if (retryValues.Length == 0)
 818            {
 0819                retryIntervals = [0];
 820            }
 821            else
 822            {
 1823                retryIntervals = new int[retryValues.Length];
 824
 1825                for (int i = 0; i < retryValues.Length; i++)
 826                {
 827                    int v;
 828
 829                    try
 830                    {
 1831                        v = int.Parse(retryValues[i], CultureInfo.InvariantCulture);
 1832                    }
 0833                    catch (System.FormatException)
 834                    {
 0835                        v = 0;
 0836                    }
 837
 838                    //
 839                    // If -1 is the first value, no retry and wait intervals.
 840                    //
 1841                    if (i == 0 && v == -1)
 842                    {
 1843                        retryIntervals = [];
 1844                        break;
 845                    }
 846
 1847                    retryIntervals[i] = v > 0 ? v : 0;
 848                }
 849            }
 850
 1851            if (_initData.properties.getIcePropertyAsInt("Ice.PreloadAssemblies") > 0)
 852            {
 1853                AssemblyUtil.preloadAssemblies();
 854            }
 1855        }
 0856        catch (Ice.LocalException)
 857        {
 0858            destroy();
 0859            throw;
 860        }
 1861    }
 862
 863    internal void finishSetup(Communicator communicator)
 864    {
 865        //
 866        // Load plug-ins.
 867        //
 868        Debug.Assert(_serverThreadPool == null);
 1869        var pluginManagerImpl = (Ice.PluginManagerI)_pluginManager;
 1870        pluginManagerImpl.loadPlugins();
 871
 872        //
 873        // Initialize the endpoint factories once all the plugins are loaded. This gives
 874        // the opportunity for the endpoint factories to find underlying factories.
 875        //
 1876        _endpointFactoryManager.initialize();
 877
 878        //
 879        // Create Admin facets, if enabled.
 880        //
 881        // Note that any logger-dependent admin facet must be created after we load all plugins,
 882        // since one of these plugins can be a Logger plugin that sets a new logger during loading
 883        //
 884
 1885        if (_initData.properties.getIceProperty("Ice.Admin.Enabled").Length == 0)
 886        {
 1887            _adminEnabled = _initData.properties.getIceProperty("Ice.Admin.Endpoints").Length > 0;
 888        }
 889        else
 890        {
 1891            _adminEnabled = _initData.properties.getIcePropertyAsInt("Ice.Admin.Enabled") > 0;
 892        }
 893
 1894        string[] facetFilter = _initData.properties.getIcePropertyAsList("Ice.Admin.Facets");
 1895        if (facetFilter.Length > 0)
 896        {
 1897            foreach (string s in facetFilter)
 898            {
 1899                _adminFacetFilter.Add(s);
 900            }
 901        }
 902
 1903        if (_adminEnabled)
 904        {
 905            //
 906            // Process facet
 907            //
 1908            string processFacetName = "Process";
 1909            if (_adminFacetFilter.Count == 0 || _adminFacetFilter.Contains(processFacetName))
 910            {
 1911                _adminFacets.Add(processFacetName, new ProcessI(communicator));
 912            }
 913
 914            //
 915            // Logger facet
 916            //
 1917            string loggerFacetName = "Logger";
 1918            if (_adminFacetFilter.Count == 0 || _adminFacetFilter.Contains(loggerFacetName))
 919            {
 1920                LoggerAdminLogger logger = new LoggerAdminLoggerI(_initData.properties, _initData.logger);
 921                // Decorate the existing logger, and don't change _ownLogger.
 1922                _initData.logger = logger;
 1923                _adminFacets.Add(loggerFacetName, logger.getFacet());
 924            }
 925
 926            //
 927            // Properties facet
 928            //
 1929            string propertiesFacetName = "Properties";
 1930            NativePropertiesAdmin propsAdmin = null;
 1931            if (_adminFacetFilter.Count == 0 || _adminFacetFilter.Contains(propertiesFacetName))
 932            {
 1933                propsAdmin = new NativePropertiesAdmin(this);
 1934                _adminFacets.Add(propertiesFacetName, propsAdmin);
 935            }
 936
 937            //
 938            // Metrics facet
 939            //
 1940            string metricsFacetName = "Metrics";
 1941            if (_adminFacetFilter.Count == 0 || _adminFacetFilter.Contains(metricsFacetName))
 942            {
 1943                var observer = new CommunicatorObserverI(_initData);
 1944                _initData.observer = observer;
 1945                _adminFacets.Add(metricsFacetName, observer.getFacet());
 946
 947                //
 948                // Make sure the admin plugin receives property updates.
 949                //
 1950                propsAdmin?.addUpdateCallback(observer.getFacet().updated);
 951            }
 952        }
 953
 954        //
 955        // Set observer updater
 956        //
 1957        _initData.observer?.setObserverUpdater(new ObserverUpdaterI(this));
 958
 959        //
 960        // Create threads.
 961        //
 962        try
 963        {
 1964            _timer = new Timer(this, Util.stringToThreadPriority(
 1965                                            initializationData().properties.getIceProperty("Ice.ThreadPriority")));
 1966        }
 0967        catch (System.Exception ex)
 968        {
 0969            string s = "cannot create thread for timer:\n" + ex;
 0970            _initData.logger.error(s);
 0971            throw;
 972        }
 973
 974        try
 975        {
 1976            _endpointHostResolver = new EndpointHostResolver(this);
 1977        }
 0978        catch (System.Exception ex)
 979        {
 0980            string s = "cannot create thread for endpoint host resolver:\n" + ex;
 0981            _initData.logger.error(s);
 0982            throw;
 983        }
 1984        _clientThreadPool = new ThreadPool(this, "Ice.ThreadPool.Client", 0);
 985
 986        //
 987        // The default router/locator may have been set during the loading of plugins.
 988        // Therefore we make sure it is not already set before checking the property.
 989        //
 1990        if (_referenceFactory.getDefaultRouter() == null)
 991        {
 1992            Ice.RouterPrx r = Ice.RouterPrxHelper.uncheckedCast(
 1993                communicator.propertyToProxy("Ice.Default.Router"));
 1994            if (r != null)
 995            {
 0996                _referenceFactory = _referenceFactory.setDefaultRouter(r);
 997            }
 998        }
 999
 11000        if (_referenceFactory.getDefaultLocator() == null)
 1001        {
 11002            Ice.LocatorPrx l = Ice.LocatorPrxHelper.uncheckedCast(
 11003                communicator.propertyToProxy("Ice.Default.Locator"));
 11004            if (l != null)
 1005            {
 11006                _referenceFactory = _referenceFactory.setDefaultLocator(l);
 1007            }
 1008        }
 1009
 1010        //
 1011        // Show process id if requested (but only once).
 1012        //
 11013        lock (_mutex)
 1014        {
 11015            if (!_printProcessIdDone && _initData.properties.getIcePropertyAsInt("Ice.PrintProcessId") > 0)
 1016            {
 01017                using var p = System.Diagnostics.Process.GetCurrentProcess();
 01018                Console.WriteLine(p.Id);
 01019                _printProcessIdDone = true;
 1020            }
 11021        }
 1022
 1023        // SslEngine initialization
 11024        _sslEngine.initialize();
 1025
 1026        //
 1027        // Server thread pool initialization is lazy in serverThreadPool().
 1028        //
 1029
 1030        //
 1031        // An application can set Ice.InitPlugins=0 if it wants to postpone
 1032        // initialization until after it has interacted directly with the
 1033        // plug-ins.
 1034        //
 11035        if (_initData.properties.getIcePropertyAsInt("Ice.InitPlugins") > 0)
 1036        {
 11037            pluginManagerImpl.initializePlugins();
 1038        }
 1039
 1040        //
 1041        // This must be done last as this call creates the Ice.Admin object adapter
 1042        // and eventually registers a process proxy with the Ice locator (allowing
 1043        // remote clients to invoke on Ice.Admin facets as soon as it's registered).
 1044        //
 11045        if (_initData.properties.getIcePropertyAsInt("Ice.Admin.DelayCreation") <= 0)
 1046        {
 11047            getAdmin();
 1048        }
 11049    }
 1050
 1051    //
 1052    // Only for use by Ice.Communicator
 1053    //
 1054    public void destroy()
 1055    {
 11056        lock (_mutex)
 1057        {
 1058            //
 1059            // If destroy is in progress, wait for it to be done. This
 1060            // is necessary in case destroy() is called concurrently
 1061            // by multiple threads.
 1062            //
 11063            while (_state == StateDestroyInProgress)
 1064            {
 01065                Monitor.Wait(_mutex);
 1066            }
 1067
 11068            if (_state == StateDestroyed)
 1069            {
 11070                return;
 1071            }
 11072            _state = StateDestroyInProgress;
 11073        }
 1074
 1075        //
 1076        // Shutdown and destroy all the incoming and outgoing Ice
 1077        // connections and wait for the connections to be finished.
 1078        //
 11079        _objectAdapterFactory?.shutdown();
 1080
 11081        _outgoingConnectionFactory?.destroy();
 1082
 11083        _objectAdapterFactory?.destroy();
 1084
 11085        _outgoingConnectionFactory?.waitUntilFinished();
 1086
 11087        _retryQueue?.destroy(); // Must be called before destroying thread pools.
 1088
 11089        _initData.observer?.setObserverUpdater(null);
 1090
 11091        if (_initData.logger is LoggerAdminLogger loggerAdminLogger)
 1092        {
 1093            // In effect, remove the decorator.
 11094            loggerAdminLogger.detach();
 1095        }
 1096
 1097        //
 1098        // Now, destroy the thread pools. This must be done *only* after
 1099        // all the connections are finished (the connections destruction
 1100        // can require invoking callbacks with the thread pools).
 1101        //
 11102        _serverThreadPool?.destroy();
 11103        _clientThreadPool?.destroy();
 11104        _endpointHostResolver?.destroy();
 1105
 1106        //
 1107        // Wait for all the threads to be finished.
 1108        //
 11109        _timer?.destroy();
 11110        _clientThreadPool?.joinWithAllThreads();
 11111        _serverThreadPool?.joinWithAllThreads();
 11112        _endpointHostResolver?.joinWithThread();
 1113
 11114        _routerManager?.destroy();
 1115
 11116        _locatorManager?.destroy();
 1117
 11118        if (_initData.properties.getIcePropertyAsInt("Ice.Warn.UnusedProperties") > 0)
 1119        {
 01120            List<string> unusedProperties = _initData.properties.getUnusedProperties();
 01121            if (unusedProperties.Count != 0)
 1122            {
 01123                var message = new StringBuilder("The following properties were set but never read:");
 01124                foreach (string s in unusedProperties)
 1125                {
 01126                    message.Append("\n    ");
 01127                    message.Append(s);
 1128                }
 01129                _initData.logger.warning(message.ToString());
 1130            }
 1131        }
 1132
 1133        //
 1134        // Destroy last so that a Logger plugin can receive all log/traces before its destruction.
 1135        //
 11136        _pluginManager?.destroy();
 1137
 11138        lock (_mutex)
 1139        {
 11140            _objectAdapterFactory = null;
 11141            _outgoingConnectionFactory = null;
 11142            _retryQueue = null;
 1143
 11144            _serverThreadPool = null;
 11145            _clientThreadPool = null;
 11146            _endpointHostResolver = null;
 11147            _timer = null;
 1148
 11149            _referenceFactory = null;
 11150            _routerManager = null;
 11151            _locatorManager = null;
 11152            _endpointFactoryManager = null;
 11153            _pluginManager = null;
 1154
 11155            _adminAdapter = null;
 11156            _adminFacets.Clear();
 1157
 11158            _state = StateDestroyed;
 11159            Monitor.PulseAll(_mutex);
 11160        }
 1161
 11162        if (_ownLogger)
 1163        {
 11164            _initData.logger!.Dispose();
 1165        }
 11166    }
 1167
 1168    public BufSizeWarnInfo getBufSizeWarn(short type)
 1169    {
 01170        lock (_setBufSizeWarn)
 1171        {
 1172            BufSizeWarnInfo info;
 01173            if (!_setBufSizeWarn.TryGetValue(type, out BufSizeWarnInfo value))
 1174            {
 01175                info = new BufSizeWarnInfo();
 01176                info.sndWarn = false;
 01177                info.sndSize = -1;
 01178                info.rcvWarn = false;
 01179                info.rcvSize = -1;
 01180                _setBufSizeWarn.Add(type, info);
 1181            }
 1182            else
 1183            {
 01184                info = _setBufSizeWarn[type];
 1185            }
 01186            return info;
 1187        }
 01188    }
 1189
 1190    public void setSndBufSizeWarn(short type, int size)
 1191    {
 01192        lock (_setBufSizeWarn)
 1193        {
 01194            BufSizeWarnInfo info = getBufSizeWarn(type);
 01195            info.sndWarn = true;
 01196            info.sndSize = size;
 01197            _setBufSizeWarn[type] = info;
 01198        }
 01199    }
 1200
 1201    public void setRcvBufSizeWarn(short type, int size)
 1202    {
 01203        lock (_setBufSizeWarn)
 1204        {
 01205            BufSizeWarnInfo info = getBufSizeWarn(type);
 01206            info.rcvWarn = true;
 01207            info.rcvSize = size;
 01208            _setBufSizeWarn[type] = info;
 01209        }
 01210    }
 1211
 1212    internal void updateConnectionObservers()
 1213    {
 1214        try
 1215        {
 1216            Debug.Assert(_outgoingConnectionFactory != null);
 11217            _outgoingConnectionFactory.updateConnectionObservers();
 1218            Debug.Assert(_objectAdapterFactory != null);
 11219            _objectAdapterFactory.updateConnectionObservers();
 11220        }
 01221        catch (Ice.CommunicatorDestroyedException)
 1222        {
 01223        }
 11224    }
 1225
 1226    internal void updateThreadObservers()
 1227    {
 1228        try
 1229        {
 11230            _clientThreadPool?.updateObservers();
 11231            _serverThreadPool?.updateObservers();
 1232            Debug.Assert(_objectAdapterFactory != null);
 11233            _objectAdapterFactory.updateThreadObservers();
 11234            _endpointHostResolver?.updateObserver();
 11235            _timer?.updateObserver(_initData.observer);
 11236        }
 01237        catch (Ice.CommunicatorDestroyedException)
 1238        {
 01239        }
 11240    }
 1241
 1242    internal void addAllAdminFacets()
 1243    {
 11244        lock (_mutex)
 1245        {
 11246            var filteredFacets = new Dictionary<string, Ice.Object>();
 1247
 11248            foreach (KeyValuePair<string, Ice.Object> entry in _adminFacets)
 1249            {
 11250                if (_adminFacetFilter.Count == 0 || _adminFacetFilter.Contains(entry.Key))
 1251                {
 11252                    _adminAdapter.addFacet(entry.Value, _adminIdentity, entry.Key);
 1253                }
 1254                else
 1255                {
 01256                    filteredFacets.Add(entry.Key, entry.Value);
 1257                }
 1258            }
 11259            _adminFacets = filteredFacets;
 11260        }
 11261    }
 1262
 1263    internal void setServerProcessProxy(Ice.ObjectAdapter adminAdapter, Ice.Identity adminIdentity)
 1264    {
 11265        Ice.ObjectPrx admin = adminAdapter.createProxy(adminIdentity);
 11266        Ice.LocatorPrx locator = adminAdapter.getLocator();
 11267        string serverId = _initData.properties.getIceProperty("Ice.Admin.ServerId");
 1268
 11269        if (locator != null && serverId.Length > 0)
 1270        {
 01271            Ice.ProcessPrx process = Ice.ProcessPrxHelper.uncheckedCast(admin.ice_facet("Process"));
 1272            try
 1273            {
 1274                //
 1275                // Note that as soon as the process proxy is registered, the communicator might be
 1276                // shutdown by a remote client and admin facets might start receiving calls.
 1277                //
 01278                locator.getRegistry().setServerProcessProxy(serverId, process);
 01279            }
 01280            catch (Ice.ServerNotFoundException)
 1281            {
 01282                if (_traceLevels.location >= 1)
 1283                {
 01284                    var s = new System.Text.StringBuilder();
 01285                    s.Append("couldn't register server `" + serverId + "' with the locator registry:\n");
 01286                    s.Append("the server is not known to the locator registry");
 01287                    _initData.logger.trace(_traceLevels.locationCat, s.ToString());
 1288                }
 1289
 01290                throw new Ice.InitializationException("Locator knows nothing about server `" + serverId + "'");
 1291            }
 01292            catch (Ice.LocalException ex)
 1293            {
 01294                if (_traceLevels.location >= 1)
 1295                {
 01296                    var s = new System.Text.StringBuilder();
 01297                    s.Append("couldn't register server `" + serverId + "' with the locator registry:\n" + ex);
 01298                    _initData.logger.trace(_traceLevels.locationCat, s.ToString());
 1299                }
 01300                throw; // TODO: Shall we raise a special exception instead of a non obvious local exception?
 1301            }
 1302
 01303            if (_traceLevels.location >= 1)
 1304            {
 01305                var s = new System.Text.StringBuilder();
 01306                s.Append("registered server `" + serverId + "' with the locator registry");
 01307                _initData.logger.trace(_traceLevels.locationCat, s.ToString());
 1308            }
 1309        }
 11310    }
 1311
 1312    internal ConnectionOptions serverConnectionOptions(string adapterName)
 1313    {
 1314        Debug.Assert(adapterName.Length > 0);
 11315        Properties properties = _initData.properties;
 11316        string propertyPrefix = $"{adapterName}.Connection";
 1317
 11318        return new(
 11319            connectTimeout: TimeSpan.FromSeconds(properties.getPropertyAsIntWithDefault(
 11320                $"{propertyPrefix}.ConnectTimeout",
 11321                (int)_serverConnectionOptions.connectTimeout.TotalSeconds)),
 11322
 11323            closeTimeout: TimeSpan.FromSeconds(properties.getPropertyAsIntWithDefault(
 11324                $"{propertyPrefix}.CloseTimeout",
 11325                (int)_serverConnectionOptions.closeTimeout.TotalSeconds)),
 11326
 11327            idleTimeout: TimeSpan.FromSeconds(properties.getPropertyAsIntWithDefault(
 11328                $"{propertyPrefix}.IdleTimeout",
 11329                (int)_serverConnectionOptions.idleTimeout.TotalSeconds)),
 11330
 11331            enableIdleCheck: properties.getPropertyAsIntWithDefault(
 11332                $"{propertyPrefix}.EnableIdleCheck",
 11333                _serverConnectionOptions.enableIdleCheck ? 1 : 0) > 0,
 11334
 11335            inactivityTimeout: TimeSpan.FromSeconds(properties.getPropertyAsIntWithDefault(
 11336                $"{propertyPrefix}.InactivityTimeout",
 11337                (int)_serverConnectionOptions.inactivityTimeout.TotalSeconds)),
 11338
 11339            maxDispatches: properties.getPropertyAsIntWithDefault(
 11340                $"{propertyPrefix}.MaxDispatches",
 11341                _serverConnectionOptions.maxDispatches));
 1342    }
 1343
 11344    internal SliceLoader sliceLoader => _initData.sliceLoader; // set in initialize
 1345
 11346    internal ConnectionOptions clientConnectionOptions { get; private set; } = null!; // set in initialize
 1347
 11348    internal int[] retryIntervals { get; private set; }
 1349
 1350    private NetworkProxy createNetworkProxy(Ice.Properties props, int protocolSupport)
 1351    {
 1352        string proxyHost;
 1353
 11354        proxyHost = props.getIceProperty("Ice.SOCKSProxyHost");
 11355        if (proxyHost.Length > 0)
 1356        {
 11357            if (protocolSupport == Network.EnableIPv6)
 1358            {
 01359                throw new Ice.InitializationException("IPv6 only is not supported with SOCKS4 proxies");
 1360            }
 11361            int proxyPort = props.getIcePropertyAsInt("Ice.SOCKSProxyPort");
 11362            return new SOCKSNetworkProxy(proxyHost, proxyPort);
 1363        }
 1364
 11365        proxyHost = props.getIceProperty("Ice.HTTPProxyHost");
 11366        if (proxyHost.Length > 0)
 1367        {
 11368            return new HTTPNetworkProxy(proxyHost, props.getIcePropertyAsInt("Ice.HTTPProxyPort"));
 1369        }
 1370
 11371        return null;
 1372    }
 1373
 1374    private ConnectionOptions readConnectionOptions(string propertyPrefix)
 1375    {
 11376        Properties properties = _initData.properties;
 1377
 1378        // The TimeSpan value can be <= 0. In this case, the timeout is considered infinite.
 11379        return new(
 11380            connectTimeout: TimeSpan.FromSeconds(properties.getIcePropertyAsInt($"{propertyPrefix}.ConnectTimeout")),
 11381            closeTimeout: TimeSpan.FromSeconds(properties.getIcePropertyAsInt($"{propertyPrefix}.CloseTimeout")),
 11382            idleTimeout: TimeSpan.FromSeconds(properties.getIcePropertyAsInt($"{propertyPrefix}.IdleTimeout")),
 11383            enableIdleCheck: properties.getIcePropertyAsInt($"{propertyPrefix}.EnableIdleCheck") > 0,
 11384            inactivityTimeout:
 11385                TimeSpan.FromSeconds(properties.getIcePropertyAsInt($"{propertyPrefix}.InactivityTimeout")),
 11386            maxDispatches: properties.getIcePropertyAsInt($"{propertyPrefix}.MaxDispatches"));
 1387    }
 1388
 1389    private static bool _printProcessIdDone;
 1390    private static bool _oneOffDone;
 11391    private static readonly object _staticLock = new object();
 1392
 1393    private const int StateActive = 0;
 1394    private const int StateDestroyInProgress = 1;
 1395    private const int StateDestroyed = 2;
 1396
 1397    private int _state;
 1398    private Ice.InitializationData _initData; // Immutable, not reset by destroy().
 1399    private bool _ownLogger; // When true, this instance owns _initData.logger and must dispose it.
 1400
 1401    private TraceLevels _traceLevels; // Immutable, not reset by destroy().
 1402    private DefaultsAndOverrides _defaultsAndOverrides; // Immutable, not reset by destroy().
 1403    private int _messageSizeMax; // Immutable, not reset by destroy().
 1404    private int _batchAutoFlushSize; // Immutable, not reset by destroy().
 1405    private int _classGraphDepthMax; // Immutable, not reset by destroy().
 1406    private Ice.ToStringMode _toStringMode; // Immutable, not reset by destroy().
 1407    private int _cacheMessageBuffers; // Immutable, not reset by destroy().
 1408    private Ice.ImplicitContextI _implicitContext; // Immutable
 1409    private RouterManager _routerManager;
 1410    private LocatorManager _locatorManager;
 1411    private ReferenceFactory _referenceFactory;
 1412    private OutgoingConnectionFactory _outgoingConnectionFactory;
 1413    private ObjectAdapterFactory _objectAdapterFactory;
 1414    private int _protocolSupport;
 1415    private bool _preferIPv6;
 1416    private NetworkProxy _networkProxy;
 1417    private ThreadPool _clientThreadPool;
 1418    private ThreadPool _serverThreadPool;
 1419    private EndpointHostResolver _endpointHostResolver;
 1420    private Timer _timer;
 1421    private RetryQueue _retryQueue;
 1422    private EndpointFactoryManager _endpointFactoryManager;
 1423    private Ice.PluginManager _pluginManager;
 1424    private bool _adminEnabled;
 1425    private Ice.ObjectAdapter _adminAdapter;
 11426    private Dictionary<string, Ice.Object> _adminFacets = new();
 11427    private readonly HashSet<string> _adminFacetFilter = new();
 1428    private Ice.Identity _adminIdentity;
 11429    private readonly Dictionary<short, BufSizeWarnInfo> _setBufSizeWarn = new();
 1430    private ConnectionOptions _serverConnectionOptions; // set in initialize
 1431    private Ice.SSL.SSLEngine _sslEngine;
 1432
 1433    // The Slice loader(s) added by the application: initData.sliceLoader followed by the loaders added by
 1434    // addSliceLoader.
 11435    private readonly CompositeSliceLoader _applicationSliceLoader = new();
 1436
 11437    private readonly object _mutex = new object();
 1438}