zeroc-ice 3.6.5 → 3.7.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/BZIP2_LICENSE +42 -0
- data/ICE_LICENSE +17 -17
- data/LICENSE +12 -12
- data/bin/slice2rb +1 -1
- data/ext/Communicator.cpp +150 -53
- data/ext/Communicator.h +1 -1
- data/ext/Config.h +2 -12
- data/ext/Connection.cpp +89 -68
- data/ext/Connection.h +1 -1
- data/ext/Endpoint.cpp +16 -45
- data/ext/Endpoint.h +1 -1
- data/ext/ImplicitContext.cpp +1 -5
- data/ext/ImplicitContext.h +1 -1
- data/ext/Init.cpp +4 -1
- data/ext/Logger.cpp +1 -1
- data/ext/Logger.h +1 -1
- data/ext/Operation.cpp +33 -44
- data/ext/Operation.h +1 -1
- data/ext/Properties.cpp +1 -1
- data/ext/Properties.h +1 -1
- data/ext/Proxy.cpp +22 -57
- data/ext/Proxy.h +1 -1
- data/ext/Slice.cpp +5 -5
- data/ext/Slice.h +1 -1
- data/ext/Types.cpp +244 -171
- data/ext/Types.h +118 -66
- data/ext/Util.cpp +13 -9
- data/ext/Util.h +10 -10
- data/ext/ValueFactoryManager.cpp +445 -0
- data/ext/ValueFactoryManager.h +100 -0
- data/ext/extconf.rb +47 -45
- data/ext/ice/bzip2/blocksort.c +1094 -0
- data/ext/ice/bzip2/bzlib.c +1572 -0
- data/ext/ice/bzip2/bzlib.h +282 -0
- data/ext/ice/bzip2/bzlib_private.h +509 -0
- data/ext/ice/bzip2/compress.c +672 -0
- data/ext/ice/bzip2/crctable.c +104 -0
- data/ext/ice/bzip2/decompress.c +646 -0
- data/ext/ice/bzip2/huffman.c +205 -0
- data/ext/ice/bzip2/randtable.c +84 -0
- data/ext/ice/cpp/include/Ice/Application.h +77 -60
- data/ext/ice/cpp/include/Ice/AsyncResult.h +34 -318
- data/ext/ice/cpp/include/Ice/AsyncResultF.h +4 -2
- data/ext/ice/cpp/include/Ice/BatchRequestInterceptor.h +5 -10
- data/ext/ice/cpp/include/Ice/BatchRequestQueueF.h +1 -1
- data/ext/ice/cpp/include/Ice/Buffer.h +10 -10
- data/ext/ice/cpp/include/Ice/CommunicatorAsync.h +14 -12
- data/ext/ice/cpp/include/Ice/Comparable.h +130 -0
- data/ext/ice/cpp/include/Ice/Config.h +7 -36
- data/ext/ice/cpp/include/Ice/ConnectionAsync.h +107 -11
- data/ext/ice/cpp/include/Ice/ConnectionIF.h +5 -1
- data/ext/ice/cpp/include/Ice/ConsoleUtil.h +28 -0
- data/ext/ice/cpp/include/Ice/{DefaultObjectFactory.h → DefaultValueFactory.h} +28 -14
- data/ext/ice/cpp/include/Ice/DispatchInterceptor.h +4 -6
- data/ext/ice/cpp/include/Ice/Dispatcher.h +14 -13
- data/ext/ice/cpp/include/Ice/DynamicLibrary.h +7 -5
- data/ext/ice/cpp/include/Ice/DynamicLibraryF.h +1 -1
- data/ext/ice/cpp/include/Ice/Exception.h +66 -56
- data/ext/ice/cpp/include/Ice/ExceptionHelpers.h +69 -0
- data/ext/ice/cpp/include/Ice/FactoryTable.h +11 -12
- data/ext/ice/cpp/include/Ice/FactoryTableInit.h +27 -25
- data/ext/ice/cpp/include/Ice/Format.h +6 -1
- data/ext/ice/cpp/include/Ice/Functional.h +33 -33
- data/ext/ice/cpp/include/Ice/GCObject.h +9 -5
- data/ext/ice/cpp/include/Ice/Handle.h +6 -11
- data/ext/ice/cpp/include/Ice/Ice.h +9 -5
- data/ext/ice/cpp/include/{IceUtil → Ice}/IconvStringConverter.h +108 -62
- data/ext/ice/cpp/include/Ice/Incoming.h +109 -33
- data/ext/ice/cpp/include/Ice/IncomingAsync.h +63 -23
- data/ext/ice/cpp/include/Ice/IncomingAsyncF.h +7 -1
- data/ext/ice/cpp/include/Ice/Initialize.h +178 -38
- data/ext/ice/cpp/include/Ice/InputStream.h +994 -0
- data/ext/ice/cpp/include/Ice/InstanceF.h +1 -2
- data/ext/ice/cpp/include/Ice/InterfaceByValue.h +46 -0
- data/ext/ice/cpp/include/Ice/LocalObject.h +9 -9
- data/ext/ice/cpp/include/Ice/LocalObjectF.h +1 -1
- data/ext/ice/cpp/include/Ice/LoggerUtil.h +20 -14
- data/ext/ice/cpp/include/Ice/MetricsAdminI.h +114 -65
- data/ext/ice/cpp/include/Ice/MetricsFunctional.h +23 -5
- data/ext/ice/cpp/include/Ice/MetricsObserverI.h +99 -26
- data/ext/ice/cpp/include/Ice/NativePropertiesAdmin.h +17 -4
- data/ext/ice/cpp/include/Ice/Object.h +105 -56
- data/ext/ice/cpp/include/Ice/ObjectF.h +8 -3
- data/ext/ice/cpp/include/Ice/ObserverHelper.h +18 -8
- data/ext/ice/cpp/include/Ice/Optional.h +1084 -0
- data/ext/ice/cpp/include/Ice/OutgoingAsync.h +655 -84
- data/ext/ice/cpp/include/Ice/OutgoingAsyncF.h +12 -6
- data/ext/ice/cpp/include/Ice/OutputStream.h +753 -0
- data/ext/ice/cpp/include/Ice/Protocol.h +19 -12
- data/ext/ice/cpp/include/Ice/Proxy.h +1329 -717
- data/ext/ice/cpp/include/Ice/ProxyF.h +11 -33
- data/ext/ice/cpp/include/Ice/ProxyFactoryF.h +1 -1
- data/ext/ice/cpp/include/Ice/ProxyHandle.h +34 -50
- data/ext/ice/cpp/include/Ice/ReferenceF.h +1 -1
- data/ext/ice/cpp/include/Ice/RegisterPlugins.h +22 -3
- data/ext/ice/cpp/include/Ice/RequestHandlerF.h +10 -4
- data/ext/ice/cpp/include/Ice/ResponseHandlerF.h +6 -1
- data/ext/ice/cpp/include/{IceUtil → Ice}/SHA1.h +16 -16
- data/ext/ice/cpp/include/Ice/ServantManagerF.h +1 -1
- data/ext/ice/cpp/include/Ice/Service.h +13 -18
- data/ext/ice/cpp/include/Ice/SliceChecksums.h +1 -1
- data/ext/ice/cpp/include/Ice/SlicedData.h +46 -20
- data/ext/ice/cpp/include/Ice/SlicedDataF.h +14 -6
- data/ext/ice/cpp/include/Ice/StreamHelpers.h +159 -49
- data/ext/ice/cpp/include/Ice/StringConverter.h +52 -0
- data/ext/ice/cpp/include/Ice/ThreadPoolF.h +1 -1
- data/{slice/Ice/ObjectFactoryF.ice → ext/ice/cpp/include/Ice/UUID.h} +9 -7
- data/ext/ice/cpp/include/{IceUtil → Ice}/UniquePtr.h +21 -22
- data/ext/ice/cpp/include/Ice/UniqueRef.h +98 -0
- data/ext/ice/cpp/include/Ice/UserExceptionFactory.h +40 -8
- data/ext/ice/cpp/include/Ice/Value.h +104 -0
- data/{slice/Freeze/ConnectionF.ice → ext/ice/cpp/include/Ice/ValueF.h} +11 -7
- data/ext/ice/cpp/include/IceSSL/Config.h +8 -23
- data/ext/ice/cpp/include/IceSSL/IceSSL.h +17 -6
- data/ext/ice/cpp/include/IceSSL/OpenSSL.h +130 -0
- data/ext/ice/cpp/include/IceSSL/Plugin.h +172 -259
- data/ext/ice/cpp/include/IceSSL/SChannel.h +66 -0
- data/ext/ice/cpp/include/IceSSL/SecureTransport.h +66 -0
- data/ext/ice/cpp/include/IceSSL/UWP.h +58 -0
- data/ext/ice/cpp/include/IceUtil/Atomic.h +8 -10
- data/ext/ice/cpp/include/IceUtil/Cond.h +17 -18
- data/ext/ice/cpp/include/IceUtil/Config.h +138 -39
- data/ext/ice/cpp/include/IceUtil/ConsoleUtil.h +97 -0
- data/ext/ice/cpp/include/IceUtil/CountDownLatch.h +5 -5
- data/ext/ice/cpp/include/IceUtil/CtrlCHandler.h +23 -17
- data/ext/ice/cpp/include/IceUtil/DisableWarnings.h +1 -3
- data/ext/ice/cpp/include/IceUtil/Exception.h +157 -67
- data/ext/ice/cpp/include/IceUtil/FileUtil.h +148 -0
- data/ext/ice/cpp/include/IceUtil/Functional.h +1 -2
- data/ext/ice/cpp/include/IceUtil/Handle.h +11 -11
- data/ext/ice/cpp/include/IceUtil/IceUtil.h +4 -10
- data/ext/ice/cpp/include/IceUtil/InputUtil.h +3 -3
- data/ext/ice/cpp/include/IceUtil/Iterator.h +2 -2
- data/ext/ice/cpp/include/IceUtil/Lock.h +8 -10
- data/ext/ice/cpp/include/IceUtil/Monitor.h +1 -2
- data/ext/ice/cpp/include/IceUtil/Mutex.h +17 -11
- data/ext/ice/cpp/include/IceUtil/MutexProtocol.h +2 -2
- data/ext/ice/cpp/include/IceUtil/MutexPtrLock.h +4 -4
- data/ext/ice/cpp/include/IceUtil/MutexPtrTryLock.h +4 -4
- data/ext/ice/cpp/include/IceUtil/Optional.h +32 -18
- data/ext/ice/cpp/include/IceUtil/Options.h +17 -18
- data/ext/ice/cpp/include/IceUtil/OutputUtil.h +55 -29
- data/ext/ice/cpp/include/IceUtil/PopDisableWarnings.h +6 -6
- data/ext/ice/cpp/include/IceUtil/PushDisableWarnings.h +11 -10
- data/ext/ice/cpp/include/IceUtil/Random.h +3 -3
- data/ext/ice/cpp/include/IceUtil/RecMutex.h +7 -8
- data/ext/ice/cpp/include/IceUtil/ResourceConfig.h +58 -0
- data/ext/ice/cpp/include/IceUtil/ScannerConfig.h +1 -9
- data/ext/ice/cpp/include/IceUtil/ScopedArray.h +8 -2
- data/ext/ice/cpp/include/IceUtil/Shared.h +5 -7
- data/ext/ice/cpp/{src → include}/IceUtil/StopWatch.h +2 -2
- data/ext/ice/cpp/include/IceUtil/StringConverter.h +77 -72
- data/ext/ice/cpp/include/IceUtil/StringUtil.h +32 -21
- data/ext/ice/cpp/include/IceUtil/Thread.h +10 -12
- data/ext/ice/cpp/include/IceUtil/ThreadException.h +33 -42
- data/ext/ice/cpp/include/IceUtil/Time.h +3 -3
- data/ext/ice/cpp/include/IceUtil/Timer.h +14 -13
- data/ext/ice/cpp/include/IceUtil/UUID.h +2 -2
- data/ext/ice/cpp/include/IceUtil/UndefSysMacros.h +1 -1
- data/ext/ice/cpp/include/{Ice → generated/Ice}/BuiltinSequences.h +41 -8
- data/ext/ice/cpp/include/generated/Ice/Communicator.h +364 -0
- data/ext/ice/cpp/include/{Ice → generated/Ice}/CommunicatorF.h +40 -8
- data/ext/ice/cpp/include/generated/Ice/Connection.h +872 -0
- data/ext/ice/cpp/include/{Ice → generated/Ice}/ConnectionF.h +46 -8
- data/ext/ice/cpp/include/{Ice → generated/Ice}/Current.h +71 -8
- data/ext/ice/cpp/include/generated/Ice/Endpoint.h +582 -0
- data/ext/ice/cpp/include/{Ice → generated/Ice}/EndpointF.h +62 -8
- data/ext/ice/cpp/include/{Ice → generated/Ice}/EndpointTypes.h +31 -16
- data/ext/ice/cpp/include/{Ice → generated/Ice}/FacetMap.h +23 -8
- data/ext/ice/cpp/include/generated/Ice/Identity.h +221 -0
- data/ext/ice/cpp/include/{Ice → generated/Ice}/ImplicitContext.h +72 -13
- data/ext/ice/cpp/include/{Ice → generated/Ice}/ImplicitContextF.h +40 -8
- data/ext/ice/cpp/include/generated/Ice/Instrumentation.h +602 -0
- data/ext/ice/cpp/include/{Ice → generated/Ice}/InstrumentationF.h +54 -8
- data/ext/ice/cpp/include/generated/Ice/LocalException.h +2802 -0
- data/ext/ice/cpp/include/generated/Ice/Locator.h +2036 -0
- data/ext/ice/cpp/include/{Ice → generated/Ice}/LocatorF.h +53 -12
- data/ext/ice/cpp/include/{Ice → generated/Ice}/Logger.h +71 -13
- data/ext/ice/cpp/include/{Ice → generated/Ice}/LoggerF.h +40 -8
- data/ext/ice/cpp/include/generated/Ice/Metrics.h +2649 -0
- data/ext/ice/cpp/include/generated/Ice/ObjectAdapter.h +302 -0
- data/ext/ice/cpp/include/{Ice → generated/Ice}/ObjectAdapterF.h +40 -8
- data/ext/ice/cpp/include/generated/Ice/ObjectFactory.h +142 -0
- data/ext/ice/cpp/include/generated/Ice/Plugin.h +197 -0
- data/ext/ice/cpp/include/{Ice → generated/Ice}/PluginF.h +43 -8
- data/ext/ice/cpp/include/generated/Ice/Process.h +536 -0
- data/ext/ice/cpp/include/{Ice → generated/Ice}/ProcessF.h +45 -10
- data/ext/ice/cpp/include/{Ice → generated/Ice}/Properties.h +88 -21
- data/ext/ice/cpp/include/generated/Ice/PropertiesAdmin.h +749 -0
- data/ext/ice/cpp/include/{Ice → generated/Ice}/PropertiesF.h +48 -10
- data/ext/ice/cpp/include/generated/Ice/RemoteLogger.h +1449 -0
- data/ext/ice/cpp/include/generated/Ice/Router.h +1032 -0
- data/ext/ice/cpp/include/{Ice → generated/Ice}/RouterF.h +45 -10
- data/ext/ice/cpp/include/{Ice → generated/Ice}/ServantLocator.h +65 -13
- data/ext/ice/cpp/include/{Ice → generated/Ice}/ServantLocatorF.h +40 -8
- data/ext/ice/cpp/include/{Ice → generated/Ice}/SliceChecksumDict.h +23 -8
- data/ext/ice/cpp/include/generated/Ice/ValueFactory.h +169 -0
- data/ext/ice/cpp/include/generated/Ice/Version.h +334 -0
- data/ext/ice/cpp/include/generated/IceSSL/ConnectionInfo.h +172 -0
- data/ext/ice/cpp/include/generated/IceSSL/ConnectionInfoF.h +98 -0
- data/ext/ice/cpp/include/generated/IceSSL/EndpointInfo.h +156 -0
- data/ext/ice/cpp/src/Ice/ACM.cpp +18 -14
- data/ext/ice/cpp/src/Ice/ACM.h +9 -2
- data/ext/ice/cpp/{include → src}/Ice/ACMF.h +10 -5
- data/ext/ice/cpp/src/Ice/Acceptor.cpp +6 -1
- data/ext/ice/cpp/src/Ice/Acceptor.h +4 -3
- data/ext/ice/cpp/src/Ice/AcceptorF.h +1 -1
- data/ext/ice/cpp/src/{IceUtil → Ice}/ArgVector.cpp +9 -9
- data/ext/ice/cpp/src/{IceUtil → Ice}/ArgVector.h +7 -7
- data/ext/ice/cpp/src/Ice/AsyncResult.cpp +15 -538
- data/ext/ice/cpp/src/Ice/Base64.cpp +11 -11
- data/ext/ice/cpp/src/Ice/Base64.h +1 -1
- data/ext/ice/cpp/src/Ice/BatchRequestQueue.cpp +40 -12
- data/ext/ice/cpp/src/Ice/BatchRequestQueue.h +15 -10
- data/ext/ice/cpp/src/Ice/Buffer.cpp +74 -12
- data/ext/ice/cpp/src/Ice/BuiltinSequences.cpp +20 -6
- data/ext/ice/cpp/src/Ice/CollocatedRequestHandler.cpp +85 -190
- data/ext/ice/cpp/src/Ice/CollocatedRequestHandler.h +17 -18
- data/ext/ice/cpp/src/Ice/Communicator.cpp +39 -8
- data/ext/ice/cpp/src/Ice/CommunicatorF.cpp +27 -5
- data/ext/ice/cpp/src/Ice/CommunicatorI.cpp +271 -104
- data/ext/ice/cpp/src/Ice/CommunicatorI.h +84 -28
- data/ext/ice/cpp/src/{IceUtil → Ice}/Cond.cpp +3 -3
- data/ext/ice/cpp/src/Ice/ConnectRequestHandler.cpp +58 -125
- data/ext/ice/cpp/src/Ice/ConnectRequestHandler.h +11 -22
- data/ext/ice/cpp/src/Ice/ConnectRequestHandlerF.h +6 -2
- data/ext/ice/cpp/src/Ice/Connection.cpp +88 -8
- data/ext/ice/cpp/src/Ice/ConnectionF.cpp +27 -5
- data/ext/ice/cpp/src/Ice/ConnectionFactory.cpp +158 -80
- data/ext/ice/cpp/src/Ice/ConnectionFactory.h +41 -23
- data/ext/ice/cpp/{include → src}/Ice/ConnectionFactoryF.h +8 -3
- data/ext/ice/cpp/src/Ice/ConnectionI.cpp +707 -653
- data/ext/ice/cpp/src/Ice/ConnectionI.h +97 -69
- data/ext/ice/cpp/src/Ice/ConnectionRequestHandler.cpp +2 -15
- data/ext/ice/cpp/src/Ice/ConnectionRequestHandler.h +4 -3
- data/ext/ice/cpp/src/Ice/Connector.cpp +6 -1
- data/ext/ice/cpp/src/Ice/Connector.h +4 -3
- data/ext/ice/cpp/src/Ice/ConnectorF.h +1 -1
- data/ext/ice/cpp/src/{IceUtil → Ice}/CountDownLatch.cpp +4 -4
- data/ext/ice/cpp/src/Ice/Current.cpp +29 -6
- data/ext/ice/cpp/src/Ice/DefaultsAndOverrides.cpp +6 -5
- data/ext/ice/cpp/src/Ice/DefaultsAndOverrides.h +1 -1
- data/ext/ice/cpp/src/Ice/DefaultsAndOverridesF.h +1 -1
- data/ext/ice/cpp/src/Ice/DispatchInterceptor.cpp +5 -25
- data/ext/ice/cpp/src/Ice/DynamicLibrary.cpp +29 -19
- data/ext/ice/cpp/src/Ice/Endpoint.cpp +85 -6
- data/ext/ice/cpp/src/Ice/EndpointF.cpp +27 -5
- data/ext/ice/cpp/src/Ice/EndpointFactory.cpp +152 -1
- data/ext/ice/cpp/src/Ice/EndpointFactory.h +72 -6
- data/ext/ice/cpp/src/Ice/EndpointFactoryF.h +1 -1
- data/ext/ice/cpp/src/Ice/EndpointFactoryManager.cpp +35 -19
- data/ext/ice/cpp/src/Ice/EndpointFactoryManager.h +10 -4
- data/ext/ice/cpp/src/Ice/EndpointFactoryManagerF.h +1 -1
- data/ext/ice/cpp/src/Ice/EndpointI.cpp +17 -1
- data/ext/ice/cpp/src/Ice/EndpointI.h +35 -9
- data/ext/ice/cpp/src/Ice/EndpointIF.h +18 -5
- data/ext/ice/cpp/src/Ice/EndpointTypes.cpp +18 -6
- data/ext/ice/cpp/src/Ice/EventHandler.cpp +6 -4
- data/ext/ice/cpp/src/Ice/EventHandler.h +13 -8
- data/ext/ice/cpp/src/Ice/EventHandlerF.h +5 -2
- data/ext/ice/cpp/src/Ice/Exception.cpp +95 -86
- data/ext/ice/cpp/src/Ice/FacetMap.cpp +20 -6
- data/ext/ice/cpp/src/Ice/FactoryTable.cpp +37 -28
- data/ext/ice/cpp/src/Ice/FactoryTableInit.cpp +2 -4
- data/ext/ice/cpp/src/Ice/GCObject.cpp +28 -25
- data/ext/ice/cpp/src/Ice/HashUtil.h +2 -3
- data/ext/ice/cpp/src/Ice/HttpParser.cpp +1 -2
- data/ext/ice/cpp/src/Ice/HttpParser.h +1 -1
- data/ext/ice/cpp/src/Ice/IPEndpointI.cpp +92 -53
- data/ext/ice/cpp/src/Ice/IPEndpointI.h +19 -10
- data/ext/ice/cpp/src/Ice/IPEndpointIF.h +6 -2
- data/ext/ice/cpp/src/Ice/IconvStringConverter.cpp +56 -0
- data/ext/ice/cpp/src/Ice/Identity.cpp +24 -10
- data/ext/ice/cpp/src/Ice/ImplicitContext.cpp +37 -6
- data/ext/ice/cpp/src/Ice/ImplicitContextF.cpp +27 -5
- data/ext/ice/cpp/src/Ice/ImplicitContextI.cpp +14 -14
- data/ext/ice/cpp/src/Ice/ImplicitContextI.h +7 -5
- data/ext/ice/cpp/src/Ice/Incoming.cpp +276 -245
- data/ext/ice/cpp/src/Ice/IncomingAsync.cpp +104 -209
- data/ext/ice/cpp/src/Ice/IncomingRequest.h +5 -4
- data/ext/ice/cpp/src/Ice/Initialize.cpp +299 -172
- data/ext/ice/cpp/src/Ice/InputStream.cpp +2773 -0
- data/ext/ice/cpp/src/Ice/Instance.cpp +191 -231
- data/ext/ice/cpp/src/Ice/Instance.h +30 -18
- data/ext/ice/cpp/src/Ice/Instrumentation.cpp +106 -7
- data/ext/ice/cpp/src/Ice/InstrumentationF.cpp +27 -5
- data/ext/ice/cpp/src/Ice/InstrumentationI.cpp +117 -99
- data/ext/ice/cpp/src/Ice/InstrumentationI.h +30 -31
- data/ext/ice/cpp/src/Ice/LocalException.cpp +1190 -416
- data/ext/ice/cpp/src/Ice/LocalObject.cpp +1 -2
- data/ext/ice/cpp/src/Ice/Locator.cpp +1167 -1215
- data/ext/ice/cpp/src/Ice/LocatorF.cpp +29 -6
- data/ext/ice/cpp/src/Ice/LocatorInfo.cpp +129 -163
- data/ext/ice/cpp/src/Ice/LocatorInfo.h +29 -29
- data/ext/ice/cpp/src/Ice/LocatorInfoF.h +1 -1
- data/ext/ice/cpp/src/Ice/Logger.cpp +35 -5
- data/ext/ice/cpp/src/Ice/LoggerAdminI.cpp +178 -73
- data/ext/ice/cpp/src/Ice/LoggerAdminI.h +4 -4
- data/ext/ice/cpp/src/Ice/LoggerF.cpp +27 -5
- data/ext/ice/cpp/src/Ice/LoggerI.cpp +14 -44
- data/ext/ice/cpp/src/Ice/LoggerI.h +7 -13
- data/ext/ice/cpp/src/Ice/LoggerUtil.cpp +10 -12
- data/ext/ice/cpp/src/Ice/Metrics.cpp +1059 -1069
- data/ext/ice/cpp/src/Ice/MetricsAdminI.cpp +49 -19
- data/ext/ice/cpp/src/Ice/MetricsObserverI.cpp +1 -2
- data/ext/ice/cpp/src/Ice/Network.cpp +534 -170
- data/ext/ice/cpp/src/Ice/Network.h +100 -23
- data/ext/ice/cpp/src/Ice/NetworkF.h +2 -2
- data/ext/ice/cpp/src/Ice/NetworkProxy.cpp +21 -14
- data/ext/ice/cpp/src/Ice/NetworkProxy.h +5 -2
- data/ext/ice/cpp/src/Ice/NetworkProxyF.h +1 -1
- data/ext/ice/cpp/src/Ice/Object.cpp +217 -221
- data/ext/ice/cpp/src/Ice/ObjectAdapter.cpp +41 -6
- data/ext/ice/cpp/src/Ice/ObjectAdapterF.cpp +27 -5
- data/ext/ice/cpp/src/Ice/ObjectAdapterFactory.cpp +35 -14
- data/ext/ice/cpp/src/Ice/ObjectAdapterFactory.h +13 -7
- data/ext/ice/cpp/{include → src}/Ice/ObjectAdapterFactoryF.h +5 -1
- data/ext/ice/cpp/src/Ice/ObjectAdapterI.cpp +184 -58
- data/ext/ice/cpp/src/Ice/ObjectAdapterI.h +32 -26
- data/ext/ice/cpp/src/Ice/ObjectFactory.cpp +37 -6
- data/ext/ice/cpp/src/Ice/ObserverHelper.cpp +9 -32
- data/ext/ice/cpp/src/Ice/OpaqueEndpointI.cpp +40 -18
- data/ext/ice/cpp/src/Ice/OpaqueEndpointI.h +14 -5
- data/ext/ice/cpp/src/Ice/OutgoingAsync.cpp +803 -365
- data/ext/ice/cpp/src/Ice/OutputStream.cpp +1399 -0
- data/ext/ice/cpp/src/Ice/Plugin.cpp +45 -6
- data/ext/ice/cpp/src/Ice/PluginF.cpp +27 -5
- data/ext/ice/cpp/src/Ice/PluginManagerI.cpp +13 -13
- data/ext/ice/cpp/src/Ice/PluginManagerI.h +5 -6
- data/ext/ice/cpp/src/Ice/Process.cpp +256 -114
- data/ext/ice/cpp/src/Ice/ProcessF.cpp +29 -6
- data/ext/ice/cpp/src/Ice/Properties.cpp +38 -8
- data/ext/ice/cpp/src/Ice/PropertiesAdmin.cpp +340 -328
- data/ext/ice/cpp/src/Ice/PropertiesAdminI.cpp +81 -17
- data/ext/ice/cpp/src/Ice/PropertiesAdminI.h +29 -5
- data/ext/ice/cpp/src/Ice/PropertiesF.cpp +29 -6
- data/ext/ice/cpp/src/Ice/PropertiesI.cpp +25 -26
- data/ext/ice/cpp/src/Ice/PropertiesI.h +8 -11
- data/ext/ice/cpp/src/Ice/PropertyNames.cpp +107 -50
- data/ext/ice/cpp/src/Ice/PropertyNames.h +4 -2
- data/ext/ice/cpp/src/Ice/Protocol.cpp +2 -2
- data/ext/ice/cpp/src/Ice/ProtocolInstance.cpp +37 -2
- data/ext/ice/cpp/src/Ice/ProtocolInstance.h +9 -20
- data/ext/ice/cpp/src/Ice/ProtocolInstanceF.h +1 -1
- data/ext/ice/cpp/src/Ice/ProtocolPluginFacade.cpp +6 -1
- data/ext/ice/cpp/src/Ice/ProtocolPluginFacade.h +3 -1
- data/ext/ice/cpp/src/Ice/ProtocolPluginFacadeF.h +1 -1
- data/ext/ice/cpp/src/Ice/Proxy.cpp +690 -964
- data/ext/ice/cpp/src/Ice/ProxyFactory.cpp +23 -32
- data/ext/ice/cpp/src/Ice/ProxyFactory.h +16 -11
- data/ext/ice/cpp/src/Ice/Reference.cpp +75 -69
- data/ext/ice/cpp/src/Ice/Reference.h +27 -22
- data/ext/ice/cpp/src/Ice/ReferenceFactory.cpp +18 -21
- data/ext/ice/cpp/src/Ice/ReferenceFactory.h +12 -12
- data/ext/ice/cpp/src/Ice/ReferenceFactoryF.h +1 -1
- data/ext/ice/cpp/src/Ice/RegisterPluginsInit.cpp +18 -4
- data/ext/ice/cpp/src/Ice/RegisterPluginsInit.h +1 -1
- data/ext/ice/cpp/src/Ice/RemoteLogger.cpp +672 -552
- data/ext/ice/cpp/src/Ice/ReplyStatus.h +1 -1
- data/ext/ice/cpp/src/Ice/RequestHandler.cpp +5 -3
- data/ext/ice/cpp/src/Ice/RequestHandler.h +10 -13
- data/ext/ice/cpp/src/Ice/RequestHandlerFactory.cpp +10 -6
- data/ext/ice/cpp/src/Ice/RequestHandlerFactory.h +2 -2
- data/ext/ice/cpp/src/Ice/ResponseHandler.cpp +3 -6
- data/ext/ice/cpp/src/Ice/ResponseHandler.h +16 -7
- data/ext/ice/cpp/src/Ice/RetryQueue.cpp +6 -12
- data/ext/ice/cpp/src/Ice/RetryQueue.h +7 -6
- data/ext/ice/cpp/src/Ice/RetryQueueF.h +1 -1
- data/ext/ice/cpp/src/Ice/Router.cpp +523 -474
- data/ext/ice/cpp/src/Ice/RouterF.cpp +29 -6
- data/ext/ice/cpp/src/Ice/RouterInfo.cpp +91 -70
- data/ext/ice/cpp/src/Ice/RouterInfo.h +43 -32
- data/ext/ice/cpp/src/Ice/RouterInfoF.h +1 -1
- data/ext/ice/cpp/src/{IceUtil → Ice}/SHA1.cpp +21 -21
- data/ext/ice/cpp/src/Ice/Selector.cpp +989 -923
- data/ext/ice/cpp/src/Ice/Selector.h +100 -147
- data/ext/ice/cpp/src/Ice/ServantLocator.cpp +37 -6
- data/ext/ice/cpp/src/Ice/ServantLocatorF.cpp +27 -5
- data/ext/ice/cpp/src/Ice/ServantManager.cpp +9 -9
- data/ext/ice/cpp/src/Ice/ServantManager.h +1 -1
- data/ext/ice/cpp/src/Ice/SharedContext.h +2 -2
- data/ext/ice/cpp/src/Ice/SliceChecksumDict.cpp +20 -6
- data/ext/ice/cpp/src/Ice/SliceChecksums.cpp +2 -2
- data/ext/ice/cpp/src/Ice/SlicedData.cpp +72 -20
- data/ext/ice/cpp/src/Ice/StreamSocket.cpp +173 -18
- data/ext/ice/cpp/src/Ice/StreamSocket.h +13 -4
- data/ext/ice/cpp/src/Ice/StringConverterPlugin.cpp +48 -17
- data/ext/ice/cpp/src/Ice/StringUtil.h +35 -0
- data/ext/ice/cpp/src/Ice/SysLoggerI.cpp +8 -4
- data/ext/ice/cpp/src/Ice/SysLoggerI.h +2 -3
- data/ext/ice/cpp/src/Ice/TcpAcceptor.cpp +158 -32
- data/ext/ice/cpp/src/Ice/TcpAcceptor.h +12 -5
- data/ext/ice/cpp/src/Ice/TcpConnector.cpp +1 -7
- data/ext/ice/cpp/src/Ice/TcpConnector.h +1 -2
- data/ext/ice/cpp/src/Ice/TcpEndpointI.cpp +40 -32
- data/ext/ice/cpp/src/Ice/TcpEndpointI.h +11 -8
- data/ext/ice/cpp/src/Ice/TcpTransceiver.cpp +12 -27
- data/ext/ice/cpp/src/Ice/TcpTransceiver.h +7 -10
- data/ext/ice/cpp/src/{IceUtil → Ice}/Thread.cpp +24 -41
- data/ext/ice/cpp/src/Ice/ThreadPool.cpp +175 -267
- data/ext/ice/cpp/src/Ice/ThreadPool.h +38 -43
- data/ext/ice/cpp/src/{IceUtil → Ice}/Timer.cpp +28 -21
- data/ext/ice/cpp/src/Ice/TraceLevels.cpp +2 -2
- data/ext/ice/cpp/src/Ice/TraceLevels.h +1 -1
- data/ext/ice/cpp/src/Ice/TraceLevelsF.h +2 -2
- data/ext/ice/cpp/src/Ice/TraceUtil.cpp +53 -31
- data/ext/ice/cpp/src/Ice/TraceUtil.h +13 -6
- data/ext/ice/cpp/src/Ice/Transceiver.cpp +1 -2
- data/ext/ice/cpp/src/Ice/Transceiver.h +8 -7
- data/ext/ice/cpp/src/Ice/TransceiverF.h +1 -1
- data/ext/ice/cpp/src/Ice/UdpConnector.cpp +2 -8
- data/ext/ice/cpp/src/Ice/UdpConnector.h +1 -2
- data/ext/ice/cpp/src/Ice/UdpEndpointI.cpp +92 -31
- data/ext/ice/cpp/src/Ice/UdpEndpointI.h +12 -4
- data/ext/ice/cpp/src/Ice/UdpTransceiver.cpp +150 -179
- data/ext/ice/cpp/src/Ice/UdpTransceiver.h +15 -17
- data/ext/ice/cpp/src/Ice/Value.cpp +81 -0
- data/ext/ice/cpp/src/Ice/ValueFactory.cpp +84 -0
- data/ext/ice/cpp/src/Ice/ValueFactoryManagerI.cpp +70 -0
- data/ext/ice/cpp/src/Ice/ValueFactoryManagerI.h +42 -0
- data/ext/ice/cpp/src/Ice/Version.cpp +24 -14
- data/ext/ice/cpp/src/Ice/VirtualShared.h +43 -0
- data/ext/ice/cpp/src/Ice/WSAcceptor.cpp +3 -9
- data/ext/ice/cpp/src/Ice/WSAcceptor.h +3 -7
- data/ext/ice/cpp/src/Ice/WSConnector.cpp +5 -11
- data/ext/ice/cpp/src/Ice/WSConnector.h +3 -6
- data/ext/ice/cpp/src/Ice/WSEndpoint.cpp +185 -80
- data/ext/ice/cpp/src/Ice/WSEndpoint.h +21 -31
- data/ext/ice/cpp/src/Ice/WSTransceiver.cpp +41 -37
- data/ext/ice/cpp/src/Ice/WSTransceiver.h +7 -21
- data/ext/ice/cpp/src/IceDiscovery/IceDiscovery.cpp +526 -264
- data/ext/ice/cpp/src/IceDiscovery/IceDiscovery.h +341 -455
- data/ext/ice/cpp/src/IceDiscovery/LocatorI.cpp +86 -26
- data/ext/ice/cpp/src/IceDiscovery/LocatorI.h +59 -23
- data/ext/ice/cpp/src/IceDiscovery/LookupI.cpp +315 -61
- data/ext/ice/cpp/src/IceDiscovery/LookupI.h +83 -36
- data/ext/ice/cpp/src/IceDiscovery/PluginI.cpp +57 -59
- data/ext/ice/cpp/src/IceDiscovery/PluginI.h +3 -3
- data/ext/ice/cpp/src/IceLocatorDiscovery/IceLocatorDiscovery.cpp +396 -159
- data/ext/ice/cpp/src/IceLocatorDiscovery/IceLocatorDiscovery.h +251 -355
- data/ext/ice/cpp/src/IceLocatorDiscovery/Plugin.h +52 -0
- data/ext/ice/cpp/src/IceLocatorDiscovery/PluginI.cpp +526 -131
- data/ext/ice/cpp/src/IceSSL/AcceptorI.cpp +19 -165
- data/ext/ice/cpp/src/IceSSL/AcceptorI.h +8 -17
- data/ext/ice/cpp/src/IceSSL/CertificateI.cpp +284 -0
- data/ext/ice/cpp/src/IceSSL/CertificateI.h +69 -0
- data/ext/ice/cpp/src/IceSSL/ConnectionInfo.cpp +39 -11
- data/ext/ice/cpp/src/{Ice/ObjectFactoryF.cpp → IceSSL/ConnectionInfoF.cpp} +31 -9
- data/ext/ice/cpp/src/IceSSL/ConnectorI.cpp +14 -56
- data/ext/ice/cpp/src/IceSSL/ConnectorI.h +6 -13
- data/ext/ice/cpp/src/IceSSL/EndpointI.cpp +205 -197
- data/ext/ice/cpp/src/IceSSL/EndpointI.h +41 -33
- data/ext/ice/cpp/src/IceSSL/EndpointInfo.cpp +39 -10
- data/ext/ice/cpp/src/IceSSL/Instance.cpp +1 -6
- data/ext/ice/cpp/src/IceSSL/Instance.h +7 -7
- data/ext/ice/cpp/src/IceSSL/InstanceF.h +11 -7
- data/ext/ice/cpp/src/IceSSL/OpenSSLCertificateI.cpp +588 -0
- data/ext/ice/cpp/src/IceSSL/OpenSSLEngine.cpp +117 -152
- data/ext/ice/cpp/src/IceSSL/OpenSSLEngine.h +64 -0
- data/ext/ice/cpp/src/IceSSL/OpenSSLEngineF.h +32 -0
- data/ext/ice/cpp/src/IceSSL/OpenSSLPluginI.cpp +132 -0
- data/ext/ice/cpp/src/IceSSL/OpenSSLTransceiverI.cpp +400 -89
- data/ext/ice/cpp/src/IceSSL/OpenSSLTransceiverI.h +36 -21
- data/ext/ice/cpp/src/IceSSL/OpenSSLUtil.cpp +291 -0
- data/ext/ice/cpp/src/IceSSL/OpenSSLUtil.h +63 -0
- data/ext/ice/cpp/src/IceSSL/PluginI.cpp +71 -41
- data/ext/ice/cpp/src/IceSSL/PluginI.h +13 -18
- data/ext/ice/cpp/src/IceSSL/RFC2253.cpp +9 -54
- data/ext/ice/cpp/src/IceSSL/RFC2253.h +7 -7
- data/ext/ice/cpp/src/IceSSL/SChannelCertificateI.cpp +585 -0
- data/ext/ice/cpp/src/IceSSL/SChannelEngine.cpp +491 -75
- data/ext/ice/cpp/src/IceSSL/SChannelEngine.h +126 -0
- data/ext/ice/cpp/src/IceSSL/SChannelEngineF.h +32 -0
- data/ext/ice/cpp/src/IceSSL/SChannelPluginI.cpp +78 -0
- data/ext/ice/cpp/src/IceSSL/SChannelTransceiverI.cpp +126 -169
- data/ext/ice/cpp/src/IceSSL/SChannelTransceiverI.h +19 -22
- data/ext/ice/cpp/src/IceSSL/SSLEngine.cpp +79 -74
- data/ext/ice/cpp/src/IceSSL/SSLEngine.h +24 -187
- data/ext/ice/cpp/src/IceSSL/SSLEngineF.h +4 -19
- data/ext/ice/cpp/src/IceSSL/SecureTransportCertificateI.cpp +862 -0
- data/ext/ice/cpp/src/IceSSL/SecureTransportEngine.cpp +56 -214
- data/ext/ice/cpp/src/IceSSL/SecureTransportEngine.h +60 -0
- data/ext/ice/cpp/src/IceSSL/SecureTransportEngineF.h +31 -0
- data/ext/ice/cpp/src/IceSSL/SecureTransportPluginI.cpp +80 -0
- data/ext/ice/cpp/src/IceSSL/SecureTransportTransceiverI.cpp +137 -144
- data/ext/ice/cpp/src/IceSSL/SecureTransportTransceiverI.h +25 -28
- data/ext/ice/cpp/src/IceSSL/SecureTransportUtil.cpp +857 -0
- data/ext/ice/cpp/src/IceSSL/SecureTransportUtil.h +46 -0
- data/ext/ice/cpp/src/IceSSL/TrustManager.cpp +9 -13
- data/ext/ice/cpp/src/IceSSL/TrustManager.h +4 -4
- data/ext/ice/cpp/src/IceSSL/TrustManagerF.h +3 -3
- data/ext/ice/cpp/src/IceSSL/UWPCertificateI.cpp +271 -0
- data/ext/ice/cpp/src/IceSSL/UWPEngine.cpp +343 -0
- data/ext/ice/cpp/src/IceSSL/UWPEngine.h +46 -0
- data/ext/ice/cpp/{include/Ice/ObjectFactoryManagerF.h → src/IceSSL/UWPEngineF.h} +13 -8
- data/ext/ice/cpp/src/IceSSL/UWPPluginI.cpp +94 -0
- data/ext/ice/cpp/src/IceSSL/UWPTransceiverI.cpp +388 -0
- data/ext/ice/cpp/src/IceSSL/UWPTransceiverI.h +76 -0
- data/ext/ice/cpp/src/IceSSL/Util.cpp +66 -1256
- data/ext/ice/cpp/src/IceSSL/Util.h +48 -137
- data/ext/ice/cpp/src/IceUtil/ConsoleUtil.cpp +162 -0
- data/ext/ice/cpp/src/IceUtil/ConvertUTF.cpp +22 -22
- data/ext/ice/cpp/src/IceUtil/ConvertUTF.h +34 -26
- data/ext/ice/cpp/src/IceUtil/CtrlCHandler.cpp +20 -31
- data/ext/ice/cpp/src/IceUtil/FileUtil.cpp +25 -116
- data/ext/ice/cpp/src/IceUtil/InputUtil.cpp +1 -1
- data/ext/ice/cpp/src/IceUtil/MutexProtocol.cpp +1 -1
- data/ext/ice/cpp/src/IceUtil/Options.cpp +23 -46
- data/ext/ice/cpp/src/IceUtil/OutputUtil.cpp +7 -6
- data/ext/ice/cpp/src/IceUtil/Random.cpp +13 -13
- data/ext/ice/cpp/src/IceUtil/RecMutex.cpp +3 -9
- data/ext/ice/cpp/src/IceUtil/Shared.cpp +8 -3
- data/ext/ice/cpp/src/IceUtil/StringConverter.cpp +501 -264
- data/ext/ice/cpp/src/IceUtil/StringUtil.cpp +540 -235
- data/ext/ice/cpp/src/IceUtil/ThreadException.cpp +37 -74
- data/ext/ice/cpp/src/IceUtil/Time.cpp +1 -1
- data/ext/ice/cpp/src/IceUtil/UUID.cpp +10 -10
- data/ext/ice/cpp/src/IceUtil/Unicode.cpp +98 -97
- data/ext/ice/cpp/src/IceUtil/Unicode.h +21 -35
- data/ext/ice/cpp/src/IceUtil/UtilException.cpp +838 -0
- data/ext/ice/cpp/src/Slice/CPlusPlusUtil.cpp +815 -163
- data/ext/ice/cpp/src/Slice/CPlusPlusUtil.h +76 -0
- data/ext/ice/cpp/src/Slice/Checksum.cpp +2 -2
- data/ext/ice/cpp/{include → src}/Slice/Checksum.h +2 -2
- data/ext/ice/cpp/src/Slice/FileTracker.cpp +25 -78
- data/ext/ice/cpp/{include → src}/Slice/FileTracker.h +9 -9
- data/ext/ice/cpp/src/Slice/Grammar.cpp +1994 -1943
- data/ext/ice/cpp/src/Slice/Grammar.h +44 -24
- data/ext/ice/cpp/src/Slice/GrammarUtil.h +14 -14
- data/ext/ice/cpp/src/Slice/JavaUtil.cpp +2658 -1927
- data/ext/ice/cpp/{include → src}/Slice/JavaUtil.h +178 -59
- data/ext/ice/cpp/src/Slice/MD5.cpp +1 -1
- data/ext/ice/cpp/src/Slice/MD5.h +1 -1
- data/ext/ice/cpp/src/Slice/MD5I.cpp +0 -1
- data/ext/ice/cpp/src/Slice/MD5I.h +1 -1
- data/ext/ice/cpp/src/Slice/PHPUtil.cpp +12 -15
- data/ext/ice/cpp/{include → src}/Slice/PHPUtil.h +6 -15
- data/ext/ice/cpp/src/Slice/Parser.cpp +802 -307
- data/ext/ice/cpp/{include → src}/Slice/Parser.h +76 -84
- data/ext/ice/cpp/src/Slice/Preprocessor.cpp +43 -21
- data/ext/ice/cpp/{include → src}/Slice/Preprocessor.h +7 -12
- data/ext/ice/cpp/src/Slice/Python.cpp +207 -86
- data/ext/ice/cpp/src/Slice/PythonUtil.cpp +683 -679
- data/ext/ice/cpp/{include → src}/Slice/PythonUtil.h +19 -8
- data/ext/ice/cpp/src/Slice/Ruby.cpp +38 -34
- data/ext/ice/cpp/src/Slice/RubyUtil.cpp +177 -445
- data/ext/ice/cpp/{include → src}/Slice/RubyUtil.h +6 -6
- data/ext/ice/cpp/src/Slice/Scanner.cpp +218 -306
- data/ext/ice/cpp/src/Slice/{Util.cpp → SliceUtil.cpp} +37 -64
- data/ext/ice/cpp/src/Slice/StringLiteralUtil.cpp +374 -0
- data/ext/ice/cpp/src/Slice/Util.h +54 -0
- data/ext/ice/mcpp/Makefile +5 -2
- data/ice.gemspec +2 -7
- data/lib/Glacier2.rb +1 -1
- data/lib/Glacier2/Metrics.rb +7 -46
- data/lib/Glacier2/PermissionsVerifier.rb +24 -95
- data/lib/Glacier2/PermissionsVerifierF.rb +3 -3
- data/lib/Glacier2/Router.rb +32 -74
- data/lib/Glacier2/RouterF.rb +3 -3
- data/lib/Glacier2/SSLInfo.rb +4 -7
- data/lib/Glacier2/Session.rb +88 -307
- data/lib/Ice.rb +83 -52
- data/lib/Ice/BuiltinSequences.rb +4 -4
- data/lib/Ice/Communicator.rb +56 -58
- data/lib/Ice/CommunicatorF.rb +3 -3
- data/lib/Ice/Connection.rb +153 -162
- data/lib/Ice/ConnectionF.rb +3 -3
- data/lib/Ice/Current.rb +4 -11
- data/lib/Ice/Endpoint.rb +57 -133
- data/lib/Ice/EndpointF.rb +3 -3
- data/lib/Ice/EndpointTypes.rb +3 -7
- data/lib/Ice/FacetMap.rb +4 -4
- data/lib/Ice/Identity.rb +5 -8
- data/lib/Ice/ImplicitContext.rb +5 -34
- data/lib/Ice/ImplicitContextF.rb +3 -3
- data/lib/Ice/Instrumentation.rb +23 -275
- data/lib/Ice/InstrumentationF.rb +3 -3
- data/lib/Ice/LocalException.rb +95 -141
- data/lib/Ice/Locator.rb +51 -165
- data/lib/Ice/LocatorF.rb +3 -3
- data/lib/Ice/Logger.rb +5 -34
- data/lib/Ice/LoggerF.rb +3 -3
- data/lib/Ice/Metrics.rb +61 -416
- data/lib/Ice/ObjectAdapter.rb +34 -0
- data/lib/Ice/ObjectAdapterF.rb +3 -3
- data/lib/Ice/ObjectFactory.rb +5 -30
- data/lib/Ice/Plugin.rb +7 -60
- data/lib/Ice/PluginF.rb +3 -3
- data/lib/Ice/Process.rb +16 -52
- data/lib/Ice/ProcessF.rb +3 -3
- data/lib/Ice/Properties.rb +5 -41
- data/lib/Ice/PropertiesAdmin.rb +19 -56
- data/lib/Ice/PropertiesF.rb +3 -3
- data/lib/Ice/RemoteLogger.rb +34 -115
- data/lib/Ice/Router.rb +29 -101
- data/lib/Ice/RouterF.rb +3 -3
- data/lib/Ice/ServantLocator.rb +31 -0
- data/lib/Ice/{ObjectFactoryF.rb → ServantLocatorF.rb} +6 -6
- data/lib/Ice/SliceChecksumDict.rb +3 -3
- data/lib/Ice/ValueFactory.rb +33 -0
- data/lib/Ice/Version.rb +5 -11
- data/lib/IceBox.rb +1 -1
- data/lib/IceBox/IceBox.rb +44 -148
- data/lib/IceGrid.rb +1 -4
- data/lib/IceGrid/Admin.rb +551 -427
- data/lib/IceGrid/Descriptor.rb +62 -529
- data/lib/IceGrid/Exception.rb +24 -45
- data/lib/IceGrid/FileParser.rb +14 -50
- data/lib/IceGrid/PluginFacade.rb +40 -0
- data/lib/IceGrid/Registry.rb +151 -58
- data/lib/IceGrid/Session.rb +25 -64
- data/lib/IceGrid/UserAccountMapper.rb +14 -50
- data/lib/IcePatch2.rb +1 -1
- data/lib/IcePatch2/FileInfo.rb +5 -11
- data/lib/IcePatch2/FileServer.rb +33 -76
- data/lib/IceStorm.rb +1 -1
- data/lib/IceStorm/IceStorm.rb +79 -206
- data/lib/IceStorm/Metrics.rb +11 -89
- data/slice/Glacier2/Metrics.ice +8 -4
- data/slice/Glacier2/PermissionsVerifier.ice +10 -7
- data/slice/Glacier2/PermissionsVerifierF.ice +7 -4
- data/slice/Glacier2/Router.ice +10 -8
- data/slice/Glacier2/RouterF.ice +7 -4
- data/slice/Glacier2/SSLInfo.ice +8 -5
- data/slice/Glacier2/Session.ice +15 -13
- data/slice/Ice/BuiltinSequences.ice +7 -4
- data/slice/Ice/Communicator.ice +141 -66
- data/slice/Ice/CommunicatorF.ice +7 -4
- data/slice/Ice/Connection.ice +183 -86
- data/slice/Ice/ConnectionF.ice +7 -4
- data/slice/Ice/Current.ice +13 -9
- data/slice/Ice/Endpoint.ice +63 -14
- data/slice/Ice/EndpointF.ice +7 -4
- data/slice/Ice/EndpointTypes.ice +8 -6
- data/slice/Ice/FacetMap.ice +7 -4
- data/slice/Ice/Identity.ice +13 -5
- data/slice/Ice/ImplicitContext.ice +20 -18
- data/slice/Ice/ImplicitContextF.ice +7 -4
- data/slice/Ice/Instrumentation.ice +20 -19
- data/slice/Ice/InstrumentationF.ice +8 -5
- data/slice/Ice/LocalException.ice +87 -87
- data/slice/Ice/Locator.ice +19 -18
- data/slice/Ice/LocatorF.ice +7 -4
- data/slice/Ice/Logger.ice +9 -7
- data/slice/Ice/LoggerF.ice +7 -4
- data/slice/Ice/Metrics.ice +18 -14
- data/slice/Ice/ObjectAdapter.ice +30 -13
- data/slice/Ice/ObjectAdapterF.ice +7 -4
- data/slice/Ice/ObjectFactory.ice +15 -12
- data/slice/Ice/Plugin.ice +9 -6
- data/slice/Ice/PluginF.ice +8 -5
- data/slice/Ice/Process.ice +9 -6
- data/slice/Ice/ProcessF.ice +7 -4
- data/slice/Ice/Properties.ice +15 -12
- data/slice/Ice/PropertiesAdmin.ice +9 -5
- data/slice/Ice/PropertiesF.ice +7 -4
- data/slice/Ice/RemoteLogger.ice +33 -24
- data/slice/Ice/Router.ice +16 -7
- data/slice/Ice/RouterF.ice +7 -4
- data/slice/Ice/ServantLocator.ice +13 -10
- data/slice/Ice/ServantLocatorF.ice +7 -4
- data/slice/Ice/SliceChecksumDict.ice +7 -4
- data/slice/Ice/ValueFactory.ice +127 -0
- data/slice/Ice/Version.ice +9 -5
- data/slice/IceBT/ConnectionInfo.ice +53 -0
- data/slice/IceBT/EndpointInfo.ice +51 -0
- data/slice/IceBT/Types.ice +39 -0
- data/slice/IceBox/IceBox.ice +20 -21
- data/slice/IceDiscovery/IceDiscovery.ice +9 -5
- data/slice/IceGrid/Admin.ice +390 -30
- data/slice/IceGrid/Descriptor.ice +37 -29
- data/slice/IceGrid/Exception.ice +33 -27
- data/slice/IceGrid/FileParser.ice +9 -6
- data/slice/IceGrid/PluginFacade.ice +11 -9
- data/slice/IceGrid/Registry.ice +139 -16
- data/slice/IceGrid/Session.ice +10 -8
- data/slice/IceGrid/UserAccountMapper.ice +9 -6
- data/slice/IceIAP/ConnectionInfo.ice +70 -0
- data/slice/IceIAP/EndpointInfo.ice +64 -0
- data/slice/IceLocatorDiscovery/IceLocatorDiscovery.ice +9 -7
- data/slice/IcePatch2/FileInfo.ice +9 -8
- data/slice/IcePatch2/FileServer.ice +17 -13
- data/slice/IceSSL/ConnectionInfo.ice +14 -17
- data/slice/IceSSL/ConnectionInfoF.ice +24 -0
- data/slice/IceSSL/EndpointInfo.ice +9 -30
- data/slice/IceStorm/IceStorm.ice +22 -18
- data/slice/IceStorm/Metrics.ice +9 -5
- metadata +154 -120
- data/ext/ObjectFactory.cpp +0 -140
- data/ext/ObjectFactory.h +0 -50
- data/ext/ice/cpp/include/Ice/BasicStream.h +0 -1335
- data/ext/ice/cpp/include/Ice/Communicator.h +0 -200
- data/ext/ice/cpp/include/Ice/Connection.h +0 -497
- data/ext/ice/cpp/include/Ice/DeprecatedStringConverter.h +0 -62
- data/ext/ice/cpp/include/Ice/Endpoint.h +0 -341
- data/ext/ice/cpp/include/Ice/Identity.h +0 -168
- data/ext/ice/cpp/include/Ice/Instrumentation.h +0 -365
- data/ext/ice/cpp/include/Ice/LocalException.h +0 -1030
- data/ext/ice/cpp/include/Ice/Locator.h +0 -2193
- data/ext/ice/cpp/include/Ice/Metrics.h +0 -2974
- data/ext/ice/cpp/include/Ice/ObjectAdapter.h +0 -168
- data/ext/ice/cpp/include/Ice/ObjectFactory.h +0 -92
- data/ext/ice/cpp/include/Ice/ObjectFactoryF.h +0 -66
- data/ext/ice/cpp/include/Ice/Outgoing.h +0 -225
- data/ext/ice/cpp/include/Ice/Plugin.h +0 -125
- data/ext/ice/cpp/include/Ice/Process.h +0 -574
- data/ext/ice/cpp/include/Ice/PropertiesAdmin.h +0 -830
- data/ext/ice/cpp/include/Ice/RemoteLogger.h +0 -1500
- data/ext/ice/cpp/include/Ice/Router.h +0 -1159
- data/ext/ice/cpp/include/Ice/Stream.h +0 -447
- data/ext/ice/cpp/include/Ice/StreamF.h +0 -30
- data/ext/ice/cpp/include/Ice/Version.h +0 -262
- data/ext/ice/cpp/include/IceSSL/ConnectionInfo.h +0 -158
- data/ext/ice/cpp/include/IceSSL/EndpointInfo.h +0 -142
- data/ext/ice/cpp/include/IceUtil/AbstractMutex.h +0 -119
- data/ext/ice/cpp/include/IceUtil/Cache.h +0 -362
- data/ext/ice/cpp/include/Slice/CPlusPlusUtil.h +0 -65
- data/ext/ice/cpp/include/Slice/CsUtil.h +0 -92
- data/ext/ice/cpp/include/Slice/DotNetNames.h +0 -34
- data/ext/ice/cpp/include/Slice/ObjCUtil.h +0 -127
- data/ext/ice/cpp/include/Slice/Util.h +0 -56
- data/ext/ice/cpp/src/Ice/BasicStream.cpp +0 -3428
- data/ext/ice/cpp/src/Ice/DeprecatedStringConverter.cpp +0 -62
- data/ext/ice/cpp/src/Ice/ObjectFactoryManager.cpp +0 -139
- data/ext/ice/cpp/src/Ice/ObjectFactoryManager.h +0 -43
- data/ext/ice/cpp/src/Ice/Outgoing.cpp +0 -694
- data/ext/ice/cpp/src/Ice/Stream.cpp +0 -53
- data/ext/ice/cpp/src/Ice/StreamI.cpp +0 -832
- data/ext/ice/cpp/src/Ice/StreamI.h +0 -198
- data/ext/ice/cpp/src/IceSSL/Certificate.cpp +0 -1336
- data/ext/ice/cpp/src/IceUtil/Exception.cpp +0 -792
- data/ext/ice/cpp/src/IceUtil/FileUtil.h +0 -185
- data/ext/ice/cpp/src/Slice/CsUtil.cpp +0 -2660
- data/ext/ice/cpp/src/Slice/DotNetNames.cpp +0 -146
- data/ext/ice/cpp/src/Slice/ObjCUtil.cpp +0 -1310
- data/lib/IceGrid/Locator.rb +0 -106
- data/lib/IceGrid/Observer.rb +0 -572
- data/lib/IceGrid/Query.rb +0 -169
- data/slice/Freeze/BackgroundSaveEvictor.ice +0 -111
- data/slice/Freeze/CatalogData.ice +0 -49
- data/slice/Freeze/Connection.ice +0 -121
- data/slice/Freeze/DB.ice +0 -37
- data/slice/Freeze/Evictor.ice +0 -346
- data/slice/Freeze/EvictorF.ice +0 -22
- data/slice/Freeze/EvictorStorage.ice +0 -72
- data/slice/Freeze/Exception.ice +0 -100
- data/slice/Freeze/Transaction.ice +0 -58
- data/slice/Freeze/TransactionalEvictor.ice +0 -50
- data/slice/IceGrid/Locator.ice +0 -57
- data/slice/IceGrid/Observer.ice +0 -395
- data/slice/IceGrid/Query.ice +0 -131
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
// **********************************************************************
|
|
2
2
|
//
|
|
3
|
-
// Copyright (c) 2003-
|
|
3
|
+
// Copyright (c) 2003-2017 ZeroC, Inc. All rights reserved.
|
|
4
4
|
//
|
|
5
5
|
// This copy of Ice is licensed to you under the terms described in the
|
|
6
6
|
// ICE_LICENSE file included in this distribution.
|
|
@@ -1,15 +1,15 @@
|
|
|
1
1
|
// **********************************************************************
|
|
2
2
|
//
|
|
3
|
-
// Copyright (c) 2003-
|
|
3
|
+
// Copyright (c) 2003-2017 ZeroC, Inc. All rights reserved.
|
|
4
4
|
//
|
|
5
5
|
// This copy of Ice is licensed to you under the terms described in the
|
|
6
6
|
// ICE_LICENSE file included in this distribution.
|
|
7
7
|
//
|
|
8
8
|
// **********************************************************************
|
|
9
9
|
|
|
10
|
-
#include <
|
|
10
|
+
#include <Ice/SHA1.h>
|
|
11
11
|
|
|
12
|
-
#ifndef
|
|
12
|
+
#ifndef ICE_OS_UWP
|
|
13
13
|
# if defined(_WIN32)
|
|
14
14
|
# include <Wincrypt.h>
|
|
15
15
|
# include <IceUtil/Exception.h>
|
|
@@ -23,29 +23,29 @@
|
|
|
23
23
|
using namespace std;
|
|
24
24
|
using namespace IceUtil;
|
|
25
25
|
|
|
26
|
-
#ifndef
|
|
26
|
+
#ifndef ICE_OS_UWP
|
|
27
27
|
|
|
28
|
-
namespace
|
|
28
|
+
namespace IceInternal
|
|
29
29
|
{
|
|
30
30
|
|
|
31
31
|
class SHA1::Hasher
|
|
32
32
|
{
|
|
33
33
|
public:
|
|
34
|
-
|
|
34
|
+
|
|
35
35
|
Hasher();
|
|
36
36
|
# ifdef _WIN32
|
|
37
37
|
~Hasher();
|
|
38
38
|
#endif
|
|
39
|
-
|
|
39
|
+
|
|
40
40
|
void update(const unsigned char*, std::size_t);
|
|
41
41
|
void finalize(std::vector<unsigned char>&);
|
|
42
|
-
|
|
42
|
+
|
|
43
43
|
private:
|
|
44
44
|
|
|
45
45
|
// noncopyable
|
|
46
46
|
Hasher(const Hasher&);
|
|
47
47
|
Hasher operator=(const Hasher&);
|
|
48
|
-
|
|
48
|
+
|
|
49
49
|
# if defined (_WIN32)
|
|
50
50
|
HCRYPTPROV _ctx;
|
|
51
51
|
HCRYPTHASH _hash;
|
|
@@ -65,7 +65,7 @@ namespace
|
|
|
65
65
|
const int SHA_DIGEST_LENGTH = 20;
|
|
66
66
|
}
|
|
67
67
|
|
|
68
|
-
|
|
68
|
+
IceInternal::SHA1::Hasher::Hasher() :
|
|
69
69
|
_ctx(0),
|
|
70
70
|
_hash(0)
|
|
71
71
|
{
|
|
@@ -80,7 +80,7 @@ IceUtilInternal::SHA1::Hasher::Hasher() :
|
|
|
80
80
|
}
|
|
81
81
|
}
|
|
82
82
|
|
|
83
|
-
|
|
83
|
+
IceInternal::SHA1::Hasher::~Hasher()
|
|
84
84
|
{
|
|
85
85
|
if(_hash)
|
|
86
86
|
{
|
|
@@ -93,19 +93,19 @@ IceUtilInternal::SHA1::Hasher::~Hasher()
|
|
|
93
93
|
}
|
|
94
94
|
}
|
|
95
95
|
# elif defined(__APPLE__)
|
|
96
|
-
|
|
96
|
+
IceInternal::SHA1::Hasher::Hasher()
|
|
97
97
|
{
|
|
98
98
|
CC_SHA1_Init(&_ctx);
|
|
99
99
|
}
|
|
100
100
|
# else
|
|
101
|
-
|
|
101
|
+
IceInternal::SHA1::Hasher::Hasher()
|
|
102
102
|
{
|
|
103
103
|
SHA1_Init(&_ctx);
|
|
104
104
|
}
|
|
105
105
|
# endif
|
|
106
106
|
|
|
107
107
|
void
|
|
108
|
-
|
|
108
|
+
IceInternal::SHA1::Hasher::update(const unsigned char* data, size_t length)
|
|
109
109
|
{
|
|
110
110
|
# if defined(_WIN32)
|
|
111
111
|
if(!CryptHashData(_hash, data, static_cast<DWORD>(length), 0))
|
|
@@ -120,7 +120,7 @@ IceUtilInternal::SHA1::Hasher::update(const unsigned char* data, size_t length)
|
|
|
120
120
|
}
|
|
121
121
|
|
|
122
122
|
void
|
|
123
|
-
|
|
123
|
+
IceInternal::SHA1::Hasher::finalize(vector<unsigned char>& md)
|
|
124
124
|
{
|
|
125
125
|
# if defined(_WIN32)
|
|
126
126
|
md.resize(SHA_DIGEST_LENGTH);
|
|
@@ -138,32 +138,32 @@ IceUtilInternal::SHA1::Hasher::finalize(vector<unsigned char>& md)
|
|
|
138
138
|
# endif
|
|
139
139
|
}
|
|
140
140
|
|
|
141
|
-
|
|
141
|
+
IceInternal::SHA1::SHA1() :
|
|
142
142
|
_hasher(new Hasher())
|
|
143
143
|
{
|
|
144
144
|
}
|
|
145
145
|
|
|
146
|
-
|
|
146
|
+
IceInternal::SHA1::~SHA1()
|
|
147
147
|
{
|
|
148
148
|
}
|
|
149
149
|
|
|
150
150
|
void
|
|
151
|
-
|
|
151
|
+
IceInternal::SHA1::update(const unsigned char* data, std::size_t length)
|
|
152
152
|
{
|
|
153
153
|
_hasher->update(data, length);
|
|
154
154
|
}
|
|
155
155
|
|
|
156
156
|
void
|
|
157
|
-
|
|
157
|
+
IceInternal::SHA1::finalize(std::vector<unsigned char>& md)
|
|
158
158
|
{
|
|
159
159
|
_hasher->finalize(md);
|
|
160
160
|
}
|
|
161
161
|
#endif
|
|
162
162
|
|
|
163
163
|
void
|
|
164
|
-
|
|
164
|
+
IceInternal::sha1(const unsigned char* data, size_t length, vector<unsigned char>& md)
|
|
165
165
|
{
|
|
166
|
-
#if defined(
|
|
166
|
+
#if defined(ICE_OS_UWP)
|
|
167
167
|
auto dataA =
|
|
168
168
|
ref new Platform::Array<unsigned char>(const_cast<unsigned char*>(data), static_cast<unsigned int>(length));
|
|
169
169
|
auto hasher = Windows::Security::Cryptography::Core::HashAlgorithmProvider::OpenAlgorithm("SHA1");
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
// **********************************************************************
|
|
2
2
|
//
|
|
3
|
-
// Copyright (c) 2003-
|
|
3
|
+
// Copyright (c) 2003-2017 ZeroC, Inc. All rights reserved.
|
|
4
4
|
//
|
|
5
5
|
// This copy of Ice is licensed to you under the terms described in the
|
|
6
6
|
// ICE_LICENSE file included in this distribution.
|
|
@@ -29,98 +29,13 @@ struct timespec zeroTimeout = { 0, 0 };
|
|
|
29
29
|
}
|
|
30
30
|
#endif
|
|
31
31
|
|
|
32
|
-
#
|
|
33
|
-
using namespace Windows::Foundation;
|
|
32
|
+
#if defined(ICE_OS_UWP)
|
|
34
33
|
using namespace Windows::Storage::Streams;
|
|
35
34
|
using namespace Windows::Networking;
|
|
36
35
|
using namespace Windows::Networking::Sockets;
|
|
36
|
+
#endif
|
|
37
37
|
|
|
38
|
-
|
|
39
|
-
{
|
|
40
|
-
}
|
|
41
|
-
|
|
42
|
-
void
|
|
43
|
-
Selector::destroy()
|
|
44
|
-
{
|
|
45
|
-
}
|
|
46
|
-
|
|
47
|
-
void
|
|
48
|
-
Selector::initialize(IceInternal::EventHandler* handler)
|
|
49
|
-
{
|
|
50
|
-
EventHandlerPtr h = handler;
|
|
51
|
-
handler->__incRef();
|
|
52
|
-
handler->getNativeInfo()->setCompletedHandler(
|
|
53
|
-
ref new SocketOperationCompletedHandler([=](int operation)
|
|
54
|
-
{
|
|
55
|
-
//
|
|
56
|
-
// Use the reference counted handler to ensure it's not
|
|
57
|
-
// destroyed as long as the callback lambda exists.
|
|
58
|
-
//
|
|
59
|
-
completed(h, static_cast<SocketOperation>(operation));
|
|
60
|
-
}));
|
|
61
|
-
}
|
|
62
|
-
|
|
63
|
-
void
|
|
64
|
-
Selector::update(IceInternal::EventHandler* handler, SocketOperation remove, SocketOperation add)
|
|
65
|
-
{
|
|
66
|
-
handler->_registered = static_cast<SocketOperation>(handler->_registered & ~remove);
|
|
67
|
-
handler->_registered = static_cast<SocketOperation>(handler->_registered | add);
|
|
68
|
-
if(add & SocketOperationRead && !(handler->_pending & SocketOperationRead))
|
|
69
|
-
{
|
|
70
|
-
handler->_pending = static_cast<SocketOperation>(handler->_pending | SocketOperationRead);
|
|
71
|
-
completed(handler, SocketOperationRead); // Start an asynchrnous read
|
|
72
|
-
}
|
|
73
|
-
else if(add & SocketOperationWrite && !(handler->_pending & SocketOperationWrite))
|
|
74
|
-
{
|
|
75
|
-
handler->_pending = static_cast<SocketOperation>(handler->_pending | SocketOperationWrite);
|
|
76
|
-
completed(handler, SocketOperationWrite); // Start an asynchrnous write
|
|
77
|
-
}
|
|
78
|
-
}
|
|
79
|
-
|
|
80
|
-
void
|
|
81
|
-
Selector::finish(IceInternal::EventHandler* handler)
|
|
82
|
-
{
|
|
83
|
-
handler->_registered = SocketOperationNone;
|
|
84
|
-
handler->_finish = false; // Ensures that finished() is only called once on the event handler.
|
|
85
|
-
handler->__decRef();
|
|
86
|
-
}
|
|
87
|
-
|
|
88
|
-
IceInternal::EventHandlerPtr
|
|
89
|
-
Selector::getNextHandler(SocketOperation& status, int timeout)
|
|
90
|
-
{
|
|
91
|
-
Lock lock(*this);
|
|
92
|
-
while(_events.empty())
|
|
93
|
-
{
|
|
94
|
-
if(timeout > 0)
|
|
95
|
-
{
|
|
96
|
-
timedWait(IceUtil::Time::seconds(timeout));
|
|
97
|
-
if(_events.empty())
|
|
98
|
-
{
|
|
99
|
-
throw SelectorTimeoutException();
|
|
100
|
-
}
|
|
101
|
-
}
|
|
102
|
-
else
|
|
103
|
-
{
|
|
104
|
-
wait();
|
|
105
|
-
}
|
|
106
|
-
}
|
|
107
|
-
assert(!_events.empty());
|
|
108
|
-
IceInternal::EventHandlerPtr handler = _events.front().handler;
|
|
109
|
-
const SelectEvent& event = _events.front();
|
|
110
|
-
status = event.status;
|
|
111
|
-
_events.pop_front();
|
|
112
|
-
return handler;
|
|
113
|
-
}
|
|
114
|
-
|
|
115
|
-
void
|
|
116
|
-
Selector::completed(const IceInternal::EventHandlerPtr& handler, SocketOperation op)
|
|
117
|
-
{
|
|
118
|
-
Lock lock(*this);
|
|
119
|
-
_events.push_back(SelectEvent(handler, op));
|
|
120
|
-
notify();
|
|
121
|
-
}
|
|
122
|
-
|
|
123
|
-
#elif defined(ICE_USE_IOCP)
|
|
38
|
+
#if defined(ICE_USE_IOCP) || defined(ICE_OS_UWP)
|
|
124
39
|
|
|
125
40
|
Selector::Selector(const InstancePtr& instance) : _instance(instance)
|
|
126
41
|
{
|
|
@@ -130,36 +45,57 @@ Selector::~Selector()
|
|
|
130
45
|
{
|
|
131
46
|
}
|
|
132
47
|
|
|
48
|
+
#ifdef ICE_USE_IOCP
|
|
133
49
|
void
|
|
134
50
|
Selector::setup(int sizeIO)
|
|
135
51
|
{
|
|
136
|
-
_handle = CreateIoCompletionPort(INVALID_HANDLE_VALUE,
|
|
137
|
-
if(_handle ==
|
|
52
|
+
_handle = CreateIoCompletionPort(INVALID_HANDLE_VALUE, ICE_NULLPTR, 0, sizeIO);
|
|
53
|
+
if(_handle == ICE_NULLPTR)
|
|
138
54
|
{
|
|
139
55
|
Ice::SocketException ex(__FILE__, __LINE__);
|
|
140
56
|
ex.error = GetLastError();
|
|
141
57
|
throw ex;
|
|
142
58
|
}
|
|
143
59
|
}
|
|
60
|
+
#endif
|
|
144
61
|
|
|
145
62
|
void
|
|
146
63
|
Selector::destroy()
|
|
147
64
|
{
|
|
65
|
+
#ifdef ICE_USE_IOCP
|
|
148
66
|
CloseHandle(_handle);
|
|
67
|
+
#endif
|
|
149
68
|
}
|
|
150
69
|
|
|
151
70
|
void
|
|
152
71
|
Selector::initialize(EventHandler* handler)
|
|
153
72
|
{
|
|
73
|
+
if(!handler->getNativeInfo())
|
|
74
|
+
{
|
|
75
|
+
return;
|
|
76
|
+
}
|
|
77
|
+
#ifdef ICE_USE_IOCP
|
|
154
78
|
HANDLE socket = reinterpret_cast<HANDLE>(handler->getNativeInfo()->fd());
|
|
155
|
-
if(CreateIoCompletionPort(socket, _handle, reinterpret_cast<ULONG_PTR>(handler), 0) ==
|
|
79
|
+
if(CreateIoCompletionPort(socket, _handle, reinterpret_cast<ULONG_PTR>(handler), 0) == ICE_NULLPTR)
|
|
156
80
|
{
|
|
157
81
|
Ice::SocketException ex(__FILE__, __LINE__);
|
|
158
82
|
ex.error = GetLastError();
|
|
159
83
|
throw ex;
|
|
160
84
|
}
|
|
161
|
-
handler->__incRef();
|
|
162
85
|
handler->getNativeInfo()->initialize(_handle, reinterpret_cast<ULONG_PTR>(handler));
|
|
86
|
+
#else
|
|
87
|
+
EventHandlerPtr h = ICE_GET_SHARED_FROM_THIS(handler);
|
|
88
|
+
handler->getNativeInfo()->setCompletedHandler(
|
|
89
|
+
ref new SocketOperationCompletedHandler(
|
|
90
|
+
[=](int operation)
|
|
91
|
+
{
|
|
92
|
+
//
|
|
93
|
+
// Use the reference counted handler to ensure it's not
|
|
94
|
+
// destroyed as long as the callback lambda exists.
|
|
95
|
+
//
|
|
96
|
+
completed(h.get(), static_cast<SocketOperation>(operation));
|
|
97
|
+
}));
|
|
98
|
+
#endif
|
|
163
99
|
}
|
|
164
100
|
|
|
165
101
|
void
|
|
@@ -167,26 +103,15 @@ Selector::update(EventHandler* handler, SocketOperation remove, SocketOperation
|
|
|
167
103
|
{
|
|
168
104
|
handler->_registered = static_cast<SocketOperation>(handler->_registered & ~remove);
|
|
169
105
|
handler->_registered = static_cast<SocketOperation>(handler->_registered | add);
|
|
170
|
-
AsyncInfo* info = 0;
|
|
171
106
|
if(add & SocketOperationRead && !(handler->_pending & SocketOperationRead))
|
|
172
107
|
{
|
|
173
108
|
handler->_pending = static_cast<SocketOperation>(handler->_pending | SocketOperationRead);
|
|
174
|
-
|
|
109
|
+
completed(handler, SocketOperationRead); // Start an asynchrnous read
|
|
175
110
|
}
|
|
176
111
|
else if(add & SocketOperationWrite && !(handler->_pending & SocketOperationWrite))
|
|
177
112
|
{
|
|
178
113
|
handler->_pending = static_cast<SocketOperation>(handler->_pending | SocketOperationWrite);
|
|
179
|
-
|
|
180
|
-
}
|
|
181
|
-
|
|
182
|
-
if(info)
|
|
183
|
-
{
|
|
184
|
-
if(!PostQueuedCompletionStatus(_handle, 0, reinterpret_cast<ULONG_PTR>(handler), info))
|
|
185
|
-
{
|
|
186
|
-
Ice::SocketException ex(__FILE__, __LINE__);
|
|
187
|
-
ex.error = GetLastError();
|
|
188
|
-
throw ex;
|
|
189
|
-
}
|
|
114
|
+
completed(handler, SocketOperationWrite); // Start an asynchrnous write
|
|
190
115
|
}
|
|
191
116
|
}
|
|
192
117
|
|
|
@@ -194,12 +119,35 @@ void
|
|
|
194
119
|
Selector::finish(IceInternal::EventHandler* handler)
|
|
195
120
|
{
|
|
196
121
|
handler->_registered = SocketOperationNone;
|
|
197
|
-
handler->
|
|
122
|
+
handler->_finish = false; // Ensures that finished() is only called once on the event handler.
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
void
|
|
126
|
+
Selector::ready(EventHandler* handler, SocketOperation status, bool value)
|
|
127
|
+
{
|
|
128
|
+
if(((handler->_ready & status) != 0) == value)
|
|
129
|
+
{
|
|
130
|
+
return; // Nothing to do if ready state already correctly set.
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
if(value)
|
|
134
|
+
{
|
|
135
|
+
handler->_ready = static_cast<SocketOperation>(handler->_ready | status);
|
|
136
|
+
}
|
|
137
|
+
else
|
|
138
|
+
{
|
|
139
|
+
handler->_ready = static_cast<SocketOperation>(handler->_ready & ~status);
|
|
140
|
+
}
|
|
198
141
|
}
|
|
199
142
|
|
|
200
143
|
EventHandler*
|
|
144
|
+
#ifdef ICE_USE_IOCP
|
|
201
145
|
Selector::getNextHandler(SocketOperation& status, DWORD& count, int& error, int timeout)
|
|
146
|
+
#else
|
|
147
|
+
Selector::getNextHandler(SocketOperation& status, int timeout)
|
|
148
|
+
#endif
|
|
202
149
|
{
|
|
150
|
+
#ifdef ICE_USE_IOCP
|
|
203
151
|
ULONG_PTR key;
|
|
204
152
|
LPOVERLAPPED ol;
|
|
205
153
|
error = 0;
|
|
@@ -215,33 +163,93 @@ Selector::getNextHandler(SocketOperation& status, DWORD& count, int& error, int
|
|
|
215
163
|
}
|
|
216
164
|
else
|
|
217
165
|
{
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
}
|
|
223
|
-
abort();
|
|
166
|
+
Ice::SocketException ex(__FILE__, __LINE__, err);
|
|
167
|
+
Ice::Error out(_instance->initializationData().logger);
|
|
168
|
+
out << "couldn't dequeue packet from completion port:\n" << ex;
|
|
169
|
+
IceUtil::ThreadControl::sleep(IceUtil::Time::seconds(5)); // Sleep 5s to avoid looping
|
|
224
170
|
}
|
|
225
171
|
}
|
|
226
172
|
AsyncInfo* info = static_cast<AsyncInfo*>(ol);
|
|
227
|
-
|
|
173
|
+
if(info)
|
|
174
|
+
{
|
|
175
|
+
status = info->status;
|
|
176
|
+
}
|
|
228
177
|
count = SOCKET_ERROR;
|
|
229
178
|
error = WSAGetLastError();
|
|
230
179
|
return reinterpret_cast<EventHandler*>(key);
|
|
231
180
|
}
|
|
232
181
|
|
|
233
|
-
assert(ol);
|
|
234
182
|
AsyncInfo* info = static_cast<AsyncInfo*>(ol);
|
|
235
|
-
|
|
183
|
+
if(info)
|
|
184
|
+
{
|
|
185
|
+
status = info->status;
|
|
186
|
+
}
|
|
187
|
+
else
|
|
188
|
+
{
|
|
189
|
+
status = reinterpret_cast<EventHandler*>(key)->_ready;
|
|
190
|
+
}
|
|
236
191
|
return reinterpret_cast<EventHandler*>(key);
|
|
192
|
+
#else
|
|
193
|
+
IceUtil::Monitor<IceUtil::Mutex>::Lock lock(_monitor);
|
|
194
|
+
while(_events.empty())
|
|
195
|
+
{
|
|
196
|
+
if(timeout > 0)
|
|
197
|
+
{
|
|
198
|
+
_monitor.timedWait(IceUtil::Time::seconds(timeout));
|
|
199
|
+
if(_events.empty())
|
|
200
|
+
{
|
|
201
|
+
throw SelectorTimeoutException();
|
|
202
|
+
}
|
|
203
|
+
}
|
|
204
|
+
else
|
|
205
|
+
{
|
|
206
|
+
_monitor.wait();
|
|
207
|
+
}
|
|
208
|
+
}
|
|
209
|
+
assert(!_events.empty());
|
|
210
|
+
IceInternal::EventHandlerPtr handler = _events.front().handler;
|
|
211
|
+
const SelectEvent& event = _events.front();
|
|
212
|
+
status = event.status;
|
|
213
|
+
_events.pop_front();
|
|
214
|
+
return handler.get();
|
|
215
|
+
#endif
|
|
216
|
+
}
|
|
217
|
+
|
|
218
|
+
void
|
|
219
|
+
Selector::completed(EventHandler* handler, SocketOperation op)
|
|
220
|
+
{
|
|
221
|
+
#ifdef ICE_USE_IOCP
|
|
222
|
+
AsyncInfo* info = 0;
|
|
223
|
+
NativeInfoPtr nativeInfo = handler->getNativeInfo();
|
|
224
|
+
if(nativeInfo)
|
|
225
|
+
{
|
|
226
|
+
info = nativeInfo->getAsyncInfo(op);
|
|
227
|
+
}
|
|
228
|
+
if(!PostQueuedCompletionStatus(_handle, 0, reinterpret_cast<ULONG_PTR>(handler), info))
|
|
229
|
+
{
|
|
230
|
+
Ice::SocketException ex(__FILE__, __LINE__);
|
|
231
|
+
ex.error = GetLastError();
|
|
232
|
+
throw ex;
|
|
233
|
+
}
|
|
234
|
+
#else
|
|
235
|
+
IceUtil::Monitor<IceUtil::Mutex>::Lock lock(_monitor);
|
|
236
|
+
_events.push_back(SelectEvent(handler->shared_from_this(), op));
|
|
237
|
+
_monitor.notify();
|
|
238
|
+
#endif
|
|
237
239
|
}
|
|
238
240
|
|
|
239
|
-
#elif defined(ICE_USE_KQUEUE) || defined(ICE_USE_EPOLL)
|
|
241
|
+
#elif defined(ICE_USE_KQUEUE) || defined(ICE_USE_EPOLL) || defined(ICE_USE_SELECT) || defined(ICE_USE_POLL)
|
|
240
242
|
|
|
241
|
-
Selector::Selector(const InstancePtr& instance) : _instance(instance)
|
|
243
|
+
Selector::Selector(const InstancePtr& instance) : _instance(instance), _interrupted(false)
|
|
242
244
|
{
|
|
243
|
-
|
|
245
|
+
SOCKET fds[2];
|
|
246
|
+
createPipe(fds);
|
|
247
|
+
_fdIntrRead = fds[0];
|
|
248
|
+
_fdIntrWrite = fds[1];
|
|
249
|
+
_selecting = false;
|
|
250
|
+
|
|
244
251
|
#if defined(ICE_USE_EPOLL)
|
|
252
|
+
_events.resize(256);
|
|
245
253
|
_queueFd = epoll_create(1);
|
|
246
254
|
if(_queueFd < 0)
|
|
247
255
|
{
|
|
@@ -249,7 +257,18 @@ Selector::Selector(const InstancePtr& instance) : _instance(instance)
|
|
|
249
257
|
ex.error = IceInternal::getSocketErrno();
|
|
250
258
|
throw ex;
|
|
251
259
|
}
|
|
252
|
-
|
|
260
|
+
|
|
261
|
+
epoll_event event;
|
|
262
|
+
memset(&event, 0, sizeof(epoll_event));
|
|
263
|
+
event.data.ptr = 0;
|
|
264
|
+
event.events = EPOLLIN;
|
|
265
|
+
if(epoll_ctl(_queueFd, EPOLL_CTL_ADD, _fdIntrRead, &event) != 0)
|
|
266
|
+
{
|
|
267
|
+
Ice::Error out(_instance->initializationData().logger);
|
|
268
|
+
out << "error while updating selector:\n" << IceUtilInternal::errorToString(IceInternal::getSocketErrno());
|
|
269
|
+
}
|
|
270
|
+
#elif defined(ICE_USE_KQUEUE)
|
|
271
|
+
_events.resize(256);
|
|
253
272
|
_queueFd = kqueue();
|
|
254
273
|
if(_queueFd < 0)
|
|
255
274
|
{
|
|
@@ -257,7 +276,25 @@ Selector::Selector(const InstancePtr& instance) : _instance(instance)
|
|
|
257
276
|
ex.error = getSocketErrno();
|
|
258
277
|
throw ex;
|
|
259
278
|
}
|
|
260
|
-
|
|
279
|
+
|
|
280
|
+
struct kevent ev;
|
|
281
|
+
EV_SET(&ev, _fdIntrRead, EVFILT_READ, EV_ADD, 0, 0, 0);
|
|
282
|
+
int rs = kevent(_queueFd, &ev, 1, 0, 0, 0);
|
|
283
|
+
if(rs < 0)
|
|
284
|
+
{
|
|
285
|
+
Ice::Error out(_instance->initializationData().logger);
|
|
286
|
+
out << "error while updating selector:\n" << IceUtilInternal::errorToString(IceInternal::getSocketErrno());
|
|
287
|
+
}
|
|
288
|
+
#elif defined(ICE_USE_SELECT)
|
|
289
|
+
FD_ZERO(&_readFdSet);
|
|
290
|
+
FD_ZERO(&_writeFdSet);
|
|
291
|
+
FD_ZERO(&_errorFdSet);
|
|
292
|
+
FD_SET(_fdIntrRead, &_readFdSet);
|
|
293
|
+
#else
|
|
294
|
+
struct pollfd pollFd;
|
|
295
|
+
pollFd.fd = _fdIntrRead;
|
|
296
|
+
pollFd.events = POLLIN;
|
|
297
|
+
_pollFdSet.push_back(pollFd);
|
|
261
298
|
#endif
|
|
262
299
|
}
|
|
263
300
|
|
|
@@ -268,6 +305,7 @@ Selector::~Selector()
|
|
|
268
305
|
void
|
|
269
306
|
Selector::destroy()
|
|
270
307
|
{
|
|
308
|
+
#if defined(ICE_USE_KQUEUE) || defined(ICE_USE_EPOLL)
|
|
271
309
|
try
|
|
272
310
|
{
|
|
273
311
|
closeSocket(_queueFd);
|
|
@@ -277,6 +315,27 @@ Selector::destroy()
|
|
|
277
315
|
Ice::Error out(_instance->initializationData().logger);
|
|
278
316
|
out << "exception in selector while calling closeSocket():\n" << ex;
|
|
279
317
|
}
|
|
318
|
+
#endif
|
|
319
|
+
|
|
320
|
+
try
|
|
321
|
+
{
|
|
322
|
+
closeSocket(_fdIntrWrite);
|
|
323
|
+
}
|
|
324
|
+
catch(const Ice::LocalException& ex)
|
|
325
|
+
{
|
|
326
|
+
Ice::Error out(_instance->initializationData().logger);
|
|
327
|
+
out << "exception in selector while calling closeSocket():\n" << ex;
|
|
328
|
+
}
|
|
329
|
+
|
|
330
|
+
try
|
|
331
|
+
{
|
|
332
|
+
closeSocket(_fdIntrRead);
|
|
333
|
+
}
|
|
334
|
+
catch(const Ice::LocalException& ex)
|
|
335
|
+
{
|
|
336
|
+
Ice::Error out(_instance->initializationData().logger);
|
|
337
|
+
out << "exception in selector while calling closeSocket():\n" << ex;
|
|
338
|
+
}
|
|
280
339
|
}
|
|
281
340
|
|
|
282
341
|
void
|
|
@@ -289,109 +348,59 @@ Selector::update(EventHandler* handler, SocketOperation remove, SocketOperation
|
|
|
289
348
|
{
|
|
290
349
|
return;
|
|
291
350
|
}
|
|
351
|
+
checkReady(handler);
|
|
292
352
|
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
epoll_event event;
|
|
296
|
-
memset(&event, 0, sizeof(epoll_event));
|
|
297
|
-
event.data.ptr = handler;
|
|
298
|
-
SocketOperation status = handler->_registered;
|
|
299
|
-
if(handler->_disabled)
|
|
353
|
+
NativeInfoPtr nativeInfo = handler->getNativeInfo();
|
|
354
|
+
if(nativeInfo && nativeInfo->fd() != INVALID_SOCKET)
|
|
300
355
|
{
|
|
301
|
-
|
|
302
|
-
previous = static_cast<SocketOperation>(previous & ~handler->_disabled);
|
|
303
|
-
}
|
|
304
|
-
event.events |= status & SocketOperationRead ? EPOLLIN : 0;
|
|
305
|
-
event.events |= status & SocketOperationWrite ? EPOLLOUT : 0;
|
|
306
|
-
int op;
|
|
307
|
-
if(!previous && status)
|
|
308
|
-
{
|
|
309
|
-
op = EPOLL_CTL_ADD;
|
|
310
|
-
}
|
|
311
|
-
else if(previous && !status)
|
|
312
|
-
{
|
|
313
|
-
op = EPOLL_CTL_DEL;
|
|
356
|
+
updateSelectorForEventHandler(handler, remove, add);
|
|
314
357
|
}
|
|
315
|
-
|
|
358
|
+
}
|
|
359
|
+
|
|
360
|
+
void
|
|
361
|
+
Selector::enable(EventHandler* handler, SocketOperation status)
|
|
362
|
+
{
|
|
363
|
+
if(!(handler->_disabled & status))
|
|
316
364
|
{
|
|
317
365
|
return;
|
|
318
366
|
}
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
if(
|
|
367
|
+
handler->_disabled = static_cast<SocketOperation>(handler->_disabled & ~status);
|
|
368
|
+
checkReady(handler);
|
|
369
|
+
|
|
370
|
+
NativeInfoPtr nativeInfo = handler->getNativeInfo();
|
|
371
|
+
if(!nativeInfo || nativeInfo->fd() == INVALID_SOCKET)
|
|
324
372
|
{
|
|
325
|
-
|
|
326
|
-
out << "error while updating selector:\n" << IceUtilInternal::errorToString(IceInternal::getSocketErrno());
|
|
373
|
+
return;
|
|
327
374
|
}
|
|
328
|
-
|
|
329
|
-
if(
|
|
375
|
+
|
|
376
|
+
if(handler->_registered & status)
|
|
330
377
|
{
|
|
378
|
+
#if defined(ICE_USE_EPOLL)
|
|
379
|
+
SOCKET fd = nativeInfo->fd();
|
|
380
|
+
SocketOperation previous = static_cast<SocketOperation>(handler->_registered & ~(handler->_disabled | status));
|
|
381
|
+
SocketOperation newStatus = static_cast<SocketOperation>(handler->_registered & ~handler->_disabled);
|
|
382
|
+
epoll_event event;
|
|
383
|
+
memset(&event, 0, sizeof(epoll_event));
|
|
384
|
+
event.data.ptr = handler;
|
|
385
|
+
event.events |= newStatus & SocketOperationRead ? EPOLLIN : 0;
|
|
386
|
+
event.events |= newStatus & SocketOperationWrite ? EPOLLOUT : 0;
|
|
387
|
+
if(epoll_ctl(_queueFd, previous ? EPOLL_CTL_MOD : EPOLL_CTL_ADD, fd, &event) != 0)
|
|
388
|
+
{
|
|
389
|
+
Ice::Error out(_instance->initializationData().logger);
|
|
390
|
+
out << "error while updating selector:\n" << IceUtilInternal::errorToString(IceInternal::getSocketErrno());
|
|
391
|
+
}
|
|
392
|
+
#elif defined(ICE_USE_KQUEUE)
|
|
331
393
|
struct kevent ev;
|
|
332
|
-
EV_SET(&ev, fd, EVFILT_READ, EV_DELETE, 0, 0, handler);
|
|
333
|
-
_changes.push_back(ev);
|
|
334
|
-
}
|
|
335
|
-
if(remove & SocketOperationWrite)
|
|
336
|
-
{
|
|
337
|
-
struct kevent ev;
|
|
338
|
-
EV_SET(&ev, fd, EVFILT_WRITE, EV_DELETE, 0, 0, handler);
|
|
339
|
-
_changes.push_back(ev);
|
|
340
|
-
}
|
|
341
|
-
if(add & SocketOperationRead)
|
|
342
|
-
{
|
|
343
|
-
struct kevent ev;
|
|
344
|
-
EV_SET(&ev, fd, EVFILT_READ, EV_ADD | (handler->_disabled & SocketOperationRead ? EV_DISABLE : 0), 0, 0,
|
|
345
|
-
handler);
|
|
346
|
-
_changes.push_back(ev);
|
|
347
|
-
}
|
|
348
|
-
if(add & SocketOperationWrite)
|
|
349
|
-
{
|
|
350
|
-
struct kevent ev;
|
|
351
|
-
EV_SET(&ev, fd, EVFILT_WRITE, EV_ADD | (handler->_disabled & SocketOperationWrite ? EV_DISABLE : 0), 0, 0,
|
|
352
|
-
handler);
|
|
353
|
-
_changes.push_back(ev);
|
|
354
|
-
}
|
|
355
|
-
if(_selecting)
|
|
356
|
-
{
|
|
357
|
-
updateSelector();
|
|
358
|
-
}
|
|
359
|
-
#endif
|
|
360
|
-
}
|
|
361
|
-
|
|
362
|
-
void
|
|
363
|
-
Selector::enable(EventHandler* handler, SocketOperation status)
|
|
364
|
-
{
|
|
365
|
-
if(!(handler->_disabled & status))
|
|
366
|
-
{
|
|
367
|
-
return;
|
|
368
|
-
}
|
|
369
|
-
handler->_disabled = static_cast<SocketOperation>(handler->_disabled & ~status);
|
|
370
|
-
|
|
371
|
-
if(handler->_registered & status)
|
|
372
|
-
{
|
|
373
394
|
SOCKET fd = handler->getNativeInfo()->fd();
|
|
374
|
-
#if defined(ICE_USE_EPOLL)
|
|
375
|
-
SocketOperation previous = static_cast<SocketOperation>(handler->_registered & ~(handler->_disabled | status));
|
|
376
|
-
SocketOperation newStatus = static_cast<SocketOperation>(handler->_registered & ~handler->_disabled);
|
|
377
|
-
epoll_event event;
|
|
378
|
-
memset(&event, 0, sizeof(epoll_event));
|
|
379
|
-
event.data.ptr = handler;
|
|
380
|
-
event.events |= newStatus & SocketOperationRead ? EPOLLIN : 0;
|
|
381
|
-
event.events |= newStatus & SocketOperationWrite ? EPOLLOUT : 0;
|
|
382
|
-
if(epoll_ctl(_queueFd, previous ? EPOLL_CTL_MOD : EPOLL_CTL_ADD, fd, &event) != 0)
|
|
383
|
-
{
|
|
384
|
-
Ice::Error out(_instance->initializationData().logger);
|
|
385
|
-
out << "error while updating selector:\n" << IceUtilInternal::errorToString(IceInternal::getSocketErrno());
|
|
386
|
-
}
|
|
387
|
-
#else // ICE_USE_KQUEUE
|
|
388
|
-
struct kevent ev;
|
|
389
395
|
EV_SET(&ev, fd, status == SocketOperationRead ? EVFILT_READ : EVFILT_WRITE, EV_ENABLE, 0, 0, handler);
|
|
390
396
|
_changes.push_back(ev);
|
|
391
397
|
if(_selecting)
|
|
392
398
|
{
|
|
393
399
|
updateSelector();
|
|
394
400
|
}
|
|
401
|
+
#else
|
|
402
|
+
_changes.push_back(make_pair(handler, static_cast<SocketOperation>(handler->_registered & ~handler->_disabled)));
|
|
403
|
+
wakeup();
|
|
395
404
|
#endif
|
|
396
405
|
}
|
|
397
406
|
}
|
|
@@ -404,11 +413,18 @@ Selector::disable(EventHandler* handler, SocketOperation status)
|
|
|
404
413
|
return;
|
|
405
414
|
}
|
|
406
415
|
handler->_disabled = static_cast<SocketOperation>(handler->_disabled | status);
|
|
416
|
+
checkReady(handler);
|
|
417
|
+
|
|
418
|
+
NativeInfoPtr nativeInfo = handler->getNativeInfo();
|
|
419
|
+
if(!nativeInfo || nativeInfo->fd() == INVALID_SOCKET)
|
|
420
|
+
{
|
|
421
|
+
return;
|
|
422
|
+
}
|
|
407
423
|
|
|
408
424
|
if(handler->_registered & status)
|
|
409
425
|
{
|
|
410
|
-
SOCKET fd = handler->getNativeInfo()->fd();
|
|
411
426
|
#if defined(ICE_USE_EPOLL)
|
|
427
|
+
SOCKET fd = nativeInfo->fd();
|
|
412
428
|
SocketOperation newStatus = static_cast<SocketOperation>(handler->_registered & ~handler->_disabled);
|
|
413
429
|
epoll_event event;
|
|
414
430
|
memset(&event, 0, sizeof(epoll_event));
|
|
@@ -420,7 +436,8 @@ Selector::disable(EventHandler* handler, SocketOperation status)
|
|
|
420
436
|
Ice::Error out(_instance->initializationData().logger);
|
|
421
437
|
out << "error while updating selector:\n" << IceUtilInternal::errorToString(IceInternal::getSocketErrno());
|
|
422
438
|
}
|
|
423
|
-
#
|
|
439
|
+
#elif defined(ICE_USE_KQUEUE)
|
|
440
|
+
SOCKET fd = nativeInfo->fd();
|
|
424
441
|
struct kevent ev;
|
|
425
442
|
EV_SET(&ev, fd, status == SocketOperationRead ? EVFILT_READ : EVFILT_WRITE, EV_DISABLE, 0, 0, handler);
|
|
426
443
|
_changes.push_back(ev);
|
|
@@ -428,6 +445,9 @@ Selector::disable(EventHandler* handler, SocketOperation status)
|
|
|
428
445
|
{
|
|
429
446
|
updateSelector();
|
|
430
447
|
}
|
|
448
|
+
#else
|
|
449
|
+
_changes.push_back(make_pair(handler, static_cast<SocketOperation>(handler->_registered & ~handler->_disabled)));
|
|
450
|
+
wakeup();
|
|
431
451
|
#endif
|
|
432
452
|
}
|
|
433
453
|
}
|
|
@@ -438,7 +458,11 @@ Selector::finish(EventHandler* handler, bool closeNow)
|
|
|
438
458
|
if(handler->_registered)
|
|
439
459
|
{
|
|
440
460
|
update(handler, handler->_registered, SocketOperationNone);
|
|
461
|
+
#if !defined(ICE_USE_EPOLL) && !defined(ICE_USE_KQUEUE)
|
|
462
|
+
return false; // Don't close now if selecting
|
|
463
|
+
#endif
|
|
441
464
|
}
|
|
465
|
+
|
|
442
466
|
#if defined(ICE_USE_KQUEUE)
|
|
443
467
|
if(closeNow && !_changes.empty())
|
|
444
468
|
{
|
|
@@ -449,98 +473,131 @@ Selector::finish(EventHandler* handler, bool closeNow)
|
|
|
449
473
|
//
|
|
450
474
|
updateSelector();
|
|
451
475
|
}
|
|
476
|
+
#elif !defined(ICE_USE_EPOLL)
|
|
477
|
+
if(!_changes.empty())
|
|
478
|
+
{
|
|
479
|
+
return false;
|
|
480
|
+
}
|
|
452
481
|
#endif
|
|
482
|
+
|
|
453
483
|
return closeNow;
|
|
454
484
|
}
|
|
455
485
|
|
|
456
|
-
#if defined(ICE_USE_KQUEUE)
|
|
457
486
|
void
|
|
458
|
-
Selector::
|
|
487
|
+
Selector::ready(EventHandler* handler, SocketOperation status, bool value)
|
|
459
488
|
{
|
|
460
|
-
|
|
461
|
-
if(rs < 0)
|
|
489
|
+
if(((handler->_ready & status) != 0) == value)
|
|
462
490
|
{
|
|
463
|
-
|
|
464
|
-
out << "error while updating selector:\n" << IceUtilInternal::errorToString(IceInternal::getSocketErrno());
|
|
491
|
+
return; // Nothing to do if ready state already correctly set.
|
|
465
492
|
}
|
|
466
|
-
|
|
493
|
+
|
|
494
|
+
if(status & SocketOperationConnect)
|
|
467
495
|
{
|
|
468
|
-
|
|
496
|
+
NativeInfoPtr nativeInfo = handler->getNativeInfo();
|
|
497
|
+
if(nativeInfo && nativeInfo->newFd() && handler->_registered)
|
|
469
498
|
{
|
|
470
|
-
//
|
|
471
|
-
|
|
472
|
-
// and which occurs when another thread removes the FD from the kqueue (see ICE-7419).
|
|
473
|
-
//
|
|
474
|
-
if(_changes[i].flags & EV_ERROR && _changes[i].data != EINPROGRESS)
|
|
475
|
-
{
|
|
476
|
-
Ice::Error out(_instance->initializationData().logger);
|
|
477
|
-
out << "error while updating selector:\n" << IceUtilInternal::errorToString(_changes[i].data);
|
|
478
|
-
}
|
|
499
|
+
// If new FD is set after connect, register the FD with the selector.
|
|
500
|
+
updateSelectorForEventHandler(handler, SocketOperationNone, handler->_registered);
|
|
479
501
|
}
|
|
480
502
|
}
|
|
481
|
-
|
|
503
|
+
|
|
504
|
+
if(value)
|
|
505
|
+
{
|
|
506
|
+
handler->_ready = static_cast<SocketOperation>(handler->_ready | status);
|
|
507
|
+
}
|
|
508
|
+
else
|
|
509
|
+
{
|
|
510
|
+
handler->_ready = static_cast<SocketOperation>(handler->_ready & ~status);
|
|
511
|
+
}
|
|
512
|
+
checkReady(handler);
|
|
482
513
|
}
|
|
483
|
-
#endif
|
|
484
514
|
|
|
485
515
|
void
|
|
486
|
-
Selector::
|
|
516
|
+
Selector::wakeup()
|
|
487
517
|
{
|
|
488
|
-
|
|
489
|
-
int spuriousWakeup = 0;
|
|
490
|
-
while(true)
|
|
518
|
+
if(_selecting && !_interrupted)
|
|
491
519
|
{
|
|
492
|
-
|
|
493
|
-
|
|
494
|
-
#else
|
|
495
|
-
assert(!_events.empty());
|
|
496
|
-
if(timeout > 0)
|
|
497
|
-
{
|
|
498
|
-
struct timespec ts;
|
|
499
|
-
ts.tv_sec = timeout;
|
|
500
|
-
ts.tv_nsec = 0;
|
|
501
|
-
ret = kevent(_queueFd, 0, 0, &_events[0], _events.size(), &ts);
|
|
502
|
-
}
|
|
503
|
-
else
|
|
504
|
-
{
|
|
505
|
-
ret = kevent(_queueFd, 0, 0, &_events[0], _events.size(), 0);
|
|
506
|
-
}
|
|
507
|
-
#endif
|
|
508
|
-
if(ret == SOCKET_ERROR)
|
|
520
|
+
char c = 0;
|
|
521
|
+
while(true)
|
|
509
522
|
{
|
|
510
|
-
if(
|
|
523
|
+
if(::write(_fdIntrWrite, &c, 1) == SOCKET_ERROR)
|
|
511
524
|
{
|
|
512
|
-
|
|
513
|
-
|
|
525
|
+
if(interrupted())
|
|
526
|
+
{
|
|
527
|
+
continue;
|
|
528
|
+
}
|
|
514
529
|
|
|
515
|
-
|
|
516
|
-
|
|
517
|
-
|
|
518
|
-
out << "fatal error: selector failed:\n" << ex;
|
|
530
|
+
Ice::SocketException ex(__FILE__, __LINE__);
|
|
531
|
+
ex.error = IceInternal::getSocketErrno();
|
|
532
|
+
throw ex;
|
|
519
533
|
}
|
|
520
|
-
|
|
534
|
+
break;
|
|
521
535
|
}
|
|
522
|
-
|
|
536
|
+
_interrupted = true;
|
|
537
|
+
}
|
|
538
|
+
}
|
|
539
|
+
|
|
540
|
+
void
|
|
541
|
+
Selector::startSelect()
|
|
542
|
+
{
|
|
543
|
+
if(_interrupted)
|
|
544
|
+
{
|
|
545
|
+
char c;
|
|
546
|
+
while(true)
|
|
523
547
|
{
|
|
524
|
-
|
|
548
|
+
ssize_t ret = ::read(_fdIntrRead, &c, 1);
|
|
549
|
+
if(ret == SOCKET_ERROR)
|
|
525
550
|
{
|
|
526
|
-
|
|
527
|
-
|
|
551
|
+
if(interrupted())
|
|
552
|
+
{
|
|
553
|
+
continue;
|
|
554
|
+
}
|
|
555
|
+
Ice::SocketException ex(__FILE__, __LINE__);
|
|
556
|
+
ex.error = IceInternal::getSocketErrno();
|
|
557
|
+
throw ex;
|
|
528
558
|
}
|
|
529
|
-
|
|
530
|
-
continue;
|
|
559
|
+
break;
|
|
531
560
|
}
|
|
532
|
-
|
|
561
|
+
_interrupted = false;
|
|
533
562
|
}
|
|
534
563
|
|
|
535
|
-
|
|
564
|
+
#if !defined(ICE_USE_EPOLL)
|
|
565
|
+
if(!_changes.empty())
|
|
536
566
|
{
|
|
537
|
-
|
|
567
|
+
updateSelector();
|
|
568
|
+
}
|
|
569
|
+
#endif
|
|
570
|
+
_selecting = true;
|
|
571
|
+
|
|
572
|
+
//
|
|
573
|
+
// If there are ready handlers, don't block in select, just do a non-blocking
|
|
574
|
+
// select to retrieve new ready handlers from the Java selector.
|
|
575
|
+
//
|
|
576
|
+
_selectNow = !_readyHandlers.empty();
|
|
577
|
+
}
|
|
578
|
+
|
|
579
|
+
void
|
|
580
|
+
Selector::finishSelect(vector<pair<EventHandler*, SocketOperation> >& handlers)
|
|
581
|
+
{
|
|
582
|
+
_selecting = false;
|
|
583
|
+
|
|
584
|
+
assert(handlers.empty());
|
|
585
|
+
|
|
586
|
+
#if defined(ICE_USE_POLL) || defined(ICE_USE_SELECT)
|
|
587
|
+
if(_interrupted) // Interrupted, we have to process the interrupt before returning any handlers
|
|
588
|
+
{
|
|
589
|
+
return;
|
|
538
590
|
}
|
|
591
|
+
#endif
|
|
539
592
|
|
|
540
|
-
|
|
541
|
-
for(
|
|
593
|
+
#if defined(ICE_USE_POLL)
|
|
594
|
+
for(vector<struct pollfd>::const_iterator r = _pollFdSet.begin(); r != _pollFdSet.end(); ++r)
|
|
595
|
+
#else
|
|
596
|
+
for(int i = 0; i < _count; ++i)
|
|
597
|
+
#endif
|
|
542
598
|
{
|
|
543
599
|
pair<EventHandler*, SocketOperation> p;
|
|
600
|
+
|
|
544
601
|
#if defined(ICE_USE_EPOLL)
|
|
545
602
|
struct epoll_event& ev = _events[i];
|
|
546
603
|
p.first = reinterpret_cast<EventHandler*>(ev.data.ptr);
|
|
@@ -548,7 +605,7 @@ Selector::select(vector<pair<EventHandler*, SocketOperation> >& handlers, int ti
|
|
|
548
605
|
SocketOperationRead : SocketOperationNone) |
|
|
549
606
|
((ev.events & (EPOLLOUT | EPOLLERR)) ?
|
|
550
607
|
SocketOperationWrite : SocketOperationNone));
|
|
551
|
-
#
|
|
608
|
+
#elif defined(ICE_USE_KQUEUE)
|
|
552
609
|
struct kevent& ev = _events[i];
|
|
553
610
|
if(ev.flags & EV_ERROR)
|
|
554
611
|
{
|
|
@@ -558,887 +615,896 @@ Selector::select(vector<pair<EventHandler*, SocketOperation> >& handlers, int ti
|
|
|
558
615
|
}
|
|
559
616
|
p.first = reinterpret_cast<EventHandler*>(ev.udata);
|
|
560
617
|
p.second = (ev.filter == EVFILT_READ) ? SocketOperationRead : SocketOperationWrite;
|
|
561
|
-
#
|
|
562
|
-
|
|
563
|
-
|
|
564
|
-
|
|
618
|
+
#elif defined(ICE_USE_SELECT)
|
|
619
|
+
//
|
|
620
|
+
// Round robin for the filedescriptors.
|
|
621
|
+
//
|
|
622
|
+
SOCKET fd;
|
|
623
|
+
p.second = SocketOperationNone;
|
|
624
|
+
if(i < _selectedReadFdSet.fd_count)
|
|
625
|
+
{
|
|
626
|
+
fd = _selectedReadFdSet.fd_array[i];
|
|
627
|
+
p.second = static_cast<SocketOperation>(p.second | SocketOperationRead);
|
|
628
|
+
}
|
|
629
|
+
else if(i < _selectedWriteFdSet.fd_count + _selectedReadFdSet.fd_count)
|
|
630
|
+
{
|
|
631
|
+
fd = _selectedWriteFdSet.fd_array[i - _selectedReadFdSet.fd_count];
|
|
632
|
+
p.second = static_cast<SocketOperation>(p.second | SocketOperationWrite);
|
|
633
|
+
}
|
|
634
|
+
else
|
|
635
|
+
{
|
|
636
|
+
fd = _selectedErrorFdSet.fd_array[i - _selectedReadFdSet.fd_count - _selectedWriteFdSet.fd_count];
|
|
637
|
+
p.second = static_cast<SocketOperation>(p.second | SocketOperationConnect);
|
|
638
|
+
}
|
|
565
639
|
|
|
566
|
-
|
|
640
|
+
assert(fd != _fdIntrRead);
|
|
641
|
+
p.first = _handlers[fd];
|
|
642
|
+
#else
|
|
643
|
+
if(r->revents == 0)
|
|
644
|
+
{
|
|
645
|
+
continue;
|
|
646
|
+
}
|
|
567
647
|
|
|
568
|
-
|
|
569
|
-
|
|
648
|
+
SOCKET fd = r->fd;
|
|
649
|
+
assert(_handlers.find(fd) != _handlers.end());
|
|
650
|
+
p.first = _handlers[fd];
|
|
651
|
+
p.second = SocketOperationNone;
|
|
652
|
+
if(r->revents & (POLLIN | POLLERR | POLLHUP))
|
|
653
|
+
{
|
|
654
|
+
p.second = static_cast<SocketOperation>(p.second | SocketOperationRead);
|
|
655
|
+
}
|
|
656
|
+
if(r->revents & (POLLOUT | POLLERR | POLLHUP))
|
|
657
|
+
{
|
|
658
|
+
p.second = static_cast<SocketOperation>(p.second | SocketOperationWrite);
|
|
659
|
+
}
|
|
660
|
+
assert(p.second);
|
|
661
|
+
#endif
|
|
662
|
+
if(!p.first)
|
|
663
|
+
{
|
|
664
|
+
continue; // Interrupted
|
|
665
|
+
}
|
|
570
666
|
|
|
571
|
-
|
|
572
|
-
{
|
|
573
|
-
reinterpret_cast<Selector*>(info)->processInterrupt();
|
|
574
|
-
}
|
|
667
|
+
map<EventHandlerPtr, SocketOperation>::iterator q = _readyHandlers.find(ICE_GET_SHARED_FROM_THIS(p.first));
|
|
575
668
|
|
|
576
|
-
|
|
577
|
-
{
|
|
578
|
-
|
|
579
|
-
|
|
580
|
-
|
|
581
|
-
|
|
582
|
-
|
|
583
|
-
|
|
584
|
-
reinterpret_cast<EventHandlerWrapper*>(info)->readyCallback(SocketOperationWrite);
|
|
669
|
+
if(q != _readyHandlers.end()) // Handler will be added by the loop below
|
|
670
|
+
{
|
|
671
|
+
q->second = p.second; // We just remember which operations are ready here.
|
|
672
|
+
}
|
|
673
|
+
else
|
|
674
|
+
{
|
|
675
|
+
handlers.push_back(p);
|
|
676
|
+
}
|
|
585
677
|
}
|
|
586
|
-
|
|
678
|
+
|
|
679
|
+
for(map<EventHandlerPtr, SocketOperation>::iterator q = _readyHandlers.begin(); q != _readyHandlers.end(); ++q)
|
|
587
680
|
{
|
|
588
|
-
|
|
589
|
-
|
|
681
|
+
pair<EventHandler*, SocketOperation> p;
|
|
682
|
+
p.first = q->first.get();
|
|
683
|
+
p.second = static_cast<SocketOperation>(p.first->_ready & ~p.first->_disabled & p.first->_registered);
|
|
684
|
+
p.second = static_cast<SocketOperation>(p.second | q->second);
|
|
685
|
+
if(p.second)
|
|
686
|
+
{
|
|
687
|
+
handlers.push_back(p);
|
|
688
|
+
}
|
|
689
|
+
|
|
690
|
+
//
|
|
691
|
+
// Reset the operation, it's only used by this method to temporarly store the socket status
|
|
692
|
+
// return by the select operation above.
|
|
693
|
+
//
|
|
694
|
+
q->second = SocketOperationNone;
|
|
590
695
|
}
|
|
591
696
|
}
|
|
592
697
|
|
|
593
|
-
|
|
698
|
+
void
|
|
699
|
+
Selector::select(int timeout)
|
|
594
700
|
{
|
|
595
|
-
|
|
596
|
-
|
|
597
|
-
SelectorHelperThread(Selector& selector) : _selector(selector)
|
|
701
|
+
if(_selectNow)
|
|
598
702
|
{
|
|
703
|
+
timeout = 0;
|
|
599
704
|
}
|
|
600
|
-
|
|
601
|
-
virtual void run()
|
|
705
|
+
else if(timeout > 0)
|
|
602
706
|
{
|
|
603
|
-
|
|
707
|
+
timeout = timeout * 1000;
|
|
708
|
+
}
|
|
709
|
+
else
|
|
710
|
+
{
|
|
711
|
+
timeout = -1;
|
|
604
712
|
}
|
|
605
713
|
|
|
606
|
-
|
|
607
|
-
|
|
608
|
-
Selector& _selector;
|
|
609
|
-
};
|
|
610
|
-
|
|
611
|
-
CFOptionFlags
|
|
612
|
-
toCFCallbacks(SocketOperation op)
|
|
613
|
-
{
|
|
614
|
-
CFOptionFlags cbs = 0;
|
|
615
|
-
if(op & SocketOperationRead)
|
|
616
|
-
{
|
|
617
|
-
cbs |= kCFSocketReadCallBack;
|
|
618
|
-
}
|
|
619
|
-
if(op & SocketOperationWrite)
|
|
714
|
+
int spuriousWakeup = 0;
|
|
715
|
+
while(true)
|
|
620
716
|
{
|
|
621
|
-
|
|
717
|
+
#if defined(ICE_USE_EPOLL)
|
|
718
|
+
_count = epoll_wait(_queueFd, &_events[0], _events.size(), timeout);
|
|
719
|
+
#elif defined(ICE_USE_KQUEUE)
|
|
720
|
+
assert(!_events.empty());
|
|
721
|
+
if(timeout >= 0)
|
|
722
|
+
{
|
|
723
|
+
struct timespec ts;
|
|
724
|
+
ts.tv_sec = timeout;
|
|
725
|
+
ts.tv_nsec = 0;
|
|
726
|
+
_count = kevent(_queueFd, 0, 0, &_events[0], _events.size(), &ts);
|
|
727
|
+
}
|
|
728
|
+
else
|
|
729
|
+
{
|
|
730
|
+
_count = kevent(_queueFd, 0, 0, &_events[0], _events.size(), 0);
|
|
731
|
+
}
|
|
732
|
+
#elif defined(ICE_USE_SELECT)
|
|
733
|
+
fd_set* rFdSet = fdSetCopy(_selectedReadFdSet, _readFdSet);
|
|
734
|
+
fd_set* wFdSet = fdSetCopy(_selectedWriteFdSet, _writeFdSet);
|
|
735
|
+
fd_set* eFdSet = fdSetCopy(_selectedErrorFdSet, _errorFdSet);
|
|
736
|
+
if(timeout >= 0)
|
|
737
|
+
{
|
|
738
|
+
struct timeval tv;
|
|
739
|
+
tv.tv_sec = timeout;
|
|
740
|
+
tv.tv_usec = 0;
|
|
741
|
+
_count = ::select(0, rFdSet, wFdSet, eFdSet, &tv); // The first parameter is ignored on Windows
|
|
742
|
+
}
|
|
743
|
+
else
|
|
744
|
+
{
|
|
745
|
+
_count = ::select(0, rFdSet, wFdSet, eFdSet, 0); // The first parameter is ignored on Windows
|
|
746
|
+
}
|
|
747
|
+
#else
|
|
748
|
+
_count = poll(&_pollFdSet[0], _pollFdSet.size(), timeout);
|
|
749
|
+
#endif
|
|
750
|
+
|
|
751
|
+
if(_count == SOCKET_ERROR)
|
|
752
|
+
{
|
|
753
|
+
if(interrupted())
|
|
754
|
+
{
|
|
755
|
+
continue;
|
|
756
|
+
}
|
|
757
|
+
|
|
758
|
+
Ice::SocketException ex(__FILE__, __LINE__, IceInternal::getSocketErrno());
|
|
759
|
+
Ice::Error out(_instance->initializationData().logger);
|
|
760
|
+
out << "selector failed:\n" << ex;
|
|
761
|
+
IceUtil::ThreadControl::sleep(IceUtil::Time::seconds(5)); // Sleep 5s to avoid looping
|
|
762
|
+
}
|
|
763
|
+
else if(_count == 0 && timeout < 0 && ++spuriousWakeup < 100)
|
|
764
|
+
{
|
|
765
|
+
if(spuriousWakeup == 1)
|
|
766
|
+
{
|
|
767
|
+
Ice::Warning out(_instance->initializationData().logger);
|
|
768
|
+
out << "spurious selector wakeup";
|
|
769
|
+
}
|
|
770
|
+
IceUtil::ThreadControl::sleep(IceUtil::Time::milliSeconds(1));
|
|
771
|
+
continue;
|
|
772
|
+
}
|
|
773
|
+
break;
|
|
622
774
|
}
|
|
623
|
-
|
|
775
|
+
|
|
776
|
+
if(_count == 0 && !_selectNow)
|
|
624
777
|
{
|
|
625
|
-
|
|
778
|
+
throw SelectorTimeoutException();
|
|
626
779
|
}
|
|
627
|
-
return cbs;
|
|
628
780
|
}
|
|
629
781
|
|
|
630
|
-
|
|
631
|
-
|
|
632
|
-
EventHandlerWrapper::EventHandlerWrapper(const EventHandlerPtr& handler, Selector& selector) :
|
|
633
|
-
_handler(handler),
|
|
634
|
-
_nativeInfo(StreamNativeInfoPtr::dynamicCast(handler->getNativeInfo())),
|
|
635
|
-
_selector(selector),
|
|
636
|
-
_ready(SocketOperationNone),
|
|
637
|
-
_finish(false)
|
|
782
|
+
void
|
|
783
|
+
Selector::checkReady(EventHandler* handler)
|
|
638
784
|
{
|
|
639
|
-
if(
|
|
785
|
+
if(handler->_ready & ~handler->_disabled & handler->_registered)
|
|
640
786
|
{
|
|
641
|
-
|
|
642
|
-
|
|
643
|
-
_socket = CFSocketCreateWithNative(kCFAllocatorDefault,
|
|
644
|
-
fd,
|
|
645
|
-
kCFSocketReadCallBack |
|
|
646
|
-
kCFSocketWriteCallBack |
|
|
647
|
-
kCFSocketConnectCallBack,
|
|
648
|
-
eventHandlerSocketCallback,
|
|
649
|
-
&ctx);
|
|
650
|
-
|
|
651
|
-
// Disable automatic re-enabling of callbacks and closing of the native socket.
|
|
652
|
-
CFSocketSetSocketFlags(_socket, 0);
|
|
653
|
-
CFSocketDisableCallBacks(_socket, kCFSocketReadCallBack | kCFSocketWriteCallBack | kCFSocketConnectCallBack);
|
|
654
|
-
_source = CFSocketCreateRunLoopSource(kCFAllocatorDefault, _socket, 0);
|
|
787
|
+
_readyHandlers.insert(make_pair(ICE_GET_SHARED_FROM_THIS(handler), SocketOperationNone));
|
|
788
|
+
wakeup();
|
|
655
789
|
}
|
|
656
790
|
else
|
|
657
791
|
{
|
|
658
|
-
|
|
659
|
-
|
|
660
|
-
|
|
661
|
-
|
|
662
|
-
}
|
|
663
|
-
|
|
664
|
-
EventHandlerWrapper::~EventHandlerWrapper()
|
|
665
|
-
{
|
|
666
|
-
if(_socket)
|
|
667
|
-
{
|
|
668
|
-
CFRelease(_socket);
|
|
669
|
-
CFRelease(_source);
|
|
792
|
+
map<EventHandlerPtr, SocketOperation>::iterator p = _readyHandlers.find(ICE_GET_SHARED_FROM_THIS(handler));
|
|
793
|
+
if(p != _readyHandlers.end())
|
|
794
|
+
{
|
|
795
|
+
_readyHandlers.erase(p);
|
|
796
|
+
}
|
|
670
797
|
}
|
|
671
798
|
}
|
|
672
799
|
|
|
673
800
|
void
|
|
674
|
-
|
|
801
|
+
Selector::updateSelector()
|
|
675
802
|
{
|
|
676
|
-
|
|
677
|
-
|
|
678
|
-
|
|
679
|
-
if(_socket)
|
|
803
|
+
#if defined(ICE_USE_KQUEUE)
|
|
804
|
+
int rs = kevent(_queueFd, &_changes[0], _changes.size(), &_changes[0], _changes.size(), &zeroTimeout);
|
|
805
|
+
if(rs < 0)
|
|
680
806
|
{
|
|
681
|
-
|
|
682
|
-
|
|
683
|
-
{
|
|
684
|
-
CFSocketEnableCallBacks(_socket, toCFCallbacks(op));
|
|
685
|
-
}
|
|
686
|
-
|
|
687
|
-
if(op && !CFRunLoopContainsSource(CFRunLoopGetCurrent(), _source, kCFRunLoopDefaultMode))
|
|
688
|
-
{
|
|
689
|
-
CFRunLoopAddSource(CFRunLoopGetCurrent(), _source, kCFRunLoopDefaultMode);
|
|
690
|
-
}
|
|
691
|
-
else if(!op && CFRunLoopContainsSource(CFRunLoopGetCurrent(), _source, kCFRunLoopDefaultMode))
|
|
692
|
-
{
|
|
693
|
-
CFRunLoopRemoveSource(CFRunLoopGetCurrent(), _source, kCFRunLoopDefaultMode);
|
|
694
|
-
}
|
|
695
|
-
|
|
696
|
-
if(_finish)
|
|
697
|
-
{
|
|
698
|
-
CFSocketInvalidate(_socket);
|
|
699
|
-
}
|
|
807
|
+
Ice::Error out(_instance->initializationData().logger);
|
|
808
|
+
out << "error while updating selector:\n" << IceUtilInternal::errorToString(IceInternal::getSocketErrno());
|
|
700
809
|
}
|
|
701
810
|
else
|
|
702
811
|
{
|
|
703
|
-
|
|
704
|
-
if(!(op & (SocketOperationWrite | SocketOperationConnect)) || _ready & SocketOperationWrite)
|
|
812
|
+
for(int i = 0; i < rs; ++i)
|
|
705
813
|
{
|
|
706
|
-
|
|
814
|
+
//
|
|
815
|
+
// Check for errors, we ignore EINPROGRESS that started showing up with macOS Sierra
|
|
816
|
+
// and which occurs when another thread removes the FD from the kqueue (see ICE-7419).
|
|
817
|
+
//
|
|
818
|
+
if(_changes[i].flags & EV_ERROR && _changes[i].data != EINPROGRESS)
|
|
819
|
+
{
|
|
820
|
+
Ice::Error out(_instance->initializationData().logger);
|
|
821
|
+
out << "error while updating selector:\n" << IceUtilInternal::errorToString(_changes[i].data);
|
|
822
|
+
}
|
|
707
823
|
}
|
|
824
|
+
}
|
|
825
|
+
_changes.clear();
|
|
826
|
+
#elif !defined(ICE_USE_EPOLL)
|
|
827
|
+
assert(!_selecting);
|
|
708
828
|
|
|
709
|
-
|
|
710
|
-
|
|
711
|
-
|
|
712
|
-
|
|
829
|
+
for(vector<pair<EventHandler*, SocketOperation> >::const_iterator p = _changes.begin(); p != _changes.end(); ++p)
|
|
830
|
+
{
|
|
831
|
+
EventHandler* handler = p->first;
|
|
832
|
+
SocketOperation status = p->second;
|
|
713
833
|
|
|
714
|
-
|
|
834
|
+
SOCKET fd = handler->getNativeInfo()->fd();
|
|
835
|
+
if(status)
|
|
715
836
|
{
|
|
716
|
-
|
|
837
|
+
#if defined(ICE_USE_SELECT)
|
|
838
|
+
if(status & SocketOperationRead)
|
|
839
|
+
{
|
|
840
|
+
FD_SET(fd, &_readFdSet);
|
|
841
|
+
}
|
|
842
|
+
else
|
|
843
|
+
{
|
|
844
|
+
FD_CLR(fd, &_readFdSet);
|
|
845
|
+
}
|
|
846
|
+
if(status & SocketOperationWrite)
|
|
847
|
+
{
|
|
848
|
+
FD_SET(fd, &_writeFdSet);
|
|
849
|
+
}
|
|
850
|
+
else
|
|
851
|
+
{
|
|
852
|
+
FD_CLR(fd, &_writeFdSet);
|
|
853
|
+
}
|
|
854
|
+
if(status & SocketOperationConnect)
|
|
855
|
+
{
|
|
856
|
+
FD_SET(fd, &_writeFdSet);
|
|
857
|
+
FD_SET(fd, &_errorFdSet);
|
|
858
|
+
}
|
|
859
|
+
else
|
|
860
|
+
{
|
|
861
|
+
FD_CLR(fd, &_writeFdSet);
|
|
862
|
+
FD_CLR(fd, &_errorFdSet);
|
|
863
|
+
}
|
|
864
|
+
_handlers[fd] = handler;
|
|
865
|
+
#else
|
|
866
|
+
short events = 0;
|
|
867
|
+
if(status & SocketOperationRead)
|
|
868
|
+
{
|
|
869
|
+
events |= POLLIN;
|
|
870
|
+
}
|
|
871
|
+
if(status & SocketOperationWrite)
|
|
872
|
+
{
|
|
873
|
+
events |= POLLOUT;
|
|
874
|
+
}
|
|
875
|
+
map<SOCKET, EventHandler*>::const_iterator q = _handlers.find(fd);
|
|
876
|
+
if(q == _handlers.end())
|
|
877
|
+
{
|
|
878
|
+
struct pollfd pollFd;
|
|
879
|
+
pollFd.fd = fd;
|
|
880
|
+
pollFd.events = events;
|
|
881
|
+
pollFd.revents = 0;
|
|
882
|
+
_pollFdSet.push_back(pollFd);
|
|
883
|
+
_handlers.insert(make_pair(fd, handler));
|
|
884
|
+
}
|
|
885
|
+
else
|
|
886
|
+
{
|
|
887
|
+
for(vector<struct pollfd>::iterator r = _pollFdSet.begin(); r != _pollFdSet.end(); ++r)
|
|
888
|
+
{
|
|
889
|
+
if(r->fd == fd)
|
|
890
|
+
{
|
|
891
|
+
r->events = events;
|
|
892
|
+
break;
|
|
893
|
+
}
|
|
894
|
+
}
|
|
895
|
+
}
|
|
896
|
+
#endif
|
|
717
897
|
}
|
|
718
|
-
|
|
719
|
-
if(_finish)
|
|
898
|
+
else
|
|
720
899
|
{
|
|
721
|
-
|
|
900
|
+
#if defined(ICE_USE_SELECT)
|
|
901
|
+
FD_CLR(fd, &_readFdSet);
|
|
902
|
+
FD_CLR(fd, &_writeFdSet);
|
|
903
|
+
FD_CLR(fd, &_errorFdSet);
|
|
904
|
+
#else
|
|
905
|
+
for(vector<struct pollfd>::iterator r = _pollFdSet.begin(); r != _pollFdSet.end(); ++r)
|
|
906
|
+
{
|
|
907
|
+
if(r->fd == fd)
|
|
908
|
+
{
|
|
909
|
+
_pollFdSet.erase(r);
|
|
910
|
+
break;
|
|
911
|
+
}
|
|
912
|
+
}
|
|
913
|
+
#endif
|
|
914
|
+
_handlers.erase(fd);
|
|
722
915
|
}
|
|
723
916
|
}
|
|
917
|
+
_changes.clear();
|
|
918
|
+
#endif
|
|
724
919
|
}
|
|
725
920
|
|
|
726
921
|
void
|
|
727
|
-
|
|
728
|
-
{
|
|
729
|
-
_selector.ready(this, op, error);
|
|
730
|
-
}
|
|
731
|
-
|
|
732
|
-
void
|
|
733
|
-
EventHandlerWrapper::ready(SocketOperation op, int error)
|
|
922
|
+
Selector::updateSelectorForEventHandler(EventHandler* handler, SocketOperation remove, SocketOperation add)
|
|
734
923
|
{
|
|
735
|
-
|
|
924
|
+
#if defined(ICE_USE_EPOLL)
|
|
925
|
+
SocketOperation previous = handler->_registered;
|
|
926
|
+
previous = static_cast<SocketOperation>(previous & ~add);
|
|
927
|
+
previous = static_cast<SocketOperation>(previous | remove);
|
|
928
|
+
SOCKET fd = handler->getNativeInfo()->fd();
|
|
929
|
+
assert(fd != INVALID_SOCKET);
|
|
930
|
+
epoll_event event;
|
|
931
|
+
memset(&event, 0, sizeof(epoll_event));
|
|
932
|
+
event.data.ptr = handler;
|
|
933
|
+
SocketOperation status = handler->_registered;
|
|
934
|
+
if(handler->_disabled)
|
|
736
935
|
{
|
|
737
|
-
|
|
738
|
-
|
|
739
|
-
// required to allow thread pool thread to perform read/write operations on the
|
|
740
|
-
// stream (which can't be used from another thread than the run loop thread if
|
|
741
|
-
// it's registered with a run loop).
|
|
742
|
-
//
|
|
743
|
-
op = _nativeInfo->unregisterFromRunLoop(op, error != 0);
|
|
936
|
+
status = static_cast<SocketOperation>(status & ~handler->_disabled);
|
|
937
|
+
previous = static_cast<SocketOperation>(previous & ~handler->_disabled);
|
|
744
938
|
}
|
|
745
|
-
|
|
746
|
-
|
|
747
|
-
|
|
939
|
+
event.events |= status & SocketOperationRead ? EPOLLIN : 0;
|
|
940
|
+
event.events |= status & SocketOperationWrite ? EPOLLOUT : 0;
|
|
941
|
+
int op;
|
|
942
|
+
if(!previous && status)
|
|
943
|
+
{
|
|
944
|
+
op = EPOLL_CTL_ADD;
|
|
945
|
+
}
|
|
946
|
+
else if(previous && !status)
|
|
947
|
+
{
|
|
948
|
+
op = EPOLL_CTL_DEL;
|
|
949
|
+
}
|
|
950
|
+
else if(previous == status)
|
|
748
951
|
{
|
|
749
952
|
return;
|
|
750
953
|
}
|
|
751
|
-
|
|
752
|
-
if(_socket)
|
|
954
|
+
else
|
|
753
955
|
{
|
|
754
|
-
|
|
755
|
-
{
|
|
756
|
-
_nativeInfo->setConnectError(error);
|
|
757
|
-
}
|
|
956
|
+
op = EPOLL_CTL_MOD;
|
|
758
957
|
}
|
|
759
|
-
|
|
760
|
-
_ready = static_cast<SocketOperation>(_ready | op);
|
|
761
|
-
if(!(_handler->_disabled & op))
|
|
958
|
+
if(epoll_ctl(_queueFd, op, fd, &event) != 0)
|
|
762
959
|
{
|
|
763
|
-
|
|
960
|
+
Ice::Error out(_instance->initializationData().logger);
|
|
961
|
+
out << "error while updating selector:\n" << IceUtilInternal::errorToString(IceInternal::getSocketErrno());
|
|
764
962
|
}
|
|
765
|
-
|
|
766
|
-
|
|
767
|
-
|
|
768
|
-
|
|
769
|
-
{
|
|
770
|
-
if(_ready & _handler->_registered)
|
|
963
|
+
#elif defined(ICE_USE_KQUEUE)
|
|
964
|
+
SOCKET fd = handler->getNativeInfo()->fd();
|
|
965
|
+
assert(fd != INVALID_SOCKET);
|
|
966
|
+
if(remove & SocketOperationRead)
|
|
771
967
|
{
|
|
772
|
-
|
|
968
|
+
struct kevent ev;
|
|
969
|
+
EV_SET(&ev, fd, EVFILT_READ, EV_DELETE, 0, 0, handler);
|
|
970
|
+
_changes.push_back(ev);
|
|
971
|
+
}
|
|
972
|
+
if(remove & SocketOperationWrite)
|
|
973
|
+
{
|
|
974
|
+
struct kevent ev;
|
|
975
|
+
EV_SET(&ev, fd, EVFILT_WRITE, EV_DELETE, 0, 0, handler);
|
|
976
|
+
_changes.push_back(ev);
|
|
977
|
+
}
|
|
978
|
+
if(add & SocketOperationRead)
|
|
979
|
+
{
|
|
980
|
+
struct kevent ev;
|
|
981
|
+
EV_SET(&ev, fd, EVFILT_READ, EV_ADD | (handler->_disabled & SocketOperationRead ? EV_DISABLE : 0), 0, 0,
|
|
982
|
+
handler);
|
|
983
|
+
_changes.push_back(ev);
|
|
984
|
+
}
|
|
985
|
+
if(add & SocketOperationWrite)
|
|
986
|
+
{
|
|
987
|
+
struct kevent ev;
|
|
988
|
+
EV_SET(&ev, fd, EVFILT_WRITE, EV_ADD | (handler->_disabled & SocketOperationWrite ? EV_DISABLE : 0), 0, 0,
|
|
989
|
+
handler);
|
|
990
|
+
_changes.push_back(ev);
|
|
773
991
|
}
|
|
992
|
+
if(_selecting)
|
|
993
|
+
{
|
|
994
|
+
updateSelector();
|
|
995
|
+
}
|
|
996
|
+
#else
|
|
997
|
+
_changes.push_back(make_pair(handler, static_cast<SocketOperation>(handler->_registered & ~handler->_disabled)));
|
|
998
|
+
wakeup();
|
|
999
|
+
#endif
|
|
1000
|
+
checkReady(handler);
|
|
774
1001
|
}
|
|
775
1002
|
|
|
776
|
-
|
|
777
|
-
EventHandlerWrapper::readyOp()
|
|
778
|
-
{
|
|
779
|
-
assert(!(~_handler->_registered & _ready));
|
|
780
|
-
SocketOperation op = static_cast<SocketOperation>(~_handler->_disabled & _ready);
|
|
781
|
-
_ready = static_cast<SocketOperation>(~op & _ready);
|
|
782
|
-
return op;
|
|
783
|
-
}
|
|
1003
|
+
#elif defined(ICE_USE_CFSTREAM)
|
|
784
1004
|
|
|
785
|
-
|
|
786
|
-
EventHandlerWrapper::update(SocketOperation remove, SocketOperation add)
|
|
1005
|
+
namespace
|
|
787
1006
|
{
|
|
788
|
-
SocketOperation previous = _handler->_registered;
|
|
789
|
-
_handler->_registered = static_cast<SocketOperation>(_handler->_registered & ~remove);
|
|
790
|
-
_handler->_registered = static_cast<SocketOperation>(_handler->_registered | add);
|
|
791
|
-
if(previous == _handler->_registered)
|
|
792
|
-
{
|
|
793
|
-
return false;
|
|
794
|
-
}
|
|
795
1007
|
|
|
796
|
-
|
|
797
|
-
_ready = static_cast<SocketOperation>(_ready & _handler->_registered);
|
|
798
|
-
return true;
|
|
799
|
-
}
|
|
800
|
-
|
|
801
|
-
void
|
|
802
|
-
EventHandlerWrapper::finish()
|
|
1008
|
+
void selectorInterrupt(void* info)
|
|
803
1009
|
{
|
|
804
|
-
|
|
805
|
-
_ready = SocketOperationNone;
|
|
806
|
-
_handler->_registered = SocketOperationNone;
|
|
1010
|
+
reinterpret_cast<Selector*>(info)->processInterrupt();
|
|
807
1011
|
}
|
|
808
1012
|
|
|
809
|
-
|
|
1013
|
+
void eventHandlerSocketCallback(CFSocketRef, CFSocketCallBackType callbackType, CFDataRef, const void* d, void* info)
|
|
810
1014
|
{
|
|
811
|
-
|
|
812
|
-
memset(&ctx, 0, sizeof(CFRunLoopSourceContext));
|
|
813
|
-
ctx.info = this;
|
|
814
|
-
ctx.perform = selectorInterrupt;
|
|
815
|
-
_source = CFRunLoopSourceCreate(0, 0, &ctx);
|
|
816
|
-
_runLoop = 0;
|
|
817
|
-
|
|
818
|
-
_thread = new SelectorHelperThread(*this);
|
|
819
|
-
_thread->start();
|
|
820
|
-
|
|
821
|
-
Lock sync(*this);
|
|
822
|
-
while(!_runLoop)
|
|
1015
|
+
if(callbackType == kCFSocketReadCallBack)
|
|
823
1016
|
{
|
|
824
|
-
|
|
1017
|
+
reinterpret_cast<EventHandlerWrapper*>(info)->readyCallback(SocketOperationRead);
|
|
1018
|
+
}
|
|
1019
|
+
else if(callbackType == kCFSocketWriteCallBack)
|
|
1020
|
+
{
|
|
1021
|
+
reinterpret_cast<EventHandlerWrapper*>(info)->readyCallback(SocketOperationWrite);
|
|
1022
|
+
}
|
|
1023
|
+
else if(callbackType == kCFSocketConnectCallBack)
|
|
1024
|
+
{
|
|
1025
|
+
reinterpret_cast<EventHandlerWrapper*>(info)->readyCallback(SocketOperationConnect,
|
|
1026
|
+
d ? *reinterpret_cast<const SInt32*>(d) : 0);
|
|
825
1027
|
}
|
|
826
1028
|
}
|
|
827
1029
|
|
|
828
|
-
|
|
829
|
-
{
|
|
830
|
-
}
|
|
831
|
-
|
|
832
|
-
void
|
|
833
|
-
Selector::destroy()
|
|
1030
|
+
class SelectorHelperThread : public IceUtil::Thread
|
|
834
1031
|
{
|
|
835
|
-
|
|
1032
|
+
public:
|
|
836
1033
|
|
|
837
|
-
|
|
838
|
-
// Make sure any pending changes are processed to ensure remaining
|
|
839
|
-
// streams/sockets are closed.
|
|
840
|
-
//
|
|
841
|
-
_destroyed = true;
|
|
842
|
-
while(!_changes.empty())
|
|
1034
|
+
SelectorHelperThread(Selector& selector) : _selector(selector)
|
|
843
1035
|
{
|
|
844
|
-
CFRunLoopSourceSignal(_source);
|
|
845
|
-
CFRunLoopWakeUp(_runLoop);
|
|
846
|
-
|
|
847
|
-
wait();
|
|
848
1036
|
}
|
|
849
1037
|
|
|
850
|
-
|
|
851
|
-
|
|
852
|
-
|
|
853
|
-
|
|
1038
|
+
virtual void run()
|
|
1039
|
+
{
|
|
1040
|
+
_selector.run();
|
|
1041
|
+
}
|
|
854
1042
|
|
|
855
|
-
|
|
856
|
-
_readyHandlers.clear();
|
|
857
|
-
_selectedHandlers.clear();
|
|
858
|
-
}
|
|
1043
|
+
private:
|
|
859
1044
|
|
|
860
|
-
|
|
861
|
-
|
|
862
|
-
{
|
|
863
|
-
Lock sync(*this);
|
|
864
|
-
_wrappers[handler] = new EventHandlerWrapper(handler, *this);
|
|
865
|
-
}
|
|
1045
|
+
Selector& _selector;
|
|
1046
|
+
};
|
|
866
1047
|
|
|
867
|
-
|
|
868
|
-
|
|
1048
|
+
CFOptionFlags
|
|
1049
|
+
toCFCallbacks(SocketOperation op)
|
|
869
1050
|
{
|
|
870
|
-
|
|
871
|
-
|
|
872
|
-
assert(wrapper);
|
|
873
|
-
if(wrapper->update(remove, add))
|
|
1051
|
+
CFOptionFlags cbs = 0;
|
|
1052
|
+
if(op & SocketOperationRead)
|
|
874
1053
|
{
|
|
875
|
-
|
|
876
|
-
notify();
|
|
1054
|
+
cbs |= kCFSocketReadCallBack;
|
|
877
1055
|
}
|
|
878
|
-
|
|
879
|
-
|
|
880
|
-
void
|
|
881
|
-
Selector::enable(EventHandler* handler, SocketOperation op)
|
|
882
|
-
{
|
|
883
|
-
Lock sync(*this);
|
|
884
|
-
if(!(handler->_disabled & op))
|
|
1056
|
+
if(op & SocketOperationWrite)
|
|
885
1057
|
{
|
|
886
|
-
|
|
1058
|
+
cbs |= kCFSocketWriteCallBack;
|
|
887
1059
|
}
|
|
888
|
-
|
|
889
|
-
|
|
890
|
-
if(handler->_registered & op)
|
|
1060
|
+
if(op & SocketOperationConnect)
|
|
891
1061
|
{
|
|
892
|
-
|
|
1062
|
+
cbs |= kCFSocketConnectCallBack;
|
|
893
1063
|
}
|
|
1064
|
+
return cbs;
|
|
894
1065
|
}
|
|
895
1066
|
|
|
896
|
-
|
|
897
|
-
|
|
1067
|
+
}
|
|
1068
|
+
|
|
1069
|
+
EventHandlerWrapper::EventHandlerWrapper(EventHandler* handler, Selector& selector) :
|
|
1070
|
+
_handler(ICE_GET_SHARED_FROM_THIS(handler)),
|
|
1071
|
+
_streamNativeInfo(StreamNativeInfoPtr::dynamicCast(handler->getNativeInfo())),
|
|
1072
|
+
_selector(selector),
|
|
1073
|
+
_ready(SocketOperationNone),
|
|
1074
|
+
_finish(false)
|
|
898
1075
|
{
|
|
899
|
-
|
|
900
|
-
if(handler->_disabled & op)
|
|
1076
|
+
if(_streamNativeInfo)
|
|
901
1077
|
{
|
|
902
|
-
|
|
1078
|
+
_streamNativeInfo->initStreams(this);
|
|
1079
|
+
}
|
|
1080
|
+
else if(handler->getNativeInfo())
|
|
1081
|
+
{
|
|
1082
|
+
SOCKET fd = handler->getNativeInfo()->fd();
|
|
1083
|
+
CFSocketContext ctx = { 0, this, 0, 0, 0 };
|
|
1084
|
+
_socket.reset(CFSocketCreateWithNative(kCFAllocatorDefault,
|
|
1085
|
+
fd,
|
|
1086
|
+
kCFSocketReadCallBack |
|
|
1087
|
+
kCFSocketWriteCallBack |
|
|
1088
|
+
kCFSocketConnectCallBack,
|
|
1089
|
+
eventHandlerSocketCallback,
|
|
1090
|
+
&ctx));
|
|
1091
|
+
|
|
1092
|
+
// Disable automatic re-enabling of callbacks and closing of the native socket.
|
|
1093
|
+
CFSocketSetSocketFlags(_socket.get(), 0);
|
|
1094
|
+
CFSocketDisableCallBacks(_socket.get(), kCFSocketReadCallBack | kCFSocketWriteCallBack | kCFSocketConnectCallBack);
|
|
1095
|
+
_source.reset(CFSocketCreateRunLoopSource(kCFAllocatorDefault, _socket.get(), 0));
|
|
903
1096
|
}
|
|
904
|
-
handler->_disabled = static_cast<SocketOperation>(handler->_disabled | op);
|
|
905
1097
|
}
|
|
906
1098
|
|
|
907
|
-
|
|
908
|
-
Selector::finish(EventHandler* handler, bool closeNow)
|
|
1099
|
+
EventHandlerWrapper::~EventHandlerWrapper()
|
|
909
1100
|
{
|
|
910
|
-
Lock sync(*this);
|
|
911
|
-
std::map<EventHandler*, EventHandlerWrapperPtr>::iterator p = _wrappers.find(handler);
|
|
912
|
-
assert(p != _wrappers.end());
|
|
913
|
-
EventHandlerWrapperPtr wrapper = p->second;
|
|
914
|
-
wrapper->finish();
|
|
915
|
-
_wrappers.erase(p);
|
|
916
|
-
_changes.insert(wrapper);
|
|
917
|
-
notify();
|
|
918
|
-
return closeNow;
|
|
919
1101
|
}
|
|
920
1102
|
|
|
921
1103
|
void
|
|
922
|
-
|
|
1104
|
+
EventHandlerWrapper::updateRunLoop()
|
|
923
1105
|
{
|
|
924
|
-
|
|
1106
|
+
SocketOperation op = _handler->_registered;
|
|
1107
|
+
assert(!op || !_finish);
|
|
925
1108
|
|
|
926
|
-
|
|
927
|
-
// Re-enable callbacks for previously selected handlers.
|
|
928
|
-
//
|
|
929
|
-
if(!_selectedHandlers.empty())
|
|
1109
|
+
if(_socket)
|
|
930
1110
|
{
|
|
931
|
-
|
|
932
|
-
|
|
1111
|
+
CFSocketDisableCallBacks(_socket.get(), kCFSocketReadCallBack | kCFSocketWriteCallBack | kCFSocketConnectCallBack);
|
|
1112
|
+
if(op)
|
|
933
1113
|
{
|
|
934
|
-
|
|
935
|
-
{
|
|
936
|
-
_changes.insert(p->first);
|
|
937
|
-
}
|
|
1114
|
+
CFSocketEnableCallBacks(_socket.get(), toCFCallbacks(op));
|
|
938
1115
|
}
|
|
939
|
-
_selectedHandlers.clear();
|
|
940
|
-
}
|
|
941
1116
|
|
|
942
|
-
|
|
943
|
-
|
|
944
|
-
|
|
945
|
-
|
|
946
|
-
|
|
1117
|
+
if(op && !CFRunLoopContainsSource(CFRunLoopGetCurrent(), _source.get(), kCFRunLoopDefaultMode))
|
|
1118
|
+
{
|
|
1119
|
+
CFRunLoopAddSource(CFRunLoopGetCurrent(), _source.get(), kCFRunLoopDefaultMode);
|
|
1120
|
+
}
|
|
1121
|
+
else if(!op && CFRunLoopContainsSource(CFRunLoopGetCurrent(), _source.get(), kCFRunLoopDefaultMode))
|
|
1122
|
+
{
|
|
1123
|
+
CFRunLoopRemoveSource(CFRunLoopGetCurrent(), _source.get(), kCFRunLoopDefaultMode);
|
|
1124
|
+
}
|
|
1125
|
+
|
|
1126
|
+
if(_finish)
|
|
1127
|
+
{
|
|
1128
|
+
CFSocketInvalidate(_socket.get());
|
|
1129
|
+
}
|
|
1130
|
+
}
|
|
1131
|
+
else
|
|
947
1132
|
{
|
|
948
|
-
|
|
1133
|
+
SocketOperation readyOp = _streamNativeInfo->registerWithRunLoop(op);
|
|
1134
|
+
if(!(op & (SocketOperationWrite | SocketOperationConnect)) || _ready & SocketOperationWrite)
|
|
949
1135
|
{
|
|
950
|
-
|
|
951
|
-
CFRunLoopWakeUp(_runLoop);
|
|
952
|
-
|
|
953
|
-
wait();
|
|
1136
|
+
_streamNativeInfo->unregisterFromRunLoop(SocketOperationWrite, false);
|
|
954
1137
|
}
|
|
955
1138
|
|
|
956
|
-
if(
|
|
1139
|
+
if(!(op & (SocketOperationRead | SocketOperationConnect)) || _ready & SocketOperationRead)
|
|
957
1140
|
{
|
|
958
|
-
|
|
959
|
-
{
|
|
960
|
-
if(!timedWait(IceUtil::Time::seconds(timeout)))
|
|
961
|
-
{
|
|
962
|
-
break;
|
|
963
|
-
}
|
|
964
|
-
}
|
|
965
|
-
else
|
|
966
|
-
{
|
|
967
|
-
wait();
|
|
968
|
-
}
|
|
1141
|
+
_streamNativeInfo->unregisterFromRunLoop(SocketOperationRead, false);
|
|
969
1142
|
}
|
|
970
1143
|
|
|
971
|
-
if(
|
|
1144
|
+
if(readyOp)
|
|
972
1145
|
{
|
|
973
|
-
|
|
1146
|
+
ready(readyOp, 0);
|
|
974
1147
|
}
|
|
975
1148
|
|
|
976
|
-
|
|
1149
|
+
if(_finish)
|
|
977
1150
|
{
|
|
978
|
-
|
|
979
|
-
if(op)
|
|
980
|
-
{
|
|
981
|
-
_selectedHandlers.push_back(pair<EventHandlerWrapperPtr, SocketOperation>(*p, op));
|
|
982
|
-
handlers.push_back(pair<EventHandler*, SocketOperation>((*p)->_handler.get(), op));
|
|
983
|
-
}
|
|
1151
|
+
_streamNativeInfo->closeStreams();
|
|
984
1152
|
}
|
|
985
|
-
_readyHandlers.clear();
|
|
986
1153
|
}
|
|
987
1154
|
}
|
|
988
1155
|
|
|
989
1156
|
void
|
|
990
|
-
|
|
1157
|
+
EventHandlerWrapper::readyCallback(SocketOperation op, int error)
|
|
991
1158
|
{
|
|
992
|
-
|
|
993
|
-
|
|
1159
|
+
_selector.ready(this, op, error);
|
|
1160
|
+
}
|
|
1161
|
+
|
|
1162
|
+
void
|
|
1163
|
+
EventHandlerWrapper::ready(SocketOperation op, int error)
|
|
1164
|
+
{
|
|
1165
|
+
if(!_socket)
|
|
994
1166
|
{
|
|
995
|
-
|
|
996
|
-
|
|
997
|
-
|
|
998
|
-
|
|
999
|
-
|
|
1000
|
-
|
|
1167
|
+
//
|
|
1168
|
+
// Unregister the stream from the runloop as soon as we got the callback. This is
|
|
1169
|
+
// required to allow thread pool thread to perform read/write operations on the
|
|
1170
|
+
// stream (which can't be used from another thread than the run loop thread if
|
|
1171
|
+
// it's registered with a run loop).
|
|
1172
|
+
//
|
|
1173
|
+
op = _streamNativeInfo->unregisterFromRunLoop(op, error != 0);
|
|
1001
1174
|
}
|
|
1002
|
-
|
|
1175
|
+
|
|
1176
|
+
op = static_cast<SocketOperation>(_handler->_registered & op);
|
|
1177
|
+
if(!op || _ready & op)
|
|
1003
1178
|
{
|
|
1004
|
-
|
|
1179
|
+
return;
|
|
1005
1180
|
}
|
|
1006
|
-
}
|
|
1007
1181
|
|
|
1008
|
-
|
|
1009
|
-
|
|
1010
|
-
|
|
1011
|
-
|
|
1012
|
-
|
|
1182
|
+
if(_socket)
|
|
1183
|
+
{
|
|
1184
|
+
if(op & SocketOperationConnect)
|
|
1185
|
+
{
|
|
1186
|
+
_streamNativeInfo->setConnectError(error);
|
|
1187
|
+
}
|
|
1188
|
+
}
|
|
1189
|
+
|
|
1190
|
+
_ready = static_cast<SocketOperation>(_ready | op);
|
|
1191
|
+
checkReady();
|
|
1013
1192
|
}
|
|
1014
1193
|
|
|
1015
|
-
|
|
1016
|
-
|
|
1194
|
+
bool
|
|
1195
|
+
EventHandlerWrapper::checkReady()
|
|
1017
1196
|
{
|
|
1018
|
-
|
|
1019
|
-
_readyHandlers.push_back(wrapper);
|
|
1020
|
-
if(_readyHandlers.size() == 1)
|
|
1197
|
+
if((_ready | _handler->_ready) & ~_handler->_disabled & _handler->_registered)
|
|
1021
1198
|
{
|
|
1022
|
-
|
|
1199
|
+
_selector.addReadyHandler(this);
|
|
1200
|
+
return false;
|
|
1201
|
+
}
|
|
1202
|
+
else
|
|
1203
|
+
{
|
|
1204
|
+
return _handler->getNativeInfo() && !_finish;
|
|
1023
1205
|
}
|
|
1024
1206
|
}
|
|
1025
1207
|
|
|
1026
|
-
|
|
1027
|
-
|
|
1208
|
+
SocketOperation
|
|
1209
|
+
EventHandlerWrapper::readyOp()
|
|
1210
|
+
{
|
|
1211
|
+
assert(!(~_handler->_registered & _ready));
|
|
1212
|
+
SocketOperation op = static_cast<SocketOperation>(~_handler->_disabled & (_ready | _handler->_ready));
|
|
1213
|
+
_ready = static_cast<SocketOperation>(~op & _ready);
|
|
1214
|
+
return op;
|
|
1215
|
+
}
|
|
1216
|
+
|
|
1217
|
+
bool
|
|
1218
|
+
EventHandlerWrapper::update(SocketOperation remove, SocketOperation add)
|
|
1028
1219
|
{
|
|
1220
|
+
SocketOperation previous = _handler->_registered;
|
|
1221
|
+
_handler->_registered = static_cast<SocketOperation>(_handler->_registered & ~remove);
|
|
1222
|
+
_handler->_registered = static_cast<SocketOperation>(_handler->_registered | add);
|
|
1223
|
+
if(previous == _handler->_registered)
|
|
1029
1224
|
{
|
|
1030
|
-
|
|
1031
|
-
_runLoop = CFRunLoopGetCurrent();
|
|
1032
|
-
notify();
|
|
1225
|
+
return false;
|
|
1033
1226
|
}
|
|
1034
1227
|
|
|
1035
|
-
|
|
1036
|
-
|
|
1037
|
-
|
|
1228
|
+
// Clear ready flags which might not be valid anymore.
|
|
1229
|
+
_ready = static_cast<SocketOperation>(_ready & _handler->_registered);
|
|
1230
|
+
return _handler->getNativeInfo();
|
|
1038
1231
|
}
|
|
1039
1232
|
|
|
1040
|
-
|
|
1041
|
-
|
|
1042
|
-
Selector::Selector(const InstancePtr& instance) : _instance(instance), _selecting(false), _interrupted(false)
|
|
1233
|
+
bool
|
|
1234
|
+
EventHandlerWrapper::finish()
|
|
1043
1235
|
{
|
|
1044
|
-
|
|
1045
|
-
|
|
1046
|
-
|
|
1047
|
-
|
|
1048
|
-
#if defined(ICE_USE_SELECT)
|
|
1049
|
-
FD_ZERO(&_readFdSet);
|
|
1050
|
-
FD_ZERO(&_writeFdSet);
|
|
1051
|
-
FD_ZERO(&_errorFdSet);
|
|
1052
|
-
FD_SET(_fdIntrRead, &_readFdSet);
|
|
1053
|
-
#else
|
|
1054
|
-
struct pollfd pollFd;
|
|
1055
|
-
pollFd.fd = _fdIntrRead;
|
|
1056
|
-
pollFd.events = POLLIN;
|
|
1057
|
-
_pollFdSet.push_back(pollFd);
|
|
1058
|
-
#endif
|
|
1236
|
+
_finish = true;
|
|
1237
|
+
_ready = SocketOperationNone;
|
|
1238
|
+
_handler->_registered = SocketOperationNone;
|
|
1239
|
+
return _handler->getNativeInfo();
|
|
1059
1240
|
}
|
|
1060
1241
|
|
|
1061
|
-
Selector
|
|
1242
|
+
Selector::Selector(const InstancePtr& instance) : _instance(instance), _destroyed(false)
|
|
1062
1243
|
{
|
|
1063
|
-
|
|
1064
|
-
|
|
1065
|
-
|
|
1066
|
-
|
|
1067
|
-
|
|
1068
|
-
|
|
1069
|
-
Ice::Error out(_instance->initializationData().logger);
|
|
1070
|
-
out << "exception in selector while calling closeSocket():\n" << ex;
|
|
1071
|
-
}
|
|
1244
|
+
CFRunLoopSourceContext ctx;
|
|
1245
|
+
memset(&ctx, 0, sizeof(CFRunLoopSourceContext));
|
|
1246
|
+
ctx.info = this;
|
|
1247
|
+
ctx.perform = selectorInterrupt;
|
|
1248
|
+
_source.reset(CFRunLoopSourceCreate(0, 0, &ctx));
|
|
1249
|
+
_runLoop = 0;
|
|
1072
1250
|
|
|
1073
|
-
|
|
1074
|
-
|
|
1075
|
-
|
|
1076
|
-
|
|
1077
|
-
|
|
1251
|
+
_thread = new SelectorHelperThread(*this);
|
|
1252
|
+
_thread->start();
|
|
1253
|
+
|
|
1254
|
+
Lock sync(*this);
|
|
1255
|
+
while(!_runLoop)
|
|
1078
1256
|
{
|
|
1079
|
-
|
|
1080
|
-
out << "exception in selector while calling closeSocket():\n" << ex;
|
|
1257
|
+
wait();
|
|
1081
1258
|
}
|
|
1082
1259
|
}
|
|
1083
1260
|
|
|
1084
|
-
|
|
1085
|
-
Selector::destroy()
|
|
1261
|
+
Selector::~Selector()
|
|
1086
1262
|
{
|
|
1087
|
-
#if !defined(ICE_USE_SELECT) && !defined(ICE_USE_POLL)
|
|
1088
|
-
assert(_events.empty());
|
|
1089
|
-
#endif
|
|
1090
1263
|
}
|
|
1091
1264
|
|
|
1092
1265
|
void
|
|
1093
|
-
Selector::
|
|
1266
|
+
Selector::destroy()
|
|
1094
1267
|
{
|
|
1095
|
-
SocketOperation previous = handler->_registered;
|
|
1096
|
-
handler->_registered = static_cast<SocketOperation>(handler->_registered & ~remove);
|
|
1097
|
-
handler->_registered = static_cast<SocketOperation>(handler->_registered | add);
|
|
1098
|
-
if(previous == handler->_registered)
|
|
1099
1268
|
{
|
|
1100
|
-
|
|
1269
|
+
Lock sync(*this);
|
|
1270
|
+
|
|
1271
|
+
//
|
|
1272
|
+
// Make sure any pending changes are processed to ensure remaining
|
|
1273
|
+
// streams/sockets are closed.
|
|
1274
|
+
//
|
|
1275
|
+
_destroyed = true;
|
|
1276
|
+
CFRunLoopSourceSignal(_source.get());
|
|
1277
|
+
CFRunLoopWakeUp(_runLoop);
|
|
1278
|
+
|
|
1279
|
+
while(!_changes.empty())
|
|
1280
|
+
{
|
|
1281
|
+
CFRunLoopSourceSignal(_source.get());
|
|
1282
|
+
CFRunLoopWakeUp(_runLoop);
|
|
1283
|
+
|
|
1284
|
+
wait();
|
|
1285
|
+
}
|
|
1101
1286
|
}
|
|
1102
1287
|
|
|
1103
|
-
|
|
1288
|
+
_thread->getThreadControl().join();
|
|
1289
|
+
_thread = 0;
|
|
1290
|
+
|
|
1291
|
+
Lock sync(*this);
|
|
1292
|
+
_source.reset(0);
|
|
1293
|
+
|
|
1294
|
+
//assert(_wrappers.empty());
|
|
1295
|
+
_readyHandlers.clear();
|
|
1296
|
+
_selectedHandlers.clear();
|
|
1104
1297
|
}
|
|
1105
1298
|
|
|
1106
1299
|
void
|
|
1107
|
-
Selector::
|
|
1300
|
+
Selector::initialize(EventHandler* handler)
|
|
1108
1301
|
{
|
|
1109
|
-
|
|
1110
|
-
|
|
1111
|
-
|
|
1112
|
-
}
|
|
1113
|
-
handler->_disabled = static_cast<SocketOperation>(handler->_disabled & ~status);
|
|
1302
|
+
Lock sync(*this);
|
|
1303
|
+
_wrappers[handler] = new EventHandlerWrapper(handler, *this);
|
|
1304
|
+
}
|
|
1114
1305
|
|
|
1115
|
-
|
|
1306
|
+
void
|
|
1307
|
+
Selector::update(EventHandler* handler, SocketOperation remove, SocketOperation add)
|
|
1308
|
+
{
|
|
1309
|
+
Lock sync(*this);
|
|
1310
|
+
const EventHandlerWrapperPtr& wrapper = _wrappers[handler];
|
|
1311
|
+
if(wrapper->update(remove, add))
|
|
1116
1312
|
{
|
|
1117
|
-
|
|
1313
|
+
_changes.insert(wrapper);
|
|
1314
|
+
notify();
|
|
1118
1315
|
}
|
|
1119
1316
|
}
|
|
1120
1317
|
|
|
1121
1318
|
void
|
|
1122
|
-
Selector::
|
|
1319
|
+
Selector::enable(EventHandler* handler, SocketOperation op)
|
|
1123
1320
|
{
|
|
1124
|
-
|
|
1321
|
+
Lock sync(*this);
|
|
1322
|
+
if(!(handler->_disabled & op))
|
|
1125
1323
|
{
|
|
1126
1324
|
return;
|
|
1127
1325
|
}
|
|
1128
|
-
handler->_disabled = static_cast<SocketOperation>(handler->_disabled
|
|
1129
|
-
|
|
1130
|
-
if(handler->_registered & status)
|
|
1131
|
-
{
|
|
1132
|
-
updateImpl(handler);
|
|
1133
|
-
}
|
|
1134
|
-
}
|
|
1326
|
+
handler->_disabled = static_cast<SocketOperation>(handler->_disabled & ~op);
|
|
1135
1327
|
|
|
1136
|
-
|
|
1137
|
-
Selector::finish(EventHandler* handler, bool closeNow)
|
|
1138
|
-
{
|
|
1139
|
-
if(handler->_registered)
|
|
1328
|
+
if(handler->_registered & op)
|
|
1140
1329
|
{
|
|
1141
|
-
|
|
1142
|
-
return false; // Don't close now if selecting.
|
|
1330
|
+
_wrappers[handler]->checkReady();
|
|
1143
1331
|
}
|
|
1144
|
-
return closeNow;
|
|
1145
1332
|
}
|
|
1146
1333
|
|
|
1147
1334
|
void
|
|
1148
|
-
Selector::
|
|
1335
|
+
Selector::disable(EventHandler* handler, SocketOperation op)
|
|
1149
1336
|
{
|
|
1150
|
-
|
|
1337
|
+
Lock sync(*this);
|
|
1338
|
+
if(handler->_disabled & op)
|
|
1151
1339
|
{
|
|
1152
|
-
|
|
1153
|
-
while(true)
|
|
1154
|
-
{
|
|
1155
|
-
ssize_t ret;
|
|
1156
|
-
#ifdef _WIN32
|
|
1157
|
-
ret = ::recv(_fdIntrRead, &c, 1, 0);
|
|
1158
|
-
#else
|
|
1159
|
-
ret = ::read(_fdIntrRead, &c, 1);
|
|
1160
|
-
#endif
|
|
1161
|
-
if(ret == SOCKET_ERROR)
|
|
1162
|
-
{
|
|
1163
|
-
if(interrupted())
|
|
1164
|
-
{
|
|
1165
|
-
continue;
|
|
1166
|
-
}
|
|
1167
|
-
|
|
1168
|
-
Ice::SocketException ex(__FILE__, __LINE__);
|
|
1169
|
-
ex.error = IceInternal::getSocketErrno();
|
|
1170
|
-
throw ex;
|
|
1171
|
-
}
|
|
1172
|
-
break;
|
|
1173
|
-
}
|
|
1174
|
-
_interrupted = false;
|
|
1175
|
-
|
|
1176
|
-
if(!_changes.empty())
|
|
1177
|
-
{
|
|
1178
|
-
updateSelector();
|
|
1179
|
-
}
|
|
1340
|
+
return;
|
|
1180
1341
|
}
|
|
1181
|
-
|
|
1342
|
+
handler->_disabled = static_cast<SocketOperation>(handler->_disabled | op);
|
|
1182
1343
|
}
|
|
1183
1344
|
|
|
1184
|
-
|
|
1185
|
-
Selector::
|
|
1345
|
+
bool
|
|
1346
|
+
Selector::finish(EventHandler* handler, bool closeNow)
|
|
1186
1347
|
{
|
|
1187
|
-
|
|
1348
|
+
Lock sync(*this);
|
|
1349
|
+
std::map<EventHandler*, EventHandlerWrapperPtr>::iterator p = _wrappers.find(handler);
|
|
1350
|
+
assert(p != _wrappers.end());
|
|
1351
|
+
EventHandlerWrapperPtr wrapper = p->second;
|
|
1352
|
+
if(wrapper->finish())
|
|
1353
|
+
{
|
|
1354
|
+
_changes.insert(wrapper);
|
|
1355
|
+
notify();
|
|
1356
|
+
}
|
|
1357
|
+
_wrappers.erase(p);
|
|
1358
|
+
return closeNow;
|
|
1188
1359
|
}
|
|
1189
1360
|
|
|
1190
1361
|
void
|
|
1191
|
-
Selector::
|
|
1362
|
+
Selector::ready(EventHandler* handler, SocketOperation status, bool value)
|
|
1192
1363
|
{
|
|
1193
|
-
|
|
1194
|
-
while(true)
|
|
1364
|
+
if(((handler->_ready & status) != 0) == value)
|
|
1195
1365
|
{
|
|
1196
|
-
|
|
1197
|
-
fd_set* rFdSet = fdSetCopy(_selectedReadFdSet, _readFdSet);
|
|
1198
|
-
fd_set* wFdSet = fdSetCopy(_selectedWriteFdSet, _writeFdSet);
|
|
1199
|
-
fd_set* eFdSet = fdSetCopy(_selectedErrorFdSet, _errorFdSet);
|
|
1200
|
-
if(timeout > 0)
|
|
1201
|
-
{
|
|
1202
|
-
struct timeval tv;
|
|
1203
|
-
tv.tv_sec = timeout;
|
|
1204
|
-
tv.tv_usec = 0;
|
|
1205
|
-
ret = ::select(0, rFdSet, wFdSet, eFdSet, &tv); // The first parameter is ignored on Windows
|
|
1206
|
-
}
|
|
1207
|
-
else
|
|
1208
|
-
{
|
|
1209
|
-
ret = ::select(0, rFdSet, wFdSet, eFdSet, 0); // The first parameter is ignored on Windows
|
|
1210
|
-
}
|
|
1211
|
-
#else
|
|
1212
|
-
ret = poll(&_pollFdSet[0], _pollFdSet.size(), timeout > 0 ? timeout * 1000 : -1);
|
|
1213
|
-
#endif
|
|
1214
|
-
if(ret == SOCKET_ERROR)
|
|
1215
|
-
{
|
|
1216
|
-
if(interrupted())
|
|
1217
|
-
{
|
|
1218
|
-
continue;
|
|
1219
|
-
}
|
|
1220
|
-
|
|
1221
|
-
{
|
|
1222
|
-
Ice::SocketException ex(__FILE__, __LINE__, IceInternal::getSocketErrno());
|
|
1223
|
-
Ice::Error out(_instance->initializationData().logger);
|
|
1224
|
-
out << "fatal error: selector failed:\n" << ex;
|
|
1225
|
-
}
|
|
1226
|
-
abort();
|
|
1227
|
-
}
|
|
1228
|
-
break;
|
|
1366
|
+
return; // Nothing to do if ready state already correctly set.
|
|
1229
1367
|
}
|
|
1230
1368
|
|
|
1231
|
-
if(
|
|
1369
|
+
if(value)
|
|
1232
1370
|
{
|
|
1233
|
-
|
|
1371
|
+
handler->_ready = static_cast<SocketOperation>(handler->_ready | status);
|
|
1234
1372
|
}
|
|
1235
|
-
|
|
1236
|
-
assert(ret > 0);
|
|
1237
|
-
|
|
1238
|
-
#if defined(ICE_USE_SELECT)
|
|
1239
|
-
if(_selectedReadFdSet.fd_count == 0 && _selectedWriteFdSet.fd_count == 0 && _selectedErrorFdSet.fd_count == 0)
|
|
1373
|
+
else
|
|
1240
1374
|
{
|
|
1241
|
-
|
|
1242
|
-
out << "select() in selector returned " << ret << " but no filedescriptor is ready";
|
|
1243
|
-
return;
|
|
1375
|
+
handler->_ready = static_cast<SocketOperation>(handler->_ready & ~status);
|
|
1244
1376
|
}
|
|
1245
1377
|
|
|
1246
|
-
|
|
1247
|
-
|
|
1248
|
-
|
|
1378
|
+
Lock sync(*this);
|
|
1379
|
+
std::map<EventHandler*, EventHandlerWrapperPtr>::iterator p = _wrappers.find(handler);
|
|
1380
|
+
assert(p != _wrappers.end());
|
|
1381
|
+
p->second->checkReady();
|
|
1382
|
+
}
|
|
1249
1383
|
|
|
1250
|
-
|
|
1251
|
-
|
|
1252
|
-
|
|
1253
|
-
|
|
1254
|
-
p.second = SocketOperationNone;
|
|
1255
|
-
if(i < _selectedReadFdSet.fd_count)
|
|
1256
|
-
{
|
|
1257
|
-
fd = _selectedReadFdSet.fd_array[i];
|
|
1258
|
-
p.second = static_cast<SocketOperation>(p.second | SocketOperationRead);
|
|
1259
|
-
}
|
|
1260
|
-
else if(i < _selectedWriteFdSet.fd_count + _selectedReadFdSet.fd_count)
|
|
1261
|
-
{
|
|
1262
|
-
fd = _selectedWriteFdSet.fd_array[i - _selectedReadFdSet.fd_count];
|
|
1263
|
-
p.second = static_cast<SocketOperation>(p.second | SocketOperationWrite);
|
|
1264
|
-
}
|
|
1265
|
-
else
|
|
1266
|
-
{
|
|
1267
|
-
fd = _selectedErrorFdSet.fd_array[i - _selectedReadFdSet.fd_count - _selectedWriteFdSet.fd_count];
|
|
1268
|
-
p.second = static_cast<SocketOperation>(p.second | SocketOperationConnect);
|
|
1269
|
-
}
|
|
1384
|
+
void
|
|
1385
|
+
Selector::startSelect()
|
|
1386
|
+
{
|
|
1387
|
+
Lock sync(*this);
|
|
1270
1388
|
|
|
1271
|
-
|
|
1389
|
+
//
|
|
1390
|
+
// Re-enable callbacks for previously selected handlers.
|
|
1391
|
+
//
|
|
1392
|
+
vector<pair<EventHandlerWrapperPtr, SocketOperation> >::const_iterator p;
|
|
1393
|
+
for(p = _selectedHandlers.begin(); p != _selectedHandlers.end(); ++p)
|
|
1394
|
+
{
|
|
1395
|
+
if(p->first->checkReady())
|
|
1272
1396
|
{
|
|
1273
|
-
|
|
1274
|
-
return;
|
|
1397
|
+
_changes.insert(p->first);
|
|
1275
1398
|
}
|
|
1276
|
-
|
|
1277
|
-
assert(_handlers.find(fd) != _handlers.end());
|
|
1278
|
-
p.first = _handlers[fd];
|
|
1279
|
-
handlers.push_back(p);
|
|
1280
1399
|
}
|
|
1281
|
-
|
|
1282
|
-
|
|
1400
|
+
_selectedHandlers.clear();
|
|
1401
|
+
}
|
|
1402
|
+
|
|
1403
|
+
void
|
|
1404
|
+
Selector::finishSelect(std::vector<std::pair<EventHandler*, SocketOperation> >& handlers)
|
|
1405
|
+
{
|
|
1406
|
+
Lock sync(*this);
|
|
1407
|
+
handlers.clear();
|
|
1408
|
+
for(set<EventHandlerWrapperPtr>::const_iterator p = _readyHandlers.begin(); p != _readyHandlers.end(); ++p)
|
|
1283
1409
|
{
|
|
1284
|
-
|
|
1410
|
+
SocketOperation op = (*p)->readyOp();
|
|
1411
|
+
if(op)
|
|
1412
|
+
{
|
|
1413
|
+
_selectedHandlers.push_back(pair<EventHandlerWrapperPtr, SocketOperation>(*p, op));
|
|
1414
|
+
handlers.push_back(pair<EventHandler*, SocketOperation>((*p)->_handler.get(), op));
|
|
1415
|
+
}
|
|
1285
1416
|
}
|
|
1417
|
+
_readyHandlers.clear();
|
|
1418
|
+
}
|
|
1286
1419
|
|
|
1287
|
-
|
|
1420
|
+
void
|
|
1421
|
+
Selector::select(int timeout)
|
|
1422
|
+
{
|
|
1423
|
+
//
|
|
1424
|
+
// Wait for handlers to be ready.
|
|
1425
|
+
//
|
|
1426
|
+
Lock sync(*this);
|
|
1427
|
+
while(!_destroyed)
|
|
1288
1428
|
{
|
|
1289
|
-
|
|
1290
|
-
|
|
1429
|
+
while(!_changes.empty())
|
|
1430
|
+
{
|
|
1431
|
+
CFRunLoopSourceSignal(_source.get());
|
|
1432
|
+
CFRunLoopWakeUp(_runLoop);
|
|
1433
|
+
|
|
1434
|
+
wait();
|
|
1435
|
+
}
|
|
1436
|
+
|
|
1437
|
+
if(_readyHandlers.empty())
|
|
1291
1438
|
{
|
|
1292
|
-
|
|
1293
|
-
assert(fd != _fdIntrRead);
|
|
1294
|
-
assert(_handlers.find(fd) != _handlers.end());
|
|
1295
|
-
p.first = _handlers[fd];
|
|
1296
|
-
p.second = SocketOperationNone;
|
|
1297
|
-
if(q->revents & (POLLIN | POLLERR | POLLHUP))
|
|
1439
|
+
if(timeout > 0)
|
|
1298
1440
|
{
|
|
1299
|
-
|
|
1441
|
+
if(!timedWait(IceUtil::Time::seconds(timeout)))
|
|
1442
|
+
{
|
|
1443
|
+
break;
|
|
1444
|
+
}
|
|
1300
1445
|
}
|
|
1301
|
-
|
|
1446
|
+
else
|
|
1302
1447
|
{
|
|
1303
|
-
|
|
1448
|
+
wait();
|
|
1304
1449
|
}
|
|
1305
|
-
|
|
1306
|
-
|
|
1450
|
+
}
|
|
1451
|
+
|
|
1452
|
+
if(_changes.empty())
|
|
1453
|
+
{
|
|
1454
|
+
break;
|
|
1307
1455
|
}
|
|
1308
1456
|
}
|
|
1309
|
-
#endif
|
|
1310
1457
|
}
|
|
1311
1458
|
|
|
1312
1459
|
void
|
|
1313
|
-
Selector::
|
|
1460
|
+
Selector::processInterrupt()
|
|
1314
1461
|
{
|
|
1315
|
-
|
|
1316
|
-
_changes.
|
|
1317
|
-
if(_selecting)
|
|
1462
|
+
Lock sync(*this);
|
|
1463
|
+
if(!_changes.empty())
|
|
1318
1464
|
{
|
|
1319
|
-
|
|
1465
|
+
for(set<EventHandlerWrapperPtr>::const_iterator p = _changes.begin(); p != _changes.end(); ++p)
|
|
1320
1466
|
{
|
|
1321
|
-
|
|
1322
|
-
while(true)
|
|
1323
|
-
{
|
|
1324
|
-
#ifdef _WIN32
|
|
1325
|
-
if(::send(_fdIntrWrite, &c, 1, 0) == SOCKET_ERROR)
|
|
1326
|
-
#else
|
|
1327
|
-
if(::write(_fdIntrWrite, &c, 1) == SOCKET_ERROR)
|
|
1328
|
-
#endif
|
|
1329
|
-
{
|
|
1330
|
-
if(interrupted())
|
|
1331
|
-
{
|
|
1332
|
-
continue;
|
|
1333
|
-
}
|
|
1334
|
-
|
|
1335
|
-
Ice::SocketException ex(__FILE__, __LINE__);
|
|
1336
|
-
ex.error = IceInternal::getSocketErrno();
|
|
1337
|
-
throw ex;
|
|
1338
|
-
}
|
|
1339
|
-
break;
|
|
1340
|
-
}
|
|
1341
|
-
_interrupted = true;
|
|
1467
|
+
(*p)->updateRunLoop();
|
|
1342
1468
|
}
|
|
1469
|
+
_changes.clear();
|
|
1470
|
+
notify();
|
|
1343
1471
|
}
|
|
1344
|
-
|
|
1472
|
+
if(_destroyed)
|
|
1345
1473
|
{
|
|
1346
|
-
|
|
1474
|
+
CFRunLoopStop(_runLoop);
|
|
1347
1475
|
}
|
|
1348
1476
|
}
|
|
1349
1477
|
|
|
1350
1478
|
void
|
|
1351
|
-
Selector::
|
|
1479
|
+
Selector::run()
|
|
1352
1480
|
{
|
|
1353
|
-
for(vector<pair<EventHandler*, SocketOperation> >::const_iterator p = _changes.begin(); p != _changes.end(); ++p)
|
|
1354
1481
|
{
|
|
1355
|
-
|
|
1356
|
-
|
|
1482
|
+
Lock sync(*this);
|
|
1483
|
+
_runLoop = CFRunLoopGetCurrent();
|
|
1484
|
+
notify();
|
|
1485
|
+
}
|
|
1357
1486
|
|
|
1358
|
-
|
|
1359
|
-
|
|
1360
|
-
|
|
1361
|
-
|
|
1362
|
-
|
|
1363
|
-
|
|
1364
|
-
|
|
1365
|
-
|
|
1366
|
-
|
|
1367
|
-
|
|
1368
|
-
|
|
1369
|
-
|
|
1370
|
-
|
|
1371
|
-
|
|
1372
|
-
|
|
1373
|
-
|
|
1374
|
-
|
|
1375
|
-
|
|
1376
|
-
|
|
1377
|
-
|
|
1378
|
-
if(status & SocketOperationConnect)
|
|
1379
|
-
{
|
|
1380
|
-
FD_SET(fd, &_writeFdSet);
|
|
1381
|
-
FD_SET(fd, &_errorFdSet);
|
|
1382
|
-
}
|
|
1383
|
-
else
|
|
1384
|
-
{
|
|
1385
|
-
FD_CLR(fd, &_writeFdSet);
|
|
1386
|
-
FD_CLR(fd, &_errorFdSet);
|
|
1387
|
-
}
|
|
1388
|
-
_handlers[fd] = handler;
|
|
1389
|
-
#else
|
|
1390
|
-
short events = 0;
|
|
1391
|
-
if(status & SocketOperationRead)
|
|
1392
|
-
{
|
|
1393
|
-
events |= POLLIN;
|
|
1394
|
-
}
|
|
1395
|
-
if(status & SocketOperationWrite)
|
|
1396
|
-
{
|
|
1397
|
-
events |= POLLOUT;
|
|
1398
|
-
}
|
|
1399
|
-
map<SOCKET, EventHandler*>::const_iterator q = _handlers.find(fd);
|
|
1400
|
-
if(q == _handlers.end())
|
|
1401
|
-
{
|
|
1402
|
-
struct pollfd pollFd;
|
|
1403
|
-
pollFd.fd = fd;
|
|
1404
|
-
pollFd.events = events;
|
|
1405
|
-
pollFd.revents = 0;
|
|
1406
|
-
_pollFdSet.push_back(pollFd);
|
|
1407
|
-
_handlers.insert(make_pair(fd, handler));
|
|
1408
|
-
}
|
|
1409
|
-
else
|
|
1410
|
-
{
|
|
1411
|
-
for(vector<struct pollfd>::iterator r = _pollFdSet.begin(); r != _pollFdSet.end(); ++r)
|
|
1412
|
-
{
|
|
1413
|
-
if(r->fd == fd)
|
|
1414
|
-
{
|
|
1415
|
-
r->events = events;
|
|
1416
|
-
break;
|
|
1417
|
-
}
|
|
1418
|
-
}
|
|
1419
|
-
}
|
|
1420
|
-
#endif
|
|
1421
|
-
}
|
|
1422
|
-
else
|
|
1423
|
-
{
|
|
1424
|
-
#if defined(ICE_USE_SELECT)
|
|
1425
|
-
FD_CLR(fd, &_readFdSet);
|
|
1426
|
-
FD_CLR(fd, &_writeFdSet);
|
|
1427
|
-
FD_CLR(fd, &_errorFdSet);
|
|
1428
|
-
#else
|
|
1429
|
-
for(vector<struct pollfd>::iterator r = _pollFdSet.begin(); r != _pollFdSet.end(); ++r)
|
|
1430
|
-
{
|
|
1431
|
-
if(r->fd == fd)
|
|
1432
|
-
{
|
|
1433
|
-
_pollFdSet.erase(r);
|
|
1434
|
-
break;
|
|
1435
|
-
}
|
|
1436
|
-
}
|
|
1437
|
-
#endif
|
|
1438
|
-
_handlers.erase(fd);
|
|
1439
|
-
}
|
|
1487
|
+
CFRunLoopAddSource(CFRunLoopGetCurrent(), _source.get(), kCFRunLoopDefaultMode);
|
|
1488
|
+
CFRunLoopRun();
|
|
1489
|
+
CFRunLoopRemoveSource(CFRunLoopGetCurrent(), _source.get(), kCFRunLoopDefaultMode);
|
|
1490
|
+
}
|
|
1491
|
+
|
|
1492
|
+
void
|
|
1493
|
+
Selector::ready(EventHandlerWrapper* wrapper, SocketOperation op, int error)
|
|
1494
|
+
{
|
|
1495
|
+
Lock sync(*this);
|
|
1496
|
+
wrapper->ready(op, error);
|
|
1497
|
+
}
|
|
1498
|
+
|
|
1499
|
+
void
|
|
1500
|
+
Selector::addReadyHandler(EventHandlerWrapper* wrapper)
|
|
1501
|
+
{
|
|
1502
|
+
// Called from ready()
|
|
1503
|
+
_readyHandlers.insert(wrapper);
|
|
1504
|
+
if(_readyHandlers.size() == 1)
|
|
1505
|
+
{
|
|
1506
|
+
notify();
|
|
1440
1507
|
}
|
|
1441
|
-
_changes.clear();
|
|
1442
1508
|
}
|
|
1443
1509
|
|
|
1444
1510
|
#endif
|