diff options
author | Michi Henning <michi@zeroc.com> | 2003-07-18 05:38:56 +0000 |
---|---|---|
committer | Michi Henning <michi@zeroc.com> | 2003-07-18 05:38:56 +0000 |
commit | 9a7252044516af5435ca202657dd7465056b74a8 (patch) | |
tree | 78ab9df8f1682fd8c22e389d8825c6dacb440eeb /cpp | |
parent | Snap-shot check-in. (diff) | |
download | ice-9a7252044516af5435ca202657dd7465056b74a8.tar.bz2 ice-9a7252044516af5435ca202657dd7465056b74a8.tar.xz ice-9a7252044516af5435ca202657dd7465056b74a8.zip |
Merging changes for DatagramLimitException
Diffstat (limited to 'cpp')
-rw-r--r-- | cpp/doc/Properties.sgml | 65 | ||||
-rw-r--r-- | cpp/slice/Ice/LocalException.ice | 17 | ||||
-rw-r--r-- | cpp/src/Ice/.depend | 2 | ||||
-rw-r--r-- | cpp/src/Ice/Connection.cpp | 22 | ||||
-rw-r--r-- | cpp/src/Ice/Connection.h | 3 | ||||
-rw-r--r-- | cpp/src/Ice/Exception.cpp | 7 | ||||
-rw-r--r-- | cpp/src/Ice/Instance.cpp | 2 | ||||
-rw-r--r-- | cpp/src/Ice/Network.cpp | 202 | ||||
-rw-r--r-- | cpp/src/Ice/Network.h | 3 | ||||
-rw-r--r-- | cpp/src/Ice/Outgoing.cpp | 9 | ||||
-rw-r--r-- | cpp/src/Ice/PropertiesI.cpp | 3 | ||||
-rw-r--r-- | cpp/src/Ice/Proxy.cpp | 4 | ||||
-rw-r--r-- | cpp/src/Ice/TcpTransceiver.cpp | 15 | ||||
-rw-r--r-- | cpp/src/Ice/TcpTransceiver.h | 3 | ||||
-rw-r--r-- | cpp/src/Ice/ThreadPool.cpp | 9 | ||||
-rw-r--r-- | cpp/src/Ice/ThreadPool.h | 2 | ||||
-rw-r--r-- | cpp/src/Ice/Transceiver.h | 2 | ||||
-rw-r--r-- | cpp/src/Ice/UdpTransceiver.cpp | 151 | ||||
-rw-r--r-- | cpp/src/Ice/UdpTransceiver.h | 11 | ||||
-rw-r--r-- | cpp/src/IceSSL/.depend | 2 | ||||
-rw-r--r-- | cpp/src/IceSSL/SslTransceiver.cpp | 30 | ||||
-rw-r--r-- | cpp/src/IceSSL/SslTransceiver.h | 3 |
22 files changed, 426 insertions, 141 deletions
diff --git a/cpp/doc/Properties.sgml b/cpp/doc/Properties.sgml index 1bf1aae4482..c91b8a3545d 100644 --- a/cpp/doc/Properties.sgml +++ b/cpp/doc/Properties.sgml @@ -222,6 +222,24 @@ conditions in connections. The default value is 0. </section> </section> +<section><title>Ice.Warn.Datagrams</title> +<section><title>Synopsis</title> +<synopsis> +Ice.Warn.Datagrams=<replaceable>num</replaceable> +</synopsis> +</section> +<section> +<title>Description</title> +<para> +If <replaceable>num</replaceable> is set to a value larger than zero, +servers will print a warning message if they receive a datagram that exceeds the +servers' receive buffer size. (Note that this condition is not detected +by all UDP implementations -- some implementations silently drop received +datagrams that are too large.) The default value is 0. +</para> +</section> +</section> + <section><title>Ice.Warn.Dispatch</title> <section><title>Synopsis</title> <synopsis> @@ -673,6 +691,12 @@ than this size cause a [MemoryLimitException]. The default size is 1024 (1 Megabyte). Settings with a value less than 1 are ignored. </para> +<para> +This property adjusts the value of <literal>Ice.UDP.RcvSize</literal> and <literal>Ice.UDP.SndSize</literal>, that +is, if <literal>Ice.UDP.RcvSize</literal> or <literal>Ice.UDP.SndSize</literal> are larger than +<literal>Ice.MessageSizeMax * 1024 + 28</literal>, they are adjusted to +<literal>Ice.MessageSizeMax * 1024 + 28</literal>. +</para> </section> </section> @@ -873,6 +897,47 @@ to run if the user that started the application logs off. (C++ only.) </section> </section> +<section><title>Ice.UDP.RcvSize, Ice.UDP.SndSize</title> +<section><title>Synopsis</title> +<synopsis> +Ice.UDP.RcvSize=<replaceable>num</replaceable> +Ice.UDP.SndSize=<replaceable>num</replaceable> +</synopsis> +</section> +<section> +<title>Description</title> +<para> +These properties set the UDP receive and send buffer sizes to the specified value +in bytes. Ice messages larger than <literal><replaceable>num</replaceable> - 28</literal> bytes +cause a <literal>DatagramLimitException</literal>. The default value depends on the configuration +of the local UDP stack. (Common default values are <literal>65535</literal> and <literal>8192</literal> bytes.) +</para> +<para> +The OS may impose lower and upper limits on the receive and send buffer sizes or otherwise adjust the buffer sizes. +If a limit is requested that is lower than the OS-imposed minimum, the value is silently adjusted to the +OS-imposed minimum. If a limit is requested that is larger than the OS-imposed maximum, the value is adjusted +to the OS-imposed maximum; in addition, &Ice; logs a warning showing the requested size and the adjusted size. +</para> +<para> +Settings of these properties less than <literal>28</literal> are ignored. +</para> +<para> +Note that, on many operating systems, it is possible to set buffer sizes greater than <literal>65535</literal>. +Such settings do not change the hard limit of <literal>65507</literal> bytes for the payload of a UDP packet, +but merely affect how much data can be buffered by the kernel. +</para> +<para> +Settings less than <literal>65535</literal> limit the size of &Ice; datagrams as well as adjust the kernel +buffer sizes. +</para> +<para> +If <literal>Ice.MessageSizeMax</literal> is set and <literal>Ice.MessageSizeMax * 1024 + 28</literal> +is smaller than the UDP receive or send buffer size, the corresponding UDP buffer size is reduced to +<literal>Ice.MessageSizeMax * 1024 + 28</literal>. +</para> +</section> +</section> + </section> <!-- ********************************************************************** --> diff --git a/cpp/slice/Ice/LocalException.ice b/cpp/slice/Ice/LocalException.ice index 2823724956c..bd8467ee31e 100644 --- a/cpp/slice/Ice/LocalException.ice +++ b/cpp/slice/Ice/LocalException.ice @@ -604,6 +604,23 @@ local exception MarshalException extends ProtocolException /** * + * This exception is a specialization of [ProtocolException] that is + * raised if a datagram exceeds the configured send or receive buffer + * size, or exceeds the maximum payload size of a UDP packet (65507 bytes). + * + **/ +local exception DatagramLimitException extends ProtocolException +{ + /** + * + * The maximum message size that can be used. + * + **/ + int maxSize; +}; + +/** + * * This exception is a specialization of [MarshalException] that is * raised if no suitable object factory was found during object * unmarshaling. diff --git a/cpp/src/Ice/.depend b/cpp/src/Ice/.depend index 402c7d78fd7..5175587d8a0 100644 --- a/cpp/src/Ice/.depend +++ b/cpp/src/Ice/.depend @@ -61,7 +61,7 @@ Transceiver.o: Transceiver.cpp ../Ice/Transceiver.h ../../include/IceUtil/Shared TcpConnector.o: TcpConnector.cpp ../Ice/TcpConnector.h ../Ice/TransceiverF.h ../../include/Ice/Handle.h ../../include/IceUtil/Handle.h ../../include/IceUtil/Exception.h ../../include/IceUtil/Config.h ../../include/Ice/Config.h ../../include/Ice/InstanceF.h ../Ice/TraceLevelsF.h ../../include/Ice/LoggerF.h ../../include/Ice/LocalObjectF.h ../../include/Ice/ProxyF.h ../../include/Ice/ProxyHandle.h ../../include/Ice/ObjectF.h ../../include/Ice/Exception.h ../../include/Ice/LocalObject.h ../../include/IceUtil/Shared.h ../../include/Ice/StreamF.h ../Ice/Connector.h ../Ice/ConnectorF.h ../Ice/TcpTransceiver.h ../../include/Ice/StatsF.h ../Ice/Transceiver.h ../Ice/Instance.h ../../include/IceUtil/Mutex.h ../../include/IceUtil/Lock.h ../../include/IceUtil/ThreadException.h ../../include/IceUtil/RecMutex.h ../../include/Ice/CommunicatorF.h ../../include/Ice/PropertiesF.h ../Ice/DefaultsAndOverridesF.h ../Ice/RouterInfoF.h ../Ice/LocatorInfoF.h ../Ice/ReferenceFactoryF.h ../../include/Ice/ProxyFactoryF.h ../Ice/ThreadPoolF.h ../../include/Ice/ConnectionFactoryF.h ../../include/Ice/ConnectionMonitorF.h ../Ice/ObjectFactoryManagerF.h ../../include/Ice/ObjectAdapterFactoryF.h ../Ice/EndpointFactoryManagerF.h ../../include/Ice/DynamicLibraryF.h ../../include/Ice/PluginF.h ../Ice/TraceLevels.h ../../include/Ice/LoggerUtil.h ../Ice/Network.h TcpAcceptor.o: TcpAcceptor.cpp ../Ice/TcpAcceptor.h ../Ice/TransceiverF.h ../../include/Ice/Handle.h ../../include/IceUtil/Handle.h ../../include/IceUtil/Exception.h ../../include/IceUtil/Config.h ../../include/Ice/Config.h ../../include/Ice/InstanceF.h ../Ice/TraceLevelsF.h ../../include/Ice/LoggerF.h ../../include/Ice/LocalObjectF.h ../../include/Ice/ProxyF.h ../../include/Ice/ProxyHandle.h ../../include/Ice/ObjectF.h ../../include/Ice/Exception.h ../../include/Ice/LocalObject.h ../../include/IceUtil/Shared.h ../../include/Ice/StreamF.h ../Ice/Acceptor.h ../Ice/AcceptorF.h ../Ice/TcpTransceiver.h ../../include/Ice/StatsF.h ../Ice/Transceiver.h ../Ice/Instance.h ../../include/IceUtil/Mutex.h ../../include/IceUtil/Lock.h ../../include/IceUtil/ThreadException.h ../../include/IceUtil/RecMutex.h ../../include/Ice/CommunicatorF.h ../../include/Ice/PropertiesF.h ../Ice/DefaultsAndOverridesF.h ../Ice/RouterInfoF.h ../Ice/LocatorInfoF.h ../Ice/ReferenceFactoryF.h ../../include/Ice/ProxyFactoryF.h ../Ice/ThreadPoolF.h ../../include/Ice/ConnectionFactoryF.h ../../include/Ice/ConnectionMonitorF.h ../Ice/ObjectFactoryManagerF.h ../../include/Ice/ObjectAdapterFactoryF.h ../Ice/EndpointFactoryManagerF.h ../../include/Ice/DynamicLibraryF.h ../../include/Ice/PluginF.h ../Ice/TraceLevels.h ../../include/Ice/LoggerUtil.h ../Ice/Network.h TcpTransceiver.o: TcpTransceiver.cpp ../Ice/TcpTransceiver.h ../../include/Ice/InstanceF.h ../../include/Ice/Handle.h ../../include/IceUtil/Handle.h ../../include/IceUtil/Exception.h ../../include/IceUtil/Config.h ../../include/Ice/Config.h ../Ice/TraceLevelsF.h ../../include/Ice/LoggerF.h ../../include/Ice/LocalObjectF.h ../../include/Ice/ProxyF.h ../../include/Ice/ProxyHandle.h ../../include/Ice/ObjectF.h ../../include/Ice/Exception.h ../../include/Ice/LocalObject.h ../../include/IceUtil/Shared.h ../../include/Ice/StreamF.h ../../include/Ice/StatsF.h ../Ice/Transceiver.h ../Ice/TransceiverF.h ../Ice/Instance.h ../../include/IceUtil/Mutex.h ../../include/IceUtil/Lock.h ../../include/IceUtil/ThreadException.h ../../include/IceUtil/RecMutex.h ../../include/Ice/CommunicatorF.h ../../include/Ice/PropertiesF.h ../Ice/DefaultsAndOverridesF.h ../Ice/RouterInfoF.h ../Ice/LocatorInfoF.h ../Ice/ReferenceFactoryF.h ../../include/Ice/ProxyFactoryF.h ../Ice/ThreadPoolF.h ../../include/Ice/ConnectionFactoryF.h ../../include/Ice/ConnectionMonitorF.h ../Ice/ObjectFactoryManagerF.h ../../include/Ice/ObjectAdapterFactoryF.h ../Ice/EndpointFactoryManagerF.h ../../include/Ice/DynamicLibraryF.h ../../include/Ice/PluginF.h ../Ice/TraceLevels.h ../../include/Ice/LoggerUtil.h ../../include/Ice/Stats.h ../../include/Ice/Buffer.h ../Ice/Network.h ../../include/Ice/LocalException.h ../../include/Ice/Proxy.h ../../include/Ice/ConnectionF.h ../../include/Ice/EndpointF.h ../../include/Ice/ObjectAdapterF.h ../../include/Ice/ReferenceF.h ../../include/Ice/OutgoingAsyncF.h ../../include/Ice/Current.h ../../include/Ice/Identity.h ../../include/Ice/Facet.h ../../include/Ice/Object.h ../../include/Ice/IncomingAsyncF.h ../../include/Ice/Outgoing.h ../../include/IceUtil/Monitor.h ../../include/IceUtil/Cond.h ../../include/IceUtil/Time.h ../../include/Ice/BasicStream.h ../../include/Ice/ObjectFactoryF.h ../../include/Ice/Incoming.h ../../include/Ice/ServantLocatorF.h ../../include/Ice/ServantManagerF.h ../../include/Ice/Direct.h ../../include/Ice/BuiltinSequences.h -UdpTransceiver.o: UdpTransceiver.cpp ../Ice/UdpTransceiver.h ../../include/Ice/InstanceF.h ../../include/Ice/Handle.h ../../include/IceUtil/Handle.h ../../include/IceUtil/Exception.h ../../include/IceUtil/Config.h ../../include/Ice/Config.h ../Ice/TraceLevelsF.h ../../include/Ice/LoggerF.h ../../include/Ice/LocalObjectF.h ../../include/Ice/ProxyF.h ../../include/Ice/ProxyHandle.h ../../include/Ice/ObjectF.h ../../include/Ice/Exception.h ../../include/Ice/LocalObject.h ../../include/IceUtil/Shared.h ../../include/Ice/StreamF.h ../../include/Ice/StatsF.h ../Ice/Transceiver.h ../Ice/TransceiverF.h ../Ice/Instance.h ../../include/IceUtil/Mutex.h ../../include/IceUtil/Lock.h ../../include/IceUtil/ThreadException.h ../../include/IceUtil/RecMutex.h ../../include/Ice/CommunicatorF.h ../../include/Ice/PropertiesF.h ../Ice/DefaultsAndOverridesF.h ../Ice/RouterInfoF.h ../Ice/LocatorInfoF.h ../Ice/ReferenceFactoryF.h ../../include/Ice/ProxyFactoryF.h ../Ice/ThreadPoolF.h ../../include/Ice/ConnectionFactoryF.h ../../include/Ice/ConnectionMonitorF.h ../Ice/ObjectFactoryManagerF.h ../../include/Ice/ObjectAdapterFactoryF.h ../Ice/EndpointFactoryManagerF.h ../../include/Ice/DynamicLibraryF.h ../../include/Ice/PluginF.h ../Ice/TraceLevels.h ../../include/Ice/LoggerUtil.h ../../include/Ice/Stats.h ../../include/Ice/Buffer.h ../Ice/Network.h ../../include/Ice/LocalException.h ../../include/Ice/Proxy.h ../../include/Ice/ConnectionF.h ../../include/Ice/EndpointF.h ../../include/Ice/ObjectAdapterF.h ../../include/Ice/ReferenceF.h ../../include/Ice/OutgoingAsyncF.h ../../include/Ice/Current.h ../../include/Ice/Identity.h ../../include/Ice/Facet.h ../../include/Ice/Object.h ../../include/Ice/IncomingAsyncF.h ../../include/Ice/Outgoing.h ../../include/IceUtil/Monitor.h ../../include/IceUtil/Cond.h ../../include/IceUtil/Time.h ../../include/Ice/BasicStream.h ../../include/Ice/ObjectFactoryF.h ../../include/Ice/Incoming.h ../../include/Ice/ServantLocatorF.h ../../include/Ice/ServantManagerF.h ../../include/Ice/Direct.h ../../include/Ice/BuiltinSequences.h +UdpTransceiver.o: UdpTransceiver.cpp ../Ice/UdpTransceiver.h ../../include/Ice/InstanceF.h ../../include/Ice/Handle.h ../../include/IceUtil/Handle.h ../../include/IceUtil/Exception.h ../../include/IceUtil/Config.h ../../include/Ice/Config.h ../Ice/TraceLevelsF.h ../../include/Ice/LoggerF.h ../../include/Ice/LocalObjectF.h ../../include/Ice/ProxyF.h ../../include/Ice/ProxyHandle.h ../../include/Ice/ObjectF.h ../../include/Ice/Exception.h ../../include/Ice/LocalObject.h ../../include/IceUtil/Shared.h ../../include/Ice/StreamF.h ../../include/Ice/StatsF.h ../Ice/Transceiver.h ../Ice/TransceiverF.h ../Ice/Instance.h ../../include/IceUtil/Mutex.h ../../include/IceUtil/Lock.h ../../include/IceUtil/ThreadException.h ../../include/IceUtil/RecMutex.h ../../include/Ice/CommunicatorF.h ../../include/Ice/PropertiesF.h ../Ice/DefaultsAndOverridesF.h ../Ice/RouterInfoF.h ../Ice/LocatorInfoF.h ../Ice/ReferenceFactoryF.h ../../include/Ice/ProxyFactoryF.h ../Ice/ThreadPoolF.h ../../include/Ice/ConnectionFactoryF.h ../../include/Ice/ConnectionMonitorF.h ../Ice/ObjectFactoryManagerF.h ../../include/Ice/ObjectAdapterFactoryF.h ../Ice/EndpointFactoryManagerF.h ../../include/Ice/DynamicLibraryF.h ../../include/Ice/PluginF.h ../Ice/TraceLevels.h ../../include/Ice/LoggerUtil.h ../../include/Ice/Stats.h ../../include/Ice/Buffer.h ../Ice/Network.h ../../include/Ice/LocalException.h ../../include/Ice/Proxy.h ../../include/Ice/ConnectionF.h ../../include/Ice/EndpointF.h ../../include/Ice/ObjectAdapterF.h ../../include/Ice/ReferenceF.h ../../include/Ice/OutgoingAsyncF.h ../../include/Ice/Current.h ../../include/Ice/Identity.h ../../include/Ice/Facet.h ../../include/Ice/Object.h ../../include/Ice/IncomingAsyncF.h ../../include/Ice/Outgoing.h ../../include/IceUtil/Monitor.h ../../include/IceUtil/Cond.h ../../include/IceUtil/Time.h ../../include/Ice/BasicStream.h ../../include/Ice/ObjectFactoryF.h ../../include/Ice/Incoming.h ../../include/Ice/ServantLocatorF.h ../../include/Ice/ServantManagerF.h ../../include/Ice/Direct.h ../../include/Ice/BuiltinSequences.h ../../include/Ice/Properties.h DynamicLibrary.o: DynamicLibrary.cpp ../../include/Ice/DynamicLibrary.h ../../include/Ice/DynamicLibraryF.h ../../include/Ice/Handle.h ../../include/IceUtil/Handle.h ../../include/IceUtil/Exception.h ../../include/IceUtil/Config.h ../../include/Ice/Config.h ../../include/IceUtil/Shared.h ../../include/IceUtil/Unicode.h Plugin.o: Plugin.cpp ../../include/Ice/Plugin.h ../../include/Ice/LocalObjectF.h ../../include/Ice/Handle.h ../../include/IceUtil/Handle.h ../../include/IceUtil/Exception.h ../../include/IceUtil/Config.h ../../include/Ice/Config.h ../../include/Ice/ProxyF.h ../../include/Ice/ProxyHandle.h ../../include/Ice/ObjectF.h ../../include/Ice/Exception.h ../../include/Ice/LocalObject.h ../../include/IceUtil/Shared.h ../../include/Ice/StreamF.h PluginManagerI.o: PluginManagerI.cpp ../Ice/PluginManagerI.h ../../include/Ice/Plugin.h ../../include/Ice/LocalObjectF.h ../../include/Ice/Handle.h ../../include/IceUtil/Handle.h ../../include/IceUtil/Exception.h ../../include/IceUtil/Config.h ../../include/Ice/Config.h ../../include/Ice/ProxyF.h ../../include/Ice/ProxyHandle.h ../../include/Ice/ObjectF.h ../../include/Ice/Exception.h ../../include/Ice/LocalObject.h ../../include/IceUtil/Shared.h ../../include/Ice/StreamF.h ../../include/Ice/InstanceF.h ../../include/Ice/CommunicatorF.h ../../include/Ice/DynamicLibraryF.h ../../include/Ice/BuiltinSequences.h ../../include/Ice/Proxy.h ../../include/IceUtil/Mutex.h ../../include/IceUtil/Lock.h ../../include/IceUtil/ThreadException.h ../../include/Ice/ProxyFactoryF.h ../../include/Ice/ConnectionF.h ../../include/Ice/EndpointF.h ../../include/Ice/ObjectAdapterF.h ../../include/Ice/ReferenceF.h ../../include/Ice/OutgoingAsyncF.h ../../include/Ice/Current.h ../../include/Ice/Identity.h ../../include/Ice/Facet.h ../../include/Ice/Object.h ../../include/Ice/IncomingAsyncF.h ../../include/Ice/Outgoing.h ../../include/IceUtil/Monitor.h ../../include/IceUtil/Cond.h ../../include/IceUtil/Time.h ../../include/Ice/BasicStream.h ../../include/Ice/ObjectFactoryF.h ../../include/Ice/Buffer.h ../../include/Ice/Incoming.h ../../include/Ice/ServantLocatorF.h ../../include/Ice/ServantManagerF.h ../../include/Ice/Direct.h ../../include/Ice/DynamicLibrary.h ../../include/Ice/Communicator.h ../../include/Ice/LoggerF.h ../../include/Ice/StatsF.h ../../include/Ice/PropertiesF.h ../../include/Ice/RouterF.h ../../include/Ice/LocatorF.h ../../include/Ice/PluginF.h ../../include/Ice/Properties.h ../../include/Ice/LoggerUtil.h ../../include/Ice/Initialize.h ../../include/Ice/LocalException.h diff --git a/cpp/src/Ice/Connection.cpp b/cpp/src/Ice/Connection.cpp index fa09f3ea6ee..c9970afbcc9 100644 --- a/cpp/src/Ice/Connection.cpp +++ b/cpp/src/Ice/Connection.cpp @@ -1019,6 +1019,23 @@ IceInternal::Connection::message(BasicStream& stream, const ThreadPoolPtr& threa doUncompress(stream, ustream); stream.b.swap(ustream.b); } + + if(_endpoint->datagram()) + { + Int messageSize; + stream.read(messageSize); + if(messageSize > _maxRecvSize) // Truncated datagram + { + DatagramLimitException ex(__FILE__, __LINE__); + ex.maxSize = _maxRecvSize; + if(_warnUdp) + { + Warning out(_logger); + out << "datagram exception:\n" << ex << '\n' << _transceiver->toString(); + } + throw ex; + } + } stream.i = stream.b.begin() + headerSize; @@ -1327,7 +1344,8 @@ IceInternal::Connection::Connection(const InstancePtr& instance, _batchRequestNum(0), _dispatchCount(0), _proxyCount(0), - _state(StateNotValidated) + _state(StateNotValidated), + _maxRecvSize(transceiver->maxRecvSize()) { if(_adapter) { @@ -1373,6 +1391,8 @@ IceInternal::Connection::Connection(const InstancePtr& instance, replyHdr[7] = encodingMinor; replyHdr[8] = replyMsg; replyHdr[9] = 1; // Default compression status: compression supported but not used. + + _warnUdp = _instance->properties()->getPropertyAsInt("Ice.Warn.Datagrams") > 0; } IceInternal::Connection::~Connection() diff --git a/cpp/src/Ice/Connection.h b/cpp/src/Ice/Connection.h index 49b0783699a..4345fda3361 100644 --- a/cpp/src/Ice/Connection.h +++ b/cpp/src/Ice/Connection.h @@ -144,6 +144,7 @@ private: bool _registeredWithPool; bool _warn; + bool _warnUdp; int _acmTimeout; IceUtil::Time _acmAbsoluteTimeout; @@ -167,6 +168,8 @@ private: int _proxyCount; // The number of proxies using this connection. State _state; + + int _maxRecvSize; }; } diff --git a/cpp/src/Ice/Exception.cpp b/cpp/src/Ice/Exception.cpp index 8b03a151550..77f3974bdd2 100644 --- a/cpp/src/Ice/Exception.cpp +++ b/cpp/src/Ice/Exception.cpp @@ -382,6 +382,13 @@ Ice::MarshalException::ice_print(ostream& out) const } void +Ice::DatagramLimitException::ice_print(ostream& out) const +{ + Exception::ice_print(out); + out << ":\nprotocol error: maximum datagram payload size of " << maxSize << " bytes exceeded"; +} + +void Ice::NoObjectFactoryException::ice_print(ostream& out) const { Exception::ice_print(out); diff --git a/cpp/src/Ice/Instance.cpp b/cpp/src/Ice/Instance.cpp index eb777d6a220..89c7ccd9cb6 100644 --- a/cpp/src/Ice/Instance.cpp +++ b/cpp/src/Ice/Instance.cpp @@ -472,7 +472,7 @@ IceInternal::Instance::Instance(const CommunicatorPtr& communicator, int& argc, Int num = _properties->getPropertyAsIntWithDefault("Ice.MessageSizeMax", defaultMessageSizeMax); if(num < 1) { - _messageSizeMax = defaultMessageSizeMax; // Ignore stupid values. + _messageSizeMax = defaultMessageSizeMax * 1024; // Ignore stupid values. } else if(static_cast<size_t>(num) > (size_t)(0x7fffffff / 1024)) { diff --git a/cpp/src/Ice/Network.cpp b/cpp/src/Ice/Network.cpp index fbd895675d4..e741c5e5c64 100644 --- a/cpp/src/Ice/Network.cpp +++ b/cpp/src/Ice/Network.cpp @@ -24,29 +24,14 @@ bool IceInternal::interrupted() { #ifdef _WIN32 - int error = WSAGetLastError(); - if(error == WSAEINTR) - { - return true; - } + return WSAGetLastError() == WSAEINTR; #else # ifdef EPROTO - if(errno == EINTR || - errno == EPROTO) - { - return true; - } + return errno == EINTR || errno == EPROTO; # else - if(errno == EINTR) - { - return true; - } + return errno == EINTR; # endif #endif - else - { - return false; - } } bool @@ -59,24 +44,14 @@ IceInternal::acceptInterrupted() #ifdef _WIN32 int error = WSAGetLastError(); - if(error == WSAECONNABORTED || - error == WSAECONNRESET || - error == WSAETIMEDOUT) - { - return true; - } + return error == WSAECONNABORTED || + error == WSAECONNRESET || + error == WSAETIMEDOUT; #else - if(errno == ECONNABORTED || - errno == ECONNRESET || - errno == ETIMEDOUT) - { - return true; - } + return errno == ECONNABORTED || + errno == ECONNRESET || + errno == ETIMEDOUT; #endif - else - { - return false; - } } bool @@ -84,43 +59,21 @@ IceInternal::noBuffers() { #ifdef _WIN32 int error = WSAGetLastError(); - if(error == WSAENOBUFS || - error == WSAEFAULT) - { - return true; - } + return error == WSAENOBUFS || + error == WSAEFAULT; #else - if(errno == ENOBUFS) - { - return true; - } + return errno == ENOBUFS; #endif - else - { - return false; - } } bool IceInternal::wouldBlock() { #ifdef _WIN32 - int error = WSAGetLastError(); - if(error == WSAEWOULDBLOCK) - { - return true; - } + return WSAGetLastError() == WSAEWOULDBLOCK; #else - if(errno == EAGAIN || - errno == EWOULDBLOCK) - { - return true; - } + return errno == EAGAIN || errno == EWOULDBLOCK; #endif - else - { - return false; - } } bool @@ -128,51 +81,30 @@ IceInternal::connectFailed() { #ifdef _WIN32 int error = WSAGetLastError(); - if(error == WSAECONNREFUSED || - error == WSAETIMEDOUT || - error == WSAENETUNREACH || - error == WSAECONNRESET || - error == WSAESHUTDOWN || - error == WSAECONNABORTED) - { - return true; - } + return error == WSAECONNREFUSED || + error == WSAETIMEDOUT || + error == WSAENETUNREACH || + error == WSAECONNRESET || + error == WSAESHUTDOWN || + error == WSAECONNABORTED; #else - if(errno == ECONNREFUSED || - errno == ETIMEDOUT || - errno == ENETUNREACH || - errno == ECONNRESET || - errno == ESHUTDOWN || - errno == ECONNABORTED) - { - return true; - } + return errno == ECONNREFUSED || + errno == ETIMEDOUT || + errno == ENETUNREACH || + errno == ECONNRESET || + errno == ESHUTDOWN || + errno == ECONNABORTED; #endif - else - { - return false; - } } bool IceInternal::connectInProgress() { #ifdef _WIN32 - int error = WSAGetLastError(); - if(error == WSAEWOULDBLOCK) - { - return true; - } + return WSAGetLastError() == WSAEWOULDBLOCK; #else - if(errno == EINPROGRESS) - { - return true; - } + return errno == EINPROGRESS; #endif - else - { - return false; - } } bool @@ -180,45 +112,35 @@ IceInternal::connectionLost() { #ifdef _WIN32 int error = WSAGetLastError(); - if(error == WSAECONNRESET || - error == WSAESHUTDOWN || - error == WSAECONNABORTED) - { - return true; - } + return error == WSAECONNRESET || + error == WSAESHUTDOWN || + error == WSAECONNABORTED; #else - if(errno == ECONNRESET || - errno == ESHUTDOWN || - errno == ECONNABORTED) - { - return true; - } + return errno == ECONNRESET || + errno == ESHUTDOWN || + errno == ECONNABORTED; #endif - else - { - return false; - } } bool IceInternal::notConnected() { #ifdef _WIN32 - int error = WSAGetLastError(); - if(error == WSAENOTCONN) - { - return true; - } + return WSAGetLastError() == WSAENOTCONN; #else - if(errno == ENOTCONN) - { - return true; - } + return errno == ENOTCONN; +#endif +} + +bool +IceInternal::recvTruncated() +{ +#ifdef _WIN32 + return WSAGetLastError() == WSAEMSGSIZE; +#else + // We don't get an error under Linux if a datagram is truncated. + return false; #endif - else - { - return false; - } } SOCKET @@ -330,6 +252,21 @@ IceInternal::setSendBufferSize(SOCKET fd, int sz) } } +int +IceInternal::getSendBufferSize(SOCKET fd) +{ + int sz; + socklen_t len = sizeof(sz); + if(getsockopt(fd, SOL_SOCKET, SO_SNDBUF, (char*)&sz, &len) == SOCKET_ERROR || len != sizeof(sz)) + { + closeSocket(fd); + SocketException ex(__FILE__, __LINE__); + ex.error = getSocketErrno(); + throw ex; + } + return sz; +} + void IceInternal::setRecvBufferSize(SOCKET fd, int sz) { @@ -342,6 +279,21 @@ IceInternal::setRecvBufferSize(SOCKET fd, int sz) } } +int +IceInternal::getRecvBufferSize(SOCKET fd) +{ + int sz; + socklen_t len = sizeof(sz); + if(getsockopt(fd, SOL_SOCKET, SO_RCVBUF, (char*)&sz, &len) == SOCKET_ERROR || len != sizeof(sz)) + { + closeSocket(fd); + SocketException ex(__FILE__, __LINE__); + ex.error = getSocketErrno(); + throw ex; + } + return sz; +} + void IceInternal::doBind(SOCKET fd, struct sockaddr_in& addr) { diff --git a/cpp/src/Ice/Network.h b/cpp/src/Ice/Network.h index 2ed6c3d084b..3bdd541d513 100644 --- a/cpp/src/Ice/Network.h +++ b/cpp/src/Ice/Network.h @@ -72,6 +72,7 @@ ICE_PROTOCOL_API bool connectFailed(); ICE_PROTOCOL_API bool connectInProgress(); ICE_PROTOCOL_API bool connectionLost(); ICE_PROTOCOL_API bool notConnected(); +ICE_PROTOCOL_API bool recvTruncated(); ICE_PROTOCOL_API SOCKET createSocket(bool); ICE_PROTOCOL_API void closeSocket(SOCKET); @@ -80,7 +81,9 @@ ICE_PROTOCOL_API void setBlock(SOCKET, bool); ICE_PROTOCOL_API void setTcpNoDelay(SOCKET); ICE_PROTOCOL_API void setKeepAlive(SOCKET); ICE_PROTOCOL_API void setSendBufferSize(SOCKET, int); +ICE_PROTOCOL_API int getSendBufferSize(SOCKET); ICE_PROTOCOL_API void setRecvBufferSize(SOCKET, int); +ICE_PROTOCOL_API int getRecvBufferSize(SOCKET); ICE_PROTOCOL_API void doBind(SOCKET, struct sockaddr_in&); ICE_PROTOCOL_API void doListen(SOCKET, int); diff --git a/cpp/src/Ice/Outgoing.cpp b/cpp/src/Ice/Outgoing.cpp index 88fee1df3c7..05a33d2294a 100644 --- a/cpp/src/Ice/Outgoing.cpp +++ b/cpp/src/Ice/Outgoing.cpp @@ -175,7 +175,14 @@ IceInternal::Outgoing::invoke() case Reference::ModeOneway: case Reference::ModeDatagram: { - _connection->sendRequest(this, true); + try + { + _connection->sendRequest(this, true); + } + catch(const DatagramLimitException& ex) + { + throw NonRepeatable(ex); + } _state = StateInProgress; break; } diff --git a/cpp/src/Ice/PropertiesI.cpp b/cpp/src/Ice/PropertiesI.cpp index d55b556aab1..db1d692c562 100644 --- a/cpp/src/Ice/PropertiesI.cpp +++ b/cpp/src/Ice/PropertiesI.cpp @@ -133,9 +133,12 @@ static const string iceProps[] = "Trace.Protocol", "Trace.Retry", "Trace.Slicing", + "UDP.RcvSize", + "UDP.SndSize", "UseSyslog", "Warn.AMICallback", "Warn.Connections", + "Warn.Datagrams", "Warn.Dispatch", "Warn.Leaks" }; diff --git a/cpp/src/Ice/Proxy.cpp b/cpp/src/Ice/Proxy.cpp index 5ad40a8277e..aadce898703 100644 --- a/cpp/src/Ice/Proxy.cpp +++ b/cpp/src/Ice/Proxy.cpp @@ -578,6 +578,10 @@ IceProxy::Ice::Object::ice_flush() __del->ice_flush(); return; } + catch(const DatagramLimitException&) + { + throw; // DatagramLimitExcpetion is not repeatable. + } catch(const LocalException& __ex) { __handleException(__ex, __cnt); diff --git a/cpp/src/Ice/TcpTransceiver.cpp b/cpp/src/Ice/TcpTransceiver.cpp index e5003c94954..c4b529a2e88 100644 --- a/cpp/src/Ice/TcpTransceiver.cpp +++ b/cpp/src/Ice/TcpTransceiver.cpp @@ -283,12 +283,25 @@ IceInternal::TcpTransceiver::toString() const return _desc; } +int +IceInternal::TcpTransceiver::maxRecvSize() const +{ + return _maxSize; +} + +int +IceInternal::TcpTransceiver::maxSendSize() const +{ + return _maxSize; +} + IceInternal::TcpTransceiver::TcpTransceiver(const InstancePtr& instance, SOCKET fd) : _traceLevels(instance->traceLevels()), _logger(instance->logger()), _stats(instance->stats()), _name("tcp"), - _fd(fd) + _fd(fd), + _maxSize(instance->messageSizeMax()) { FD_ZERO(&_rFdSet); FD_ZERO(&_wFdSet); diff --git a/cpp/src/Ice/TcpTransceiver.h b/cpp/src/Ice/TcpTransceiver.h index 3b4e22e934d..fb6e488283a 100644 --- a/cpp/src/Ice/TcpTransceiver.h +++ b/cpp/src/Ice/TcpTransceiver.h @@ -37,6 +37,8 @@ public: virtual void write(Buffer&, int); virtual void read(Buffer&, int); virtual std::string toString() const; + virtual int maxRecvSize() const; + virtual int maxSendSize() const; private: @@ -54,6 +56,7 @@ private: SOCKET _fd; fd_set _rFdSet; fd_set _wFdSet; + int _maxSize; }; } diff --git a/cpp/src/Ice/ThreadPool.cpp b/cpp/src/Ice/ThreadPool.cpp index 69fa4892a50..f14a4986fa4 100644 --- a/cpp/src/Ice/ThreadPool.cpp +++ b/cpp/src/Ice/ThreadPool.cpp @@ -39,6 +39,7 @@ IceInternal::ThreadPool::ThreadPool(const InstancePtr& instance, const string& p _size(0), _sizeMax(0), _sizeWarn(0), + _messageSizeMax(0), _running(0), _inUse(0), _load(0) @@ -71,6 +72,8 @@ IceInternal::ThreadPool::ThreadPool(const InstancePtr& instance, const string& p int sizeWarn = _instance->properties()->getPropertyAsIntWithDefault(_prefix + ".SizeWarn", _sizeMax * 80 / 100); const_cast<int&>(_sizeWarn) = sizeWarn; + const_cast<int&>(_messageSizeMax) = instance->messageSizeMax(); + __setNoDelete(true); try { @@ -539,6 +542,10 @@ IceInternal::ThreadPool::run() { continue; } + catch(const DatagramLimitException&) // Expected. + { + continue; + } catch(const LocalException& ex) { handler->exception(ex); @@ -683,7 +690,7 @@ IceInternal::ThreadPool::read(const EventHandlerPtr& handler) { throw IllegalMessageSizeException(__FILE__, __LINE__); } - if(size > 1024 * 1024) // TODO: configurable + if(size > _messageSizeMax) { throw MemoryLimitException(__FILE__, __LINE__); } diff --git a/cpp/src/Ice/ThreadPool.h b/cpp/src/Ice/ThreadPool.h index 1f514c6535f..c5a79409bdc 100644 --- a/cpp/src/Ice/ThreadPool.h +++ b/cpp/src/Ice/ThreadPool.h @@ -93,6 +93,8 @@ private: const int _sizeMax; // Maximum number of threads. const int _sizeWarn; // If _inUse reaches _sizeWarn, a "low on threads" warning will be printed. + const int _messageSizeMax; + std::vector<IceUtil::ThreadControl> _threads; // Control for all threads, running or not. int _running; // Number of running threads. int _inUse; // Number of threads that are currently in use. diff --git a/cpp/src/Ice/Transceiver.h b/cpp/src/Ice/Transceiver.h index b5cd431fdae..d9ea8415a27 100644 --- a/cpp/src/Ice/Transceiver.h +++ b/cpp/src/Ice/Transceiver.h @@ -39,6 +39,8 @@ public: virtual void write(Buffer&, int) = 0; virtual void read(Buffer&, int) = 0; virtual std::string toString() const = 0; + virtual int maxRecvSize() const = 0; + virtual int maxSendSize() const = 0; }; } diff --git a/cpp/src/Ice/UdpTransceiver.cpp b/cpp/src/Ice/UdpTransceiver.cpp index 78b18e997c6..6a4a74c38df 100644 --- a/cpp/src/Ice/UdpTransceiver.cpp +++ b/cpp/src/Ice/UdpTransceiver.cpp @@ -20,6 +20,7 @@ #include <Ice/Buffer.h> #include <Ice/Network.h> #include <Ice/LocalException.h> +#include <Ice/Properties.h> using namespace std; using namespace Ice; @@ -55,10 +56,13 @@ void IceInternal::UdpTransceiver::write(Buffer& buf, int) { assert(buf.i == buf.b.begin()); -#ifndef NDEBUG - const int packetSize = 64 * 1024; // TODO: configurable - assert(packetSize >= static_cast<int>(buf.b.size())); // TODO: exception -#endif + const int packetSize = min(_maxPacketSize, _sndSize - _udpOverhead); + if(packetSize < static_cast<int>(buf.b.size())) + { + Ice::DatagramLimitException ex(__FILE__, __LINE__); + ex.maxSize = packetSize; + throw ex; + } repeat: @@ -119,8 +123,14 @@ void IceInternal::UdpTransceiver::read(Buffer& buf, int) { assert(buf.i == buf.b.begin()); - const int packetSize = 64 * 1024; // TODO: configurable - assert(packetSize >= static_cast<int>(buf.b.size())); // TODO: exception + + const int packetSize = min(_maxPacketSize, _rcvSize - _udpOverhead); + if(packetSize < static_cast<int>(buf.b.size())) + { + Ice::DatagramLimitException ex(__FILE__, __LINE__); + ex.maxSize = packetSize; + throw ex; + } buf.b.resize(packetSize); buf.i = buf.b.begin(); @@ -137,7 +147,8 @@ repeat: memset(&peerAddr, 0, sizeof(struct sockaddr_in)); socklen_t len = static_cast<socklen_t>(sizeof(peerAddr)); assert(_fd != INVALID_SOCKET); - ret = recvfrom(_fd, reinterpret_cast<char*>(&buf.b[0]), packetSize, 0, reinterpret_cast<struct sockaddr*>(&peerAddr), &len); + ret = recvfrom(_fd, reinterpret_cast<char*>(&buf.b[0]), packetSize, + 0, reinterpret_cast<struct sockaddr*>(&peerAddr), &len); if(ret != SOCKET_ERROR) { doConnect(_fd, peerAddr, -1); @@ -186,6 +197,19 @@ repeat: goto repeat; } + if(recvTruncated()) + { + DatagramLimitException ex(__FILE__, __LINE__); + ex.maxSize = packetSize; + if(_warn) + { + Warning out(_logger); + out << "datagram exception:\n" << ex << '\n' << toString(); + } + throw ex; + + } + SocketException ex(__FILE__, __LINE__); ex.error = getSocketErrno(); throw ex; @@ -212,6 +236,18 @@ IceInternal::UdpTransceiver::toString() const return fdToString(_fd); } +int +IceInternal::UdpTransceiver::maxRecvSize() const +{ + return _rcvSize; +} + +int +IceInternal::UdpTransceiver::maxSendSize() const +{ + return _sndSize; +} + bool IceInternal::UdpTransceiver::equivalent(const string& host, int port) const { @@ -221,7 +257,7 @@ IceInternal::UdpTransceiver::equivalent(const string& host, int port) const } int -IceInternal::UdpTransceiver::effectivePort() +IceInternal::UdpTransceiver::effectivePort() const { return ntohs(_addr.sin_port); } @@ -235,6 +271,7 @@ IceInternal::UdpTransceiver::UdpTransceiver(const InstancePtr& instance, const s try { _fd = createSocket(true); + setBufSize(instance); setBlock(_fd, false); getAddress(host, port, _addr); doConnect(_fd, _addr, -1); @@ -267,6 +304,7 @@ IceInternal::UdpTransceiver::UdpTransceiver(const InstancePtr& instance, const s try { _fd = createSocket(true); + setBufSize(instance); setBlock(_fd, false); getAddress(host, port, _addr); if(_traceLevels->network >= 2) @@ -295,4 +333,101 @@ IceInternal::UdpTransceiver::UdpTransceiver(const InstancePtr& instance, const s IceInternal::UdpTransceiver::~UdpTransceiver() { assert(_fd == INVALID_SOCKET); +} + +// +// Set UDP receive and send buffer sizes. +// + +void +IceInternal::UdpTransceiver::setBufSize(const InstancePtr& instance) +{ + assert(_fd != INVALID_SOCKET); + + _warn = instance->properties()->getPropertyAsInt("Ice.Warn.Datagrams") > 0; + + for(int i = 0; i < 2; ++i) + { + string direction; + string prop; + int* addr; + int dfltSize; + if(i == 0) + { + direction = "receive"; + prop = "Ice.UDP.RcvSize"; + addr = &_rcvSize; + dfltSize = getRecvBufferSize(_fd); + } + else + { + direction = "send"; + prop = "Ice.UDP.SndSize"; + addr = &_sndSize; + dfltSize = getSendBufferSize(_fd); + } + + // + // Get property for buffer size and check for sanity. + // + Int sizeRequested = instance->properties()->getPropertyAsIntWithDefault(prop, dfltSize); + if(sizeRequested < _udpOverhead) + { + Warning out(_logger); + out << "Invalid " << prop << " of " << sizeRequested << " adjusted to " << dfltSize; + sizeRequested = dfltSize; + } + + // + // Ice.MessageSizeMax overrides UDP buffer sizes if Ice.MessageSizeMax + _udpOverhead is less. + // + size_t messageSizeMax = instance->messageSizeMax(); + if(static_cast<size_t>(sizeRequested) > messageSizeMax + _udpOverhead) + { + Warning out(_logger); + out << "UDP " << direction << " buffer size: requested size of " << sizeRequested << " adjusted to "; + sizeRequested = min(messageSizeMax + _udpOverhead, static_cast<size_t>(_maxPacketSize) + _udpOverhead); + out << sizeRequested << " (Ice.MessageSizeMax takes precendence)"; + } + + if(sizeRequested != dfltSize) + { + // + // Try to set the buffer size. The kernel will silently adjust + // the size to an acceptable value. Then read the size back to + // get the size that was actually set. + // + if(i == 0) + { + setRecvBufferSize(_fd, sizeRequested); + *addr = getRecvBufferSize(_fd); + } + else + { + setSendBufferSize(_fd, sizeRequested); + *addr = getSendBufferSize(_fd); + } + + // + // Warn if the size that was set is less than the requested size. + // + if(*addr < sizeRequested) + { + Warning out(_logger); + out << "UDP " << direction << " buffer size: requested size of " + << sizeRequested << " adjusted to " << *addr; + } + } + else + { + *addr = dfltSize; + } + } } + +// +// The maximum IP datagram size is 65535. Subtract 20 bytes for the IP header and 8 bytes for the UDP header +// to get the maximum payload. +// +const int IceInternal::UdpTransceiver::_udpOverhead = 20 + 8; +const int IceInternal::UdpTransceiver::_maxPacketSize = 65535 - _udpOverhead; diff --git a/cpp/src/Ice/UdpTransceiver.h b/cpp/src/Ice/UdpTransceiver.h index df48d35c372..1b961860230 100644 --- a/cpp/src/Ice/UdpTransceiver.h +++ b/cpp/src/Ice/UdpTransceiver.h @@ -42,9 +42,11 @@ public: virtual void write(Buffer&, int); virtual void read(Buffer&, int); virtual std::string toString() const; + virtual int maxRecvSize() const; + virtual int maxSendSize() const; bool equivalent(const std::string&, int) const; - int effectivePort(); + int effectivePort() const; private: @@ -52,6 +54,8 @@ private: UdpTransceiver(const InstancePtr&, const std::string&, int, bool); virtual ~UdpTransceiver(); + void setBufSize(const InstancePtr&); + friend class UdpEndpoint; const TraceLevelsPtr _traceLevels; @@ -65,6 +69,11 @@ private: fd_set _rFdSet; fd_set _wFdSet; bool _connect; + int _rcvSize; + int _sndSize; + static const int _udpOverhead; + static const int _maxPacketSize; + bool _warn; }; } diff --git a/cpp/src/IceSSL/.depend b/cpp/src/IceSSL/.depend index 37dc6b768a7..f0528166acf 100644 --- a/cpp/src/IceSSL/.depend +++ b/cpp/src/IceSSL/.depend @@ -5,7 +5,7 @@ SslEndpoint.o: SslEndpoint.cpp ../Ice/Network.h ../../include/Ice/Config.h ../.. SslException.o: SslException.cpp ../../include/Ice/LocalException.h ../../include/Ice/LocalObjectF.h ../../include/Ice/Handle.h ../../include/IceUtil/Handle.h ../../include/IceUtil/Exception.h ../../include/IceUtil/Config.h ../../include/Ice/Config.h ../../include/Ice/ProxyF.h ../../include/Ice/ProxyHandle.h ../../include/Ice/ObjectF.h ../../include/Ice/Exception.h ../../include/Ice/LocalObject.h ../../include/IceUtil/Shared.h ../../include/Ice/StreamF.h ../../include/Ice/Proxy.h ../../include/IceUtil/Mutex.h ../../include/IceUtil/Lock.h ../../include/IceUtil/ThreadException.h ../../include/Ice/ProxyFactoryF.h ../../include/Ice/ConnectionF.h ../../include/Ice/EndpointF.h ../../include/Ice/ObjectAdapterF.h ../../include/Ice/ReferenceF.h ../../include/Ice/OutgoingAsyncF.h ../../include/Ice/Current.h ../../include/Ice/Identity.h ../../include/Ice/Facet.h ../../include/Ice/Object.h ../../include/Ice/IncomingAsyncF.h ../../include/Ice/Outgoing.h ../../include/IceUtil/Monitor.h ../../include/IceUtil/Cond.h ../../include/IceUtil/Time.h ../../include/Ice/BasicStream.h ../../include/Ice/InstanceF.h ../../include/Ice/ObjectFactoryF.h ../../include/Ice/Buffer.h ../../include/Ice/Incoming.h ../../include/Ice/ServantLocatorF.h ../../include/Ice/ServantManagerF.h ../../include/Ice/Direct.h ../../include/Ice/BuiltinSequences.h ../../include/IceSSL/Exception.h SslConnector.o: SslConnector.cpp ../../include/Ice/Logger.h ../../include/Ice/LocalObjectF.h ../../include/Ice/Handle.h ../../include/IceUtil/Handle.h ../../include/IceUtil/Exception.h ../../include/IceUtil/Config.h ../../include/Ice/Config.h ../../include/Ice/ProxyF.h ../../include/Ice/ProxyHandle.h ../../include/Ice/ObjectF.h ../../include/Ice/Exception.h ../../include/Ice/LocalObject.h ../../include/IceUtil/Shared.h ../../include/Ice/StreamF.h ../Ice/Network.h ../IceSSL/OpenSSLPluginI.h ../../include/IceUtil/RecMutex.h ../../include/IceUtil/Lock.h ../../include/IceUtil/ThreadException.h ../../include/Ice/LoggerF.h ../../include/Ice/StatsF.h ../../include/Ice/PropertiesF.h ../../include/Ice/ProtocolPluginFacadeF.h ../../include/IceSSL/Plugin.h ../../include/Ice/Proxy.h ../../include/IceUtil/Mutex.h ../../include/Ice/ProxyFactoryF.h ../../include/Ice/ConnectionF.h ../../include/Ice/EndpointF.h ../../include/Ice/ObjectAdapterF.h ../../include/Ice/ReferenceF.h ../../include/Ice/OutgoingAsyncF.h ../../include/Ice/Current.h ../../include/Ice/Identity.h ../../include/Ice/Facet.h ../../include/Ice/Object.h ../../include/Ice/IncomingAsyncF.h ../../include/Ice/Outgoing.h ../../include/IceUtil/Monitor.h ../../include/IceUtil/Cond.h ../../include/IceUtil/Time.h ../../include/Ice/BasicStream.h ../../include/Ice/InstanceF.h ../../include/Ice/ObjectFactoryF.h ../../include/Ice/Buffer.h ../../include/Ice/Incoming.h ../../include/Ice/ServantLocatorF.h ../../include/Ice/ServantManagerF.h ../../include/Ice/Direct.h ../../include/Ice/BuiltinSequences.h ../../include/Ice/Plugin.h ../../include/IceSSL/CertificateVerifierF.h ../IceSSL/OpenSSLPluginIF.h ../IceSSL/TraceLevelsF.h ../IceSSL/SslTransceiverF.h ../IceSSL/CertificateDesc.h ../IceSSL/CertificateAuthority.h ../IceSSL/BaseCerts.h ../IceSSL/TempCerts.h ../IceSSL/ServerContext.h ../IceSSL/Context.h ../../include/Ice/CommunicatorF.h ../IceSSL/OpenSSL.h ../../include/IceSSL/CertificateVerifierOpenSSL.h ../../include/IceSSL/Config.h ../../include/IceSSL/CertificateVerifier.h ../IceSSL/GeneralConfig.h ../IceSSL/SslTransceiver.h ../Ice/Transceiver.h ../Ice/TransceiverF.h ../IceSSL/ContextF.h ../../include/IceSSL/RSAPublicKey.h ../../include/IceSSL/RSAPublicKeyF.h ../../include/IceSSL/RSAKeyPairF.h ../IceSSL/ClientContext.h ../../include/IceSSL/RSAPrivateKeyF.h ../IceSSL/DHParamsF.h ../IceSSL/SslConnector.h ../Ice/Connector.h ../Ice/ConnectorF.h ../IceSSL/TraceLevels.h SslAcceptor.o: SslAcceptor.cpp ../../include/Ice/LoggerUtil.h ../../include/Ice/LoggerF.h ../../include/Ice/LocalObjectF.h ../../include/Ice/Handle.h ../../include/IceUtil/Handle.h ../../include/IceUtil/Exception.h ../../include/IceUtil/Config.h ../../include/Ice/Config.h ../../include/Ice/ProxyF.h ../../include/Ice/ProxyHandle.h ../../include/Ice/ObjectF.h ../../include/Ice/Exception.h ../../include/Ice/LocalObject.h ../../include/IceUtil/Shared.h ../../include/Ice/StreamF.h ../Ice/Network.h ../IceSSL/OpenSSLPluginI.h ../../include/IceUtil/RecMutex.h ../../include/IceUtil/Lock.h ../../include/IceUtil/ThreadException.h ../../include/Ice/StatsF.h ../../include/Ice/PropertiesF.h ../../include/Ice/ProtocolPluginFacadeF.h ../../include/IceSSL/Plugin.h ../../include/Ice/Proxy.h ../../include/IceUtil/Mutex.h ../../include/Ice/ProxyFactoryF.h ../../include/Ice/ConnectionF.h ../../include/Ice/EndpointF.h ../../include/Ice/ObjectAdapterF.h ../../include/Ice/ReferenceF.h ../../include/Ice/OutgoingAsyncF.h ../../include/Ice/Current.h ../../include/Ice/Identity.h ../../include/Ice/Facet.h ../../include/Ice/Object.h ../../include/Ice/IncomingAsyncF.h ../../include/Ice/Outgoing.h ../../include/IceUtil/Monitor.h ../../include/IceUtil/Cond.h ../../include/IceUtil/Time.h ../../include/Ice/BasicStream.h ../../include/Ice/InstanceF.h ../../include/Ice/ObjectFactoryF.h ../../include/Ice/Buffer.h ../../include/Ice/Incoming.h ../../include/Ice/ServantLocatorF.h ../../include/Ice/ServantManagerF.h ../../include/Ice/Direct.h ../../include/Ice/BuiltinSequences.h ../../include/Ice/Plugin.h ../../include/IceSSL/CertificateVerifierF.h ../IceSSL/OpenSSLPluginIF.h ../IceSSL/TraceLevelsF.h ../IceSSL/SslTransceiverF.h ../IceSSL/CertificateDesc.h ../IceSSL/CertificateAuthority.h ../IceSSL/BaseCerts.h ../IceSSL/TempCerts.h ../IceSSL/ServerContext.h ../IceSSL/Context.h ../../include/Ice/CommunicatorF.h ../IceSSL/OpenSSL.h ../../include/IceSSL/CertificateVerifierOpenSSL.h ../../include/IceSSL/Config.h ../../include/IceSSL/CertificateVerifier.h ../IceSSL/GeneralConfig.h ../IceSSL/SslTransceiver.h ../Ice/Transceiver.h ../Ice/TransceiverF.h ../IceSSL/ContextF.h ../../include/IceSSL/RSAPublicKey.h ../../include/IceSSL/RSAPublicKeyF.h ../../include/IceSSL/RSAKeyPairF.h ../IceSSL/ClientContext.h ../../include/IceSSL/RSAPrivateKeyF.h ../IceSSL/DHParamsF.h ../IceSSL/SslAcceptor.h ../Ice/Acceptor.h ../Ice/AcceptorF.h ../IceSSL/TraceLevels.h -SslTransceiver.o: SslTransceiver.cpp ../../include/Ice/LoggerUtil.h ../../include/Ice/LoggerF.h ../../include/Ice/LocalObjectF.h ../../include/Ice/Handle.h ../../include/IceUtil/Handle.h ../../include/IceUtil/Exception.h ../../include/IceUtil/Config.h ../../include/Ice/Config.h ../../include/Ice/ProxyF.h ../../include/Ice/ProxyHandle.h ../../include/Ice/ObjectF.h ../../include/Ice/Exception.h ../../include/Ice/LocalObject.h ../../include/IceUtil/Shared.h ../../include/Ice/StreamF.h ../../include/Ice/Stats.h ../../include/Ice/Buffer.h ../Ice/Network.h ../../include/Ice/LocalException.h ../../include/Ice/Proxy.h ../../include/IceUtil/Mutex.h ../../include/IceUtil/Lock.h ../../include/IceUtil/ThreadException.h ../../include/Ice/ProxyFactoryF.h ../../include/Ice/ConnectionF.h ../../include/Ice/EndpointF.h ../../include/Ice/ObjectAdapterF.h ../../include/Ice/ReferenceF.h ../../include/Ice/OutgoingAsyncF.h ../../include/Ice/Current.h ../../include/Ice/Identity.h ../../include/Ice/Facet.h ../../include/Ice/Object.h ../../include/Ice/IncomingAsyncF.h ../../include/Ice/Outgoing.h ../../include/IceUtil/Monitor.h ../../include/IceUtil/Cond.h ../../include/IceUtil/Time.h ../../include/Ice/BasicStream.h ../../include/Ice/InstanceF.h ../../include/Ice/ObjectFactoryF.h ../../include/Ice/Incoming.h ../../include/Ice/ServantLocatorF.h ../../include/Ice/ServantManagerF.h ../../include/Ice/Direct.h ../../include/Ice/BuiltinSequences.h ../IceSSL/OpenSSL.h ../IceSSL/SslTransceiver.h ../../include/Ice/StatsF.h ../Ice/Transceiver.h ../Ice/TransceiverF.h ../IceSSL/SslTransceiverF.h ../IceSSL/OpenSSLPluginIF.h ../IceSSL/TraceLevelsF.h ../../include/IceSSL/CertificateVerifierF.h ../../include/IceSSL/CertificateVerifierOpenSSL.h ../../include/IceSSL/Config.h ../../include/IceSSL/CertificateVerifier.h ../IceSSL/OpenSSLPluginI.h ../../include/IceUtil/RecMutex.h ../../include/Ice/PropertiesF.h ../../include/Ice/ProtocolPluginFacadeF.h ../../include/IceSSL/Plugin.h ../../include/Ice/Plugin.h ../IceSSL/CertificateDesc.h ../IceSSL/CertificateAuthority.h ../IceSSL/BaseCerts.h ../IceSSL/TempCerts.h ../IceSSL/ServerContext.h ../IceSSL/Context.h ../../include/Ice/CommunicatorF.h ../IceSSL/GeneralConfig.h ../IceSSL/ContextF.h ../../include/IceSSL/RSAPublicKey.h ../../include/IceSSL/RSAPublicKeyF.h ../../include/IceSSL/RSAKeyPairF.h ../IceSSL/ClientContext.h ../../include/IceSSL/RSAPrivateKeyF.h ../IceSSL/DHParamsF.h ../IceSSL/TraceLevels.h ../../include/IceSSL/Exception.h ../IceSSL/OpenSSLUtils.h +SslTransceiver.o: SslTransceiver.cpp ../../include/Ice/LoggerUtil.h ../../include/Ice/LoggerF.h ../../include/Ice/LocalObjectF.h ../../include/Ice/Handle.h ../../include/IceUtil/Handle.h ../../include/IceUtil/Exception.h ../../include/IceUtil/Config.h ../../include/Ice/Config.h ../../include/Ice/ProxyF.h ../../include/Ice/ProxyHandle.h ../../include/Ice/ObjectF.h ../../include/Ice/Exception.h ../../include/Ice/LocalObject.h ../../include/IceUtil/Shared.h ../../include/Ice/StreamF.h ../../include/Ice/Stats.h ../../include/Ice/Buffer.h ../Ice/Network.h ../../include/Ice/LocalException.h ../../include/Ice/Proxy.h ../../include/IceUtil/Mutex.h ../../include/IceUtil/Lock.h ../../include/IceUtil/ThreadException.h ../../include/Ice/ProxyFactoryF.h ../../include/Ice/ConnectionF.h ../../include/Ice/EndpointF.h ../../include/Ice/ObjectAdapterF.h ../../include/Ice/ReferenceF.h ../../include/Ice/OutgoingAsyncF.h ../../include/Ice/Current.h ../../include/Ice/Identity.h ../../include/Ice/Facet.h ../../include/Ice/Object.h ../../include/Ice/IncomingAsyncF.h ../../include/Ice/Outgoing.h ../../include/IceUtil/Monitor.h ../../include/IceUtil/Cond.h ../../include/IceUtil/Time.h ../../include/Ice/BasicStream.h ../../include/Ice/InstanceF.h ../../include/Ice/ObjectFactoryF.h ../../include/Ice/Incoming.h ../../include/Ice/ServantLocatorF.h ../../include/Ice/ServantManagerF.h ../../include/Ice/Direct.h ../../include/Ice/BuiltinSequences.h ../../include/Ice/Properties.h ../IceSSL/OpenSSL.h ../IceSSL/SslTransceiver.h ../../include/Ice/StatsF.h ../Ice/Transceiver.h ../Ice/TransceiverF.h ../IceSSL/SslTransceiverF.h ../IceSSL/OpenSSLPluginIF.h ../IceSSL/TraceLevelsF.h ../../include/IceSSL/CertificateVerifierF.h ../../include/IceSSL/CertificateVerifierOpenSSL.h ../../include/IceSSL/Config.h ../../include/IceSSL/CertificateVerifier.h ../IceSSL/OpenSSLPluginI.h ../../include/IceUtil/RecMutex.h ../../include/Ice/PropertiesF.h ../../include/Ice/ProtocolPluginFacadeF.h ../../include/IceSSL/Plugin.h ../../include/Ice/Plugin.h ../IceSSL/CertificateDesc.h ../IceSSL/CertificateAuthority.h ../IceSSL/BaseCerts.h ../IceSSL/TempCerts.h ../IceSSL/ServerContext.h ../IceSSL/Context.h ../../include/Ice/CommunicatorF.h ../IceSSL/GeneralConfig.h ../IceSSL/ContextF.h ../../include/IceSSL/RSAPublicKey.h ../../include/IceSSL/RSAPublicKeyF.h ../../include/IceSSL/RSAKeyPairF.h ../IceSSL/ClientContext.h ../../include/IceSSL/RSAPrivateKeyF.h ../IceSSL/DHParamsF.h ../IceSSL/TraceLevels.h ../../include/IceSSL/Exception.h ../IceSSL/OpenSSLUtils.h SslClientTransceiver.o: SslClientTransceiver.cpp ../../include/Ice/LoggerUtil.h ../../include/Ice/LoggerF.h ../../include/Ice/LocalObjectF.h ../../include/Ice/Handle.h ../../include/IceUtil/Handle.h ../../include/IceUtil/Exception.h ../../include/IceUtil/Config.h ../../include/Ice/Config.h ../../include/Ice/ProxyF.h ../../include/Ice/ProxyHandle.h ../../include/Ice/ObjectF.h ../../include/Ice/Exception.h ../../include/Ice/LocalObject.h ../../include/IceUtil/Shared.h ../../include/Ice/StreamF.h ../../include/Ice/Stats.h ../Ice/Network.h ../../include/Ice/LocalException.h ../../include/Ice/Proxy.h ../../include/IceUtil/Mutex.h ../../include/IceUtil/Lock.h ../../include/IceUtil/ThreadException.h ../../include/Ice/ProxyFactoryF.h ../../include/Ice/ConnectionF.h ../../include/Ice/EndpointF.h ../../include/Ice/ObjectAdapterF.h ../../include/Ice/ReferenceF.h ../../include/Ice/OutgoingAsyncF.h ../../include/Ice/Current.h ../../include/Ice/Identity.h ../../include/Ice/Facet.h ../../include/Ice/Object.h ../../include/Ice/IncomingAsyncF.h ../../include/Ice/Outgoing.h ../../include/IceUtil/Monitor.h ../../include/IceUtil/Cond.h ../../include/IceUtil/Time.h ../../include/Ice/BasicStream.h ../../include/Ice/InstanceF.h ../../include/Ice/ObjectFactoryF.h ../../include/Ice/Buffer.h ../../include/Ice/Incoming.h ../../include/Ice/ServantLocatorF.h ../../include/Ice/ServantManagerF.h ../../include/Ice/Direct.h ../../include/Ice/BuiltinSequences.h ../IceSSL/OpenSSL.h ../IceSSL/SslClientTransceiver.h ../IceSSL/SslTransceiver.h ../../include/Ice/StatsF.h ../Ice/Transceiver.h ../Ice/TransceiverF.h ../IceSSL/SslTransceiverF.h ../IceSSL/OpenSSLPluginIF.h ../IceSSL/TraceLevelsF.h ../../include/IceSSL/CertificateVerifierF.h ../../include/IceSSL/CertificateVerifierOpenSSL.h ../../include/IceSSL/Config.h ../../include/IceSSL/CertificateVerifier.h ../IceSSL/OpenSSLPluginI.h ../../include/IceUtil/RecMutex.h ../../include/Ice/PropertiesF.h ../../include/Ice/ProtocolPluginFacadeF.h ../../include/IceSSL/Plugin.h ../../include/Ice/Plugin.h ../IceSSL/CertificateDesc.h ../IceSSL/CertificateAuthority.h ../IceSSL/BaseCerts.h ../IceSSL/TempCerts.h ../IceSSL/ServerContext.h ../IceSSL/Context.h ../../include/Ice/CommunicatorF.h ../IceSSL/GeneralConfig.h ../IceSSL/ContextF.h ../../include/IceSSL/RSAPublicKey.h ../../include/IceSSL/RSAPublicKeyF.h ../../include/IceSSL/RSAKeyPairF.h ../IceSSL/ClientContext.h ../../include/IceSSL/RSAPrivateKeyF.h ../IceSSL/DHParamsF.h ../IceSSL/TraceLevels.h ../IceSSL/OpenSSLUtils.h ../../include/IceSSL/Exception.h ../IceSSL/OpenSSLJanitors.h SslServerTransceiver.o: SslServerTransceiver.cpp ../../include/Ice/LoggerUtil.h ../../include/Ice/LoggerF.h ../../include/Ice/LocalObjectF.h ../../include/Ice/Handle.h ../../include/IceUtil/Handle.h ../../include/IceUtil/Exception.h ../../include/IceUtil/Config.h ../../include/Ice/Config.h ../../include/Ice/ProxyF.h ../../include/Ice/ProxyHandle.h ../../include/Ice/ObjectF.h ../../include/Ice/Exception.h ../../include/Ice/LocalObject.h ../../include/IceUtil/Shared.h ../../include/Ice/StreamF.h ../../include/Ice/Stats.h ../Ice/Network.h ../../include/Ice/LocalException.h ../../include/Ice/Proxy.h ../../include/IceUtil/Mutex.h ../../include/IceUtil/Lock.h ../../include/IceUtil/ThreadException.h ../../include/Ice/ProxyFactoryF.h ../../include/Ice/ConnectionF.h ../../include/Ice/EndpointF.h ../../include/Ice/ObjectAdapterF.h ../../include/Ice/ReferenceF.h ../../include/Ice/OutgoingAsyncF.h ../../include/Ice/Current.h ../../include/Ice/Identity.h ../../include/Ice/Facet.h ../../include/Ice/Object.h ../../include/Ice/IncomingAsyncF.h ../../include/Ice/Outgoing.h ../../include/IceUtil/Monitor.h ../../include/IceUtil/Cond.h ../../include/IceUtil/Time.h ../../include/Ice/BasicStream.h ../../include/Ice/InstanceF.h ../../include/Ice/ObjectFactoryF.h ../../include/Ice/Buffer.h ../../include/Ice/Incoming.h ../../include/Ice/ServantLocatorF.h ../../include/Ice/ServantManagerF.h ../../include/Ice/Direct.h ../../include/Ice/BuiltinSequences.h ../IceSSL/OpenSSL.h ../IceSSL/OpenSSLPluginI.h ../../include/IceUtil/RecMutex.h ../../include/Ice/StatsF.h ../../include/Ice/PropertiesF.h ../../include/Ice/ProtocolPluginFacadeF.h ../../include/IceSSL/Plugin.h ../../include/Ice/Plugin.h ../../include/IceSSL/CertificateVerifierF.h ../IceSSL/OpenSSLPluginIF.h ../IceSSL/TraceLevelsF.h ../IceSSL/SslTransceiverF.h ../IceSSL/CertificateDesc.h ../IceSSL/CertificateAuthority.h ../IceSSL/BaseCerts.h ../IceSSL/TempCerts.h ../IceSSL/ServerContext.h ../IceSSL/Context.h ../../include/Ice/CommunicatorF.h ../../include/IceSSL/CertificateVerifierOpenSSL.h ../../include/IceSSL/Config.h ../../include/IceSSL/CertificateVerifier.h ../IceSSL/GeneralConfig.h ../IceSSL/SslTransceiver.h ../Ice/Transceiver.h ../Ice/TransceiverF.h ../IceSSL/ContextF.h ../../include/IceSSL/RSAPublicKey.h ../../include/IceSSL/RSAPublicKeyF.h ../../include/IceSSL/RSAKeyPairF.h ../IceSSL/ClientContext.h ../../include/IceSSL/RSAPrivateKeyF.h ../IceSSL/DHParamsF.h ../IceSSL/TraceLevels.h ../IceSSL/OpenSSLUtils.h ../../include/IceSSL/Exception.h ../IceSSL/OpenSSLJanitors.h ../IceSSL/SslServerTransceiver.h BaseCerts.o: BaseCerts.cpp ../IceSSL/BaseCerts.h ../IceSSL/CertificateDesc.h ../../include/IceUtil/Config.h diff --git a/cpp/src/IceSSL/SslTransceiver.cpp b/cpp/src/IceSSL/SslTransceiver.cpp index 2fd8b3ed2df..93fdfda5ec0 100644 --- a/cpp/src/IceSSL/SslTransceiver.cpp +++ b/cpp/src/IceSSL/SslTransceiver.cpp @@ -17,6 +17,7 @@ #include <Ice/Buffer.h> #include <Ice/Network.h> #include <Ice/LocalException.h> +#include <Ice/Properties.h> #include <IceSSL/OpenSSL.h> #include <IceSSL/SslTransceiver.h> #include <IceSSL/OpenSSLPluginI.h> @@ -275,6 +276,17 @@ IceSSL::SslTransceiver::toString() const return _desc; } +int +IceSSL::SslTransceiver::maxRecvSize() const +{ + return _messageSizeMax; +} + +int +IceSSL::SslTransceiver::maxSendSize() const +{ + return _messageSizeMax; +} void IceSSL::SslTransceiver::forceHandshake() { @@ -1021,6 +1033,24 @@ IceSSL::SslTransceiver::SslTransceiver(const OpenSSLPluginIPtr& plugin, // fdToString may raise a socket exception. // const_cast<string&>(_desc) = fdToString(_fd); + + // + // Initialize max message size. + // + static const int defaultMessageSizeMax = 1024; + Int num = plugin->getProperties()->getPropertyAsIntWithDefault("Ice.MessageSizeMax", defaultMessageSizeMax); + if(num < 1) + { + _messageSizeMax = defaultMessageSizeMax; // Ignore stupid values. + } + else if(static_cast<size_t>(num) > (size_t)(0x7fffffff / 1024)) + { + _messageSizeMax = static_cast<size_t>(0x7fffffff); + } + else + { + _messageSizeMax = static_cast<size_t>(num) * 1024; // Property is in kilobytes, _messageSizeMax in bytes. + } } IceSSL::SslTransceiver::~SslTransceiver() diff --git a/cpp/src/IceSSL/SslTransceiver.h b/cpp/src/IceSSL/SslTransceiver.h index 582d648587e..61945dff90f 100644 --- a/cpp/src/IceSSL/SslTransceiver.h +++ b/cpp/src/IceSSL/SslTransceiver.h @@ -138,6 +138,8 @@ public: virtual void write(IceInternal::Buffer&, int) = 0; virtual void read(IceInternal::Buffer&, int); virtual std::string toString() const; + virtual int maxRecvSize() const; + virtual int maxSendSize() const; void forceHandshake(); virtual int handshake(int timeout = 0) = 0; @@ -216,6 +218,7 @@ protected: SOCKET _fd; fd_set _rFdSet; fd_set _wFdSet; + int _messageSizeMax; IceSSL::CertificateVerifierPtr _certificateVerifier; }; |