diff options
author | Michi Henning <michi@zeroc.com> | 2003-07-01 08:23:49 +0000 |
---|---|---|
committer | Michi Henning <michi@zeroc.com> | 2003-07-01 08:23:49 +0000 |
commit | ccfbb57f0441e738c7b1c10473a8311778c031ba (patch) | |
tree | eb12d2e70e5adb5e5ec1c4d6e0287018e77e9fdd /cpp/src/Ice/BasicStream.cpp | |
parent | Changed code to permit evictor sizes of zero. This is useful for cleaning (diff) | |
download | ice-ccfbb57f0441e738c7b1c10473a8311778c031ba.tar.bz2 ice-ccfbb57f0441e738c7b1c10473a8311778c031ba.tar.xz ice-ccfbb57f0441e738c7b1c10473a8311778c031ba.zip |
Added Ice.MessageSizeMax property to make max message size configurable.
Diffstat (limited to 'cpp/src/Ice/BasicStream.cpp')
-rw-r--r-- | cpp/src/Ice/BasicStream.cpp | 30 |
1 files changed, 27 insertions, 3 deletions
diff --git a/cpp/src/Ice/BasicStream.cpp b/cpp/src/Ice/BasicStream.cpp index 5f8d8a07676..1cba0a8d013 100644 --- a/cpp/src/Ice/BasicStream.cpp +++ b/cpp/src/Ice/BasicStream.cpp @@ -20,10 +20,12 @@ #include <Ice/ObjectFactory.h> #include <Ice/ObjectFactoryManager.h> #include <Ice/LocalException.h> +#include <Ice/Properties.h> #include <Ice/Protocol.h> #include <Ice/FactoryTable.h> #include <Ice/TraceUtil.h> #include <Ice/TraceLevels.h> +#include <IceUtil/StaticMutex.h> template<typename InputIter, typename OutputIter> void @@ -47,12 +49,34 @@ using namespace std; using namespace Ice; using namespace IceInternal; +static IceUtil::StaticMutex initMutex = ICE_STATIC_MUTEX_INITIALIZER; +static size_t bufSize = 0; + IceInternal::BasicStream::BasicStream(Instance* instance) : _instance(instance), _currentReadEncaps(0), _currentWriteEncaps(0), _traceSlicing(-1) { + IceUtil::StaticMutex::Lock lock(initMutex); + if(bufSize == 0) + { + const size_t defaultSize = 1024; // Default size in kilobytes. + Int num = _instance->properties()->getPropertyAsInt("Ice.MessageSizeMax"); + if(num < 1) + { + bufSize = defaultSize; + } + else if(static_cast<size_t>(num) > (size_t)(0xffffffff / 1024)) + { + bufSize = static_cast<size_t>(0xffffffff / 1024); + } + else + { + bufSize = static_cast<size_t>(num); + } + bufSize *= 1024; // Property value is in kilobytes, bufSize in bytes. + } } Instance* @@ -77,7 +101,7 @@ IceInternal::BasicStream::swap(BasicStream& other) void inline inlineResize(Buffer* buffer, size_t total) { - if(total > 1024 * 1024) // TODO: configurable. + if(total > bufSize) { throw MemoryLimitException(__FILE__, __LINE__); } @@ -98,9 +122,9 @@ IceInternal::BasicStream::resize(int total) } void -IceInternal::BasicStream::reserve(int total) +IceInternal::BasicStream::reserve(size_t total) { - if(total > 1024 * 1024) // TODO: configurable. + if(total > bufSize) { throw MemoryLimitException(__FILE__, __LINE__); } |