< Summary

Information
Class: Ice.Internal.Instance
Assembly: Ice
File(s): /_/csharp/src/Ice/Internal/Instance.cs
Tag: 125_37167941578
Line coverage
73%
Covered lines: 447
Uncovered lines: 158
Coverable lines: 605
Total lines: 1471
Line coverage: 73.8%
Branch coverage
71%
Covered branches: 209
Total branches: 292
Branch coverage: 71.5%
Method coverage
90%
Covered methods: 48
Fully covered methods: 23
Total methods: 53
Method coverage: 90.5%
Full method coverage: 43.3%

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%2280%
locatorManager()50%2280%
referenceFactory()100%22100%
outgoingConnectionFactory()50%2280%
objectAdapterFactory()100%22100%
protocolSupport()100%11100%
preferIPv6()100%11100%
networkProxy()100%11100%
clientThreadPool()100%22100%
serverThreadPool()66.67%6680%
endpointHostResolver()50%2280%
retryQueue()50%2280%
timer()50%2280%
endpointFactoryManager()50%2280%
pluginManager()50%2280%
messageSizeMax()100%11100%
batchAutoFlushSize()100%11100%
classGraphDepthMax()100%11100%
toStringMode()100%11100%
cacheMessageBuffers()100%11100%
getImplicitContext()100%11100%
createAdmin(...)56.25%481650%
getAdmin()80%121075%
addAdminFacet(...)90%101090%
removeAdminFacet(...)87.5%8892.31%
findAdminFacet(...)87.5%8891.67%
findAllAdminFacets()87.5%8890.91%
setDefaultLocator(...)50%2283.33%
setDefaultRouter(...)50%2283.33%
setLogger(...)0%620%
addSliceLoader(...)100%210%
initialize(...)68.75%1676470.68%
finishSetup(...)87.5%624881.82%
destroy()68.75%554885.71%
getBufSizeWarn(...)0%620%
setSndBufSizeWarn(...)100%210%
setRcvBufSizeWarn(...)100%210%
updateConnectionObservers()50%2275%
updateThreadObservers()90%101083.33%
addAllAdminFacets()83.33%6688.89%
setServerProcessProxy(...)25%861220%
serverConnectionOptions(...)100%11100%
get_sliceLoader()100%11100%
createNetworkProxy(...)83.33%6690%
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
 24// CA1001: Instance holds an IDisposable _sslEngine but follows Ice's destroy()-based
 25// lifecycle instead of IDisposable.
 26#pragma warning disable CA1001
 27public sealed class Instance
 28#pragma warning restore CA1001
 29{
 30    private class ObserverUpdaterI : Ice.Instrumentation.ObserverUpdater
 31    {
 132        public ObserverUpdaterI(Instance instance) => _instance = instance;
 33
 134        public void updateConnectionObservers() => _instance.updateConnectionObservers();
 35
 136        public void updateThreadObservers() => _instance.updateThreadObservers();
 37
 38        private readonly Instance _instance;
 39    }
 40
 41    public Ice.InitializationData initializationData() =>
 42        //
 43        // No check for destruction. It must be possible to access the
 44        // initialization data after destruction.
 45        //
 46        // No mutex lock, immutable.
 47        //
 148        _initData;
 49
 50    public TraceLevels traceLevels()
 51    {
 52        // No mutex lock, immutable.
 53        Debug.Assert(_traceLevels != null);
 154        return _traceLevels;
 55    }
 56
 57    public DefaultsAndOverrides defaultsAndOverrides()
 58    {
 59        // No mutex lock, immutable.
 60        Debug.Assert(_defaultsAndOverrides != null);
 161        return _defaultsAndOverrides;
 62    }
 63
 64    public RouterManager routerManager()
 65    {
 166        lock (_mutex)
 67        {
 168            if (_state == StateDestroyed)
 69            {
 070                throw new Ice.CommunicatorDestroyedException();
 71            }
 72
 73            Debug.Assert(_routerManager != null);
 174            return _routerManager;
 75        }
 176    }
 77
 78    public LocatorManager locatorManager()
 79    {
 180        lock (_mutex)
 81        {
 182            if (_state == StateDestroyed)
 83            {
 084                throw new Ice.CommunicatorDestroyedException();
 85            }
 86
 87            Debug.Assert(_locatorManager != null);
 188            return _locatorManager;
 89        }
 190    }
 91
 92    internal ReferenceFactory referenceFactory()
 93    {
 194        lock (_mutex)
 95        {
 196            if (_state == StateDestroyed)
 97            {
 198                throw new Ice.CommunicatorDestroyedException();
 99            }
 100
 101            Debug.Assert(_referenceFactory != null);
 1102            return _referenceFactory;
 103        }
 1104    }
 105
 106    internal OutgoingConnectionFactory outgoingConnectionFactory()
 107    {
 1108        lock (_mutex)
 109        {
 1110            if (_state == StateDestroyed)
 111            {
 0112                throw new Ice.CommunicatorDestroyedException();
 113            }
 114
 115            Debug.Assert(_outgoingConnectionFactory != null);
 1116            return _outgoingConnectionFactory;
 117        }
 1118    }
 119
 120    public ObjectAdapterFactory objectAdapterFactory()
 121    {
 1122        lock (_mutex)
 123        {
 1124            if (_state == StateDestroyed)
 125            {
 1126                throw new Ice.CommunicatorDestroyedException();
 127            }
 128
 129            Debug.Assert(_objectAdapterFactory != null);
 1130            return _objectAdapterFactory;
 131        }
 1132    }
 133
 1134    public int protocolSupport() => _protocolSupport;
 135
 1136    public bool preferIPv6() => _preferIPv6;
 137
 1138    public NetworkProxy networkProxy() => _networkProxy;
 139
 140    public ThreadPool clientThreadPool()
 141    {
 1142        lock (_mutex)
 143        {
 1144            if (_state == StateDestroyed)
 145            {
 1146                throw new Ice.CommunicatorDestroyedException();
 147            }
 148
 149            Debug.Assert(_clientThreadPool != null);
 1150            return _clientThreadPool;
 151        }
 1152    }
 153
 154    public ThreadPool serverThreadPool()
 155    {
 1156        lock (_mutex)
 157        {
 1158            if (_state == StateDestroyed)
 159            {
 0160                throw new Ice.CommunicatorDestroyedException();
 161            }
 162
 1163            if (_serverThreadPool == null) // Lazy initialization.
 164            {
 1165                if (_state == StateDestroyInProgress)
 166                {
 0167                    throw new Ice.CommunicatorDestroyedException();
 168                }
 1169                int timeout = _initData.properties.getIcePropertyAsInt("Ice.ServerIdleTime");
 1170                _serverThreadPool = new ThreadPool(this, "Ice.ThreadPool.Server", timeout);
 171            }
 172
 1173            return _serverThreadPool;
 174        }
 1175    }
 176
 177    public EndpointHostResolver endpointHostResolver()
 178    {
 1179        lock (_mutex)
 180        {
 1181            if (_state == StateDestroyed)
 182            {
 0183                throw new Ice.CommunicatorDestroyedException();
 184            }
 185
 186            Debug.Assert(_endpointHostResolver != null);
 1187            return _endpointHostResolver;
 188        }
 1189    }
 190
 191    public RetryQueue
 192    retryQueue()
 193    {
 1194        lock (_mutex)
 195        {
 1196            if (_state == StateDestroyed)
 197            {
 0198                throw new Ice.CommunicatorDestroyedException();
 199            }
 200
 201            Debug.Assert(_retryQueue != null);
 1202            return _retryQueue;
 203        }
 1204    }
 205
 206    public Timer
 207    timer()
 208    {
 1209        lock (_mutex)
 210        {
 1211            if (_state == StateDestroyed)
 212            {
 0213                throw new Ice.CommunicatorDestroyedException();
 214            }
 215
 216            Debug.Assert(_timer != null);
 1217            return _timer;
 218        }
 1219    }
 220
 221    public EndpointFactoryManager endpointFactoryManager()
 222    {
 1223        lock (_mutex)
 224        {
 1225            if (_state == StateDestroyed)
 226            {
 0227                throw new Ice.CommunicatorDestroyedException();
 228            }
 229
 230            Debug.Assert(_endpointFactoryManager != null);
 1231            return _endpointFactoryManager;
 232        }
 1233    }
 234
 235    public Ice.PluginManager pluginManager()
 236    {
 1237        lock (_mutex)
 238        {
 1239            if (_state == StateDestroyed)
 240            {
 0241                throw new Ice.CommunicatorDestroyedException();
 242            }
 243
 244            Debug.Assert(_pluginManager != null);
 1245            return _pluginManager;
 246        }
 1247    }
 248
 249    public int messageSizeMax() =>
 250        // No mutex lock, immutable.
 1251        _messageSizeMax;
 252
 253    public int batchAutoFlushSize() =>
 254        // No mutex lock, immutable.
 1255        _batchAutoFlushSize;
 256
 257    public int classGraphDepthMax() =>
 258        // No mutex lock, immutable.
 1259        _classGraphDepthMax;
 260
 261    public Ice.ToStringMode
 262    toStringMode() =>
 263        // No mutex lock, immutable
 1264        _toStringMode;
 265
 266    public int cacheMessageBuffers() =>
 267        // No mutex lock, immutable.
 1268        _cacheMessageBuffers;
 269
 1270    public Ice.ImplicitContextI getImplicitContext() => _implicitContext;
 271
 272    public Ice.ObjectPrx createAdmin(Ice.ObjectAdapter adminAdapter, Ice.Identity adminIdentity)
 273    {
 1274        bool createAdapter = adminAdapter == null;
 275
 1276        lock (_mutex)
 277        {
 1278            if (_state == StateDestroyed)
 279            {
 0280                throw new Ice.CommunicatorDestroyedException();
 281            }
 282
 1283            if (adminIdentity == null || adminIdentity.name.Length == 0)
 284            {
 0285                throw new ArgumentException("The admin identity is not valid", nameof(adminIdentity));
 286            }
 287
 1288            if (_adminAdapter != null)
 289            {
 0290                throw new Ice.InitializationException("Admin already created");
 291            }
 292
 1293            if (!_adminEnabled)
 294            {
 0295                throw new Ice.InitializationException("Admin is disabled");
 296            }
 297
 1298            if (createAdapter)
 299            {
 1300                if (_initData.properties.getIceProperty("Ice.Admin.Endpoints").Length > 0)
 301                {
 0302                    adminAdapter = _objectAdapterFactory.createObjectAdapter(
 0303                        "Ice.Admin",
 0304                        router: null,
 0305                        serverAuthenticationOptions: null);
 306                }
 307                else
 308                {
 1309                    throw new Ice.InitializationException("Ice.Admin.Endpoints is not set");
 310                }
 311            }
 312
 1313            _adminIdentity = adminIdentity;
 1314            _adminAdapter = adminAdapter;
 1315            addAllAdminFacets();
 1316        }
 317
 1318        if (createAdapter)
 319        {
 320            try
 321            {
 0322                adminAdapter.activate();
 0323            }
 0324            catch (Ice.LocalException)
 325            {
 326                //
 327                // We cleanup _adminAdapter, however this error is not recoverable
 328                // (can't call again getAdmin() after fixing the problem)
 329                // since all the facets (servants) in the adapter are lost
 330                //
 0331                adminAdapter.destroy();
 0332                lock (_mutex)
 333                {
 0334                    _adminAdapter = null;
 0335                }
 0336                throw;
 337            }
 338        }
 1339        setServerProcessProxy(adminAdapter, adminIdentity);
 1340        return adminAdapter.createProxy(adminIdentity);
 341    }
 342
 343    public Ice.ObjectPrx
 344    getAdmin()
 345    {
 346        Ice.ObjectAdapter adminAdapter;
 347        Ice.Identity adminIdentity;
 348
 1349        lock (_mutex)
 350        {
 1351            if (_state == StateDestroyed)
 352            {
 0353                throw new Ice.CommunicatorDestroyedException();
 354            }
 355
 1356            if (_adminAdapter != null)
 357            {
 1358                return _adminAdapter.createProxy(_adminIdentity);
 359            }
 1360            else if (_adminEnabled)
 361            {
 1362                if (_initData.properties.getIceProperty("Ice.Admin.Endpoints").Length > 0)
 363                {
 1364                    adminAdapter = _objectAdapterFactory.createObjectAdapter(
 1365                        "Ice.Admin",
 1366                        router: null,
 1367                        serverAuthenticationOptions: null);
 368                }
 369                else
 370                {
 1371                    return null;
 372                }
 1373                adminIdentity = new Ice.Identity(
 1374                    "admin",
 1375                    _initData.properties.getIceProperty("Ice.Admin.InstanceName"));
 1376                if (adminIdentity.category.Length == 0)
 377                {
 0378                    adminIdentity.category = System.Guid.NewGuid().ToString();
 379                }
 380
 1381                _adminIdentity = adminIdentity;
 1382                _adminAdapter = adminAdapter;
 1383                addAllAdminFacets();
 384                // continue below outside synchronization
 385            }
 386            else
 387            {
 1388                return null;
 389            }
 390        }
 391
 392        try
 393        {
 1394            adminAdapter.activate();
 1395        }
 0396        catch (Ice.LocalException)
 397        {
 398            //
 399            // We cleanup _adminAdapter, however this error is not recoverable
 400            // (can't call again getAdmin() after fixing the problem)
 401            // since all the facets (servants) in the adapter are lost
 402            //
 0403            adminAdapter.destroy();
 0404            lock (_mutex)
 405            {
 0406                _adminAdapter = null;
 0407            }
 0408            throw;
 409        }
 410
 1411        setServerProcessProxy(adminAdapter, adminIdentity);
 1412        return adminAdapter.createProxy(adminIdentity);
 1413    }
 414
 415    public void
 416    addAdminFacet(Ice.Object servant, string facet)
 417    {
 1418        lock (_mutex)
 419        {
 1420            if (_state == StateDestroyed)
 421            {
 0422                throw new Ice.CommunicatorDestroyedException();
 423            }
 424
 1425            if (_adminAdapter == null || (_adminFacetFilter.Count > 0 && !_adminFacetFilter.Contains(facet)))
 426            {
 1427                if (_adminFacets.ContainsKey(facet))
 428                {
 1429                    throw new Ice.AlreadyRegisteredException("facet", facet);
 430                }
 1431                _adminFacets.Add(facet, servant);
 432            }
 433            else
 434            {
 1435                _adminAdapter.addFacet(servant, _adminIdentity, facet);
 436            }
 1437        }
 1438    }
 439
 440    public Ice.Object
 441    removeAdminFacet(string facet)
 442    {
 1443        lock (_mutex)
 444        {
 1445            if (_state == StateDestroyed)
 446            {
 0447                throw new Ice.CommunicatorDestroyedException();
 448            }
 449
 1450            Ice.Object result = null;
 1451            if (_adminAdapter == null || (_adminFacetFilter.Count > 0 && !_adminFacetFilter.Contains(facet)))
 452            {
 453                try
 454                {
 1455                    result = _adminFacets[facet];
 1456                }
 1457                catch (KeyNotFoundException)
 458                {
 1459                    throw new Ice.NotRegisteredException("facet", facet);
 460                }
 461
 1462                _adminFacets.Remove(facet);
 463            }
 464            else
 465            {
 1466                result = _adminAdapter.removeFacet(_adminIdentity, facet);
 467            }
 1468            return result;
 469        }
 1470    }
 471
 472    public Ice.Object
 473    findAdminFacet(string facet)
 474    {
 1475        lock (_mutex)
 476        {
 1477            if (_state == StateDestroyed)
 478            {
 0479                throw new Ice.CommunicatorDestroyedException();
 480            }
 481
 1482            Ice.Object result = null;
 1483            if (_adminAdapter == null || (_adminFacetFilter.Count > 0 && !_adminFacetFilter.Contains(facet)))
 484            {
 485                try
 486                {
 1487                    result = _adminFacets[facet];
 1488                }
 1489                catch (KeyNotFoundException)
 490                {
 1491                }
 492            }
 493            else
 494            {
 1495                result = _adminAdapter.findFacet(_adminIdentity, facet);
 496            }
 1497            return result;
 498        }
 1499    }
 500
 501    public Dictionary<string, Ice.Object>
 502    findAllAdminFacets()
 503    {
 1504        lock (_mutex)
 505        {
 1506            if (_state == StateDestroyed)
 507            {
 0508                throw new Ice.CommunicatorDestroyedException();
 509            }
 510
 1511            if (_adminAdapter == null)
 512            {
 1513                return new Dictionary<string, Ice.Object>(_adminFacets);
 514            }
 515            else
 516            {
 1517                Dictionary<string, Ice.Object> result = _adminAdapter.findAllFacets(_adminIdentity);
 1518                if (_adminFacets.Count > 0)
 519                {
 1520                    foreach (KeyValuePair<string, Ice.Object> p in _adminFacets)
 521                    {
 1522                        result.Add(p.Key, p.Value);
 523                    }
 524                }
 1525                return result;
 526            }
 527        }
 1528    }
 529
 530    public void
 531    setDefaultLocator(Ice.LocatorPrx locator)
 532    {
 1533        lock (_mutex)
 534        {
 1535            if (_state == StateDestroyed)
 536            {
 0537                throw new Ice.CommunicatorDestroyedException();
 538            }
 539
 1540            _referenceFactory = _referenceFactory.setDefaultLocator(locator);
 1541        }
 1542    }
 543
 544    public void
 545    setDefaultRouter(Ice.RouterPrx router)
 546    {
 1547        lock (_mutex)
 548        {
 1549            if (_state == StateDestroyed)
 550            {
 0551                throw new Ice.CommunicatorDestroyedException();
 552            }
 553
 1554            _referenceFactory = _referenceFactory.setDefaultRouter(router);
 1555        }
 1556    }
 557
 558    internal void setLogger(Logger logger)
 559    {
 560        // Only called by the LoggerPlugin constructor, so no need to lock.
 0561        if (_ownLogger)
 562        {
 0563            _initData.logger!.Dispose();
 564        }
 0565        _initData.logger = logger;
 0566        _ownLogger = true;
 0567    }
 568
 0569    internal void addSliceLoader(SliceLoader loader) => _applicationSliceLoader.add(loader);
 570
 571    //
 572    // Only for use by Ice.Communicator
 573    //
 574    internal void initialize(Ice.Communicator communicator, Ice.InitializationData initData)
 575    {
 1576        _state = StateActive;
 1577        _initData = initData;
 578
 579        try
 580        {
 1581            _initData.properties ??= new Properties();
 582
 1583            string programName = _initData.properties.getIceProperty("Ice.ProgramName");
 1584            if (programName.Length == 0)
 585            {
 1586                _initData.properties.setProperty("Ice.ProgramName", AppDomain.CurrentDomain.FriendlyName);
 587                // Re-read it to mark it as used.
 1588                programName = _initData.properties.getIceProperty("Ice.ProgramName");
 589            }
 590
 1591            lock (_staticLock)
 592            {
 1593                if (!_oneOffDone)
 594                {
 1595                    string stdOut = _initData.properties.getIceProperty("Ice.StdOut");
 1596                    string stdErr = _initData.properties.getIceProperty("Ice.StdErr");
 597
 1598                    System.IO.StreamWriter outStream = null;
 599
 1600                    if (stdOut.Length > 0)
 601                    {
 602                        try
 603                        {
 0604                            outStream = System.IO.File.AppendText(stdOut);
 0605                        }
 0606                        catch (IOException ex)
 607                        {
 0608                            throw new FileException($"Cannot append to '{stdOut}'", ex);
 609                        }
 0610                        outStream.AutoFlush = true;
 0611                        Console.Out.Close();
 0612                        Console.SetOut(outStream);
 613                    }
 1614                    if (stdErr.Length > 0)
 615                    {
 0616                        if (stdErr.Equals(stdOut, StringComparison.Ordinal))
 617                        {
 0618                            Console.SetError(outStream);
 619                        }
 620                        else
 621                        {
 0622                            System.IO.StreamWriter errStream = null;
 623                            try
 624                            {
 0625                                errStream = System.IO.File.AppendText(stdErr);
 0626                            }
 0627                            catch (IOException ex)
 628                            {
 0629                                throw new FileException($"Cannot append to '{stdErr}'", ex);
 630                            }
 0631                            errStream.AutoFlush = true;
 0632                            Console.Error.Close();
 0633                            Console.SetError(errStream);
 634                        }
 635                    }
 636
 1637                    _oneOffDone = true;
 638                }
 1639            }
 640
 1641            if (_initData.logger is null)
 642            {
 1643                string logfile = _initData.properties.getIceProperty("Ice.LogFile");
 1644                if (logfile.Length != 0)
 645                {
 1646                    _initData.logger = new FileLoggerI(programName, logfile);
 1647                    _ownLogger = true;
 648                }
 1649                else if (Ice.Util.getProcessLogger() is LoggerI)
 650                {
 651                    //
 652                    // Ice.ConsoleListener is enabled by default.
 653                    //
 1654                    bool console = _initData.properties.getIcePropertyAsInt("Ice.ConsoleListener") > 0;
 1655                    _initData.logger = new TraceLoggerI(programName, console);
 1656                    _ownLogger = true;
 657                }
 658                else
 659                {
 0660                    _initData.logger = Ice.Util.getProcessLogger();
 661                    // _ownLogger remains false
 662                }
 663            }
 664            // else _ownLogger remains false
 665
 1666            _traceLevels = new TraceLevels(_initData.properties);
 667
 1668            _defaultsAndOverrides = new DefaultsAndOverrides(_initData.properties, _initData.logger);
 669
 1670            clientConnectionOptions = readConnectionOptions("Ice.Connection.Client");
 1671            _serverConnectionOptions = readConnectionOptions("Ice.Connection.Server");
 672
 673            // The maximum size of an Ice protocol message in bytes. This is limited to 0x7fffffff, which corresponds to
 674            // the maximum value of a 32-bit signed integer (int).
 675            const int messageSizeMaxUpperLimit = int.MaxValue;
 1676            int messageSizeMax = _initData.properties.getIcePropertyAsInt("Ice.MessageSizeMax");
 1677            if (messageSizeMax > messageSizeMaxUpperLimit / 1024)
 678            {
 0679                throw new Ice.InitializationException(
 0680                    $"Ice.MessageSizeMax '{messageSizeMax}' is too large, it must be less than or equal to '{messageSize
 681            }
 1682            else if (messageSizeMax < 1)
 683            {
 0684                _messageSizeMax = messageSizeMaxUpperLimit;
 685            }
 686            else
 687            {
 688                // The property is specified in kibibytes (KiB); _messageSizeMax is stored in bytes.
 1689                _messageSizeMax = messageSizeMax * 1024;
 690            }
 691
 1692            int batchAutoFlushSize = _initData.properties.getIcePropertyAsInt("Ice.BatchAutoFlushSize");
 1693            if (batchAutoFlushSize > messageSizeMaxUpperLimit / 1024)
 694            {
 0695                throw new Ice.InitializationException(
 0696                    $"Ice.BatchAutoFlushSize '{batchAutoFlushSize}' is too large, it must be less than or equal to '{mes
 697            }
 1698            else if (batchAutoFlushSize < 1)
 699            {
 0700                _batchAutoFlushSize = messageSizeMaxUpperLimit;
 701            }
 702            else
 703            {
 704                // The property is specified in kibibytes (KiB); _batchAutoFlushSize is stored in bytes.
 1705                _batchAutoFlushSize = batchAutoFlushSize * 1024;
 706            }
 707
 1708            int classGraphDepthMax = _initData.properties.getIcePropertyAsInt("Ice.ClassGraphDepthMax");
 1709            if (classGraphDepthMax < 1)
 710            {
 0711                _classGraphDepthMax = 0x7fffffff;
 712            }
 713            else
 714            {
 1715                _classGraphDepthMax = classGraphDepthMax;
 716            }
 717
 718            // Update _initData.sliceLoader
 719
 1720            if (_initData.sliceLoader is not null)
 721            {
 1722                _applicationSliceLoader.add(_initData.sliceLoader);
 723            }
 724
 725            // We create a lazy Slice loader that searches assemblies the first time we unmarshal a class or
 726            // exception. At that time, all the assemblies should have been loaded.
 1727            var lazySliceLoader = new LazySliceLoader(
 1728                () => SliceLoader.fromAssemblies(AppDomain.CurrentDomain.GetAssemblies()));
 729
 1730            _initData.sliceLoader = new CompositeSliceLoader(_applicationSliceLoader, lazySliceLoader);
 731
 1732            string toStringModeStr = _initData.properties.getIceProperty("Ice.ToStringMode");
 1733            if (toStringModeStr == "Unicode")
 734            {
 1735                _toStringMode = Ice.ToStringMode.Unicode;
 736            }
 0737            else if (toStringModeStr == "ASCII")
 738            {
 0739                _toStringMode = Ice.ToStringMode.ASCII;
 740            }
 0741            else if (toStringModeStr == "Compat")
 742            {
 0743                _toStringMode = Ice.ToStringMode.Compat;
 744            }
 745            else
 746            {
 0747                throw new Ice.InitializationException(
 0748                    "The value for Ice.ToStringMode must be Unicode, ASCII or Compat");
 749            }
 750
 1751            _cacheMessageBuffers = _initData.properties.getIcePropertyAsInt("Ice.CacheMessageBuffers");
 752
 1753            _implicitContext = Ice.ImplicitContextI.create(_initData.properties.getIceProperty("Ice.ImplicitContext"));
 1754            _routerManager = new RouterManager();
 755
 1756            _locatorManager = new LocatorManager(_initData.properties);
 757
 1758            _referenceFactory = new ReferenceFactory(this, communicator);
 759
 1760            bool isIPv6Supported = Network.isIPv6Supported();
 1761            bool ipv4 = _initData.properties.getIcePropertyAsInt("Ice.IPv4") > 0;
 1762            bool ipv6 = isIPv6Supported && _initData.properties.getIcePropertyAsInt("Ice.IPv6") > 0;
 1763            if (!ipv4 && !ipv6)
 764            {
 0765                throw new Ice.InitializationException("Both IPv4 and IPv6 support cannot be disabled.");
 766            }
 1767            else if (ipv4 && ipv6)
 768            {
 1769                _protocolSupport = Network.EnableBoth;
 770            }
 1771            else if (ipv4)
 772            {
 1773                _protocolSupport = Network.EnableIPv4;
 774            }
 775            else
 776            {
 1777                _protocolSupport = Network.EnableIPv6;
 778            }
 1779            _preferIPv6 = _initData.properties.getIcePropertyAsInt("Ice.PreferIPv6Address") > 0;
 780
 1781            _networkProxy = createNetworkProxy(_initData.properties, _protocolSupport);
 782
 1783            _sslEngine = new Ice.SSL.SSLEngine(communicator);
 784
 1785            _endpointFactoryManager = new EndpointFactoryManager(this);
 786
 1787            var tcpInstance = new ProtocolInstance(this, Ice.TCPEndpointType.value, "tcp", false);
 1788            _endpointFactoryManager.add(new TcpEndpointFactory(tcpInstance));
 789
 1790            var udpInstance = new ProtocolInstance(this, Ice.UDPEndpointType.value, "udp", false);
 1791            _endpointFactoryManager.add(new UdpEndpointFactory(udpInstance));
 792
 1793            var wsInstance = new ProtocolInstance(this, Ice.WSEndpointType.value, "ws", false);
 1794            _endpointFactoryManager.add(new WSEndpointFactory(wsInstance, Ice.TCPEndpointType.value));
 795
 1796            var sslInstance = new Ice.SSL.Instance(_sslEngine, Ice.SSLEndpointType.value, "ssl");
 1797            _endpointFactoryManager.add(new Ice.SSL.EndpointFactoryI(sslInstance, Ice.TCPEndpointType.value));
 798
 1799            var wssInstance = new ProtocolInstance(this, Ice.WSSEndpointType.value, "wss", true);
 1800            _endpointFactoryManager.add(new WSEndpointFactory(wssInstance, Ice.SSLEndpointType.value));
 801
 1802            _pluginManager = new Ice.PluginManagerI(communicator);
 803
 1804            _outgoingConnectionFactory = new OutgoingConnectionFactory(this);
 805
 1806            _objectAdapterFactory = new ObjectAdapterFactory(this, communicator);
 807
 1808            _retryQueue = new RetryQueue(this);
 809
 1810            string[] retryValues = _initData.properties.getIcePropertyAsList("Ice.RetryIntervals");
 1811            if (retryValues.Length == 0)
 812            {
 0813                retryIntervals = [0];
 814            }
 815            else
 816            {
 1817                retryIntervals = new int[retryValues.Length];
 818
 1819                for (int i = 0; i < retryValues.Length; i++)
 820                {
 1821                    bool parsed =
 1822                        int.TryParse(retryValues[i], NumberStyles.Integer, CultureInfo.InvariantCulture, out int v);
 823
 824                    //
 825                    // If -1 is the first value, no retry and wait intervals.
 826                    //
 1827                    if (parsed && i == 0 && v == -1)
 828                    {
 1829                        retryIntervals = [];
 1830                        break;
 831                    }
 832
 833                    // Any value that is not a non-negative integer (or the leading -1 handled above) is
 834                    // invalid and treated as 0.
 1835                    if (!parsed || v < 0)
 836                    {
 0837                        _initData.logger.warning(
 0838                            $"invalid value '{retryValues[i]}' in property Ice.RetryIntervals, assuming 0");
 0839                        v = 0;
 840                    }
 841
 1842                    retryIntervals[i] = v;
 843                }
 844            }
 845
 1846            if (_initData.properties.getIcePropertyAsInt("Ice.PreloadAssemblies") > 0)
 847            {
 1848                AssemblyUtil.preloadAssemblies();
 849            }
 1850        }
 0851        catch (Ice.LocalException)
 852        {
 0853            destroy();
 0854            throw;
 855        }
 1856    }
 857
 858    internal void finishSetup(Communicator communicator)
 859    {
 860        //
 861        // Load plug-ins.
 862        //
 863        Debug.Assert(_serverThreadPool == null);
 1864        var pluginManagerImpl = (Ice.PluginManagerI)_pluginManager;
 1865        pluginManagerImpl.loadPlugins();
 866
 867        //
 868        // Initialize the endpoint factories once all the plugins are loaded. This gives
 869        // the opportunity for the endpoint factories to find underlying factories.
 870        //
 1871        _endpointFactoryManager.initialize();
 872
 873        //
 874        // Create Admin facets, if enabled.
 875        //
 876        // Note that any logger-dependent admin facet must be created after we load all plugins,
 877        // since one of these plugins can be a Logger plugin that sets a new logger during loading
 878        //
 879
 1880        if (_initData.properties.getIceProperty("Ice.Admin.Enabled").Length == 0)
 881        {
 1882            _adminEnabled = _initData.properties.getIceProperty("Ice.Admin.Endpoints").Length > 0;
 883        }
 884        else
 885        {
 1886            _adminEnabled = _initData.properties.getIcePropertyAsInt("Ice.Admin.Enabled") > 0;
 887        }
 888
 1889        string[] facetFilter = _initData.properties.getIcePropertyAsList("Ice.Admin.Facets");
 1890        if (facetFilter.Length > 0)
 891        {
 1892            foreach (string s in facetFilter)
 893            {
 1894                _adminFacetFilter.Add(s);
 895            }
 896        }
 897
 1898        if (_adminEnabled)
 899        {
 900            //
 901            // Process facet
 902            //
 1903            string processFacetName = "Process";
 1904            if (_adminFacetFilter.Count == 0 || _adminFacetFilter.Contains(processFacetName))
 905            {
 1906                _adminFacets.Add(processFacetName, new ProcessI(communicator));
 907            }
 908
 909            //
 910            // Logger facet
 911            //
 1912            string loggerFacetName = "Logger";
 1913            if (_adminFacetFilter.Count == 0 || _adminFacetFilter.Contains(loggerFacetName))
 914            {
 1915                LoggerAdminLogger logger = new LoggerAdminLoggerI(_initData.properties, _initData.logger);
 916                // Decorate the existing logger, and don't change _ownLogger.
 1917                _initData.logger = logger;
 1918                _adminFacets.Add(loggerFacetName, logger.getFacet());
 919            }
 920
 921            //
 922            // Properties facet
 923            //
 1924            string propertiesFacetName = "Properties";
 1925            NativePropertiesAdmin propsAdmin = null;
 1926            if (_adminFacetFilter.Count == 0 || _adminFacetFilter.Contains(propertiesFacetName))
 927            {
 1928                propsAdmin = new NativePropertiesAdmin(this);
 1929                _adminFacets.Add(propertiesFacetName, propsAdmin);
 930            }
 931
 932            //
 933            // Metrics facet
 934            //
 1935            string metricsFacetName = "Metrics";
 1936            if (_adminFacetFilter.Count == 0 || _adminFacetFilter.Contains(metricsFacetName))
 937            {
 1938                var observer = new CommunicatorObserverI(_initData);
 1939                _initData.observer = observer;
 1940                _adminFacets.Add(metricsFacetName, observer.getFacet());
 941
 942                //
 943                // Make sure the admin plugin receives property updates.
 944                //
 1945                propsAdmin?.addUpdateCallback(observer.getFacet().updated);
 946            }
 947        }
 948
 949        //
 950        // Set observer updater
 951        //
 1952        _initData.observer?.setObserverUpdater(new ObserverUpdaterI(this));
 953
 954        //
 955        // Create threads.
 956        //
 957        try
 958        {
 1959            _timer = new Timer(this, Util.getThreadPriorityProperty(initializationData().properties, "Ice"));
 1960        }
 0961        catch (System.Exception ex)
 962        {
 0963            string s = "cannot create thread for timer:\n" + ex;
 0964            _initData.logger.error(s);
 0965            throw;
 966        }
 967
 968        try
 969        {
 1970            _endpointHostResolver = new EndpointHostResolver(this);
 1971        }
 0972        catch (System.Exception ex)
 973        {
 0974            string s = "cannot create thread for endpoint host resolver:\n" + ex;
 0975            _initData.logger.error(s);
 0976            throw;
 977        }
 1978        _clientThreadPool = new ThreadPool(this, "Ice.ThreadPool.Client", 0);
 979
 980        //
 981        // The default router/locator may have been set during the loading of plugins.
 982        // Therefore we make sure it is not already set before checking the property.
 983        //
 1984        if (_referenceFactory.getDefaultRouter() == null)
 985        {
 1986            Ice.RouterPrx r = Ice.RouterPrxHelper.uncheckedCast(
 1987                communicator.propertyToProxy("Ice.Default.Router"));
 1988            if (r != null)
 989            {
 0990                _referenceFactory = _referenceFactory.setDefaultRouter(r);
 991            }
 992        }
 993
 1994        if (_referenceFactory.getDefaultLocator() == null)
 995        {
 1996            Ice.LocatorPrx l = Ice.LocatorPrxHelper.uncheckedCast(
 1997                communicator.propertyToProxy("Ice.Default.Locator"));
 1998            if (l != null)
 999            {
 11000                _referenceFactory = _referenceFactory.setDefaultLocator(l);
 1001            }
 1002        }
 1003
 1004        //
 1005        // Show process id if requested (but only once).
 1006        //
 11007        lock (_mutex)
 1008        {
 11009            if (!_printProcessIdDone && _initData.properties.getIcePropertyAsInt("Ice.PrintProcessId") > 0)
 1010            {
 01011                using var p = System.Diagnostics.Process.GetCurrentProcess();
 01012                Console.WriteLine(p.Id);
 01013                _printProcessIdDone = true;
 1014            }
 11015        }
 1016
 1017        // SslEngine initialization
 11018        _sslEngine.initialize();
 1019
 1020        //
 1021        // Server thread pool initialization is lazy in serverThreadPool().
 1022        //
 1023
 1024        //
 1025        // An application can set Ice.InitPlugins=0 if it wants to postpone
 1026        // initialization until after it has interacted directly with the
 1027        // plug-ins.
 1028        //
 11029        if (_initData.properties.getIcePropertyAsInt("Ice.InitPlugins") > 0)
 1030        {
 11031            pluginManagerImpl.initializePlugins();
 1032        }
 1033
 1034        //
 1035        // This must be done last as this call creates the Ice.Admin object adapter
 1036        // and eventually registers a process proxy with the Ice locator (allowing
 1037        // remote clients to invoke on Ice.Admin facets as soon as it's registered).
 1038        //
 11039        if (_initData.properties.getIcePropertyAsInt("Ice.Admin.DelayCreation") <= 0)
 1040        {
 11041            getAdmin();
 1042        }
 11043    }
 1044
 1045    //
 1046    // Only for use by Ice.Communicator
 1047    //
 1048    public void destroy()
 1049    {
 11050        lock (_mutex)
 1051        {
 1052            //
 1053            // If destroy is in progress, wait for it to be done. This
 1054            // is necessary in case destroy() is called concurrently
 1055            // by multiple threads.
 1056            //
 11057            while (_state == StateDestroyInProgress)
 1058            {
 01059                Monitor.Wait(_mutex);
 1060            }
 1061
 11062            if (_state == StateDestroyed)
 1063            {
 11064                return;
 1065            }
 11066            _state = StateDestroyInProgress;
 11067        }
 1068
 1069        //
 1070        // Shutdown and destroy all the incoming and outgoing Ice
 1071        // connections and wait for the connections to be finished.
 1072        //
 11073        _objectAdapterFactory?.shutdown();
 1074
 11075        _outgoingConnectionFactory?.destroy();
 1076
 11077        _objectAdapterFactory?.destroy();
 1078
 11079        _outgoingConnectionFactory?.waitUntilFinished();
 1080
 11081        _retryQueue?.destroy(); // Must be called before destroying thread pools.
 1082
 11083        _initData.observer?.setObserverUpdater(null);
 1084
 11085        if (_initData.logger is LoggerAdminLogger loggerAdminLogger)
 1086        {
 1087            // In effect, remove the decorator.
 11088            loggerAdminLogger.detach();
 1089        }
 1090
 1091        //
 1092        // Now, destroy the thread pools. This must be done *only* after
 1093        // all the connections are finished (the connections destruction
 1094        // can require invoking callbacks with the thread pools).
 1095        //
 11096        _serverThreadPool?.destroy();
 11097        _clientThreadPool?.destroy();
 11098        _endpointHostResolver?.destroy();
 1099
 1100        //
 1101        // Wait for all the threads to be finished.
 1102        //
 11103        _timer?.destroy();
 11104        _clientThreadPool?.joinWithAllThreads();
 11105        _serverThreadPool?.joinWithAllThreads();
 11106        _endpointHostResolver?.joinWithThread();
 1107
 11108        _routerManager?.destroy();
 1109
 11110        _locatorManager?.destroy();
 1111
 11112        if (_initData.properties.getIcePropertyAsInt("Ice.Warn.UnusedProperties") > 0)
 1113        {
 01114            List<string> unusedProperties = _initData.properties.getUnusedProperties();
 01115            if (unusedProperties.Count != 0)
 1116            {
 01117                var message = new StringBuilder("The following properties were set but never read:");
 01118                foreach (string s in unusedProperties)
 1119                {
 01120                    message.Append("\n    ");
 01121                    message.Append(s);
 1122                }
 01123                _initData.logger.warning(message.ToString());
 1124            }
 1125        }
 1126
 1127        //
 1128        // Destroy last so that a Logger plugin can receive all log/traces before its destruction.
 1129        //
 11130        _pluginManager?.destroy();
 1131
 11132        lock (_mutex)
 1133        {
 11134            _objectAdapterFactory = null;
 11135            _outgoingConnectionFactory = null;
 11136            _retryQueue = null;
 1137
 11138            _serverThreadPool = null;
 11139            _clientThreadPool = null;
 11140            _endpointHostResolver = null;
 11141            _timer = null;
 1142
 11143            _referenceFactory = null;
 11144            _routerManager = null;
 11145            _locatorManager = null;
 11146            _endpointFactoryManager = null;
 11147            _pluginManager = null;
 1148
 11149            _sslEngine?.Dispose();
 11150            _sslEngine = null;
 1151
 11152            _adminAdapter = null;
 11153            _adminFacets.Clear();
 1154
 11155            _state = StateDestroyed;
 11156            Monitor.PulseAll(_mutex);
 11157        }
 1158
 11159        if (_ownLogger)
 1160        {
 11161            _initData.logger!.Dispose();
 1162        }
 11163    }
 1164
 1165    public BufSizeWarnInfo getBufSizeWarn(short type)
 1166    {
 01167        lock (_setBufSizeWarn)
 1168        {
 1169            BufSizeWarnInfo info;
 01170            if (!_setBufSizeWarn.TryGetValue(type, out BufSizeWarnInfo value))
 1171            {
 01172                info = new BufSizeWarnInfo();
 01173                info.sndWarn = false;
 01174                info.sndSize = -1;
 01175                info.rcvWarn = false;
 01176                info.rcvSize = -1;
 01177                _setBufSizeWarn.Add(type, info);
 1178            }
 1179            else
 1180            {
 01181                info = _setBufSizeWarn[type];
 1182            }
 01183            return info;
 1184        }
 01185    }
 1186
 1187    public void setSndBufSizeWarn(short type, int size)
 1188    {
 01189        lock (_setBufSizeWarn)
 1190        {
 01191            BufSizeWarnInfo info = getBufSizeWarn(type);
 01192            info.sndWarn = true;
 01193            info.sndSize = size;
 01194            _setBufSizeWarn[type] = info;
 01195        }
 01196    }
 1197
 1198    public void setRcvBufSizeWarn(short type, int size)
 1199    {
 01200        lock (_setBufSizeWarn)
 1201        {
 01202            BufSizeWarnInfo info = getBufSizeWarn(type);
 01203            info.rcvWarn = true;
 01204            info.rcvSize = size;
 01205            _setBufSizeWarn[type] = info;
 01206        }
 01207    }
 1208
 1209    internal void updateConnectionObservers()
 1210    {
 1211        try
 1212        {
 1213            // This updater can run concurrently with destroy(). Copy the subsystem references under the lock, and bail
 1214            // out once destruction has started: destroy() tears down these subsystems (while _state is
 1215            // StateDestroyInProgress) before nulling them (when it sets _state to StateDestroyed).
 1216            OutgoingConnectionFactory outgoingConnectionFactory;
 1217            ObjectAdapterFactory objectAdapterFactory;
 11218            lock (_mutex)
 1219            {
 11220                if (_state >= StateDestroyInProgress)
 1221                {
 01222                    return;
 1223                }
 11224                outgoingConnectionFactory = _outgoingConnectionFactory;
 11225                objectAdapterFactory = _objectAdapterFactory;
 11226            }
 1227
 1228            Debug.Assert(outgoingConnectionFactory != null);
 11229            outgoingConnectionFactory.updateConnectionObservers();
 1230            Debug.Assert(objectAdapterFactory != null);
 11231            objectAdapterFactory.updateConnectionObservers();
 11232        }
 01233        catch (CommunicatorDestroyedException)
 1234        {
 01235        }
 11236    }
 1237
 1238    internal void updateThreadObservers()
 1239    {
 1240        try
 1241        {
 1242            // This updater can run concurrently with destroy(). Copy the subsystem references under the lock, and bail
 1243            // out once destruction has started: destroy() tears down these subsystems (while _state is
 1244            // StateDestroyInProgress) before nulling them (when it sets _state to StateDestroyed).
 1245            ThreadPool clientThreadPool;
 1246            ThreadPool serverThreadPool;
 1247            ObjectAdapterFactory objectAdapterFactory;
 1248            EndpointHostResolver endpointHostResolver;
 1249            Timer timer;
 11250            lock (_mutex)
 1251            {
 11252                if (_state >= StateDestroyInProgress)
 1253                {
 01254                    return;
 1255                }
 11256                clientThreadPool = _clientThreadPool;
 11257                serverThreadPool = _serverThreadPool;
 11258                objectAdapterFactory = _objectAdapterFactory;
 11259                endpointHostResolver = _endpointHostResolver;
 11260                timer = _timer;
 11261            }
 1262
 11263            clientThreadPool?.updateObservers();
 11264            serverThreadPool?.updateObservers();
 1265            Debug.Assert(objectAdapterFactory != null);
 11266            objectAdapterFactory.updateThreadObservers();
 11267            endpointHostResolver?.updateObserver();
 11268            timer?.updateObserver(_initData.observer);
 11269        }
 01270        catch (CommunicatorDestroyedException)
 1271        {
 01272        }
 11273    }
 1274
 1275    internal void addAllAdminFacets()
 1276    {
 11277        lock (_mutex)
 1278        {
 11279            var filteredFacets = new Dictionary<string, Ice.Object>();
 1280
 11281            foreach (KeyValuePair<string, Ice.Object> entry in _adminFacets)
 1282            {
 11283                if (_adminFacetFilter.Count == 0 || _adminFacetFilter.Contains(entry.Key))
 1284                {
 11285                    _adminAdapter.addFacet(entry.Value, _adminIdentity, entry.Key);
 1286                }
 1287                else
 1288                {
 01289                    filteredFacets.Add(entry.Key, entry.Value);
 1290                }
 1291            }
 11292            _adminFacets = filteredFacets;
 11293        }
 11294    }
 1295
 1296    internal void setServerProcessProxy(Ice.ObjectAdapter adminAdapter, Ice.Identity adminIdentity)
 1297    {
 11298        Ice.ObjectPrx admin = adminAdapter.createProxy(adminIdentity);
 11299        Ice.LocatorPrx locator = adminAdapter.getLocator();
 11300        string serverId = _initData.properties.getIceProperty("Ice.Admin.ServerId");
 1301
 11302        if (locator != null && serverId.Length > 0)
 1303        {
 01304            Ice.ProcessPrx process = Ice.ProcessPrxHelper.uncheckedCast(admin.ice_facet("Process"));
 1305            try
 1306            {
 1307                //
 1308                // Note that as soon as the process proxy is registered, the communicator might be
 1309                // shutdown by a remote client and admin facets might start receiving calls.
 1310                //
 01311                locator.getRegistry().setServerProcessProxy(serverId, process);
 01312            }
 01313            catch (Ice.ServerNotFoundException)
 1314            {
 01315                if (_traceLevels.location >= 1)
 1316                {
 01317                    var s = new System.Text.StringBuilder();
 01318                    s.Append("couldn't register server `" + serverId + "' with the locator registry:\n");
 01319                    s.Append("the server is not known to the locator registry");
 01320                    _initData.logger.trace(_traceLevels.locationCat, s.ToString());
 1321                }
 1322
 01323                throw new Ice.InitializationException("Locator knows nothing about server `" + serverId + "'");
 1324            }
 01325            catch (Ice.LocalException ex)
 1326            {
 01327                if (_traceLevels.location >= 1)
 1328                {
 01329                    var s = new System.Text.StringBuilder();
 01330                    s.Append("couldn't register server `" + serverId + "' with the locator registry:\n" + ex);
 01331                    _initData.logger.trace(_traceLevels.locationCat, s.ToString());
 1332                }
 01333                throw; // TODO: Shall we raise a special exception instead of a non obvious local exception?
 1334            }
 1335
 01336            if (_traceLevels.location >= 1)
 1337            {
 01338                var s = new System.Text.StringBuilder();
 01339                s.Append("registered server `" + serverId + "' with the locator registry");
 01340                _initData.logger.trace(_traceLevels.locationCat, s.ToString());
 1341            }
 1342        }
 11343    }
 1344
 1345    internal ConnectionOptions serverConnectionOptions(string adapterName)
 1346    {
 1347        Debug.Assert(adapterName.Length > 0);
 11348        Properties properties = _initData.properties;
 11349        string propertyPrefix = $"{adapterName}.Connection";
 1350
 11351        return new(
 11352            connectTimeout: TimeSpan.FromSeconds(properties.getPropertyAsIntWithDefault(
 11353                $"{propertyPrefix}.ConnectTimeout",
 11354                (int)_serverConnectionOptions.connectTimeout.TotalSeconds)),
 11355
 11356            closeTimeout: TimeSpan.FromSeconds(properties.getPropertyAsIntWithDefault(
 11357                $"{propertyPrefix}.CloseTimeout",
 11358                (int)_serverConnectionOptions.closeTimeout.TotalSeconds)),
 11359
 11360            idleTimeout: TimeSpan.FromSeconds(properties.getPropertyAsIntWithDefault(
 11361                $"{propertyPrefix}.IdleTimeout",
 11362                (int)_serverConnectionOptions.idleTimeout.TotalSeconds)),
 11363
 11364            enableIdleCheck: properties.getPropertyAsIntWithDefault(
 11365                $"{propertyPrefix}.EnableIdleCheck",
 11366                _serverConnectionOptions.enableIdleCheck ? 1 : 0) > 0,
 11367
 11368            inactivityTimeout: TimeSpan.FromSeconds(properties.getPropertyAsIntWithDefault(
 11369                $"{propertyPrefix}.InactivityTimeout",
 11370                (int)_serverConnectionOptions.inactivityTimeout.TotalSeconds)),
 11371
 11372            maxDispatches: properties.getPropertyAsIntWithDefault(
 11373                $"{propertyPrefix}.MaxDispatches",
 11374                _serverConnectionOptions.maxDispatches));
 1375    }
 1376
 11377    internal SliceLoader sliceLoader => _initData.sliceLoader; // set in initialize
 1378
 1379    internal ConnectionOptions clientConnectionOptions { get; private set; } = null!; // set in initialize
 1380
 1381    internal int[] retryIntervals { get; private set; }
 1382
 1383    private NetworkProxy createNetworkProxy(Ice.Properties props, int protocolSupport)
 1384    {
 1385        string proxyHost;
 1386
 11387        proxyHost = props.getIceProperty("Ice.SOCKSProxyHost");
 11388        if (proxyHost.Length > 0)
 1389        {
 11390            if (protocolSupport == Network.EnableIPv6)
 1391            {
 01392                throw new Ice.InitializationException("IPv6 only is not supported with SOCKS4 proxies");
 1393            }
 11394            int proxyPort = props.getIcePropertyAsInt("Ice.SOCKSProxyPort");
 11395            return new SOCKSNetworkProxy(proxyHost, proxyPort);
 1396        }
 1397
 11398        proxyHost = props.getIceProperty("Ice.HTTPProxyHost");
 11399        if (proxyHost.Length > 0)
 1400        {
 11401            return new HTTPNetworkProxy(proxyHost, props.getIcePropertyAsInt("Ice.HTTPProxyPort"));
 1402        }
 1403
 11404        return null;
 1405    }
 1406
 1407    private ConnectionOptions readConnectionOptions(string propertyPrefix)
 1408    {
 11409        Properties properties = _initData.properties;
 1410
 1411        // The TimeSpan value can be <= 0. In this case, the timeout is considered infinite.
 11412        return new(
 11413            connectTimeout: TimeSpan.FromSeconds(properties.getIcePropertyAsInt($"{propertyPrefix}.ConnectTimeout")),
 11414            closeTimeout: TimeSpan.FromSeconds(properties.getIcePropertyAsInt($"{propertyPrefix}.CloseTimeout")),
 11415            idleTimeout: TimeSpan.FromSeconds(properties.getIcePropertyAsInt($"{propertyPrefix}.IdleTimeout")),
 11416            enableIdleCheck: properties.getIcePropertyAsInt($"{propertyPrefix}.EnableIdleCheck") > 0,
 11417            inactivityTimeout:
 11418                TimeSpan.FromSeconds(properties.getIcePropertyAsInt($"{propertyPrefix}.InactivityTimeout")),
 11419            maxDispatches: properties.getIcePropertyAsInt($"{propertyPrefix}.MaxDispatches"));
 1420    }
 1421
 1422    private static bool _printProcessIdDone;
 1423    private static bool _oneOffDone;
 11424    private static readonly object _staticLock = new object();
 1425
 1426    private const int StateActive = 0;
 1427    private const int StateDestroyInProgress = 1;
 1428    private const int StateDestroyed = 2;
 1429
 1430    private int _state;
 1431    private Ice.InitializationData _initData; // Immutable, not reset by destroy().
 1432    private bool _ownLogger; // When true, this instance owns _initData.logger and must dispose it.
 1433
 1434    private TraceLevels _traceLevels; // Immutable, not reset by destroy().
 1435    private DefaultsAndOverrides _defaultsAndOverrides; // Immutable, not reset by destroy().
 1436    private int _messageSizeMax; // Immutable, not reset by destroy().
 1437    private int _batchAutoFlushSize; // Immutable, not reset by destroy().
 1438    private int _classGraphDepthMax; // Immutable, not reset by destroy().
 1439    private Ice.ToStringMode _toStringMode; // Immutable, not reset by destroy().
 1440    private int _cacheMessageBuffers; // Immutable, not reset by destroy().
 1441    private Ice.ImplicitContextI _implicitContext; // Immutable
 1442    private RouterManager _routerManager;
 1443    private LocatorManager _locatorManager;
 1444    private ReferenceFactory _referenceFactory;
 1445    private OutgoingConnectionFactory _outgoingConnectionFactory;
 1446    private ObjectAdapterFactory _objectAdapterFactory;
 1447    private int _protocolSupport;
 1448    private bool _preferIPv6;
 1449    private NetworkProxy _networkProxy;
 1450    private ThreadPool _clientThreadPool;
 1451    private ThreadPool _serverThreadPool;
 1452    private EndpointHostResolver _endpointHostResolver;
 1453    private Timer _timer;
 1454    private RetryQueue _retryQueue;
 1455    private EndpointFactoryManager _endpointFactoryManager;
 1456    private Ice.PluginManager _pluginManager;
 1457    private bool _adminEnabled;
 1458    private Ice.ObjectAdapter _adminAdapter;
 11459    private Dictionary<string, Ice.Object> _adminFacets = new();
 11460    private readonly HashSet<string> _adminFacetFilter = new();
 1461    private Ice.Identity _adminIdentity;
 11462    private readonly Dictionary<short, BufSizeWarnInfo> _setBufSizeWarn = new();
 1463    private ConnectionOptions _serverConnectionOptions; // set in initialize
 1464    private Ice.SSL.SSLEngine _sslEngine;
 1465
 1466    // The Slice loader(s) added by the application: initData.sliceLoader followed by the loaders added by
 1467    // addSliceLoader.
 11468    private readonly CompositeSliceLoader _applicationSliceLoader = new();
 1469
 11470    private readonly object _mutex = new object();
 1471}