< Summary

Information
Class: Ice.Internal.Instance.ObserverUpdaterI
Assembly: Ice
File(s): /_/csharp/src/Ice/Internal/Instance.cs
Tag: 125_37167941578
Line coverage
100%
Covered lines: 3
Uncovered lines: 0
Coverable lines: 3
Total lines: 1471
Line coverage: 100%
Branch coverage
N/A
Covered branches: 0
Total branches: 0
Branch coverage: N/A
Method coverage
100%
Covered methods: 3
Fully covered methods: 3
Total methods: 3
Method coverage: 100%
Full method coverage: 100%

Metrics

MethodBranch coverage Crap Score Cyclomatic complexity Line coverage
.ctor(...)100%11100%
updateConnectionObservers()100%11100%
updateThreadObservers()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        //
 48        _initData;
 49
 50    public TraceLevels traceLevels()
 51    {
 52        // No mutex lock, immutable.
 53        Debug.Assert(_traceLevels != null);
 54        return _traceLevels;
 55    }
 56
 57    public DefaultsAndOverrides defaultsAndOverrides()
 58    {
 59        // No mutex lock, immutable.
 60        Debug.Assert(_defaultsAndOverrides != null);
 61        return _defaultsAndOverrides;
 62    }
 63
 64    public RouterManager routerManager()
 65    {
 66        lock (_mutex)
 67        {
 68            if (_state == StateDestroyed)
 69            {
 70                throw new Ice.CommunicatorDestroyedException();
 71            }
 72
 73            Debug.Assert(_routerManager != null);
 74            return _routerManager;
 75        }
 76    }
 77
 78    public LocatorManager locatorManager()
 79    {
 80        lock (_mutex)
 81        {
 82            if (_state == StateDestroyed)
 83            {
 84                throw new Ice.CommunicatorDestroyedException();
 85            }
 86
 87            Debug.Assert(_locatorManager != null);
 88            return _locatorManager;
 89        }
 90    }
 91
 92    internal ReferenceFactory referenceFactory()
 93    {
 94        lock (_mutex)
 95        {
 96            if (_state == StateDestroyed)
 97            {
 98                throw new Ice.CommunicatorDestroyedException();
 99            }
 100
 101            Debug.Assert(_referenceFactory != null);
 102            return _referenceFactory;
 103        }
 104    }
 105
 106    internal OutgoingConnectionFactory outgoingConnectionFactory()
 107    {
 108        lock (_mutex)
 109        {
 110            if (_state == StateDestroyed)
 111            {
 112                throw new Ice.CommunicatorDestroyedException();
 113            }
 114
 115            Debug.Assert(_outgoingConnectionFactory != null);
 116            return _outgoingConnectionFactory;
 117        }
 118    }
 119
 120    public ObjectAdapterFactory objectAdapterFactory()
 121    {
 122        lock (_mutex)
 123        {
 124            if (_state == StateDestroyed)
 125            {
 126                throw new Ice.CommunicatorDestroyedException();
 127            }
 128
 129            Debug.Assert(_objectAdapterFactory != null);
 130            return _objectAdapterFactory;
 131        }
 132    }
 133
 134    public int protocolSupport() => _protocolSupport;
 135
 136    public bool preferIPv6() => _preferIPv6;
 137
 138    public NetworkProxy networkProxy() => _networkProxy;
 139
 140    public ThreadPool clientThreadPool()
 141    {
 142        lock (_mutex)
 143        {
 144            if (_state == StateDestroyed)
 145            {
 146                throw new Ice.CommunicatorDestroyedException();
 147            }
 148
 149            Debug.Assert(_clientThreadPool != null);
 150            return _clientThreadPool;
 151        }
 152    }
 153
 154    public ThreadPool serverThreadPool()
 155    {
 156        lock (_mutex)
 157        {
 158            if (_state == StateDestroyed)
 159            {
 160                throw new Ice.CommunicatorDestroyedException();
 161            }
 162
 163            if (_serverThreadPool == null) // Lazy initialization.
 164            {
 165                if (_state == StateDestroyInProgress)
 166                {
 167                    throw new Ice.CommunicatorDestroyedException();
 168                }
 169                int timeout = _initData.properties.getIcePropertyAsInt("Ice.ServerIdleTime");
 170                _serverThreadPool = new ThreadPool(this, "Ice.ThreadPool.Server", timeout);
 171            }
 172
 173            return _serverThreadPool;
 174        }
 175    }
 176
 177    public EndpointHostResolver endpointHostResolver()
 178    {
 179        lock (_mutex)
 180        {
 181            if (_state == StateDestroyed)
 182            {
 183                throw new Ice.CommunicatorDestroyedException();
 184            }
 185
 186            Debug.Assert(_endpointHostResolver != null);
 187            return _endpointHostResolver;
 188        }
 189    }
 190
 191    public RetryQueue
 192    retryQueue()
 193    {
 194        lock (_mutex)
 195        {
 196            if (_state == StateDestroyed)
 197            {
 198                throw new Ice.CommunicatorDestroyedException();
 199            }
 200
 201            Debug.Assert(_retryQueue != null);
 202            return _retryQueue;
 203        }
 204    }
 205
 206    public Timer
 207    timer()
 208    {
 209        lock (_mutex)
 210        {
 211            if (_state == StateDestroyed)
 212            {
 213                throw new Ice.CommunicatorDestroyedException();
 214            }
 215
 216            Debug.Assert(_timer != null);
 217            return _timer;
 218        }
 219    }
 220
 221    public EndpointFactoryManager endpointFactoryManager()
 222    {
 223        lock (_mutex)
 224        {
 225            if (_state == StateDestroyed)
 226            {
 227                throw new Ice.CommunicatorDestroyedException();
 228            }
 229
 230            Debug.Assert(_endpointFactoryManager != null);
 231            return _endpointFactoryManager;
 232        }
 233    }
 234
 235    public Ice.PluginManager pluginManager()
 236    {
 237        lock (_mutex)
 238        {
 239            if (_state == StateDestroyed)
 240            {
 241                throw new Ice.CommunicatorDestroyedException();
 242            }
 243
 244            Debug.Assert(_pluginManager != null);
 245            return _pluginManager;
 246        }
 247    }
 248
 249    public int messageSizeMax() =>
 250        // No mutex lock, immutable.
 251        _messageSizeMax;
 252
 253    public int batchAutoFlushSize() =>
 254        // No mutex lock, immutable.
 255        _batchAutoFlushSize;
 256
 257    public int classGraphDepthMax() =>
 258        // No mutex lock, immutable.
 259        _classGraphDepthMax;
 260
 261    public Ice.ToStringMode
 262    toStringMode() =>
 263        // No mutex lock, immutable
 264        _toStringMode;
 265
 266    public int cacheMessageBuffers() =>
 267        // No mutex lock, immutable.
 268        _cacheMessageBuffers;
 269
 270    public Ice.ImplicitContextI getImplicitContext() => _implicitContext;
 271
 272    public Ice.ObjectPrx createAdmin(Ice.ObjectAdapter adminAdapter, Ice.Identity adminIdentity)
 273    {
 274        bool createAdapter = adminAdapter == null;
 275
 276        lock (_mutex)
 277        {
 278            if (_state == StateDestroyed)
 279            {
 280                throw new Ice.CommunicatorDestroyedException();
 281            }
 282
 283            if (adminIdentity == null || adminIdentity.name.Length == 0)
 284            {
 285                throw new ArgumentException("The admin identity is not valid", nameof(adminIdentity));
 286            }
 287
 288            if (_adminAdapter != null)
 289            {
 290                throw new Ice.InitializationException("Admin already created");
 291            }
 292
 293            if (!_adminEnabled)
 294            {
 295                throw new Ice.InitializationException("Admin is disabled");
 296            }
 297
 298            if (createAdapter)
 299            {
 300                if (_initData.properties.getIceProperty("Ice.Admin.Endpoints").Length > 0)
 301                {
 302                    adminAdapter = _objectAdapterFactory.createObjectAdapter(
 303                        "Ice.Admin",
 304                        router: null,
 305                        serverAuthenticationOptions: null);
 306                }
 307                else
 308                {
 309                    throw new Ice.InitializationException("Ice.Admin.Endpoints is not set");
 310                }
 311            }
 312
 313            _adminIdentity = adminIdentity;
 314            _adminAdapter = adminAdapter;
 315            addAllAdminFacets();
 316        }
 317
 318        if (createAdapter)
 319        {
 320            try
 321            {
 322                adminAdapter.activate();
 323            }
 324            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                //
 331                adminAdapter.destroy();
 332                lock (_mutex)
 333                {
 334                    _adminAdapter = null;
 335                }
 336                throw;
 337            }
 338        }
 339        setServerProcessProxy(adminAdapter, adminIdentity);
 340        return adminAdapter.createProxy(adminIdentity);
 341    }
 342
 343    public Ice.ObjectPrx
 344    getAdmin()
 345    {
 346        Ice.ObjectAdapter adminAdapter;
 347        Ice.Identity adminIdentity;
 348
 349        lock (_mutex)
 350        {
 351            if (_state == StateDestroyed)
 352            {
 353                throw new Ice.CommunicatorDestroyedException();
 354            }
 355
 356            if (_adminAdapter != null)
 357            {
 358                return _adminAdapter.createProxy(_adminIdentity);
 359            }
 360            else if (_adminEnabled)
 361            {
 362                if (_initData.properties.getIceProperty("Ice.Admin.Endpoints").Length > 0)
 363                {
 364                    adminAdapter = _objectAdapterFactory.createObjectAdapter(
 365                        "Ice.Admin",
 366                        router: null,
 367                        serverAuthenticationOptions: null);
 368                }
 369                else
 370                {
 371                    return null;
 372                }
 373                adminIdentity = new Ice.Identity(
 374                    "admin",
 375                    _initData.properties.getIceProperty("Ice.Admin.InstanceName"));
 376                if (adminIdentity.category.Length == 0)
 377                {
 378                    adminIdentity.category = System.Guid.NewGuid().ToString();
 379                }
 380
 381                _adminIdentity = adminIdentity;
 382                _adminAdapter = adminAdapter;
 383                addAllAdminFacets();
 384                // continue below outside synchronization
 385            }
 386            else
 387            {
 388                return null;
 389            }
 390        }
 391
 392        try
 393        {
 394            adminAdapter.activate();
 395        }
 396        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            //
 403            adminAdapter.destroy();
 404            lock (_mutex)
 405            {
 406                _adminAdapter = null;
 407            }
 408            throw;
 409        }
 410
 411        setServerProcessProxy(adminAdapter, adminIdentity);
 412        return adminAdapter.createProxy(adminIdentity);
 413    }
 414
 415    public void
 416    addAdminFacet(Ice.Object servant, string facet)
 417    {
 418        lock (_mutex)
 419        {
 420            if (_state == StateDestroyed)
 421            {
 422                throw new Ice.CommunicatorDestroyedException();
 423            }
 424
 425            if (_adminAdapter == null || (_adminFacetFilter.Count > 0 && !_adminFacetFilter.Contains(facet)))
 426            {
 427                if (_adminFacets.ContainsKey(facet))
 428                {
 429                    throw new Ice.AlreadyRegisteredException("facet", facet);
 430                }
 431                _adminFacets.Add(facet, servant);
 432            }
 433            else
 434            {
 435                _adminAdapter.addFacet(servant, _adminIdentity, facet);
 436            }
 437        }
 438    }
 439
 440    public Ice.Object
 441    removeAdminFacet(string facet)
 442    {
 443        lock (_mutex)
 444        {
 445            if (_state == StateDestroyed)
 446            {
 447                throw new Ice.CommunicatorDestroyedException();
 448            }
 449
 450            Ice.Object result = null;
 451            if (_adminAdapter == null || (_adminFacetFilter.Count > 0 && !_adminFacetFilter.Contains(facet)))
 452            {
 453                try
 454                {
 455                    result = _adminFacets[facet];
 456                }
 457                catch (KeyNotFoundException)
 458                {
 459                    throw new Ice.NotRegisteredException("facet", facet);
 460                }
 461
 462                _adminFacets.Remove(facet);
 463            }
 464            else
 465            {
 466                result = _adminAdapter.removeFacet(_adminIdentity, facet);
 467            }
 468            return result;
 469        }
 470    }
 471
 472    public Ice.Object
 473    findAdminFacet(string facet)
 474    {
 475        lock (_mutex)
 476        {
 477            if (_state == StateDestroyed)
 478            {
 479                throw new Ice.CommunicatorDestroyedException();
 480            }
 481
 482            Ice.Object result = null;
 483            if (_adminAdapter == null || (_adminFacetFilter.Count > 0 && !_adminFacetFilter.Contains(facet)))
 484            {
 485                try
 486                {
 487                    result = _adminFacets[facet];
 488                }
 489                catch (KeyNotFoundException)
 490                {
 491                }
 492            }
 493            else
 494            {
 495                result = _adminAdapter.findFacet(_adminIdentity, facet);
 496            }
 497            return result;
 498        }
 499    }
 500
 501    public Dictionary<string, Ice.Object>
 502    findAllAdminFacets()
 503    {
 504        lock (_mutex)
 505        {
 506            if (_state == StateDestroyed)
 507            {
 508                throw new Ice.CommunicatorDestroyedException();
 509            }
 510
 511            if (_adminAdapter == null)
 512            {
 513                return new Dictionary<string, Ice.Object>(_adminFacets);
 514            }
 515            else
 516            {
 517                Dictionary<string, Ice.Object> result = _adminAdapter.findAllFacets(_adminIdentity);
 518                if (_adminFacets.Count > 0)
 519                {
 520                    foreach (KeyValuePair<string, Ice.Object> p in _adminFacets)
 521                    {
 522                        result.Add(p.Key, p.Value);
 523                    }
 524                }
 525                return result;
 526            }
 527        }
 528    }
 529
 530    public void
 531    setDefaultLocator(Ice.LocatorPrx locator)
 532    {
 533        lock (_mutex)
 534        {
 535            if (_state == StateDestroyed)
 536            {
 537                throw new Ice.CommunicatorDestroyedException();
 538            }
 539
 540            _referenceFactory = _referenceFactory.setDefaultLocator(locator);
 541        }
 542    }
 543
 544    public void
 545    setDefaultRouter(Ice.RouterPrx router)
 546    {
 547        lock (_mutex)
 548        {
 549            if (_state == StateDestroyed)
 550            {
 551                throw new Ice.CommunicatorDestroyedException();
 552            }
 553
 554            _referenceFactory = _referenceFactory.setDefaultRouter(router);
 555        }
 556    }
 557
 558    internal void setLogger(Logger logger)
 559    {
 560        // Only called by the LoggerPlugin constructor, so no need to lock.
 561        if (_ownLogger)
 562        {
 563            _initData.logger!.Dispose();
 564        }
 565        _initData.logger = logger;
 566        _ownLogger = true;
 567    }
 568
 569    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    {
 576        _state = StateActive;
 577        _initData = initData;
 578
 579        try
 580        {
 581            _initData.properties ??= new Properties();
 582
 583            string programName = _initData.properties.getIceProperty("Ice.ProgramName");
 584            if (programName.Length == 0)
 585            {
 586                _initData.properties.setProperty("Ice.ProgramName", AppDomain.CurrentDomain.FriendlyName);
 587                // Re-read it to mark it as used.
 588                programName = _initData.properties.getIceProperty("Ice.ProgramName");
 589            }
 590
 591            lock (_staticLock)
 592            {
 593                if (!_oneOffDone)
 594                {
 595                    string stdOut = _initData.properties.getIceProperty("Ice.StdOut");
 596                    string stdErr = _initData.properties.getIceProperty("Ice.StdErr");
 597
 598                    System.IO.StreamWriter outStream = null;
 599
 600                    if (stdOut.Length > 0)
 601                    {
 602                        try
 603                        {
 604                            outStream = System.IO.File.AppendText(stdOut);
 605                        }
 606                        catch (IOException ex)
 607                        {
 608                            throw new FileException($"Cannot append to '{stdOut}'", ex);
 609                        }
 610                        outStream.AutoFlush = true;
 611                        Console.Out.Close();
 612                        Console.SetOut(outStream);
 613                    }
 614                    if (stdErr.Length > 0)
 615                    {
 616                        if (stdErr.Equals(stdOut, StringComparison.Ordinal))
 617                        {
 618                            Console.SetError(outStream);
 619                        }
 620                        else
 621                        {
 622                            System.IO.StreamWriter errStream = null;
 623                            try
 624                            {
 625                                errStream = System.IO.File.AppendText(stdErr);
 626                            }
 627                            catch (IOException ex)
 628                            {
 629                                throw new FileException($"Cannot append to '{stdErr}'", ex);
 630                            }
 631                            errStream.AutoFlush = true;
 632                            Console.Error.Close();
 633                            Console.SetError(errStream);
 634                        }
 635                    }
 636
 637                    _oneOffDone = true;
 638                }
 639            }
 640
 641            if (_initData.logger is null)
 642            {
 643                string logfile = _initData.properties.getIceProperty("Ice.LogFile");
 644                if (logfile.Length != 0)
 645                {
 646                    _initData.logger = new FileLoggerI(programName, logfile);
 647                    _ownLogger = true;
 648                }
 649                else if (Ice.Util.getProcessLogger() is LoggerI)
 650                {
 651                    //
 652                    // Ice.ConsoleListener is enabled by default.
 653                    //
 654                    bool console = _initData.properties.getIcePropertyAsInt("Ice.ConsoleListener") > 0;
 655                    _initData.logger = new TraceLoggerI(programName, console);
 656                    _ownLogger = true;
 657                }
 658                else
 659                {
 660                    _initData.logger = Ice.Util.getProcessLogger();
 661                    // _ownLogger remains false
 662                }
 663            }
 664            // else _ownLogger remains false
 665
 666            _traceLevels = new TraceLevels(_initData.properties);
 667
 668            _defaultsAndOverrides = new DefaultsAndOverrides(_initData.properties, _initData.logger);
 669
 670            clientConnectionOptions = readConnectionOptions("Ice.Connection.Client");
 671            _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;
 676            int messageSizeMax = _initData.properties.getIcePropertyAsInt("Ice.MessageSizeMax");
 677            if (messageSizeMax > messageSizeMaxUpperLimit / 1024)
 678            {
 679                throw new Ice.InitializationException(
 680                    $"Ice.MessageSizeMax '{messageSizeMax}' is too large, it must be less than or equal to '{messageSize
 681            }
 682            else if (messageSizeMax < 1)
 683            {
 684                _messageSizeMax = messageSizeMaxUpperLimit;
 685            }
 686            else
 687            {
 688                // The property is specified in kibibytes (KiB); _messageSizeMax is stored in bytes.
 689                _messageSizeMax = messageSizeMax * 1024;
 690            }
 691
 692            int batchAutoFlushSize = _initData.properties.getIcePropertyAsInt("Ice.BatchAutoFlushSize");
 693            if (batchAutoFlushSize > messageSizeMaxUpperLimit / 1024)
 694            {
 695                throw new Ice.InitializationException(
 696                    $"Ice.BatchAutoFlushSize '{batchAutoFlushSize}' is too large, it must be less than or equal to '{mes
 697            }
 698            else if (batchAutoFlushSize < 1)
 699            {
 700                _batchAutoFlushSize = messageSizeMaxUpperLimit;
 701            }
 702            else
 703            {
 704                // The property is specified in kibibytes (KiB); _batchAutoFlushSize is stored in bytes.
 705                _batchAutoFlushSize = batchAutoFlushSize * 1024;
 706            }
 707
 708            int classGraphDepthMax = _initData.properties.getIcePropertyAsInt("Ice.ClassGraphDepthMax");
 709            if (classGraphDepthMax < 1)
 710            {
 711                _classGraphDepthMax = 0x7fffffff;
 712            }
 713            else
 714            {
 715                _classGraphDepthMax = classGraphDepthMax;
 716            }
 717
 718            // Update _initData.sliceLoader
 719
 720            if (_initData.sliceLoader is not null)
 721            {
 722                _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.
 727            var lazySliceLoader = new LazySliceLoader(
 728                () => SliceLoader.fromAssemblies(AppDomain.CurrentDomain.GetAssemblies()));
 729
 730            _initData.sliceLoader = new CompositeSliceLoader(_applicationSliceLoader, lazySliceLoader);
 731
 732            string toStringModeStr = _initData.properties.getIceProperty("Ice.ToStringMode");
 733            if (toStringModeStr == "Unicode")
 734            {
 735                _toStringMode = Ice.ToStringMode.Unicode;
 736            }
 737            else if (toStringModeStr == "ASCII")
 738            {
 739                _toStringMode = Ice.ToStringMode.ASCII;
 740            }
 741            else if (toStringModeStr == "Compat")
 742            {
 743                _toStringMode = Ice.ToStringMode.Compat;
 744            }
 745            else
 746            {
 747                throw new Ice.InitializationException(
 748                    "The value for Ice.ToStringMode must be Unicode, ASCII or Compat");
 749            }
 750
 751            _cacheMessageBuffers = _initData.properties.getIcePropertyAsInt("Ice.CacheMessageBuffers");
 752
 753            _implicitContext = Ice.ImplicitContextI.create(_initData.properties.getIceProperty("Ice.ImplicitContext"));
 754            _routerManager = new RouterManager();
 755
 756            _locatorManager = new LocatorManager(_initData.properties);
 757
 758            _referenceFactory = new ReferenceFactory(this, communicator);
 759
 760            bool isIPv6Supported = Network.isIPv6Supported();
 761            bool ipv4 = _initData.properties.getIcePropertyAsInt("Ice.IPv4") > 0;
 762            bool ipv6 = isIPv6Supported && _initData.properties.getIcePropertyAsInt("Ice.IPv6") > 0;
 763            if (!ipv4 && !ipv6)
 764            {
 765                throw new Ice.InitializationException("Both IPv4 and IPv6 support cannot be disabled.");
 766            }
 767            else if (ipv4 && ipv6)
 768            {
 769                _protocolSupport = Network.EnableBoth;
 770            }
 771            else if (ipv4)
 772            {
 773                _protocolSupport = Network.EnableIPv4;
 774            }
 775            else
 776            {
 777                _protocolSupport = Network.EnableIPv6;
 778            }
 779            _preferIPv6 = _initData.properties.getIcePropertyAsInt("Ice.PreferIPv6Address") > 0;
 780
 781            _networkProxy = createNetworkProxy(_initData.properties, _protocolSupport);
 782
 783            _sslEngine = new Ice.SSL.SSLEngine(communicator);
 784
 785            _endpointFactoryManager = new EndpointFactoryManager(this);
 786
 787            var tcpInstance = new ProtocolInstance(this, Ice.TCPEndpointType.value, "tcp", false);
 788            _endpointFactoryManager.add(new TcpEndpointFactory(tcpInstance));
 789
 790            var udpInstance = new ProtocolInstance(this, Ice.UDPEndpointType.value, "udp", false);
 791            _endpointFactoryManager.add(new UdpEndpointFactory(udpInstance));
 792
 793            var wsInstance = new ProtocolInstance(this, Ice.WSEndpointType.value, "ws", false);
 794            _endpointFactoryManager.add(new WSEndpointFactory(wsInstance, Ice.TCPEndpointType.value));
 795
 796            var sslInstance = new Ice.SSL.Instance(_sslEngine, Ice.SSLEndpointType.value, "ssl");
 797            _endpointFactoryManager.add(new Ice.SSL.EndpointFactoryI(sslInstance, Ice.TCPEndpointType.value));
 798
 799            var wssInstance = new ProtocolInstance(this, Ice.WSSEndpointType.value, "wss", true);
 800            _endpointFactoryManager.add(new WSEndpointFactory(wssInstance, Ice.SSLEndpointType.value));
 801
 802            _pluginManager = new Ice.PluginManagerI(communicator);
 803
 804            _outgoingConnectionFactory = new OutgoingConnectionFactory(this);
 805
 806            _objectAdapterFactory = new ObjectAdapterFactory(this, communicator);
 807
 808            _retryQueue = new RetryQueue(this);
 809
 810            string[] retryValues = _initData.properties.getIcePropertyAsList("Ice.RetryIntervals");
 811            if (retryValues.Length == 0)
 812            {
 813                retryIntervals = [0];
 814            }
 815            else
 816            {
 817                retryIntervals = new int[retryValues.Length];
 818
 819                for (int i = 0; i < retryValues.Length; i++)
 820                {
 821                    bool parsed =
 822                        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                    //
 827                    if (parsed && i == 0 && v == -1)
 828                    {
 829                        retryIntervals = [];
 830                        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.
 835                    if (!parsed || v < 0)
 836                    {
 837                        _initData.logger.warning(
 838                            $"invalid value '{retryValues[i]}' in property Ice.RetryIntervals, assuming 0");
 839                        v = 0;
 840                    }
 841
 842                    retryIntervals[i] = v;
 843                }
 844            }
 845
 846            if (_initData.properties.getIcePropertyAsInt("Ice.PreloadAssemblies") > 0)
 847            {
 848                AssemblyUtil.preloadAssemblies();
 849            }
 850        }
 851        catch (Ice.LocalException)
 852        {
 853            destroy();
 854            throw;
 855        }
 856    }
 857
 858    internal void finishSetup(Communicator communicator)
 859    {
 860        //
 861        // Load plug-ins.
 862        //
 863        Debug.Assert(_serverThreadPool == null);
 864        var pluginManagerImpl = (Ice.PluginManagerI)_pluginManager;
 865        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        //
 871        _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
 880        if (_initData.properties.getIceProperty("Ice.Admin.Enabled").Length == 0)
 881        {
 882            _adminEnabled = _initData.properties.getIceProperty("Ice.Admin.Endpoints").Length > 0;
 883        }
 884        else
 885        {
 886            _adminEnabled = _initData.properties.getIcePropertyAsInt("Ice.Admin.Enabled") > 0;
 887        }
 888
 889        string[] facetFilter = _initData.properties.getIcePropertyAsList("Ice.Admin.Facets");
 890        if (facetFilter.Length > 0)
 891        {
 892            foreach (string s in facetFilter)
 893            {
 894                _adminFacetFilter.Add(s);
 895            }
 896        }
 897
 898        if (_adminEnabled)
 899        {
 900            //
 901            // Process facet
 902            //
 903            string processFacetName = "Process";
 904            if (_adminFacetFilter.Count == 0 || _adminFacetFilter.Contains(processFacetName))
 905            {
 906                _adminFacets.Add(processFacetName, new ProcessI(communicator));
 907            }
 908
 909            //
 910            // Logger facet
 911            //
 912            string loggerFacetName = "Logger";
 913            if (_adminFacetFilter.Count == 0 || _adminFacetFilter.Contains(loggerFacetName))
 914            {
 915                LoggerAdminLogger logger = new LoggerAdminLoggerI(_initData.properties, _initData.logger);
 916                // Decorate the existing logger, and don't change _ownLogger.
 917                _initData.logger = logger;
 918                _adminFacets.Add(loggerFacetName, logger.getFacet());
 919            }
 920
 921            //
 922            // Properties facet
 923            //
 924            string propertiesFacetName = "Properties";
 925            NativePropertiesAdmin propsAdmin = null;
 926            if (_adminFacetFilter.Count == 0 || _adminFacetFilter.Contains(propertiesFacetName))
 927            {
 928                propsAdmin = new NativePropertiesAdmin(this);
 929                _adminFacets.Add(propertiesFacetName, propsAdmin);
 930            }
 931
 932            //
 933            // Metrics facet
 934            //
 935            string metricsFacetName = "Metrics";
 936            if (_adminFacetFilter.Count == 0 || _adminFacetFilter.Contains(metricsFacetName))
 937            {
 938                var observer = new CommunicatorObserverI(_initData);
 939                _initData.observer = observer;
 940                _adminFacets.Add(metricsFacetName, observer.getFacet());
 941
 942                //
 943                // Make sure the admin plugin receives property updates.
 944                //
 945                propsAdmin?.addUpdateCallback(observer.getFacet().updated);
 946            }
 947        }
 948
 949        //
 950        // Set observer updater
 951        //
 952        _initData.observer?.setObserverUpdater(new ObserverUpdaterI(this));
 953
 954        //
 955        // Create threads.
 956        //
 957        try
 958        {
 959            _timer = new Timer(this, Util.getThreadPriorityProperty(initializationData().properties, "Ice"));
 960        }
 961        catch (System.Exception ex)
 962        {
 963            string s = "cannot create thread for timer:\n" + ex;
 964            _initData.logger.error(s);
 965            throw;
 966        }
 967
 968        try
 969        {
 970            _endpointHostResolver = new EndpointHostResolver(this);
 971        }
 972        catch (System.Exception ex)
 973        {
 974            string s = "cannot create thread for endpoint host resolver:\n" + ex;
 975            _initData.logger.error(s);
 976            throw;
 977        }
 978        _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        //
 984        if (_referenceFactory.getDefaultRouter() == null)
 985        {
 986            Ice.RouterPrx r = Ice.RouterPrxHelper.uncheckedCast(
 987                communicator.propertyToProxy("Ice.Default.Router"));
 988            if (r != null)
 989            {
 990                _referenceFactory = _referenceFactory.setDefaultRouter(r);
 991            }
 992        }
 993
 994        if (_referenceFactory.getDefaultLocator() == null)
 995        {
 996            Ice.LocatorPrx l = Ice.LocatorPrxHelper.uncheckedCast(
 997                communicator.propertyToProxy("Ice.Default.Locator"));
 998            if (l != null)
 999            {
 1000                _referenceFactory = _referenceFactory.setDefaultLocator(l);
 1001            }
 1002        }
 1003
 1004        //
 1005        // Show process id if requested (but only once).
 1006        //
 1007        lock (_mutex)
 1008        {
 1009            if (!_printProcessIdDone && _initData.properties.getIcePropertyAsInt("Ice.PrintProcessId") > 0)
 1010            {
 1011                using var p = System.Diagnostics.Process.GetCurrentProcess();
 1012                Console.WriteLine(p.Id);
 1013                _printProcessIdDone = true;
 1014            }
 1015        }
 1016
 1017        // SslEngine initialization
 1018        _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        //
 1029        if (_initData.properties.getIcePropertyAsInt("Ice.InitPlugins") > 0)
 1030        {
 1031            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        //
 1039        if (_initData.properties.getIcePropertyAsInt("Ice.Admin.DelayCreation") <= 0)
 1040        {
 1041            getAdmin();
 1042        }
 1043    }
 1044
 1045    //
 1046    // Only for use by Ice.Communicator
 1047    //
 1048    public void destroy()
 1049    {
 1050        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            //
 1057            while (_state == StateDestroyInProgress)
 1058            {
 1059                Monitor.Wait(_mutex);
 1060            }
 1061
 1062            if (_state == StateDestroyed)
 1063            {
 1064                return;
 1065            }
 1066            _state = StateDestroyInProgress;
 1067        }
 1068
 1069        //
 1070        // Shutdown and destroy all the incoming and outgoing Ice
 1071        // connections and wait for the connections to be finished.
 1072        //
 1073        _objectAdapterFactory?.shutdown();
 1074
 1075        _outgoingConnectionFactory?.destroy();
 1076
 1077        _objectAdapterFactory?.destroy();
 1078
 1079        _outgoingConnectionFactory?.waitUntilFinished();
 1080
 1081        _retryQueue?.destroy(); // Must be called before destroying thread pools.
 1082
 1083        _initData.observer?.setObserverUpdater(null);
 1084
 1085        if (_initData.logger is LoggerAdminLogger loggerAdminLogger)
 1086        {
 1087            // In effect, remove the decorator.
 1088            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        //
 1096        _serverThreadPool?.destroy();
 1097        _clientThreadPool?.destroy();
 1098        _endpointHostResolver?.destroy();
 1099
 1100        //
 1101        // Wait for all the threads to be finished.
 1102        //
 1103        _timer?.destroy();
 1104        _clientThreadPool?.joinWithAllThreads();
 1105        _serverThreadPool?.joinWithAllThreads();
 1106        _endpointHostResolver?.joinWithThread();
 1107
 1108        _routerManager?.destroy();
 1109
 1110        _locatorManager?.destroy();
 1111
 1112        if (_initData.properties.getIcePropertyAsInt("Ice.Warn.UnusedProperties") > 0)
 1113        {
 1114            List<string> unusedProperties = _initData.properties.getUnusedProperties();
 1115            if (unusedProperties.Count != 0)
 1116            {
 1117                var message = new StringBuilder("The following properties were set but never read:");
 1118                foreach (string s in unusedProperties)
 1119                {
 1120                    message.Append("\n    ");
 1121                    message.Append(s);
 1122                }
 1123                _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        //
 1130        _pluginManager?.destroy();
 1131
 1132        lock (_mutex)
 1133        {
 1134            _objectAdapterFactory = null;
 1135            _outgoingConnectionFactory = null;
 1136            _retryQueue = null;
 1137
 1138            _serverThreadPool = null;
 1139            _clientThreadPool = null;
 1140            _endpointHostResolver = null;
 1141            _timer = null;
 1142
 1143            _referenceFactory = null;
 1144            _routerManager = null;
 1145            _locatorManager = null;
 1146            _endpointFactoryManager = null;
 1147            _pluginManager = null;
 1148
 1149            _sslEngine?.Dispose();
 1150            _sslEngine = null;
 1151
 1152            _adminAdapter = null;
 1153            _adminFacets.Clear();
 1154
 1155            _state = StateDestroyed;
 1156            Monitor.PulseAll(_mutex);
 1157        }
 1158
 1159        if (_ownLogger)
 1160        {
 1161            _initData.logger!.Dispose();
 1162        }
 1163    }
 1164
 1165    public BufSizeWarnInfo getBufSizeWarn(short type)
 1166    {
 1167        lock (_setBufSizeWarn)
 1168        {
 1169            BufSizeWarnInfo info;
 1170            if (!_setBufSizeWarn.TryGetValue(type, out BufSizeWarnInfo value))
 1171            {
 1172                info = new BufSizeWarnInfo();
 1173                info.sndWarn = false;
 1174                info.sndSize = -1;
 1175                info.rcvWarn = false;
 1176                info.rcvSize = -1;
 1177                _setBufSizeWarn.Add(type, info);
 1178            }
 1179            else
 1180            {
 1181                info = _setBufSizeWarn[type];
 1182            }
 1183            return info;
 1184        }
 1185    }
 1186
 1187    public void setSndBufSizeWarn(short type, int size)
 1188    {
 1189        lock (_setBufSizeWarn)
 1190        {
 1191            BufSizeWarnInfo info = getBufSizeWarn(type);
 1192            info.sndWarn = true;
 1193            info.sndSize = size;
 1194            _setBufSizeWarn[type] = info;
 1195        }
 1196    }
 1197
 1198    public void setRcvBufSizeWarn(short type, int size)
 1199    {
 1200        lock (_setBufSizeWarn)
 1201        {
 1202            BufSizeWarnInfo info = getBufSizeWarn(type);
 1203            info.rcvWarn = true;
 1204            info.rcvSize = size;
 1205            _setBufSizeWarn[type] = info;
 1206        }
 1207    }
 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;
 1218            lock (_mutex)
 1219            {
 1220                if (_state >= StateDestroyInProgress)
 1221                {
 1222                    return;
 1223                }
 1224                outgoingConnectionFactory = _outgoingConnectionFactory;
 1225                objectAdapterFactory = _objectAdapterFactory;
 1226            }
 1227
 1228            Debug.Assert(outgoingConnectionFactory != null);
 1229            outgoingConnectionFactory.updateConnectionObservers();
 1230            Debug.Assert(objectAdapterFactory != null);
 1231            objectAdapterFactory.updateConnectionObservers();
 1232        }
 1233        catch (CommunicatorDestroyedException)
 1234        {
 1235        }
 1236    }
 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;
 1250            lock (_mutex)
 1251            {
 1252                if (_state >= StateDestroyInProgress)
 1253                {
 1254                    return;
 1255                }
 1256                clientThreadPool = _clientThreadPool;
 1257                serverThreadPool = _serverThreadPool;
 1258                objectAdapterFactory = _objectAdapterFactory;
 1259                endpointHostResolver = _endpointHostResolver;
 1260                timer = _timer;
 1261            }
 1262
 1263            clientThreadPool?.updateObservers();
 1264            serverThreadPool?.updateObservers();
 1265            Debug.Assert(objectAdapterFactory != null);
 1266            objectAdapterFactory.updateThreadObservers();
 1267            endpointHostResolver?.updateObserver();
 1268            timer?.updateObserver(_initData.observer);
 1269        }
 1270        catch (CommunicatorDestroyedException)
 1271        {
 1272        }
 1273    }
 1274
 1275    internal void addAllAdminFacets()
 1276    {
 1277        lock (_mutex)
 1278        {
 1279            var filteredFacets = new Dictionary<string, Ice.Object>();
 1280
 1281            foreach (KeyValuePair<string, Ice.Object> entry in _adminFacets)
 1282            {
 1283                if (_adminFacetFilter.Count == 0 || _adminFacetFilter.Contains(entry.Key))
 1284                {
 1285                    _adminAdapter.addFacet(entry.Value, _adminIdentity, entry.Key);
 1286                }
 1287                else
 1288                {
 1289                    filteredFacets.Add(entry.Key, entry.Value);
 1290                }
 1291            }
 1292            _adminFacets = filteredFacets;
 1293        }
 1294    }
 1295
 1296    internal void setServerProcessProxy(Ice.ObjectAdapter adminAdapter, Ice.Identity adminIdentity)
 1297    {
 1298        Ice.ObjectPrx admin = adminAdapter.createProxy(adminIdentity);
 1299        Ice.LocatorPrx locator = adminAdapter.getLocator();
 1300        string serverId = _initData.properties.getIceProperty("Ice.Admin.ServerId");
 1301
 1302        if (locator != null && serverId.Length > 0)
 1303        {
 1304            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                //
 1311                locator.getRegistry().setServerProcessProxy(serverId, process);
 1312            }
 1313            catch (Ice.ServerNotFoundException)
 1314            {
 1315                if (_traceLevels.location >= 1)
 1316                {
 1317                    var s = new System.Text.StringBuilder();
 1318                    s.Append("couldn't register server `" + serverId + "' with the locator registry:\n");
 1319                    s.Append("the server is not known to the locator registry");
 1320                    _initData.logger.trace(_traceLevels.locationCat, s.ToString());
 1321                }
 1322
 1323                throw new Ice.InitializationException("Locator knows nothing about server `" + serverId + "'");
 1324            }
 1325            catch (Ice.LocalException ex)
 1326            {
 1327                if (_traceLevels.location >= 1)
 1328                {
 1329                    var s = new System.Text.StringBuilder();
 1330                    s.Append("couldn't register server `" + serverId + "' with the locator registry:\n" + ex);
 1331                    _initData.logger.trace(_traceLevels.locationCat, s.ToString());
 1332                }
 1333                throw; // TODO: Shall we raise a special exception instead of a non obvious local exception?
 1334            }
 1335
 1336            if (_traceLevels.location >= 1)
 1337            {
 1338                var s = new System.Text.StringBuilder();
 1339                s.Append("registered server `" + serverId + "' with the locator registry");
 1340                _initData.logger.trace(_traceLevels.locationCat, s.ToString());
 1341            }
 1342        }
 1343    }
 1344
 1345    internal ConnectionOptions serverConnectionOptions(string adapterName)
 1346    {
 1347        Debug.Assert(adapterName.Length > 0);
 1348        Properties properties = _initData.properties;
 1349        string propertyPrefix = $"{adapterName}.Connection";
 1350
 1351        return new(
 1352            connectTimeout: TimeSpan.FromSeconds(properties.getPropertyAsIntWithDefault(
 1353                $"{propertyPrefix}.ConnectTimeout",
 1354                (int)_serverConnectionOptions.connectTimeout.TotalSeconds)),
 1355
 1356            closeTimeout: TimeSpan.FromSeconds(properties.getPropertyAsIntWithDefault(
 1357                $"{propertyPrefix}.CloseTimeout",
 1358                (int)_serverConnectionOptions.closeTimeout.TotalSeconds)),
 1359
 1360            idleTimeout: TimeSpan.FromSeconds(properties.getPropertyAsIntWithDefault(
 1361                $"{propertyPrefix}.IdleTimeout",
 1362                (int)_serverConnectionOptions.idleTimeout.TotalSeconds)),
 1363
 1364            enableIdleCheck: properties.getPropertyAsIntWithDefault(
 1365                $"{propertyPrefix}.EnableIdleCheck",
 1366                _serverConnectionOptions.enableIdleCheck ? 1 : 0) > 0,
 1367
 1368            inactivityTimeout: TimeSpan.FromSeconds(properties.getPropertyAsIntWithDefault(
 1369                $"{propertyPrefix}.InactivityTimeout",
 1370                (int)_serverConnectionOptions.inactivityTimeout.TotalSeconds)),
 1371
 1372            maxDispatches: properties.getPropertyAsIntWithDefault(
 1373                $"{propertyPrefix}.MaxDispatches",
 1374                _serverConnectionOptions.maxDispatches));
 1375    }
 1376
 1377    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
 1387        proxyHost = props.getIceProperty("Ice.SOCKSProxyHost");
 1388        if (proxyHost.Length > 0)
 1389        {
 1390            if (protocolSupport == Network.EnableIPv6)
 1391            {
 1392                throw new Ice.InitializationException("IPv6 only is not supported with SOCKS4 proxies");
 1393            }
 1394            int proxyPort = props.getIcePropertyAsInt("Ice.SOCKSProxyPort");
 1395            return new SOCKSNetworkProxy(proxyHost, proxyPort);
 1396        }
 1397
 1398        proxyHost = props.getIceProperty("Ice.HTTPProxyHost");
 1399        if (proxyHost.Length > 0)
 1400        {
 1401            return new HTTPNetworkProxy(proxyHost, props.getIcePropertyAsInt("Ice.HTTPProxyPort"));
 1402        }
 1403
 1404        return null;
 1405    }
 1406
 1407    private ConnectionOptions readConnectionOptions(string propertyPrefix)
 1408    {
 1409        Properties properties = _initData.properties;
 1410
 1411        // The TimeSpan value can be <= 0. In this case, the timeout is considered infinite.
 1412        return new(
 1413            connectTimeout: TimeSpan.FromSeconds(properties.getIcePropertyAsInt($"{propertyPrefix}.ConnectTimeout")),
 1414            closeTimeout: TimeSpan.FromSeconds(properties.getIcePropertyAsInt($"{propertyPrefix}.CloseTimeout")),
 1415            idleTimeout: TimeSpan.FromSeconds(properties.getIcePropertyAsInt($"{propertyPrefix}.IdleTimeout")),
 1416            enableIdleCheck: properties.getIcePropertyAsInt($"{propertyPrefix}.EnableIdleCheck") > 0,
 1417            inactivityTimeout:
 1418                TimeSpan.FromSeconds(properties.getIcePropertyAsInt($"{propertyPrefix}.InactivityTimeout")),
 1419            maxDispatches: properties.getIcePropertyAsInt($"{propertyPrefix}.MaxDispatches"));
 1420    }
 1421
 1422    private static bool _printProcessIdDone;
 1423    private static bool _oneOffDone;
 1424    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;
 1459    private Dictionary<string, Ice.Object> _adminFacets = new();
 1460    private readonly HashSet<string> _adminFacetFilter = new();
 1461    private Ice.Identity _adminIdentity;
 1462    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.
 1468    private readonly CompositeSliceLoader _applicationSliceLoader = new();
 1469
 1470    private readonly object _mutex = new object();
 1471}