diff options
author | Benoit Foucher <benoit@zeroc.com> | 2014-11-05 15:33:01 +0100 |
---|---|---|
committer | Benoit Foucher <benoit@zeroc.com> | 2014-11-05 15:33:01 +0100 |
commit | cb4d5772e9a7a9228577df83027e45ec7de022ea (patch) | |
tree | bd6489fe77ed5fba43adff613293d580fda8e0f3 /cpp | |
parent | Fixed src tree build of IceJS (diff) | |
download | ice-cb4d5772e9a7a9228577df83027e45ec7de022ea.tar.bz2 ice-cb4d5772e9a7a9228577df83027e45ec7de022ea.tar.xz ice-cb4d5772e9a7a9228577df83027e45ec7de022ea.zip |
Fixed ICE-5607: relaxed Ice.MessageSizeMax
Diffstat (limited to 'cpp')
53 files changed, 178 insertions, 221 deletions
diff --git a/cpp/include/Freeze/Map.h b/cpp/include/Freeze/Map.h index 6be1a77002f..8c139489aba 100644 --- a/cpp/include/Freeze/Map.h +++ b/cpp/include/Freeze/Map.h @@ -807,7 +807,7 @@ public: const Ice::CommunicatorPtr& communicator, const Ice::EncodingVersion& encoding) { - IceInternal::BasicStream stream(IceInternal::getInstance(communicator).get(), encoding, true); + IceInternal::BasicStream stream(IceInternal::getInstance(communicator).get(), encoding); stream.write(v); std::vector<Ice::Byte>(stream.b.begin(), stream.b.end()).swap(bytes); } @@ -848,7 +848,7 @@ public: const Ice::CommunicatorPtr& communicator, const Ice::EncodingVersion& encoding) { - IceInternal::BasicStream stream(IceInternal::getInstance(communicator).get(), encoding, true); + IceInternal::BasicStream stream(IceInternal::getInstance(communicator).get(), encoding); stream.startWriteEncaps(); stream.write(v); stream.endWriteEncaps(); @@ -894,7 +894,7 @@ public: const Ice::CommunicatorPtr& communicator, const Ice::EncodingVersion& encoding) { - IceInternal::BasicStream stream(IceInternal::getInstance(communicator).get(), encoding, true); + IceInternal::BasicStream stream(IceInternal::getInstance(communicator).get(), encoding); stream.startWriteEncaps(); stream.write(v); stream.writePendingObjects(); diff --git a/cpp/include/Ice/BasicStream.h b/cpp/include/Ice/BasicStream.h index 7d5fc49b720..9e23e2d2295 100644 --- a/cpp/include/Ice/BasicStream.h +++ b/cpp/include/Ice/BasicStream.h @@ -47,7 +47,7 @@ public: typedef size_t size_type; typedef void (*PatchFunc)(void*, const Ice::ObjectPtr&); - BasicStream(Instance*, const Ice::EncodingVersion&, bool = false); + BasicStream(Instance*, const Ice::EncodingVersion&); BasicStream(Instance*, const Ice::EncodingVersion&, const Ice::Byte*, const Ice::Byte*); ~BasicStream() { @@ -75,14 +75,6 @@ public: void resize(Container::size_type sz) { - // - // Check memory limit if stream is not unlimited. - // - if(!_unlimited && sz > _messageSizeMax) - { - IceInternal::Ex::throwMemoryLimitException(__FILE__, __LINE__, sz, _messageSizeMax); - } - b.resize(sz); i = b.end(); } @@ -1311,9 +1303,6 @@ private: bool _sliceObjects; - const Container::size_type _messageSizeMax; - bool _unlimited; - const IceUtil::StringConverterPtr _stringConverter; const IceUtil::WstringConverterPtr _wstringConverter; diff --git a/cpp/include/Ice/Buffer.h b/cpp/include/Ice/Buffer.h index d7c81a13b83..8c614f1ed14 100644 --- a/cpp/include/Ice/Buffer.h +++ b/cpp/include/Ice/Buffer.h @@ -19,7 +19,7 @@ class ICE_API Buffer : private IceUtil::noncopyable { public: - Buffer(size_t maxCapacity) : b(maxCapacity), i(b.begin()) { } + Buffer() : i(b.begin()) { } Buffer(const Ice::Byte* beg, const Ice::Byte* end) : b(beg, end), i(b.begin()) { } virtual ~Buffer() { } @@ -41,7 +41,7 @@ public: typedef Ice::Byte* pointer; typedef size_t size_type; - Container(size_type maxCapacity); + Container(); Container(const_iterator, const_iterator); ~Container(); @@ -90,7 +90,7 @@ public: } else if(n > _capacity) { - reserve(n); + reserve(n); } _size = n; } @@ -147,7 +147,6 @@ public: pointer _buf; size_type _size; size_type _capacity; - size_type _maxCapacity; int _shrinkCounter; }; diff --git a/cpp/src/Freeze/MapI.cpp b/cpp/src/Freeze/MapI.cpp index 38fe535e7d6..ae2d16bcdde 100644 --- a/cpp/src/Freeze/MapI.cpp +++ b/cpp/src/Freeze/MapI.cpp @@ -339,7 +339,7 @@ Freeze::IteratorHelper::~IteratorHelper() ICE_NOEXCEPT_FALSE // MapCodecBase (from Map.h) // Freeze::MapCodecBase::MapCodecBase(const Ice::CommunicatorPtr& communicator, const Ice::EncodingVersion& encoding) : - _stream(IceInternal::getInstance(communicator).get(), encoding, true), + _stream(IceInternal::getInstance(communicator).get(), encoding), _dbt(0) { } diff --git a/cpp/src/Freeze/ObjectStore.cpp b/cpp/src/Freeze/ObjectStore.cpp index b079086b2bb..f864964f435 100644 --- a/cpp/src/Freeze/ObjectStore.cpp +++ b/cpp/src/Freeze/ObjectStore.cpp @@ -332,7 +332,7 @@ Freeze::ObjectStoreBase::save(Dbt& key, Dbt& value, Byte status, DbTxn* tx) Freeze::ObjectStoreBase::Marshaler::Marshaler(const CommunicatorPtr& communicator, const EncodingVersion& encoding) : - _os(IceInternal::getInstance(communicator).get(), encoding, true) + _os(IceInternal::getInstance(communicator).get(), encoding) { } diff --git a/cpp/src/Ice/BasicStream.cpp b/cpp/src/Ice/BasicStream.cpp index 2321bf1515e..683b230c1cb 100644 --- a/cpp/src/Ice/BasicStream.cpp +++ b/cpp/src/Ice/BasicStream.cpp @@ -88,16 +88,13 @@ const Byte FLAG_IS_LAST_SLICE = (1<<5); } -IceInternal::BasicStream::BasicStream(Instance* instance, const EncodingVersion& encoding, bool unlimited) : - IceInternal::Buffer(instance->messageSizeMax()), +IceInternal::BasicStream::BasicStream(Instance* instance, const EncodingVersion& encoding) : _instance(instance), _closure(0), _encoding(encoding), _currentReadEncaps(0), _currentWriteEncaps(0), _sliceObjects(true), - _messageSizeMax(_instance->messageSizeMax()), // Cached for efficiency. - _unlimited(unlimited), _stringConverter(instance->getStringConverter()), _wstringConverter(instance->getWstringConverter()), _startSeq(-1) @@ -119,8 +116,6 @@ IceInternal::BasicStream::BasicStream(Instance* instance, const EncodingVersion& _currentReadEncaps(0), _currentWriteEncaps(0), _sliceObjects(true), - _messageSizeMax(_instance->messageSizeMax()), // Cached for efficiency. - _unlimited(false), _stringConverter(instance->getStringConverter()), _wstringConverter(instance->getWstringConverter()), _startSeq(-1) @@ -185,7 +180,6 @@ IceInternal::BasicStream::swap(BasicStream& other) resetEncaps(); other.resetEncaps(); - std::swap(_unlimited, other._unlimited); std::swap(_startSeq, other._startSeq); std::swap(_minSeqSize, other._minSeqSize); } diff --git a/cpp/src/Ice/Buffer.cpp b/cpp/src/Ice/Buffer.cpp index 8da1b4ab2f2..33c6858aefb 100644 --- a/cpp/src/Ice/Buffer.cpp +++ b/cpp/src/Ice/Buffer.cpp @@ -21,11 +21,10 @@ IceInternal::Buffer::swapBuffer(Buffer& other) std::swap(i, other.i); } -IceInternal::Buffer::Container::Container(size_type maxCapacity) : +IceInternal::Buffer::Container::Container() : _buf(0), _size(0), _capacity(0), - _maxCapacity(maxCapacity), _shrinkCounter(0) { } @@ -34,7 +33,6 @@ IceInternal::Buffer::Container::Container(const_iterator beg, const_iterator end _buf(const_cast<iterator>(beg)), _size(end - beg), _capacity(0), - _maxCapacity(0), _shrinkCounter(0) { } @@ -78,7 +76,7 @@ IceInternal::Buffer::Container::reserve(size_type n) size_type c = _capacity; if(n > _capacity) { - _capacity = std::max<size_type>(n, std::min(2 * _capacity, _maxCapacity)); + _capacity = std::max<size_type>(n, 2 * _capacity); _capacity = std::max<size_type>(static_cast<size_type>(240), _capacity); } else if(n < _capacity) diff --git a/cpp/src/Ice/CollocatedRequestHandler.cpp b/cpp/src/Ice/CollocatedRequestHandler.cpp index 543a1b50153..99555c76998 100644 --- a/cpp/src/Ice/CollocatedRequestHandler.cpp +++ b/cpp/src/Ice/CollocatedRequestHandler.cpp @@ -139,12 +139,11 @@ CollocatedRequestHandler::CollocatedRequestHandler(const ReferencePtr& ref, cons _dispatcher(_reference->getInstance()->initializationData().dispatcher), _logger(_reference->getInstance()->initializationData().logger), // Cached for better performance. _traceLevels(_reference->getInstance()->traceLevels()), // Cached for better performance. - _batchAutoFlush( - ref->getInstance()->initializationData().properties->getPropertyAsIntWithDefault("Ice.BatchAutoFlush", 1) > 0), + _batchAutoFlushSize(ref->getInstance()->batchAutoFlushSize()), _requestId(0), _batchStreamInUse(false), _batchRequestNum(0), - _batchStream(ref->getInstance().get(), currentProtocolEncoding, _batchAutoFlush) + _batchStream(ref->getInstance().get(), currentProtocolEncoding) { } @@ -198,7 +197,7 @@ CollocatedRequestHandler::finishBatchRequest(BasicStream* os) Lock sync(*this); _batchStream.swap(*os); - if(_batchAutoFlush && (_batchStream.b.size() > _reference->getInstance()->messageSizeMax())) + if(_batchAutoFlushSize > 0 && (_batchStream.b.size() > _batchAutoFlushSize)) { // // Temporarily save the last request. @@ -211,21 +210,12 @@ CollocatedRequestHandler::finishBatchRequest(BasicStream* os) // // Reset the batch. // - BasicStream dummy(_reference->getInstance().get(), currentProtocolEncoding, _batchAutoFlush); + BasicStream dummy(_reference->getInstance().get(), currentProtocolEncoding); _batchStream.swap(dummy); _batchRequestNum = 0; _batchMarker = 0; // - // Check again if the last request doesn't exceed what we can send with the auto flush - // - if(sizeof(requestBatchHdr) + lastRequest.size() > _reference->getInstance()->messageSizeMax()) - { - Ex::throwMemoryLimitException(__FILE__, __LINE__, sizeof(requestBatchHdr) + lastRequest.size(), - _reference->getInstance()->messageSizeMax()); - } - - // // Start a new batch with the last message that caused us to go over the limit. // _batchStream.writeBlob(requestBatchHdr, sizeof(requestBatchHdr)); @@ -252,7 +242,7 @@ CollocatedRequestHandler::abortBatchRequest() { Lock sync(*this); - BasicStream dummy(_reference->getInstance().get(), currentProtocolEncoding, _batchAutoFlush); + BasicStream dummy(_reference->getInstance().get(), currentProtocolEncoding); _batchStream.swap(dummy); _batchRequestNum = 0; _batchMarker = 0; @@ -436,7 +426,7 @@ CollocatedRequestHandler::invokeBatchRequests(OutgoingBase* out) // // Reset the batch stream. // - BasicStream dummy(_reference->getInstance().get(), currentProtocolEncoding, _batchAutoFlush); + BasicStream dummy(_reference->getInstance().get(), currentProtocolEncoding); _batchStream.swap(dummy); _batchRequestNum = 0; _batchMarker = 0; @@ -494,7 +484,7 @@ CollocatedRequestHandler::invokeAsyncBatchRequests(OutgoingAsyncBase* outAsync) // // Reset the batch stream. // - BasicStream dummy(_reference->getInstance().get(), currentProtocolEncoding, _batchAutoFlush); + BasicStream dummy(_reference->getInstance().get(), currentProtocolEncoding); _batchStream.swap(dummy); _batchRequestNum = 0; _batchMarker = 0; diff --git a/cpp/src/Ice/CollocatedRequestHandler.h b/cpp/src/Ice/CollocatedRequestHandler.h index 8561ba6eb2e..d2d8c5bab01 100644 --- a/cpp/src/Ice/CollocatedRequestHandler.h +++ b/cpp/src/Ice/CollocatedRequestHandler.h @@ -84,7 +84,7 @@ private: const bool _dispatcher; const Ice::LoggerPtr _logger; const TraceLevelsPtr _traceLevels; - const bool _batchAutoFlush; + const size_t _batchAutoFlushSize; int _requestId; diff --git a/cpp/src/Ice/ConnectRequestHandler.cpp b/cpp/src/Ice/ConnectRequestHandler.cpp index 20fd886ee0d..73da7bbae43 100644 --- a/cpp/src/Ice/ConnectRequestHandler.cpp +++ b/cpp/src/Ice/ConnectRequestHandler.cpp @@ -27,13 +27,10 @@ ConnectRequestHandler::ConnectRequestHandler(const ReferencePtr& ref, const Ice: RequestHandler(ref), _connect(true), _proxy(proxy), - _batchAutoFlush( - ref->getInstance()->initializationData().properties->getPropertyAsIntWithDefault("Ice.BatchAutoFlush", 1) > 0), _initialized(false), _flushing(false), _batchRequestInProgress(false), - _batchRequestsSize(sizeof(requestBatchHdr)), - _batchStream(ref->getInstance().get(), Ice::currentProtocolEncoding, _batchAutoFlush) + _batchStream(ref->getInstance().get(), Ice::currentProtocolEncoding) { } @@ -125,17 +122,8 @@ ConnectRequestHandler::finishBatchRequest(BasicStream* os) _batchStream.swap(*os); - if(!_batchAutoFlush && - _batchStream.b.size() + _batchRequestsSize > _reference->getInstance()->messageSizeMax()) - { - Ex::throwMemoryLimitException(__FILE__, __LINE__, _batchStream.b.size() + _batchRequestsSize, - _reference->getInstance()->messageSizeMax()); - } - - _batchRequestsSize += _batchStream.b.size(); - Request req; - req.os = new BasicStream(_reference->getInstance().get(), Ice::currentProtocolEncoding, _batchAutoFlush); + req.os = new BasicStream(_reference->getInstance().get(), Ice::currentProtocolEncoding); req.os->swap(_batchStream); _requests.push_back(req); return; @@ -155,9 +143,8 @@ ConnectRequestHandler::abortBatchRequest() _batchRequestInProgress = false; notifyAll(); - BasicStream dummy(_reference->getInstance().get(), Ice::currentProtocolEncoding, _batchAutoFlush); + BasicStream dummy(_reference->getInstance().get(), Ice::currentProtocolEncoding); _batchStream.swap(dummy); - _batchRequestsSize = sizeof(requestBatchHdr); return; } } diff --git a/cpp/src/Ice/ConnectRequestHandler.h b/cpp/src/Ice/ConnectRequestHandler.h index 1ca160e31e1..76f93803325 100644 --- a/cpp/src/Ice/ConnectRequestHandler.h +++ b/cpp/src/Ice/ConnectRequestHandler.h @@ -80,8 +80,6 @@ private: Ice::ObjectPrx _proxy; std::set<Ice::ObjectPrx> _proxies; - const bool _batchAutoFlush; - Ice::ConnectionIPtr _connection; bool _compress; IceUtil::UniquePtr<Ice::LocalException> _exception; @@ -90,7 +88,6 @@ private: std::deque<Request> _requests; bool _batchRequestInProgress; - size_t _batchRequestsSize; BasicStream _batchStream; RequestHandlerPtr _connectionRequestHandler; diff --git a/cpp/src/Ice/ConnectionI.cpp b/cpp/src/Ice/ConnectionI.cpp index b9eba1e2461..36bb80fc952 100644 --- a/cpp/src/Ice/ConnectionI.cpp +++ b/cpp/src/Ice/ConnectionI.cpp @@ -630,7 +630,7 @@ Ice::ConnectionI::sendRequest(Outgoing* out, bool compress, bool response) // Ensure the message isn't bigger than what we can send with the // transport. // - _transceiver->checkSendSize(*os, _instance->messageSizeMax()); + _transceiver->checkSendSize(*os); Int requestId = 0; if(response) @@ -709,7 +709,7 @@ Ice::ConnectionI::sendAsyncRequest(const OutgoingAsyncPtr& out, bool compress, b // Ensure the message isn't bigger than what we can send with the // transport. // - _transceiver->checkSendSize(*os, _instance->messageSizeMax()); + _transceiver->checkSendSize(*os); // // Notify the request that it's cancelable with this connection. @@ -841,8 +841,13 @@ Ice::ConnectionI::finishBatchRequest(BasicStream* os, bool compress) } bool flush = false; - if(_batchAutoFlush) + if(_batchAutoFlushSize > 0) { + if(_batchStream.b.size() > _batchAutoFlushSize) + { + flush = true; + } + // // Throw memory limit exception if the first message added causes us to // go over limit. Otherwise put aside the marshalled message that caused @@ -850,7 +855,7 @@ Ice::ConnectionI::finishBatchRequest(BasicStream* os, bool compress) // try { - _transceiver->checkSendSize(_batchStream, _instance->messageSizeMax()); + _transceiver->checkSendSize(_batchStream); } catch(const Ice::Exception&) { @@ -901,22 +906,13 @@ Ice::ConnectionI::finishBatchRequest(BasicStream* os, bool compress) // // Reset the batch. // - BasicStream dummy(_instance.get(), currentProtocolEncoding, _batchAutoFlush); + BasicStream dummy(_instance.get(), currentProtocolEncoding); _batchStream.swap(dummy); _batchRequestNum = 0; _batchRequestCompress = false; _batchMarker = 0; // - // Check again if the last request doesn't exceed what we can send with the auto flush - // - if(sizeof(requestBatchHdr) + lastRequest.size() > _instance->messageSizeMax()) - { - Ex::throwMemoryLimitException(__FILE__, __LINE__, sizeof(requestBatchHdr) + lastRequest.size(), - _instance->messageSizeMax()); - } - - // // Start a new batch with the last message that caused us to go over the limit. // _batchStream.writeBlob(requestBatchHdr, sizeof(requestBatchHdr)); @@ -956,7 +952,7 @@ Ice::ConnectionI::abortBatchRequest() { IceUtil::Monitor<IceUtil::Mutex>::Lock sync(*this); - BasicStream dummy(_instance.get(), currentProtocolEncoding, _batchAutoFlush); + BasicStream dummy(_instance.get(), currentProtocolEncoding); _batchStream.swap(dummy); _batchRequestNum = 0; _batchRequestCompress = false; @@ -1105,7 +1101,7 @@ Ice::ConnectionI::flushBatchRequests(OutgoingBase* out) // // Reset the batch stream. // - BasicStream dummy(_instance.get(), Ice::currentProtocolEncoding, _batchAutoFlush); + BasicStream dummy(_instance.get(), Ice::currentProtocolEncoding); _batchStream.swap(dummy); _batchRequestNum = 0; _batchRequestCompress = false; @@ -1175,7 +1171,7 @@ Ice::ConnectionI::flushAsyncBatchRequests(const OutgoingAsyncBasePtr& outAsync) // // Reset the batch stream. // - BasicStream dummy(_instance.get(), Ice::currentProtocolEncoding, _batchAutoFlush); + BasicStream dummy(_instance.get(), Ice::currentProtocolEncoding); _batchStream.swap(dummy); _batchRequestNum = 0; _batchRequestCompress = false; @@ -1851,7 +1847,7 @@ Ice::ConnectionI::message(ThreadPoolCurrent& current) } if(size > static_cast<Int>(_instance->messageSizeMax())) { - throw MemoryLimitException(__FILE__, __LINE__); + Ex::throwMemoryLimitException(__FILE__, __LINE__, size, _instance->messageSizeMax()); } if(size > static_cast<Int>(_readStream.b.size())) { @@ -2408,9 +2404,8 @@ Ice::ConnectionI::ConnectionI(const CommunicatorPtr& communicator, _nextRequestId(1), _requestsHint(_requests.end()), _asyncRequestsHint(_asyncRequests.end()), - _batchAutoFlush( - _instance->initializationData().properties->getPropertyAsIntWithDefault("Ice.BatchAutoFlush", 1) > 0), - _batchStream(_instance.get(), Ice::currentProtocolEncoding, _batchAutoFlush), + _batchAutoFlushSize(_instance->batchAutoFlushSize()), + _batchStream(_instance.get(), Ice::currentProtocolEncoding), _batchStreamInUse(false), _batchRequestNum(0), _batchRequestCompress(false), @@ -2424,9 +2419,10 @@ Ice::ConnectionI::ConnectionI(const CommunicatorPtr& communicator, _initialized(false), _validated(false) { + const Ice::PropertiesPtr& properties = _instance->initializationData().properties; + int& compressionLevel = const_cast<int&>(_compressionLevel); - compressionLevel = _instance->initializationData().properties->getPropertyAsIntWithDefault( - "Ice.Compression.Level", 1); + compressionLevel = properties->getPropertyAsIntWithDefault("Ice.Compression.Level", 1); if(compressionLevel < 1) { compressionLevel = 1; @@ -3384,7 +3380,12 @@ Ice::ConnectionI::doUncompress(BasicStream& compressed, BasicStream& uncompresse throw IllegalMessageSizeException(__FILE__, __LINE__); } + if(uncompressedSize > static_cast<Int>(_instance->messageSizeMax())) + { + Ex::throwMemoryLimitException(__FILE__, __LINE__, uncompressedSize, _instance->messageSizeMax()); + } uncompressed.resize(uncompressedSize); + unsigned int uncompressedLen = uncompressedSize - headerSize; unsigned int compressedLen = static_cast<unsigned int>(compressed.b.size() - headerSize - sizeof(Int)); int bzError = BZ2_bzBuffToBuffDecompress(reinterpret_cast<char*>(&uncompressed.b[0]) + headerSize, diff --git a/cpp/src/Ice/ConnectionI.h b/cpp/src/Ice/ConnectionI.h index 0542741e49b..6432863185c 100644 --- a/cpp/src/Ice/ConnectionI.h +++ b/cpp/src/Ice/ConnectionI.h @@ -331,7 +331,7 @@ private: IceUtil::UniquePtr<LocalException> _exception; - const bool _batchAutoFlush; + const size_t _batchAutoFlushSize; IceInternal::BasicStream _batchStream; bool _batchStreamInUse; int _batchRequestNum; diff --git a/cpp/src/Ice/Instance.cpp b/cpp/src/Ice/Instance.cpp index bf3dc73c8ed..11d27fc1111 100644 --- a/cpp/src/Ice/Instance.cpp +++ b/cpp/src/Ice/Instance.cpp @@ -1059,6 +1059,7 @@ IceInternal::Instance::Instance(const CommunicatorPtr& communicator, const Initi _state(StateActive), _initData(initData), _messageSizeMax(0), + _batchAutoFlushSize(0), _collectObjects(false), _implicitContext(0), _stringConverter(IceUtil::getProcessStringConverter()), @@ -1274,6 +1275,32 @@ IceInternal::Instance::Instance(const CommunicatorPtr& communicator, const Initi } } + if(_initData.properties->getProperty("Ice.BatchAutoFlushSize").empty() && + !_initData.properties->getProperty("Ice.BatchAutoFlush").empty()) + { + if(_initData.properties->getPropertyAsInt("Ice.BatchAutoFlush") > 0) + { + const_cast<size_t&>(_batchAutoFlushSize) = _messageSizeMax; + } + } + else + { + Int num = _initData.properties->getPropertyAsIntWithDefault("Ice.BatchAutoFlushSize", 1024); // 1MB default + if(num < 1) + { + const_cast<size_t&>(_batchAutoFlushSize) = num; + } + else if(static_cast<size_t>(num) > static_cast<size_t>(0x7fffffff / 1024)) + { + const_cast<size_t&>(_batchAutoFlushSize) = static_cast<size_t>(0x7fffffff); + } + else + { + // Property is in kilobytes, convert in bytes. + const_cast<size_t&>(_batchAutoFlushSize) = static_cast<size_t>(num) * 1024; + } + } + const_cast<bool&>(_collectObjects) = _initData.properties->getPropertyAsInt("Ice.CollectObjects") > 0; // diff --git a/cpp/src/Ice/Instance.h b/cpp/src/Ice/Instance.h index c008d278f2e..6733f0fc845 100644 --- a/cpp/src/Ice/Instance.h +++ b/cpp/src/Ice/Instance.h @@ -91,6 +91,7 @@ public: DynamicLibraryListPtr dynamicLibraryList() const; Ice::PluginManagerPtr pluginManager() const; size_t messageSizeMax() const { return _messageSizeMax; } + size_t batchAutoFlushSize() const { return _batchAutoFlushSize; } bool collectObjects() const { return _collectObjects; } const ACMConfig& clientACM() const; const ACMConfig& serverACM() const; @@ -144,6 +145,7 @@ private: const TraceLevelsPtr _traceLevels; // Immutable, not reset by destroy(). const DefaultsAndOverridesPtr _defaultsAndOverrides; // Immutable, not reset by destroy(). const size_t _messageSizeMax; // Immutable, not reset by destroy(). + const size_t _batchAutoFlushSize; // Immutable, not reset by destroy(). const bool _collectObjects; // Immutable, not reset by destroy(). ACMConfig _clientACM; ACMConfig _serverACM; diff --git a/cpp/src/Ice/PropertyNames.cpp b/cpp/src/Ice/PropertyNames.cpp index e44afdcb0d3..c2b39f9cd04 100644 --- a/cpp/src/Ice/PropertyNames.cpp +++ b/cpp/src/Ice/PropertyNames.cpp @@ -6,7 +6,7 @@ // ICE_LICENSE file included in this distribution. // // ********************************************************************** -// Generated by makeprops.py from file ../config/PropertyNames.xml, Tue Oct 28 14:34:04 2014 +// Generated by makeprops.py from file ./config/PropertyNames.xml, Wed Nov 5 13:47:49 2014 // IMPORTANT: Do not edit this file -- any edits made here will be lost! @@ -73,7 +73,8 @@ const IceInternal::Property IcePropsData[] = IceInternal::Property("Ice.Admin.Logger.Properties", false, 0), IceInternal::Property("Ice.Admin.ServerId", false, 0), IceInternal::Property("Ice.BackgroundLocatorCacheUpdates", false, 0), - IceInternal::Property("Ice.BatchAutoFlush", false, 0), + IceInternal::Property("Ice.BatchAutoFlush", true, 0), + IceInternal::Property("Ice.BatchAutoFlushSize", false, 0), IceInternal::Property("Ice.ChangeUser", false, 0), IceInternal::Property("Ice.ClientAccessPolicyProtocol", false, 0), IceInternal::Property("Ice.Compression.Level", false, 0), diff --git a/cpp/src/Ice/PropertyNames.h b/cpp/src/Ice/PropertyNames.h index bded5da1a11..3068deee4b7 100644 --- a/cpp/src/Ice/PropertyNames.h +++ b/cpp/src/Ice/PropertyNames.h @@ -6,7 +6,7 @@ // ICE_LICENSE file included in this distribution. // // ********************************************************************** -// Generated by makeprops.py from file ../config/PropertyNames.xml, Tue Oct 28 14:34:04 2014 +// Generated by makeprops.py from file ./config/PropertyNames.xml, Wed Nov 5 13:47:49 2014 // IMPORTANT: Do not edit this file -- any edits made here will be lost! diff --git a/cpp/src/Ice/StreamI.cpp b/cpp/src/Ice/StreamI.cpp index f889f71b8be..e3de0df3be0 100644 --- a/cpp/src/Ice/StreamI.cpp +++ b/cpp/src/Ice/StreamI.cpp @@ -402,7 +402,7 @@ InputStreamI::initialize(Instance* instance, const pair<const Byte*, const Byte* { if(copyData) { - _is = new BasicStream(instance, v, true); + _is = new BasicStream(instance, v); _is->writeBlob(buf.first, buf.second - buf.first); _is->i = _is->b.begin(); } @@ -420,7 +420,7 @@ OutputStreamI::OutputStreamI(const CommunicatorPtr& communicator) : _communicator(communicator), _own(true) { Instance* instance = getInstance(communicator).get(); - _os = new BasicStream(instance, instance->defaultsAndOverrides()->defaultEncoding, true); + _os = new BasicStream(instance, instance->defaultsAndOverrides()->defaultEncoding); _os->closure(this); } @@ -428,7 +428,7 @@ OutputStreamI::OutputStreamI(const CommunicatorPtr& communicator, const Encoding _communicator(communicator), _own(true) { Instance* instance = getInstance(communicator).get(); - _os = new BasicStream(instance, v, true); + _os = new BasicStream(instance, v); _os->closure(this); } diff --git a/cpp/src/Ice/TcpTransceiver.cpp b/cpp/src/Ice/TcpTransceiver.cpp index 9f7a04c9496..61ef4589137 100644 --- a/cpp/src/Ice/TcpTransceiver.cpp +++ b/cpp/src/Ice/TcpTransceiver.cpp @@ -111,12 +111,8 @@ IceInternal::TcpTransceiver::getInfo() const } void -IceInternal::TcpTransceiver::checkSendSize(const Buffer& buf, size_t messageSizeMax) +IceInternal::TcpTransceiver::checkSendSize(const Buffer&) { - if(buf.b.size() > messageSizeMax) - { - Ex::throwMemoryLimitException(__FILE__, __LINE__, buf.b.size(), messageSizeMax); - } } IceInternal::TcpTransceiver::TcpTransceiver(const ProtocolInstancePtr& instance, const StreamSocketPtr& stream) : diff --git a/cpp/src/Ice/TcpTransceiver.h b/cpp/src/Ice/TcpTransceiver.h index a3a170b85ee..d60a4bc6d22 100644 --- a/cpp/src/Ice/TcpTransceiver.h +++ b/cpp/src/Ice/TcpTransceiver.h @@ -42,7 +42,7 @@ public: virtual std::string toString() const; virtual std::string toDetailedString() const; virtual Ice::ConnectionInfoPtr getInfo() const; - virtual void checkSendSize(const Buffer&, size_t); + virtual void checkSendSize(const Buffer&); private: diff --git a/cpp/src/Ice/Transceiver.cpp b/cpp/src/Ice/Transceiver.cpp index 7e8802467b4..ee9d5f01162 100644 --- a/cpp/src/Ice/Transceiver.cpp +++ b/cpp/src/Ice/Transceiver.cpp @@ -21,3 +21,4 @@ IceInternal::Transceiver::bind() assert(false); return 0; } + diff --git a/cpp/src/Ice/Transceiver.h b/cpp/src/Ice/Transceiver.h index d650ac94472..5eeaf3080c9 100644 --- a/cpp/src/Ice/Transceiver.h +++ b/cpp/src/Ice/Transceiver.h @@ -44,7 +44,7 @@ public: virtual std::string toString() const = 0; virtual std::string toDetailedString() const = 0; virtual Ice::ConnectionInfoPtr getInfo() const = 0; - virtual void checkSendSize(const Buffer&, size_t) = 0; + virtual void checkSendSize(const Buffer&) = 0; }; } diff --git a/cpp/src/Ice/UdpTransceiver.cpp b/cpp/src/Ice/UdpTransceiver.cpp index 72bfc604a15..cd5ad2f4f40 100644 --- a/cpp/src/Ice/UdpTransceiver.cpp +++ b/cpp/src/Ice/UdpTransceiver.cpp @@ -865,13 +865,8 @@ IceInternal::UdpTransceiver::getInfo() const } void -IceInternal::UdpTransceiver::checkSendSize(const Buffer& buf, size_t messageSizeMax) +IceInternal::UdpTransceiver::checkSendSize(const Buffer& buf) { - if(buf.b.size() > messageSizeMax) - { - Ex::throwMemoryLimitException(__FILE__, __LINE__, buf.b.size(), messageSizeMax); - } - // // The maximum packetSize is either the maximum allowable UDP packet size, or // the UDP send buffer size (which ever is smaller). diff --git a/cpp/src/Ice/UdpTransceiver.h b/cpp/src/Ice/UdpTransceiver.h index c43e7a636a4..40900ba034a 100644 --- a/cpp/src/Ice/UdpTransceiver.h +++ b/cpp/src/Ice/UdpTransceiver.h @@ -60,7 +60,7 @@ public: virtual std::string toString() const; virtual std::string toDetailedString() const; virtual Ice::ConnectionInfoPtr getInfo() const; - virtual void checkSendSize(const Buffer&, size_t); + virtual void checkSendSize(const Buffer&); int effectivePort() const; diff --git a/cpp/src/Ice/WSTransceiver.cpp b/cpp/src/Ice/WSTransceiver.cpp index 441ef688abb..2e97aa219b4 100644 --- a/cpp/src/Ice/WSTransceiver.cpp +++ b/cpp/src/Ice/WSTransceiver.cpp @@ -800,9 +800,9 @@ IceInternal::WSTransceiver::getInfo() const } void -IceInternal::WSTransceiver::checkSendSize(const Buffer& buf, size_t messageSizeMax) +IceInternal::WSTransceiver::checkSendSize(const Buffer& buf) { - _delegate->checkSendSize(buf, messageSizeMax); + _delegate->checkSendSize(buf); } IceInternal::WSTransceiver::WSTransceiver(const ProtocolInstancePtr& instance, const TransceiverPtr& del, @@ -816,14 +816,12 @@ IceInternal::WSTransceiver::WSTransceiver(const ProtocolInstancePtr& instance, c _state(StateInitializeDelegate), _parser(new HttpParser), _readState(ReadStateOpcode), - _readBuffer(0), _readBufferSize(1024), _readLastFrame(false), _readOpCode(0), _readHeaderLength(0), _readPayloadLength(0), _writeState(WriteStateHeader), - _writeBuffer(0), _writeBufferSize(1024), _readPending(false), _writePending(false), @@ -852,14 +850,12 @@ IceInternal::WSTransceiver::WSTransceiver(const ProtocolInstancePtr& instance, c _state(StateInitializeDelegate), _parser(new HttpParser), _readState(ReadStateOpcode), - _readBuffer(0), _readBufferSize(1024), _readLastFrame(false), _readOpCode(0), _readHeaderLength(0), _readPayloadLength(0), _writeState(WriteStateHeader), - _writeBuffer(0), _writeBufferSize(1024), _readPending(false), _writePending(false), diff --git a/cpp/src/Ice/WSTransceiver.h b/cpp/src/Ice/WSTransceiver.h index 655dbdb7023..c67ac7721d6 100644 --- a/cpp/src/Ice/WSTransceiver.h +++ b/cpp/src/Ice/WSTransceiver.h @@ -50,7 +50,7 @@ public: virtual std::string toString() const; virtual std::string toDetailedString() const; virtual Ice::ConnectionInfoPtr getInfo() const; - virtual void checkSendSize(const Buffer&, size_t); + virtual void checkSendSize(const Buffer&); private: diff --git a/cpp/src/Ice/winrt/StreamTransceiver.cpp b/cpp/src/Ice/winrt/StreamTransceiver.cpp index 50edac7ed02..013245b0094 100644 --- a/cpp/src/Ice/winrt/StreamTransceiver.cpp +++ b/cpp/src/Ice/winrt/StreamTransceiver.cpp @@ -307,12 +307,8 @@ IceInternal::StreamTransceiver::getInfo() const } void -IceInternal::StreamTransceiver::checkSendSize(const Buffer& buf, size_t messageSizeMax) +IceInternal::StreamTransceiver::checkSendSize(const Buffer&) { - if(buf.b.size() > messageSizeMax) - { - Ex::throwMemoryLimitException(__FILE__, __LINE__, buf.b.size(), messageSizeMax); - } } IceInternal::StreamTransceiver::StreamTransceiver(const ProtocolInstancePtr& instance, SOCKET fd, bool connected) : diff --git a/cpp/src/Ice/winrt/StreamTransceiver.h b/cpp/src/Ice/winrt/StreamTransceiver.h index e7c63589e5f..447d98ecd63 100644 --- a/cpp/src/Ice/winrt/StreamTransceiver.h +++ b/cpp/src/Ice/winrt/StreamTransceiver.h @@ -49,7 +49,7 @@ public: virtual std::string toString() const; virtual std::string toDetailedString() const; virtual Ice::ConnectionInfoPtr getInfo() const; - virtual void checkSendSize(const Buffer&, size_t); + virtual void checkSendSize(const Buffer&); private: diff --git a/cpp/src/IceSSL/OpenSSLTransceiverI.cpp b/cpp/src/IceSSL/OpenSSLTransceiverI.cpp index 51b3dd733f8..c24ef888396 100644 --- a/cpp/src/IceSSL/OpenSSLTransceiverI.cpp +++ b/cpp/src/IceSSL/OpenSSLTransceiverI.cpp @@ -533,12 +533,8 @@ IceSSL::TransceiverI::getInfo() const } void -IceSSL::TransceiverI::checkSendSize(const IceInternal::Buffer& buf, size_t messageSizeMax) +IceSSL::TransceiverI::checkSendSize(const IceInternal::Buffer&) { - if(buf.b.size() > messageSizeMax) - { - IceInternal::Ex::throwMemoryLimitException(__FILE__, __LINE__, buf.b.size(), messageSizeMax); - } } IceSSL::TransceiverI::TransceiverI(const InstancePtr& instance, const IceInternal::StreamSocketPtr& stream, diff --git a/cpp/src/IceSSL/OpenSSLTransceiverI.h b/cpp/src/IceSSL/OpenSSLTransceiverI.h index b9e5fb6761d..0bdad67ece1 100644 --- a/cpp/src/IceSSL/OpenSSLTransceiverI.h +++ b/cpp/src/IceSSL/OpenSSLTransceiverI.h @@ -45,7 +45,7 @@ public: virtual std::string toString() const; virtual std::string toDetailedString() const; virtual Ice::ConnectionInfoPtr getInfo() const; - virtual void checkSendSize(const IceInternal::Buffer&, size_t); + virtual void checkSendSize(const IceInternal::Buffer&); private: diff --git a/cpp/src/IceSSL/SChannelTransceiverI.cpp b/cpp/src/IceSSL/SChannelTransceiverI.cpp index 7939d7a9bb6..9886633752c 100644 --- a/cpp/src/IceSSL/SChannelTransceiverI.cpp +++ b/cpp/src/IceSSL/SChannelTransceiverI.cpp @@ -947,12 +947,8 @@ IceSSL::TransceiverI::getInfo() const } void -IceSSL::TransceiverI::checkSendSize(const IceInternal::Buffer& buf, size_t messageSizeMax) +IceSSL::TransceiverI::checkSendSize(const IceInternal::Buffer&) { - if(buf.b.size() > messageSizeMax) - { - IceInternal::Ex::throwMemoryLimitException(__FILE__, __LINE__, buf.b.size(), messageSizeMax); - } } IceSSL::TransceiverI::TransceiverI(const InstancePtr& instance, diff --git a/cpp/src/IceSSL/SChannelTransceiverI.h b/cpp/src/IceSSL/SChannelTransceiverI.h index be9b1f89af0..326f08e8d7a 100644 --- a/cpp/src/IceSSL/SChannelTransceiverI.h +++ b/cpp/src/IceSSL/SChannelTransceiverI.h @@ -63,7 +63,7 @@ public: virtual std::string toString() const; virtual std::string toDetailedString() const; virtual Ice::ConnectionInfoPtr getInfo() const; - virtual void checkSendSize(const IceInternal::Buffer&, size_t); + virtual void checkSendSize(const IceInternal::Buffer&); private: diff --git a/cpp/src/IceSSL/SecureTransportTransceiverI.cpp b/cpp/src/IceSSL/SecureTransportTransceiverI.cpp index a8f491db570..eeb2cea5e9e 100644 --- a/cpp/src/IceSSL/SecureTransportTransceiverI.cpp +++ b/cpp/src/IceSSL/SecureTransportTransceiverI.cpp @@ -485,12 +485,8 @@ IceSSL::TransceiverI::getInfo() const } void -IceSSL::TransceiverI::checkSendSize(const IceInternal::Buffer& buf, size_t messageSizeMax) +IceSSL::TransceiverI::checkSendSize(const IceInternal::Buffer&) { - if(buf.b.size() > messageSizeMax) - { - IceInternal::Ex::throwMemoryLimitException(__FILE__, __LINE__, buf.b.size(), messageSizeMax); - } } IceSSL::TransceiverI::TransceiverI(const InstancePtr& instance, diff --git a/cpp/src/IceSSL/SecureTransportTransceiverI.h b/cpp/src/IceSSL/SecureTransportTransceiverI.h index 5da9e628784..c28c1b59a1f 100644 --- a/cpp/src/IceSSL/SecureTransportTransceiverI.h +++ b/cpp/src/IceSSL/SecureTransportTransceiverI.h @@ -46,7 +46,7 @@ public: virtual std::string toString() const; virtual std::string toDetailedString() const; virtual Ice::ConnectionInfoPtr getInfo() const; - virtual void checkSendSize(const IceInternal::Buffer&, size_t); + virtual void checkSendSize(const IceInternal::Buffer&); OSStatus writeRaw(const char*, size_t*) const; OSStatus readRaw(char*, size_t*) const; diff --git a/cpp/src/slice2freeze/Main.cpp b/cpp/src/slice2freeze/Main.cpp index ada958b3c23..4c4579affac 100644 --- a/cpp/src/slice2freeze/Main.cpp +++ b/cpp/src/slice2freeze/Main.cpp @@ -637,7 +637,7 @@ writeDictC(const string& name, const string& absolute, const Dict& dict, const v assert(!indexTypes[i].type->usesClasses()); C << nl << "IceInternal::InstancePtr __instance = IceInternal::getInstance(__communicator);"; - C << nl << "IceInternal::BasicStream __stream(__instance.get(), __encoding, true);"; + C << nl << "IceInternal::BasicStream __stream(__instance.get(), __encoding);"; string valueS; if(dict.indices[i].caseSensitive) @@ -1166,7 +1166,7 @@ writeIndexC(const TypePtr& type, const TypePtr& memberType, const string& member C << nl << fullName << "::" << "marshalKey(" << inputType << " __index, Freeze::Key& __bytes) const"; C << sb; C << nl << "IceInternal::InstancePtr __instance = IceInternal::getInstance(_communicator);"; - C << nl << "IceInternal::BasicStream __stream(__instance.get(), _encoding, true);"; + C << nl << "IceInternal::BasicStream __stream(__instance.get(), _encoding);"; string valueS; if(caseSensitive) diff --git a/cpp/src/slice2freezej/Main.cpp b/cpp/src/slice2freezej/Main.cpp index 83d21db861b..da13299ea81 100644 --- a/cpp/src/slice2freezej/Main.cpp +++ b/cpp/src/slice2freezej/Main.cpp @@ -1383,7 +1383,7 @@ FreezeGenerator::generate(UnitPtr& u, const Index& index) << "marshalKey(" << memberTypeString << " __key)"; out << sb; out << nl << "IceInternal.BasicStream __os = " - << "new IceInternal.BasicStream(IceInternal.Util.getInstance(communicator()), encoding(), true, false);"; + << "new IceInternal.BasicStream(IceInternal.Util.getInstance(communicator()), encoding(), false);"; int iter = 0; writeMarshalUnmarshalCode(out, "", dataMember->type(), OptionalNone, false, 0, valueS, true, iter, false); if(dataMember->type()->usesClasses()) diff --git a/cpp/test/Ice/background/Transceiver.cpp b/cpp/test/Ice/background/Transceiver.cpp index 3156b7343cd..4cfc8acd6ca 100644 --- a/cpp/test/Ice/background/Transceiver.cpp +++ b/cpp/test/Ice/background/Transceiver.cpp @@ -238,9 +238,9 @@ Transceiver::getInfo() const } void -Transceiver::checkSendSize(const IceInternal::Buffer& buf, size_t messageSizeMax) +Transceiver::checkSendSize(const IceInternal::Buffer& buf) { - _transceiver->checkSendSize(buf, messageSizeMax); + _transceiver->checkSendSize(buf); } // @@ -250,7 +250,6 @@ Transceiver::Transceiver(const IceInternal::TransceiverPtr& transceiver) : _transceiver(transceiver), _configuration(Configuration::getInstance()), _initialized(false), - _readBuffer(0), _buffered(_configuration->buffered()) { _readBuffer.b.resize(1024 * 8); // 8KB buffer diff --git a/cpp/test/Ice/background/Transceiver.h b/cpp/test/Ice/background/Transceiver.h index 68df63a0f65..8ff244000ea 100644 --- a/cpp/test/Ice/background/Transceiver.h +++ b/cpp/test/Ice/background/Transceiver.h @@ -34,7 +34,7 @@ public: virtual std::string toDetailedString() const; virtual Ice::ConnectionInfoPtr getInfo() const; virtual IceInternal::SocketOperation initialize(IceInternal::Buffer&, IceInternal::Buffer&, bool&); - virtual void checkSendSize(const IceInternal::Buffer&, size_t); + virtual void checkSendSize(const IceInternal::Buffer&); IceInternal::TransceiverPtr delegate() const { return _transceiver; } diff --git a/cpp/test/Ice/exceptions/AllTests.cpp b/cpp/test/Ice/exceptions/AllTests.cpp index 36a55f54c49..f03bdab60b5 100644 --- a/cpp/test/Ice/exceptions/AllTests.cpp +++ b/cpp/test/Ice/exceptions/AllTests.cpp @@ -908,6 +908,7 @@ allTests(const Ice::CommunicatorPtr& communicator) cout << "ok" << endl; } + if(thrower->ice_getConnection()) { cout << "testing memory limit marshal exception..." << flush; try @@ -915,7 +916,7 @@ allTests(const Ice::CommunicatorPtr& communicator) thrower->throwMemoryLimitException(Ice::ByteSeq()); test(false); } - catch(const Ice::UnknownLocalException&) + catch(const Ice::MemoryLimitException&) { } catch(...) @@ -928,21 +929,7 @@ allTests(const Ice::CommunicatorPtr& communicator) thrower->throwMemoryLimitException(Ice::ByteSeq(20 * 1024)); // 20KB test(false); } - catch(const Ice::MemoryLimitException&) - { - } - catch(...) - { - test(false); - } - - try - { - thrower->end_throwMemoryLimitException( - thrower->begin_throwMemoryLimitException(Ice::ByteSeq(20 * 1024))); // 20KB - test(false); - } - catch(const Ice::MemoryLimitException&) + catch(const Ice::ConnectionLostException&) { } catch(...) diff --git a/cpp/test/Ice/exceptions/Client.cpp b/cpp/test/Ice/exceptions/Client.cpp index 86d7a75e493..01cea364100 100644 --- a/cpp/test/Ice/exceptions/Client.cpp +++ b/cpp/test/Ice/exceptions/Client.cpp @@ -34,7 +34,8 @@ main(int argc, char* argv[]) try { Ice::InitializationData initData; - initData.properties = Ice::createProperties(); + initData.properties = Ice::createProperties(argc, argv); + initData.properties->setProperty("Ice.Warn.Connections", "0"); initData.properties->setProperty("Ice.MessageSizeMax", "10"); // 10KB max communicator = Ice::initialize(argc, argv, initData); status = run(argc, argv, communicator); diff --git a/cpp/test/Ice/exceptions/Collocated.cpp b/cpp/test/Ice/exceptions/Collocated.cpp index bcd9e1882bb..305bb58af85 100644 --- a/cpp/test/Ice/exceptions/Collocated.cpp +++ b/cpp/test/Ice/exceptions/Collocated.cpp @@ -41,6 +41,7 @@ main(int argc, char* argv[]) Ice::InitializationData initData; initData.properties = Ice::createProperties(); initData.properties->setProperty("Ice.MessageSizeMax", "10"); // 10KB max + initData.properties->setProperty("Ice.Warn.Connections", "0"); initData.properties->setProperty("Ice.Warn.Dispatch", "0"); communicator = Ice::initialize(argc, argv, initData); status = run(argc, argv, communicator); diff --git a/cpp/test/Ice/exceptions/Server.cpp b/cpp/test/Ice/exceptions/Server.cpp index ef20b9c428f..d50ffc78dd6 100644 --- a/cpp/test/Ice/exceptions/Server.cpp +++ b/cpp/test/Ice/exceptions/Server.cpp @@ -36,8 +36,9 @@ main(int argc, char* argv[]) try { Ice::InitializationData initData; - initData.properties = Ice::createProperties(); + initData.properties = Ice::createProperties(argc, argv); initData.properties->setProperty("Ice.Warn.Dispatch", "0"); + initData.properties->setProperty("Ice.Warn.Connections", "0"); initData.properties->setProperty("TestAdapter.Endpoints", "default -p 12010:udp"); initData.properties->setProperty("Ice.MessageSizeMax", "10"); // 10KB max communicator = Ice::initialize(argc, argv, initData); diff --git a/cpp/test/Ice/exceptions/ServerAMD.cpp b/cpp/test/Ice/exceptions/ServerAMD.cpp index 79e3bc1b165..04f4d5805bc 100644 --- a/cpp/test/Ice/exceptions/ServerAMD.cpp +++ b/cpp/test/Ice/exceptions/ServerAMD.cpp @@ -36,8 +36,9 @@ main(int argc, char* argv[]) try { Ice::InitializationData initData; - initData.properties = Ice::createProperties(); + initData.properties = Ice::createProperties(argc, argv); initData.properties->setProperty("Ice.Warn.Dispatch", "0"); + initData.properties->setProperty("Ice.Warn.Connections", "0"); initData.properties->setProperty("TestAdapter.Endpoints", "default -p 12010:udp"); initData.properties->setProperty("Ice.MessageSizeMax", "10"); // 10KB max communicator = Ice::initialize(argc, argv, initData); diff --git a/cpp/test/Ice/operations/BatchOneways.cpp b/cpp/test/Ice/operations/BatchOneways.cpp index 97dad6c84c7..62baee3653b 100644 --- a/cpp/test/Ice/operations/BatchOneways.cpp +++ b/cpp/test/Ice/operations/BatchOneways.cpp @@ -18,7 +18,6 @@ batchOneways(const Test::MyClassPrx& p) { const Test::ByteS bs1(10 * 1024); const Test::ByteS bs2(99 * 1024); - const Test::ByteS bs3(100 * 1024); try { p->opByteSOneway(bs1); @@ -37,32 +36,30 @@ batchOneways(const Test::MyClassPrx& p) test(false); } - try - { - p->opByteSOneway(bs3); - test(false); - } - catch(const Ice::MemoryLimitException&) - { - } - Test::MyClassPrx batch = Test::MyClassPrx::uncheckedCast(p->ice_batchOneway()); batch->ice_flushBatchRequests(); int i; - + p->opByteSOnewayCallCount(); // Reset the call count for(i = 0 ; i < 30 ; ++i) { try { batch->opByteSOneway(bs1); } - catch(const Ice::MemoryLimitException&) + catch(const Ice::LocalException&) { test(false); } } + int count = 0; + while(count != 27) // 3 * 9 requests auto-flushed. + { + count += p->opByteSOnewayCallCount(); + IceUtil::ThreadControl::sleep(IceUtil::Time::milliSeconds(10)); + } + if(batch->ice_getConnection()) { batch->ice_getConnection()->flushBatchRequests(); diff --git a/cpp/test/Ice/operations/BatchOnewaysAMI.cpp b/cpp/test/Ice/operations/BatchOnewaysAMI.cpp index a722b7868ee..a56d1f8d214 100644 --- a/cpp/test/Ice/operations/BatchOnewaysAMI.cpp +++ b/cpp/test/Ice/operations/BatchOnewaysAMI.cpp @@ -74,28 +74,6 @@ public: } }; -class Callback_ByteSOneway2 : public IceUtil::Shared -{ - CallbackPtr _cb; - -public: - - Callback_ByteSOneway2(const CallbackPtr& cb) : _cb(cb) - { - } - - void response() - { - test(false); - } - - void exception(const ::Ice::Exception& ex) - { - test(dynamic_cast<const ::Ice::MemoryLimitException*>(&ex)); - _cb->called(); - } -}; - class Callback_ByteSOneway3 : public IceUtil::Shared { public: @@ -149,10 +127,6 @@ batchOnewaysAMI(const Test::MyClassPrx& p) &Callback_ByteSOneway1::response, &Callback_ByteSOneway1::exception)); cb->check(); - p->begin_opByteSOneway(bs3, Test::newCallback_MyClass_opByteSOneway(new Callback_ByteSOneway2(cb), - &Callback_ByteSOneway2::response, &Callback_ByteSOneway2::exception)); - cb->check(); - Test::MyClassPrx batch = Test::MyClassPrx::uncheckedCast(p->ice_batchOneway()); batch->end_ice_flushBatchRequests(batch->begin_ice_flushBatchRequests()); @@ -160,7 +134,9 @@ batchOnewaysAMI(const Test::MyClassPrx& p) for(i = 0 ; i < 30 ; ++i) { - p->begin_opByteSOneway(bs1, Test::newCallback_MyClass_opByteSOneway(new Callback_ByteSOneway3(), &Callback_ByteSOneway3::response, &Callback_ByteSOneway3::exception)); + p->begin_opByteSOneway(bs1, Test::newCallback_MyClass_opByteSOneway(new Callback_ByteSOneway3(), + &Callback_ByteSOneway3::response, + &Callback_ByteSOneway3::exception)); } if(batch->ice_getConnection()) diff --git a/cpp/test/Ice/operations/Client.cpp b/cpp/test/Ice/operations/Client.cpp index 69cf0d8f57a..5ac63b3ca0f 100644 --- a/cpp/test/Ice/operations/Client.cpp +++ b/cpp/test/Ice/operations/Client.cpp @@ -60,12 +60,7 @@ main(int argc, char* argv[]) initData.properties->setProperty("Ice.ThreadPool.Client.Size", "2"); initData.properties->setProperty("Ice.ThreadPool.Client.SizeWarn", "0"); - // - // We must set MessageSizeMax to an explicit values, because - // we run tests to check whether Ice.MemoryLimitException is - // raised as expected. - // - initData.properties->setProperty("Ice.MessageSizeMax", "100"); + initData.properties->setProperty("Ice.BatchAutoFlushSize", "100"); communicator = Ice::initialize(argc, argv, initData); status = run(argc, argv, communicator, initData); diff --git a/cpp/test/Ice/operations/Collocated.cpp b/cpp/test/Ice/operations/Collocated.cpp index 1bae52850c1..8f9cf822279 100644 --- a/cpp/test/Ice/operations/Collocated.cpp +++ b/cpp/test/Ice/operations/Collocated.cpp @@ -44,12 +44,7 @@ main(int argc, char* argv[]) Ice::InitializationData initData; initData.properties = Ice::createProperties(argc, argv); - // - // We must set MessageSizeMax to an explicit values, because - // we run tests to check whether Ice.MemoryLimitException is - // raised as expected. - // - initData.properties->setProperty("Ice.MessageSizeMax", "100"); + initData.properties->setProperty("Ice.BatchAutoFlushSize", "100"); communicator = Ice::initialize(argc, argv, initData); status = run(argc, argv, communicator, initData); diff --git a/cpp/test/Ice/operations/Test.ice b/cpp/test/Ice/operations/Test.ice index 004fe7eee02..6a7cbd17625 100644 --- a/cpp/test/Ice/operations/Test.ice +++ b/cpp/test/Ice/operations/Test.ice @@ -230,6 +230,8 @@ class MyClass void opByteSOneway(ByteS s); + int opByteSOnewayCallCount(); + Ice::Context opContext(); void opDoubleMarshaling(double p1, DoubleS p2); diff --git a/cpp/test/Ice/operations/TestAMD.ice b/cpp/test/Ice/operations/TestAMD.ice index 5f3828d96cf..57fce5ee6ae 100644 --- a/cpp/test/Ice/operations/TestAMD.ice +++ b/cpp/test/Ice/operations/TestAMD.ice @@ -227,6 +227,7 @@ dictionary<MyEnum, MyEnumS> MyEnumMyEnumSD; IntS opIntS(IntS s); void opByteSOneway(ByteS s); + int opByteSOnewayCallCount(); Ice::Context opContext(); diff --git a/cpp/test/Ice/operations/TestAMDI.cpp b/cpp/test/Ice/operations/TestAMDI.cpp index ce242444937..e794f3c384d 100644 --- a/cpp/test/Ice/operations/TestAMDI.cpp +++ b/cpp/test/Ice/operations/TestAMDI.cpp @@ -32,6 +32,10 @@ private: const Test::AMD_MyClass_opVoidPtr _cb; }; +MyDerivedClassI::MyDerivedClassI() : _opByteSOnewayCallCount(0) +{ +} + bool MyDerivedClassI::ice_isA(const std::string& id, const Ice::Current& current) const { @@ -637,10 +641,21 @@ void MyDerivedClassI::opByteSOneway_async(const Test::AMD_MyClass_opByteSOnewayPtr& cb, const Test::ByteS&, const Ice::Current&) { + IceUtil::Mutex::Lock sync(_mutex); + ++_opByteSOnewayCallCount; cb->ice_response(); } void +MyDerivedClassI::opByteSOnewayCallCount_async(const Test::AMD_MyClass_opByteSOnewayCallCountPtr& cb, + const Ice::Current&) +{ + IceUtil::Mutex::Lock sync(_mutex); + cb->ice_response(_opByteSOnewayCallCount); + _opByteSOnewayCallCount = 0; +} + +void MyDerivedClassI::opContext_async(const Test::AMD_MyClass_opContextPtr& cb, const Ice::Current& c) { Test::StringStringD r = c.ctx; diff --git a/cpp/test/Ice/operations/TestAMDI.h b/cpp/test/Ice/operations/TestAMDI.h index 18cf15daa13..f7f83430a29 100644 --- a/cpp/test/Ice/operations/TestAMDI.h +++ b/cpp/test/Ice/operations/TestAMDI.h @@ -16,6 +16,8 @@ class MyDerivedClassI : public Test::MyDerivedClass { public: + + MyDerivedClassI(); // // Override the Object "pseudo" operations to verify the operation mode. @@ -206,6 +208,7 @@ public: virtual void opByteSOneway_async(const Test::AMD_MyClass_opByteSOnewayPtr&, const Test::ByteS&, const Ice::Current&); + virtual void opByteSOnewayCallCount_async(const Test::AMD_MyClass_opByteSOnewayCallCountPtr&, const Ice::Current&); virtual void opContext_async(const Test::AMD_MyClass_opContextPtr&, const Ice::Current&); @@ -225,6 +228,9 @@ private: IceUtil::ThreadPtr _opVoidThread; IceUtil::Mutex _opVoidMutex; + + IceUtil::Mutex _mutex; + int _opByteSOnewayCallCount; }; #endif diff --git a/cpp/test/Ice/operations/TestI.cpp b/cpp/test/Ice/operations/TestI.cpp index cc6423fcd03..6e5ec355950 100644 --- a/cpp/test/Ice/operations/TestI.cpp +++ b/cpp/test/Ice/operations/TestI.cpp @@ -14,6 +14,10 @@ #include <functional> #include <iterator> +MyDerivedClassI::MyDerivedClassI() : _opByteSOnewayCallCount(0) +{ +} + bool MyDerivedClassI::ice_isA(const std::string& id, const Ice::Current& current) const { @@ -610,6 +614,17 @@ MyDerivedClassI::opIntS(const Test::IntS& s, const Ice::Current&) void MyDerivedClassI::opByteSOneway(const Test::ByteS&, const Ice::Current&) { + IceUtil::Mutex::Lock sync(_mutex); + ++_opByteSOnewayCallCount; +} + +int +MyDerivedClassI::opByteSOnewayCallCount(const Ice::Current&) +{ + IceUtil::Mutex::Lock sync(_mutex); + int count = _opByteSOnewayCallCount; + _opByteSOnewayCallCount = 0; + return count; } Test::StringStringD diff --git a/cpp/test/Ice/operations/TestI.h b/cpp/test/Ice/operations/TestI.h index 78b14652c17..d40b9bd1f51 100644 --- a/cpp/test/Ice/operations/TestI.h +++ b/cpp/test/Ice/operations/TestI.h @@ -16,6 +16,8 @@ class MyDerivedClassI : public Test::MyDerivedClass { public: + MyDerivedClassI(); + // // Override the Object "pseudo" operations to verify the operation mode. // @@ -229,6 +231,7 @@ public: virtual Test::IntS opIntS(const Test::IntS&, const Ice::Current&); virtual void opByteSOneway(const Test::ByteS&, const Ice::Current&); + virtual int opByteSOnewayCallCount(const Ice::Current&); virtual Ice::Context opContext(const Ice::Current&); @@ -239,6 +242,11 @@ public: virtual void opNonmutating(const Ice::Current&); virtual void opDerived(const Ice::Current&); + +private: + + IceUtil::Mutex _mutex; + int _opByteSOnewayCallCount; }; #endif |