diff options
149 files changed, 752 insertions, 804 deletions
@@ -27,6 +27,24 @@ Changes since version 3.5.1 General Changes =============== +- Added new Ice.BatchAutoFlushSize property to allow controlling how + much data (in kilo bytes) is queued for batching before the batch is + sent over the connection. Previously, this was controlled by the + Ice.MessageSizeMax property. + + The Ice.BatchAutoFlush property has also been deprecated. To disable + auto flush you can set Ice.BatchAutoFlushSize=0. The default value + is 1024. + +- We have relaxed the semantics of Ice.MessageSizeMax. The check for + the maximum message size is now only performed on the receving + side. If the size of the message is superior to the limit the + Ice::MemoryLimitException is raised and the connection is closed. + + Previously, the limit was also checked to limit the size of the data + sent to a peer. This is no longer the case, we no longer limit the + amount of data sent (either by an request or a reply). + - The Ice run time now raises Ice::IllegalServantException if a null servant is provided to a method that requires a non-null servant (such as the Ice::ObjectAdapter::add methods or the Freeze evictor diff --git a/config/PropertyNames.xml b/config/PropertyNames.xml index 5023bcee34c..5a63b11b31a 100644 --- a/config/PropertyNames.xml +++ b/config/PropertyNames.xml @@ -323,7 +323,8 @@ generated from the section label. <property name="Admin.Logger.Properties" /> <property name="Admin.ServerId" /> <property name="BackgroundLocatorCacheUpdates"/> - <property name="BatchAutoFlush" /> + <property name="BatchAutoFlush" deprecated="true"/> + <property name="BatchAutoFlushSize" /> <property name="ChangeUser" /> <property name="ClientAccessPolicyProtocol" /> <property name="Compression.Level" /> 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 diff --git a/cs/src/Ice/BasicStream.cs b/cs/src/Ice/BasicStream.cs index ea9be7e7d9e..3ce5b71c121 100644 --- a/cs/src/Ice/BasicStream.cs +++ b/cs/src/Ice/BasicStream.cs @@ -103,23 +103,17 @@ namespace IceInternal public BasicStream(Instance instance, Ice.EncodingVersion encoding) { - initialize(instance, encoding, false); - _buf = new Buffer(instance.messageSizeMax()); - } - - public BasicStream(Instance instance, Ice.EncodingVersion encoding, bool unlimited) - { - initialize(instance, encoding, unlimited); - _buf = new Buffer(instance.messageSizeMax()); + initialize(instance, encoding); + _buf = new Buffer(); } public BasicStream(Instance instance, Ice.EncodingVersion encoding, byte[] data) { - initialize(instance, encoding, false); + initialize(instance, encoding); _buf = new Buffer(data); } - private void initialize(Instance instance, Ice.EncodingVersion encoding, bool unlimited) + private void initialize(Instance instance, Ice.EncodingVersion encoding) { instance_ = instance; _closure = null; @@ -132,9 +126,6 @@ namespace IceInternal _sliceObjects = true; - _messageSizeMax = instance_.messageSizeMax(); // Cached for efficiency. - _unlimited = unlimited; - _startSeq = -1; } @@ -210,10 +201,6 @@ namespace IceInternal resetEncaps(); other.resetEncaps(); - bool tmpUnlimited = other._unlimited; - other._unlimited = _unlimited; - _unlimited = tmpUnlimited; - int tmpStartSeq = other._startSeq; other._startSeq = _startSeq; _startSeq = tmpStartSeq; @@ -231,14 +218,6 @@ namespace IceInternal public void resize(int sz, bool reading) { - // - // Check memory limit if stream is not unlimited. - // - if(!_unlimited && sz > _messageSizeMax) - { - Ex.throwMemoryLimitException(sz, _messageSizeMax); - } - _buf.resize(sz, reading); _buf.b.position(sz); } @@ -3420,6 +3399,10 @@ namespace IceInternal { throw new Ice.IllegalMessageSizeException("compressed size <= header size"); } + if(uncompressedSize > instance_.messageSizeMax()) + { + IceInternal.Ex.throwMemoryLimitException(uncompressedSize, instance_.messageSizeMax()); + } int compressedLen = size() - headerSize - 4; byte[] compressed = _buf.b.rawBytes(headerSize + 4, compressedLen); @@ -3449,10 +3432,6 @@ namespace IceInternal public void expand(int n) { - if(!_unlimited && _buf.b != null && _buf.b.position() + n > _messageSizeMax) - { - Ex.throwMemoryLimitException(_buf.b.position() + n, _messageSizeMax); - } _buf.expand(n); } @@ -5401,9 +5380,6 @@ namespace IceInternal private bool _sliceObjects; - private int _messageSizeMax; - private bool _unlimited; - private int _startSeq; private int _minSeqSize; diff --git a/cs/src/Ice/Buffer.cs b/cs/src/Ice/Buffer.cs index 17a9ddc8c70..d7e133447b3 100644 --- a/cs/src/Ice/Buffer.cs +++ b/cs/src/Ice/Buffer.cs @@ -17,16 +17,15 @@ namespace IceInternal // public class Buffer { - public Buffer(int maxCapacity) : this(maxCapacity, ByteBuffer.ByteOrder.LITTLE_ENDIAN) + public Buffer() : this(ByteBuffer.ByteOrder.LITTLE_ENDIAN) { } - public Buffer(int maxCapacity, ByteBuffer.ByteOrder order) + public Buffer(ByteBuffer.ByteOrder order) { b = _emptyBuffer; _size = 0; _capacity = 0; - _maxCapacity = maxCapacity; _order = order; } @@ -40,7 +39,6 @@ namespace IceInternal b.order(order); _size = data.Length; _capacity = 0; - _maxCapacity = 0; _order = order; } @@ -133,7 +131,7 @@ namespace IceInternal if(n > _capacity) { - _capacity = System.Math.Max(n, System.Math.Min(2 * _capacity, _maxCapacity)); + _capacity = System.Math.Max(n, 2 * _capacity); _capacity = System.Math.Max(240, _capacity); } else if(n < _capacity) @@ -190,7 +188,6 @@ namespace IceInternal private int _size; private int _capacity; // Cache capacity to avoid excessive method calls. - private int _maxCapacity; private int _shrinkCounter; private ByteBuffer.ByteOrder _order; } diff --git a/cs/src/Ice/CollocatedRequestHandler.cs b/cs/src/Ice/CollocatedRequestHandler.cs index 90079d3bc40..d49635f415e 100644 --- a/cs/src/Ice/CollocatedRequestHandler.cs +++ b/cs/src/Ice/CollocatedRequestHandler.cs @@ -34,12 +34,11 @@ namespace IceInternal _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 = new BasicStream(@ref.getInstance(), Ice.Util.currentProtocolEncoding, _batchAutoFlush); + _batchStream = new BasicStream(@ref.getInstance(), Ice.Util.currentProtocolEncoding); } public RequestHandler connect(Ice.ObjectPrxHelperBase proxy) @@ -88,7 +87,7 @@ namespace IceInternal { _batchStream.swap(os); - if(_batchAutoFlush & (_batchStream.size() > _reference.getInstance().messageSizeMax())) + if(_batchAutoFlushSize > 0 && (_batchStream.size() > _batchAutoFlushSize)) { // // Temporarily save the last request. @@ -101,8 +100,7 @@ namespace IceInternal int invokeNum = _batchRequestNum; BasicStream stream = new BasicStream(_reference.getInstance(), - Ice.Util.currentProtocolEncoding, - _batchAutoFlush); + Ice.Util.currentProtocolEncoding); stream.swap(_batchStream); _adapter.getThreadPool().dispatch(() => @@ -117,16 +115,6 @@ namespace IceInternal _batchMarker = 0; // - // Check again if the last request doesn't exceed what we can send with the auto flush - // - if(Protocol.requestBatchHdr.Length + lastRequest.Length > - _reference.getInstance().messageSizeMax()) - { - Ex.throwMemoryLimitException(Protocol.requestBatchHdr.Length + lastRequest.Length, - _reference.getInstance().messageSizeMax()); - } - - // // Start a new batch with the last message that caused us to go over the limit. // _batchStream.writeBlob(Protocol.requestBatchHdr); @@ -153,8 +141,7 @@ namespace IceInternal { lock(this) { - BasicStream dummy = new BasicStream(_reference.getInstance(), Ice.Util.currentProtocolEncoding, - _batchAutoFlush); + BasicStream dummy = new BasicStream(_reference.getInstance(), Ice.Util.currentProtocolEncoding); _batchStream.swap(dummy); _batchRequestNum = 0; _batchMarker = 0; @@ -378,8 +365,7 @@ namespace IceInternal // // Reset the batch stream. // - BasicStream dummy = new BasicStream(_reference.getInstance(), Ice.Util.currentProtocolEncoding, - _batchAutoFlush); + BasicStream dummy = new BasicStream(_reference.getInstance(), Ice.Util.currentProtocolEncoding); _batchStream.swap(dummy); _batchRequestNum = 0; _batchMarker = 0; @@ -512,7 +498,7 @@ namespace IceInternal private readonly Ice.ObjectAdapterI _adapter; private readonly Ice.Logger _logger; private readonly TraceLevels _traceLevels; - private bool _batchAutoFlush; + private readonly int _batchAutoFlushSize; private int _requestId; diff --git a/cs/src/Ice/ConnectRequestHandler.cs b/cs/src/Ice/ConnectRequestHandler.cs index 7807ea98a68..156084cbb81 100644 --- a/cs/src/Ice/ConnectRequestHandler.cs +++ b/cs/src/Ice/ConnectRequestHandler.cs @@ -118,12 +118,6 @@ namespace IceInternal _batchStream.swap(os); - if(!_batchAutoFlush && - _batchStream.size() + _batchRequestsSize > _reference.getInstance().messageSizeMax()) - { - Ex.throwMemoryLimitException(_batchStream.size() + _batchRequestsSize, - _reference.getInstance().messageSizeMax()); - } _requests.AddLast(new Request(_batchStream)); return; } @@ -141,10 +135,8 @@ namespace IceInternal _batchRequestInProgress = false; System.Threading.Monitor.PulseAll(this); - BasicStream dummy = new BasicStream(_reference.getInstance(), Ice.Util.currentProtocolEncoding, - _batchAutoFlush); + BasicStream dummy = new BasicStream(_reference.getInstance(), Ice.Util.currentProtocolEncoding); _batchStream.swap(dummy); - _batchRequestsSize = Protocol.requestBatchHdr.Length; return; } @@ -326,13 +318,10 @@ namespace IceInternal _connect = true; _response = _reference.getMode() == Reference.Mode.ModeTwoway; _proxy = (Ice.ObjectPrxHelperBase)proxy; - _batchAutoFlush = @ref.getInstance().initializationData().properties.getPropertyAsIntWithDefault( - "Ice.BatchAutoFlush", 1) > 0 ? true : false; _initialized = false; _flushing = false; _batchRequestInProgress = false; - _batchRequestsSize = Protocol.requestBatchHdr.Length; - _batchStream = new BasicStream(@ref.getInstance(), Ice.Util.currentProtocolEncoding, _batchAutoFlush); + _batchStream = new BasicStream(@ref.getInstance(), Ice.Util.currentProtocolEncoding); } private bool initialized() @@ -503,8 +492,6 @@ namespace IceInternal private Ice.ObjectPrxHelperBase _proxy; private HashSet<Ice.ObjectPrxHelperBase> _proxies = new HashSet<Ice.ObjectPrxHelperBase>(); - private bool _batchAutoFlush; - private Ice.ConnectionI _connection; private bool _compress; private Ice.LocalException _exception; @@ -513,7 +500,6 @@ namespace IceInternal private LinkedList<Request> _requests = new LinkedList<Request>(); private bool _batchRequestInProgress; - private int _batchRequestsSize; private BasicStream _batchStream; private RequestHandler _connectionRequestHandler; diff --git a/cs/src/Ice/ConnectionI.cs b/cs/src/Ice/ConnectionI.cs index db509426f1a..11a3ba0fe84 100644 --- a/cs/src/Ice/ConnectionI.cs +++ b/cs/src/Ice/ConnectionI.cs @@ -406,7 +406,7 @@ namespace Ice // Ensure the message isn't bigger than what we can send with the // transport. // - _transceiver.checkSendSize(os.getBuffer(), _instance.messageSizeMax()); + _transceiver.checkSendSize(os.getBuffer()); // // Notify the request that it's cancelable with this connection. @@ -534,8 +534,13 @@ namespace Ice } bool flush = false; - if(_batchAutoFlush) + if(_batchAutoFlushSize > 0) { + if(_batchStream.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 @@ -543,7 +548,7 @@ namespace Ice // try { - _transceiver.checkSendSize(_batchStream.getBuffer(), _instance.messageSizeMax()); + _transceiver.checkSendSize(_batchStream.getBuffer()); } catch(LocalException) { @@ -593,24 +598,12 @@ namespace Ice // // Reset the batch stream. // - _batchStream = new IceInternal.BasicStream(_instance, Util.currentProtocolEncoding, - _batchAutoFlush); + _batchStream = new IceInternal.BasicStream(_instance, Util.currentProtocolEncoding); _batchRequestNum = 0; _batchRequestCompress = false; _batchMarker = 0; // - // Check again if the last request doesn't exceed the maximum message size. - // - if(IceInternal.Protocol.requestBatchHdr.Length + lastRequest.Length > - _instance.messageSizeMax()) - { - IceInternal.Ex.throwMemoryLimitException( - IceInternal.Protocol.requestBatchHdr.Length + lastRequest.Length, - _instance.messageSizeMax()); - } - - // // Start a new batch with the last message that caused us to go over the limit. // _batchStream.writeBlob(IceInternal.Protocol.requestBatchHdr); @@ -650,7 +643,7 @@ namespace Ice { lock(this) { - _batchStream = new IceInternal.BasicStream(_instance, Util.currentProtocolEncoding, _batchAutoFlush); + _batchStream = new IceInternal.BasicStream(_instance, Util.currentProtocolEncoding); _batchRequestNum = 0; _batchRequestCompress = false; _batchMarker = 0; @@ -753,7 +746,7 @@ namespace Ice // // Reset the batch stream. // - _batchStream = new IceInternal.BasicStream(_instance, Util.currentProtocolEncoding, _batchAutoFlush); + _batchStream = new IceInternal.BasicStream(_instance, Util.currentProtocolEncoding); _batchRequestNum = 0; _batchRequestCompress = false; _batchMarker = 0; @@ -1810,8 +1803,8 @@ namespace Ice _acmLastActivity = -1; } _nextRequestId = 1; - _batchAutoFlush = initData.properties.getPropertyAsIntWithDefault("Ice.BatchAutoFlush", 1) > 0; - _batchStream = new IceInternal.BasicStream(instance, Util.currentProtocolEncoding, _batchAutoFlush); + _batchAutoFlushSize = instance.batchAutoFlushSize(); + _batchStream = new IceInternal.BasicStream(instance, Util.currentProtocolEncoding); _batchStreamInUse = false; _batchRequestNum = 0; _batchRequestCompress = false; @@ -3177,7 +3170,7 @@ namespace Ice private LocalException _exception; - private bool _batchAutoFlush; + private int _batchAutoFlushSize; private IceInternal.BasicStream _batchStream; private bool _batchStreamInUse; private int _batchRequestNum; diff --git a/cs/src/Ice/EndpointFactoryManager.cs b/cs/src/Ice/EndpointFactoryManager.cs index 96a7477717e..7088b5fc012 100644 --- a/cs/src/Ice/EndpointFactoryManager.cs +++ b/cs/src/Ice/EndpointFactoryManager.cs @@ -142,7 +142,7 @@ namespace IceInternal // and ask the factory to read the endpoint data from that stream to create // the actual endpoint. // - BasicStream bs = new BasicStream(instance_, Ice.Util.currentProtocolEncoding, true); + BasicStream bs = new BasicStream(instance_, Ice.Util.currentProtocolEncoding); bs.writeShort(ue.type()); ue.streamWrite(bs); Buffer buf = bs.getBuffer(); diff --git a/cs/src/Ice/Instance.cs b/cs/src/Ice/Instance.cs index 3d1e498c0f3..afaa0132fa7 100644 --- a/cs/src/Ice/Instance.cs +++ b/cs/src/Ice/Instance.cs @@ -337,6 +337,12 @@ namespace IceInternal return _messageSizeMax; } + public int batchAutoFlushSize() + { + // No mutex lock, immutable. + return _batchAutoFlushSize; + } + public int cacheMessageBuffers() { // No mutex lock, immutable. @@ -824,6 +830,31 @@ namespace IceInternal } } + if(_initData.properties.getProperty("Ice.BatchAutoFlushSize").Length == 0 && + _initData.properties.getProperty("Ice.BatchAutoFlush").Length > 0) + { + if(_initData.properties.getPropertyAsInt("Ice.BatchAutoFlush") > 0) + { + _batchAutoFlushSize = _messageSizeMax; + } + } + else + { + int num = _initData.properties.getPropertyAsIntWithDefault("Ice.BatchAutoFlushSize", 1024); // 1MB + if(num < 1) + { + _batchAutoFlushSize = num; + } + else if(num > 0x7fffffff / 1024) + { + _batchAutoFlushSize = 0x7fffffff; + } + else + { + _batchAutoFlushSize = num * 1024; // Property is in kilobytes, _batchAutoFlushSize in bytes + } + } + _cacheMessageBuffers = _initData.properties.getPropertyAsIntWithDefault("Ice.CacheMessageBuffers", 2); _implicitContext = Ice.ImplicitContextI.create(_initData.properties.getProperty("Ice.ImplicitContext")); @@ -1435,6 +1466,7 @@ namespace IceInternal private string[] _factoryAssemblies; // Immutable, not reset by destroy(). #endif private int _messageSizeMax; // Immutable, not reset by destroy(). + private int _batchAutoFlushSize; // Immutable, not reset by destroy(). private int _cacheMessageBuffers; // Immutable, not reset by destroy(). private ACMConfig _clientACM; // Immutable, not reset by destroy(). private ACMConfig _serverACM; // Immutable, not reset by destroy(). diff --git a/cs/src/Ice/PropertyNames.cs b/cs/src/Ice/PropertyNames.cs index d6239243995..9a4878b8c85 100644 --- a/cs/src/Ice/PropertyNames.cs +++ b/cs/src/Ice/PropertyNames.cs @@ -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! @@ -75,7 +75,8 @@ namespace IceInternal new Property(@"^Ice\.Admin\.Logger\.Properties$", false, null), new Property(@"^Ice\.Admin\.ServerId$", false, null), new Property(@"^Ice\.BackgroundLocatorCacheUpdates$", false, null), - new Property(@"^Ice\.BatchAutoFlush$", false, null), + new Property(@"^Ice\.BatchAutoFlush$", true, null), + new Property(@"^Ice\.BatchAutoFlushSize$", false, null), new Property(@"^Ice\.ChangeUser$", false, null), new Property(@"^Ice\.ClientAccessPolicyProtocol$", false, null), new Property(@"^Ice\.Compression\.Level$", false, null), diff --git a/cs/src/Ice/StreamI.cs b/cs/src/Ice/StreamI.cs index d617aed190e..c9210c23ba9 100644 --- a/cs/src/Ice/StreamI.cs +++ b/cs/src/Ice/StreamI.cs @@ -28,7 +28,7 @@ namespace Ice { if(copyData) { - _is = new IceInternal.BasicStream(instance, v, true); + _is = new IceInternal.BasicStream(instance, v); _is.resize(data.Length, true); IceInternal.Buffer buf = _is.getBuffer(); buf.b.position(0); @@ -311,7 +311,7 @@ namespace Ice _communicator = communicator; IceInternal.Instance instance = IceInternal.Util.getInstance(communicator); - _os = new IceInternal.BasicStream(instance, instance.defaultsAndOverrides().defaultEncoding, true); + _os = new IceInternal.BasicStream(instance, instance.defaultsAndOverrides().defaultEncoding); _os.closure(this); } @@ -320,7 +320,7 @@ namespace Ice _communicator = communicator; IceInternal.Instance instance = IceInternal.Util.getInstance(communicator); - _os = new IceInternal.BasicStream(instance, v, true); + _os = new IceInternal.BasicStream(instance, v); _os.closure(this); } diff --git a/cs/src/Ice/TcpTransceiver.cs b/cs/src/Ice/TcpTransceiver.cs index 55e36e75ee2..6c9d1440132 100644 --- a/cs/src/Ice/TcpTransceiver.cs +++ b/cs/src/Ice/TcpTransceiver.cs @@ -100,12 +100,8 @@ namespace IceInternal return info; } - public void checkSendSize(Buffer buf, int messageSizeMax) + public void checkSendSize(Buffer buf) { - if(buf.size() > messageSizeMax) - { - Ex.throwMemoryLimitException(buf.size(), messageSizeMax); - } } public override string ToString() diff --git a/cs/src/Ice/Transceiver.cs b/cs/src/Ice/Transceiver.cs index 4a3fd4af609..a32575fc0b7 100644 --- a/cs/src/Ice/Transceiver.cs +++ b/cs/src/Ice/Transceiver.cs @@ -52,7 +52,7 @@ namespace IceInternal string protocol(); string toDetailedString(); Ice.ConnectionInfo getInfo(); - void checkSendSize(Buffer buf, int messageSizeMax); + void checkSendSize(Buffer buf); } } diff --git a/cs/src/Ice/UdpTransceiver.cs b/cs/src/Ice/UdpTransceiver.cs index c5c224ea4a9..423cf4af423 100644 --- a/cs/src/Ice/UdpTransceiver.cs +++ b/cs/src/Ice/UdpTransceiver.cs @@ -751,13 +751,8 @@ namespace IceInternal return info; } - public void checkSendSize(Buffer buf, int messageSizeMax) + public void checkSendSize(Buffer buf) { - if(buf.size() > messageSizeMax) - { - Ex.throwMemoryLimitException(buf.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/cs/src/Ice/WSTransceiver.cs b/cs/src/Ice/WSTransceiver.cs index f5a778bff21..76883b4d898 100644 --- a/cs/src/Ice/WSTransceiver.cs +++ b/cs/src/Ice/WSTransceiver.cs @@ -627,9 +627,9 @@ namespace IceInternal return info; } - public void checkSendSize(IceInternal.Buffer buf, int messageSizeMax) + public void checkSendSize(IceInternal.Buffer buf) { - _delegate.checkSendSize(buf, messageSizeMax); + _delegate.checkSendSize(buf); } public override string ToString() @@ -689,8 +689,7 @@ namespace IceInternal _state = StateInitializeDelegate; _parser = new HttpParser(); _readState = ReadStateOpcode; - _readBuffer = new IceInternal.Buffer(0, IceInternal.ByteBuffer.ByteOrder.BIG_ENDIAN); // Use network - // byte order. + _readBuffer = new IceInternal.Buffer(IceInternal.ByteBuffer.ByteOrder.BIG_ENDIAN); // Network byte order _readBufferSize = 1024; _readLastFrame = false; _readOpCode = 0; @@ -698,8 +697,7 @@ namespace IceInternal _readPayloadLength = 0; _readMask = new byte[4]; _writeState = WriteStateHeader; - _writeBuffer = new IceInternal.Buffer(0, IceInternal.ByteBuffer.ByteOrder.BIG_ENDIAN); // Use network - // byte order. + _writeBuffer = new IceInternal.Buffer(IceInternal.ByteBuffer.ByteOrder.BIG_ENDIAN); // Network byte order _writeBufferSize = 1024; _readPending = false; _finishRead = false; diff --git a/cs/src/IceSSL/TransceiverI.cs b/cs/src/IceSSL/TransceiverI.cs index a79d2a88748..6060bcae79d 100644 --- a/cs/src/IceSSL/TransceiverI.cs +++ b/cs/src/IceSSL/TransceiverI.cs @@ -305,12 +305,8 @@ namespace IceSSL return getNativeConnectionInfo(); } - public void checkSendSize(IceInternal.Buffer buf, int messageSizeMax) + public void checkSendSize(IceInternal.Buffer buf) { - if(buf.size() > messageSizeMax) - { - IceInternal.Ex.throwMemoryLimitException(buf.size(), messageSizeMax); - } } public override string ToString() diff --git a/cs/test/Ice/background/Transceiver.cs b/cs/test/Ice/background/Transceiver.cs index e1b4eb353a8..67cf7402a79 100644 --- a/cs/test/Ice/background/Transceiver.cs +++ b/cs/test/Ice/background/Transceiver.cs @@ -220,9 +220,9 @@ internal class Transceiver : IceInternal.Transceiver return _transceiver.toDetailedString(); } - public void checkSendSize(IceInternal.Buffer buf, int messageSizeMax) + public void checkSendSize(IceInternal.Buffer buf ) { - _transceiver.checkSendSize(buf, messageSizeMax); + _transceiver.checkSendSize(buf); } public void destroy() @@ -243,7 +243,7 @@ internal class Transceiver : IceInternal.Transceiver _transceiver = transceiver; _configuration = Configuration.getInstance(); _initialized = false; - _readBuffer = new IceInternal.Buffer(100 * 1024); + _readBuffer = new IceInternal.Buffer(); _readBuffer.resize(1024 * 8, true); // 8KB buffer _readBuffer.b.position(0); _readBufferPos = 0; diff --git a/cs/test/Ice/exceptions/AllTests.cs b/cs/test/Ice/exceptions/AllTests.cs index b14cdae66a7..6c7d4f41f64 100644 --- a/cs/test/Ice/exceptions/AllTests.cs +++ b/cs/test/Ice/exceptions/AllTests.cs @@ -431,15 +431,16 @@ public class AllTests : TestCommon.TestApp WriteLine("ok"); } - Write("testing memory limit marshal exception..."); - Flush(); + if(thrower.ice_getConnection() != null) { + Write("testing memory limit marshal exception..."); + Flush(); try { thrower.throwMemoryLimitException(null); test(false); } - catch(Ice.UnknownLocalException) + catch(Ice.MemoryLimitException) { } catch(Exception) @@ -452,29 +453,15 @@ public class AllTests : TestCommon.TestApp thrower.throwMemoryLimitException(new byte[20 * 1024]); // 20KB test(false); } - catch(Ice.MemoryLimitException) - { - } - catch(Exception) - { - test(false); - } - - try - { - thrower.end_throwMemoryLimitException( - thrower.begin_throwMemoryLimitException(new byte[20 * 1024])); // 20KB - test(false); - } - catch(Ice.MemoryLimitException) + catch(Ice.ConnectionLostException) { } catch(Exception) { test(false); } + WriteLine("ok"); } - WriteLine("ok"); Write("catching object not exist exception... "); Flush(); diff --git a/cs/test/Ice/exceptions/Client.cs b/cs/test/Ice/exceptions/Client.cs index efcd5099300..7feb9bba0d3 100644 --- a/cs/test/Ice/exceptions/Client.cs +++ b/cs/test/Ice/exceptions/Client.cs @@ -35,7 +35,7 @@ public class Client try { Ice.InitializationData initData = new Ice.InitializationData(); - initData.properties = Ice.Util.createProperties(); + initData.properties = Ice.Util.createProperties(ref args); #if COMPACT // // When using Ice for .NET Compact Framework, we need to specify @@ -43,8 +43,7 @@ public class Client // initData.properties.setProperty("Ice.FactoryAssemblies", "client"); #endif - // We don't need to disable warnings because we have a dummy logger. - //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.Util.initialize(ref args, initData); diff --git a/cs/test/Ice/exceptions/Server.cs b/cs/test/Ice/exceptions/Server.cs index 76fe76dc7d4..bf219e4228c 100644 --- a/cs/test/Ice/exceptions/Server.cs +++ b/cs/test/Ice/exceptions/Server.cs @@ -66,8 +66,9 @@ public class Server try { Ice.InitializationData initData = new Ice.InitializationData(); - initData.properties = Ice.Util.createProperties(); + initData.properties = Ice.Util.createProperties(ref args); 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.Util.initialize(ref args, initData); diff --git a/cs/test/Ice/operations/BatchOneways.cs b/cs/test/Ice/operations/BatchOneways.cs index 5a42e44603f..cd34c134cfc 100644 --- a/cs/test/Ice/operations/BatchOneways.cs +++ b/cs/test/Ice/operations/BatchOneways.cs @@ -23,7 +23,6 @@ class BatchOneways { byte[] bs1 = new byte[10 * 1024]; byte[] bs2 = new byte[99 * 1024]; - byte[] bs3 = new byte[100 * 1024]; try { @@ -45,19 +44,11 @@ class BatchOneways test(false); } - try - { - p.opByteSOneway(bs3); - test(false); - } - catch(Ice.MemoryLimitException) - { - test(true); - } - Test.MyClassPrx batch = Test.MyClassPrxHelper.uncheckedCast(p.ice_batchOneway()); batch.ice_flushBatchRequests(); + p.opByteSOnewayCallCount(); // Reset the call count + for(int i = 0 ; i < 30 ; ++i) { try @@ -71,6 +62,13 @@ class BatchOneways } } + int count = 0; + while(count != 27) // 3 * 9 requests auto-flushed. + { + count += p.opByteSOnewayCallCount(); + System.Threading.Thread.Sleep(10); + } + if(batch.ice_getConnection() != null) { batch.ice_getConnection().flushBatchRequests(); diff --git a/cs/test/Ice/operations/BatchOnewaysAMI.cs b/cs/test/Ice/operations/BatchOnewaysAMI.cs index c2599b243d8..cc465a95c6b 100644 --- a/cs/test/Ice/operations/BatchOnewaysAMI.cs +++ b/cs/test/Ice/operations/BatchOnewaysAMI.cs @@ -57,7 +57,6 @@ class BatchOnewaysAMI { byte[] bs1 = new byte[10 * 1024]; byte[] bs2 = new byte[99 * 1024]; - byte[] bs3 = new byte[100 * 1024]; Callback cb = new Callback(); p.begin_opByteSOneway(bs1).whenCompleted( @@ -82,18 +81,6 @@ class BatchOnewaysAMI }); cb.check(); - p.begin_opByteSOneway(bs3).whenCompleted( - () => - { - test(false); - }, - (Ice.Exception ex) => - { - test(ex is Ice.MemoryLimitException); - cb.called(); - }); - cb.check(); - Test.MyClassPrx batch = Test.MyClassPrxHelper.uncheckedCast(p.ice_batchOneway()); batch.end_ice_flushBatchRequests(batch.begin_ice_flushBatchRequests()); diff --git a/cs/test/Ice/operations/Client.cs b/cs/test/Ice/operations/Client.cs index d839e2dcbca..1864170ee58 100644 --- a/cs/test/Ice/operations/Client.cs +++ b/cs/test/Ice/operations/Client.cs @@ -54,13 +54,7 @@ public class Client initData.properties = Ice.Util.createProperties(ref args); 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.Util.initialize(ref args, initData); status = run(args, communicator); diff --git a/cs/test/Ice/operations/Collocated.cs b/cs/test/Ice/operations/Collocated.cs index b2185183739..ae03ee2eeb5 100644 --- a/cs/test/Ice/operations/Collocated.cs +++ b/cs/test/Ice/operations/Collocated.cs @@ -48,13 +48,7 @@ public class Collocated initData.properties = Ice.Util.createProperties(ref args); initData.properties.setProperty("Ice.ThreadPool.Client.Size", "2"); // For nested AMI. 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"); // // Its possible to have batch oneway requests dispatched diff --git a/cs/test/Ice/operations/MyDerivedClassAMDI.cs b/cs/test/Ice/operations/MyDerivedClassAMDI.cs index aca02741584..2d22e8b9beb 100644 --- a/cs/test/Ice/operations/MyDerivedClassAMDI.cs +++ b/cs/test/Ice/operations/MyDerivedClassAMDI.cs @@ -404,9 +404,23 @@ public sealed class MyDerivedClassI : Test.MyDerivedClass public override void opByteSOneway_async(Test.AMD_MyClass_opByteSOneway cb, byte[] s, Ice.Current current) { + lock(this) + { + ++_opByteSOnewayCallCount; + } cb.ice_response(); } + public override void opByteSOnewayCallCount_async(Test.AMD_MyClass_opByteSOnewayCallCount cb, Ice.Current current) + { + lock(this) + { + int count = _opByteSOnewayCallCount; + _opByteSOnewayCallCount = 0; + cb.ice_response(count); + } + } + public override void opDoubleMarshaling_async(Test.AMD_MyClass_opDoubleMarshaling cb, double p1, double[] p2, Ice.Current current) { @@ -506,4 +520,5 @@ public sealed class MyDerivedClassI : Test.MyDerivedClass } private Thread_opVoid _opVoidThread; + private int _opByteSOnewayCallCount = 0; } diff --git a/cs/test/Ice/operations/MyDerivedClassAMDTieI.cs b/cs/test/Ice/operations/MyDerivedClassAMDTieI.cs index 76419454da3..602696f1f65 100644 --- a/cs/test/Ice/operations/MyDerivedClassAMDTieI.cs +++ b/cs/test/Ice/operations/MyDerivedClassAMDTieI.cs @@ -384,9 +384,23 @@ public sealed class MyDerivedClassTieI : Test.MyDerivedClassOperations_ public void opByteSOneway_async(Test.AMD_MyClass_opByteSOneway cb, byte[] s, Ice.Current current) { + lock(this) + { + ++_opByteSOnewayCallCount; + } cb.ice_response(); } + public void opByteSOnewayCallCount_async(Test.AMD_MyClass_opByteSOnewayCallCount cb, Ice.Current current) + { + lock(this) + { + int count = _opByteSOnewayCallCount; + _opByteSOnewayCallCount = 0; + cb.ice_response(count); + } + } + public void opDoubleMarshaling_async(Test.AMD_MyClass_opDoubleMarshaling cb, double p1, double[] p2, Ice.Current current) { @@ -485,4 +499,5 @@ public sealed class MyDerivedClassTieI : Test.MyDerivedClassOperations_ } private Thread_opVoid _opVoidThread; + private int _opByteSOnewayCallCount = 0; } diff --git a/cs/test/Ice/operations/MyDerivedClassI.cs b/cs/test/Ice/operations/MyDerivedClassI.cs index 9bfa64dc327..7dd69d16e87 100644 --- a/cs/test/Ice/operations/MyDerivedClassI.cs +++ b/cs/test/Ice/operations/MyDerivedClassI.cs @@ -369,6 +369,20 @@ public sealed class MyDerivedClassI : Test.MyDerivedClass public override void opByteSOneway(byte[] s, Ice.Current current) { + lock(this) + { + ++_opByteSOnewayCallCount; + } + } + + public override int opByteSOnewayCallCount(Ice.Current current) + { + lock(this) + { + int count = _opByteSOnewayCallCount; + _opByteSOnewayCallCount = 0; + return count; + } } public override Dictionary<string, string> opContext(Ice.Current current) @@ -467,4 +481,6 @@ public sealed class MyDerivedClassI : Test.MyDerivedClass public override void opDerived(Ice.Current current) { } + + private int _opByteSOnewayCallCount = 0; } diff --git a/cs/test/Ice/operations/MyDerivedClassTieI.cs b/cs/test/Ice/operations/MyDerivedClassTieI.cs index ade1d2cd667..7f33308ddf3 100644 --- a/cs/test/Ice/operations/MyDerivedClassTieI.cs +++ b/cs/test/Ice/operations/MyDerivedClassTieI.cs @@ -344,6 +344,20 @@ public sealed class MyDerivedClassTieI : Test.MyDerivedClassOperations_ public void opByteSOneway(byte[] s, Ice.Current current) { + lock(this) + { + ++_opByteSOnewayCallCount; + } + } + + public int opByteSOnewayCallCount(Ice.Current current) + { + lock(this) + { + int count = _opByteSOnewayCallCount; + _opByteSOnewayCallCount = 0; + return count; + } } public Dictionary<string, string> opContext(Ice.Current current) @@ -442,4 +456,6 @@ public sealed class MyDerivedClassTieI : Test.MyDerivedClassOperations_ public void opDerived(Ice.Current current) { } + + private int _opByteSOnewayCallCount = 0; } diff --git a/cs/test/Ice/operations/Test.ice b/cs/test/Ice/operations/Test.ice index 20780a4c6d1..a1da70b779a 100644 --- a/cs/test/Ice/operations/Test.ice +++ b/cs/test/Ice/operations/Test.ice @@ -164,6 +164,8 @@ class MyClass void opByteSOneway(ByteS s); + int opByteSOnewayCallCount(); + Ice::Context opContext(); void opDoubleMarshaling(double p1, DoubleS p2); diff --git a/cs/test/Ice/operations/TestAMD.ice b/cs/test/Ice/operations/TestAMD.ice index 8f7c710df12..926ee7875c3 100644 --- a/cs/test/Ice/operations/TestAMD.ice +++ b/cs/test/Ice/operations/TestAMD.ice @@ -162,6 +162,8 @@ dictionary<MyStruct, MyEnum> MyStructMyEnumD; void opByteSOneway(ByteS s); + int opByteSOnewayCallCount(); + Ice::Context opContext(); void opDoubleMarshaling(double p1, DoubleS p2); diff --git a/java/src/Freeze/src/main/java/Freeze/MapInternal/MapI.java b/java/src/Freeze/src/main/java/Freeze/MapInternal/MapI.java index 389e935ed41..379f4d31c5b 100644 --- a/java/src/Freeze/src/main/java/Freeze/MapInternal/MapI.java +++ b/java/src/Freeze/src/main/java/Freeze/MapInternal/MapI.java @@ -1172,7 +1172,7 @@ public abstract class MapI<K, V> extends java.util.AbstractMap<K, V> IceInternal.BasicStream createWriteStream() { - return new IceInternal.BasicStream(IceInternal.Util.getInstance(_communicator), _encoding, true, false); + return new IceInternal.BasicStream(IceInternal.Util.getInstance(_communicator), _encoding, false); } IceInternal.BasicStream createReadStream(byte[] arr) diff --git a/java/src/Freeze/src/main/java/Freeze/ObjectStore.java b/java/src/Freeze/src/main/java/Freeze/ObjectStore.java index fcd3253dab0..76993b39655 100644 --- a/java/src/Freeze/src/main/java/Freeze/ObjectStore.java +++ b/java/src/Freeze/src/main/java/Freeze/ObjectStore.java @@ -295,8 +295,8 @@ class ObjectStore implements IceUtil.Store static com.sleepycat.db.DatabaseEntry marshalKey(Ice.Identity v, Ice.Communicator communicator, Ice.EncodingVersion encoding) { - IceInternal.BasicStream os = - new IceInternal.BasicStream(IceInternal.Util.getInstance(communicator), encoding, true, false); + IceInternal.BasicStream os = + new IceInternal.BasicStream(IceInternal.Util.getInstance(communicator), encoding, false); v.__write(os); return new com.sleepycat.db.DatabaseEntry(os.prepareWrite().b); } @@ -322,7 +322,7 @@ class ObjectStore implements IceUtil.Store marshalValue(ObjectRecord v, Ice.Communicator communicator, Ice.EncodingVersion encoding, boolean keepStats) { IceInternal.BasicStream os = - new IceInternal.BasicStream(IceInternal.Util.getInstance(communicator), encoding, true, false); + new IceInternal.BasicStream(IceInternal.Util.getInstance(communicator), encoding, false); os.startWriteEncaps(); if(keepStats) diff --git a/java/src/Ice/src/main/java/Ice/ConnectionI.java b/java/src/Ice/src/main/java/Ice/ConnectionI.java index c0b74d70bac..cfef2312b11 100644 --- a/java/src/Ice/src/main/java/Ice/ConnectionI.java +++ b/java/src/Ice/src/main/java/Ice/ConnectionI.java @@ -352,7 +352,7 @@ public final class ConnectionI extends IceInternal.EventHandler // Ensure the message isn't bigger than what we can send with the // transport. // - _transceiver.checkSendSize(os.getBuffer(), _instance.messageSizeMax()); + _transceiver.checkSendSize(os.getBuffer()); // // Notify the request that it's cancelable with this connection. @@ -469,8 +469,13 @@ public final class ConnectionI extends IceInternal.EventHandler } boolean flush = false; - if(_batchAutoFlush) + if(_batchAutoFlushSize > 0) { + if(_batchStream.size() > _batchAutoFlushSize) + { + flush = true; + } + // // Throw memory limit exception if the first message added // causes us to go over limit. Otherwise put aside the @@ -479,7 +484,7 @@ public final class ConnectionI extends IceInternal.EventHandler // try { - _transceiver.checkSendSize(_batchStream.getBuffer(), _instance.messageSizeMax()); + _transceiver.checkSendSize(_batchStream.getBuffer()); } catch(Ice.LocalException ex) { @@ -529,23 +534,12 @@ public final class ConnectionI extends IceInternal.EventHandler // // Reset the batch stream. // - _batchStream = new IceInternal.BasicStream(_instance, IceInternal.Protocol.currentProtocolEncoding, - _batchAutoFlush); + _batchStream = new IceInternal.BasicStream(_instance, IceInternal.Protocol.currentProtocolEncoding); _batchRequestNum = 0; _batchRequestCompress = false; _batchMarker = 0; // - // Check again if the last request doesn't exceed the - // maximum message size. - // - if(IceInternal.Protocol.requestBatchHdr.length + lastRequest.length > _instance.messageSizeMax()) - { - IceInternal.Ex.throwMemoryLimitException(IceInternal.Protocol.requestBatchHdr.length + - lastRequest.length, _instance.messageSizeMax()); - } - - // // Start a new batch with the last message that caused us to // go over the limit. // @@ -585,8 +579,7 @@ public final class ConnectionI extends IceInternal.EventHandler public synchronized void abortBatchRequest() { - _batchStream = new IceInternal.BasicStream(_instance, IceInternal.Protocol.currentProtocolEncoding, - _batchAutoFlush); + _batchStream = new IceInternal.BasicStream(_instance, IceInternal.Protocol.currentProtocolEncoding); _batchRequestNum = 0; _batchRequestCompress = false; _batchMarker = 0; @@ -714,8 +707,7 @@ public final class ConnectionI extends IceInternal.EventHandler // // Reset the batch stream. // - _batchStream = new IceInternal.BasicStream(_instance, IceInternal.Protocol.currentProtocolEncoding, - _batchAutoFlush); + _batchStream = new IceInternal.BasicStream(_instance, IceInternal.Protocol.currentProtocolEncoding); _batchRequestNum = 0; _batchRequestCompress = false; _batchMarker = 0; @@ -1667,9 +1659,8 @@ public final class ConnectionI extends IceInternal.EventHandler _acmLastActivity = -1; } _nextRequestId = 1; - _batchAutoFlush = initData.properties.getPropertyAsIntWithDefault("Ice.BatchAutoFlush", 1) > 0 ? true : false; - _batchStream = new IceInternal.BasicStream(instance, IceInternal.Protocol.currentProtocolEncoding, - _batchAutoFlush); + _batchAutoFlushSize = _instance.batchAutoFlushSize(); + _batchStream = new IceInternal.BasicStream(instance, IceInternal.Protocol.currentProtocolEncoding); _batchStreamInUse = false; _batchRequestNum = 0; _batchRequestCompress = false; @@ -3124,11 +3115,12 @@ public final class ConnectionI extends IceInternal.EventHandler private int _nextRequestId; - private java.util.Map<Integer, IceInternal.OutgoingAsync> _asyncRequests = new java.util.HashMap<Integer, IceInternal.OutgoingAsync>(); + private java.util.Map<Integer, IceInternal.OutgoingAsync> _asyncRequests = + new java.util.HashMap<Integer, IceInternal.OutgoingAsync>(); private LocalException _exception; - private boolean _batchAutoFlush; + private int _batchAutoFlushSize; private IceInternal.BasicStream _batchStream; private boolean _batchStreamInUse; private int _batchRequestNum; diff --git a/java/src/Ice/src/main/java/Ice/InputStreamI.java b/java/src/Ice/src/main/java/Ice/InputStreamI.java index a05e64de5ac..164be606e0a 100644 --- a/java/src/Ice/src/main/java/Ice/InputStreamI.java +++ b/java/src/Ice/src/main/java/Ice/InputStreamI.java @@ -31,7 +31,7 @@ public class InputStreamI implements InputStream { if(copyData) { - _is = new IceInternal.BasicStream(instance, v, true, false); + _is = new IceInternal.BasicStream(instance, v, false); _is.resize(data.length, true); IceInternal.Buffer buf = _is.getBuffer(); buf.b.position(0); diff --git a/java/src/Ice/src/main/java/Ice/OutputStreamI.java b/java/src/Ice/src/main/java/Ice/OutputStreamI.java index a5b8836c5cf..f3d3432056c 100644 --- a/java/src/Ice/src/main/java/Ice/OutputStreamI.java +++ b/java/src/Ice/src/main/java/Ice/OutputStreamI.java @@ -16,7 +16,7 @@ public class OutputStreamI implements OutputStream { _communicator = communicator; IceInternal.Instance instance = IceInternal.Util.getInstance(communicator); - _os = new IceInternal.BasicStream(instance, instance.defaultsAndOverrides().defaultEncoding, true, false); + _os = new IceInternal.BasicStream(instance, instance.defaultsAndOverrides().defaultEncoding, false); _os.closure(this); } @@ -25,7 +25,7 @@ public class OutputStreamI implements OutputStream { _communicator = communicator; IceInternal.Instance instance = IceInternal.Util.getInstance(communicator); - _os = new IceInternal.BasicStream(instance, v, true, false); + _os = new IceInternal.BasicStream(instance, v, false); _os.closure(this); } diff --git a/java/src/Ice/src/main/java/IceInternal/BasicStream.java b/java/src/Ice/src/main/java/IceInternal/BasicStream.java index ac2fcc3fdaa..b325cf0fb85 100644 --- a/java/src/Ice/src/main/java/IceInternal/BasicStream.java +++ b/java/src/Ice/src/main/java/IceInternal/BasicStream.java @@ -16,38 +16,32 @@ public class BasicStream public BasicStream(Instance instance, Ice.EncodingVersion encoding) { - this(instance, encoding, false); + this(instance, encoding, instance.cacheMessageBuffers() > 1); } public - BasicStream(Instance instance, Ice.EncodingVersion encoding, boolean unlimited) + BasicStream(Instance instance, Ice.EncodingVersion encoding, boolean direct) { - this(instance, encoding, unlimited, instance.cacheMessageBuffers() > 1); - } - - public - BasicStream(Instance instance, Ice.EncodingVersion encoding, boolean unlimited, boolean direct) - { - initialize(instance, encoding, unlimited); - _buf = new Buffer(_instance.messageSizeMax(), direct); + initialize(instance, encoding); + _buf = new Buffer(direct); } public BasicStream(Instance instance, Ice.EncodingVersion encoding, byte[] data) { - initialize(instance, encoding, true); + initialize(instance, encoding); _buf = new Buffer(data); } public BasicStream(Instance instance, Ice.EncodingVersion encoding, java.nio.ByteBuffer data) { - initialize(instance, encoding, true); + initialize(instance, encoding); _buf = new Buffer(data); } private void - initialize(Instance instance, Ice.EncodingVersion encoding, boolean unlimited) + initialize(Instance instance, Ice.EncodingVersion encoding) { _instance = instance; _closure = null; @@ -60,9 +54,6 @@ public class BasicStream _sliceObjects = true; - _messageSizeMax = _instance.messageSizeMax(); // Cached for efficiency. - _unlimited = unlimited; - _startSeq = -1; } @@ -144,10 +135,6 @@ public class BasicStream resetEncaps(); other.resetEncaps(); - boolean tmpUnlimited = other._unlimited; - other._unlimited = _unlimited; - _unlimited = tmpUnlimited; - int tmpStartSeq = other._startSeq; other._startSeq = _startSeq; _startSeq = tmpStartSeq; @@ -167,14 +154,6 @@ public class BasicStream public void resize(int sz, boolean reading) { - // - // Check memory limit if stream is not unlimited. - // - if(!_unlimited && sz > _messageSizeMax) - { - Ex.throwMemoryLimitException(sz, _messageSizeMax); - } - _buf.resize(sz, reading); _buf.b.position(sz); } @@ -2667,6 +2646,10 @@ public class BasicStream { throw new Ice.IllegalMessageSizeException(); } + if(uncompressedSize > _instance.messageSizeMax()) + { + IceInternal.Ex.throwMemoryLimitException(uncompressedSize, _instance.messageSizeMax()); + } int compressedLen = size() - headerSize - 4; @@ -2744,10 +2727,6 @@ public class BasicStream public void expand(int n) { - if(!_unlimited && _buf.b != null && _buf.b.position() + n > _messageSizeMax) - { - Ex.throwMemoryLimitException(_buf.b.position() + n, _messageSizeMax); - } _buf.expand(n); } @@ -4830,9 +4809,6 @@ public class BasicStream private boolean _sliceObjects; - private int _messageSizeMax; - private boolean _unlimited; - private int _startSeq; private int _minSeqSize; diff --git a/java/src/Ice/src/main/java/IceInternal/Buffer.java b/java/src/Ice/src/main/java/IceInternal/Buffer.java index fc7f88966c1..19dc5587a81 100644 --- a/java/src/Ice/src/main/java/IceInternal/Buffer.java +++ b/java/src/Ice/src/main/java/IceInternal/Buffer.java @@ -16,17 +16,16 @@ package IceInternal; public class Buffer { public - Buffer(int maxCapacity, boolean direct) + Buffer(boolean direct) { - this(maxCapacity, direct, java.nio.ByteOrder.LITTLE_ENDIAN); + this(direct, java.nio.ByteOrder.LITTLE_ENDIAN); } - Buffer(int maxCapacity, boolean direct, java.nio.ByteOrder order) + Buffer(boolean direct, java.nio.ByteOrder order) { b = _emptyBuffer; _size = 0; _capacity = 0; - _maxCapacity = maxCapacity; _direct = direct; _order = order; } @@ -42,7 +41,6 @@ public class Buffer b.order(order); _size = data.length; _capacity = 0; - _maxCapacity = 0; _direct = false; _order = order; } @@ -58,7 +56,6 @@ public class Buffer b.order(order); _size = data.remaining(); _capacity = 0; - _maxCapacity = 0; _direct = false; _order = order; } @@ -157,7 +154,7 @@ public class Buffer { if(n > _capacity) { - _capacity = java.lang.Math.max(n, java.lang.Math.min(2 * _capacity, _maxCapacity)); + _capacity = java.lang.Math.max(n, 2 * _capacity); _capacity = java.lang.Math.max(240, _capacity); } else if(n < _capacity) @@ -212,7 +209,6 @@ public class Buffer private int _size; private int _capacity; // Cache capacity to avoid excessive method calls. - private int _maxCapacity; private boolean _direct; // Use direct buffers? private int _shrinkCounter; private java.nio.ByteOrder _order; diff --git a/java/src/Ice/src/main/java/IceInternal/CollocatedRequestHandler.java b/java/src/Ice/src/main/java/IceInternal/CollocatedRequestHandler.java index bd882384441..931a04cb1f2 100644 --- a/java/src/Ice/src/main/java/IceInternal/CollocatedRequestHandler.java +++ b/java/src/Ice/src/main/java/IceInternal/CollocatedRequestHandler.java @@ -48,12 +48,11 @@ public class CollocatedRequestHandler implements RequestHandler, ResponseHandler _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 = new BasicStream(ref.getInstance(), Protocol.currentProtocolEncoding, _batchAutoFlush); + _batchStream = new BasicStream(ref.getInstance(), Protocol.currentProtocolEncoding); } @Override @@ -102,7 +101,7 @@ public class CollocatedRequestHandler implements RequestHandler, ResponseHandler { _batchStream.swap(os); - if(_batchAutoFlush & (_batchStream.size() > _reference.getInstance().messageSizeMax())) + if(_batchAutoFlushSize > 0 && (_batchStream.size() > _batchAutoFlushSize)) { // // Temporarily save the last request. @@ -115,8 +114,7 @@ public class CollocatedRequestHandler implements RequestHandler, ResponseHandler final int invokeNum = _batchRequestNum; final BasicStream stream = new BasicStream(_reference.getInstance(), - Protocol.currentProtocolEncoding, - _batchAutoFlush); + Protocol.currentProtocolEncoding); stream.swap(_batchStream); _adapter.getThreadPool().dispatch( @@ -137,15 +135,6 @@ public class CollocatedRequestHandler implements RequestHandler, ResponseHandler _batchMarker = 0; // - // Check again if the last request doesn't exceed what we can send with the auto flush - // - if(Protocol.requestBatchHdr.length + lastRequest.length > _reference.getInstance().messageSizeMax()) - { - Ex.throwMemoryLimitException(Protocol.requestBatchHdr.length + lastRequest.length, - _reference.getInstance().messageSizeMax()); - } - - // // Start a new batch with the last message that caused us to go over the limit. // _batchStream.writeBlob(Protocol.requestBatchHdr); @@ -172,8 +161,7 @@ public class CollocatedRequestHandler implements RequestHandler, ResponseHandler synchronized public void abortBatchRequest() { - BasicStream dummy = new BasicStream(_reference.getInstance(), Protocol.currentProtocolEncoding, - _batchAutoFlush); + BasicStream dummy = new BasicStream(_reference.getInstance(), Protocol.currentProtocolEncoding); _batchStream.swap(dummy); _batchRequestNum = 0; _batchMarker = 0; @@ -380,8 +368,7 @@ public class CollocatedRequestHandler implements RequestHandler, ResponseHandler // // Reset the batch stream. // - BasicStream dummy = new BasicStream(_reference.getInstance(), Protocol.currentProtocolEncoding, - _batchAutoFlush); + BasicStream dummy = new BasicStream(_reference.getInstance(), Protocol.currentProtocolEncoding); _batchStream.swap(dummy); _batchRequestNum = 0; _batchMarker = 0; @@ -567,7 +554,7 @@ public class CollocatedRequestHandler implements RequestHandler, ResponseHandler private final Ice.ObjectAdapterI _adapter; private final Ice.Logger _logger; private final TraceLevels _traceLevels; - private boolean _batchAutoFlush; + private int _batchAutoFlushSize; private int _requestId; diff --git a/java/src/Ice/src/main/java/IceInternal/ConnectRequestHandler.java b/java/src/Ice/src/main/java/IceInternal/ConnectRequestHandler.java index 16158b23106..a89e5d5a5b2 100644 --- a/java/src/Ice/src/main/java/IceInternal/ConnectRequestHandler.java +++ b/java/src/Ice/src/main/java/IceInternal/ConnectRequestHandler.java @@ -119,13 +119,6 @@ public class ConnectRequestHandler _batchStream.swap(os); - if(!_batchAutoFlush && - _batchStream.size() + _batchRequestsSize > _reference.getInstance().messageSizeMax()) - { - Ex.throwMemoryLimitException(_batchStream.size() + _batchRequestsSize, - _reference.getInstance().messageSizeMax()); - } - _requests.add(new Request(_batchStream)); return; } @@ -145,10 +138,8 @@ public class ConnectRequestHandler _batchRequestInProgress = false; notifyAll(); - BasicStream dummy = new BasicStream(_reference.getInstance(), Protocol.currentProtocolEncoding, - _batchAutoFlush); + BasicStream dummy = new BasicStream(_reference.getInstance(), Protocol.currentProtocolEncoding); _batchStream.swap(dummy); - _batchRequestsSize = Protocol.requestBatchHdr.length; return; } @@ -338,13 +329,10 @@ public class ConnectRequestHandler _connect = true; _response = _reference.getMode() == Reference.ModeTwoway; _proxy = (Ice.ObjectPrxHelperBase)proxy; - _batchAutoFlush = ref.getInstance().initializationData().properties.getPropertyAsIntWithDefault( - "Ice.BatchAutoFlush", 1) > 0 ? true : false; _initialized = false; _flushing = false; _batchRequestInProgress = false; - _batchRequestsSize = Protocol.requestBatchHdr.length; - _batchStream = new BasicStream(ref.getInstance(), Protocol.currentProtocolEncoding, _batchAutoFlush); + _batchStream = new BasicStream(ref.getInstance(), Protocol.currentProtocolEncoding); } private boolean @@ -560,8 +548,6 @@ public class ConnectRequestHandler private Ice.ObjectPrxHelperBase _proxy; private java.util.Set<Ice.ObjectPrxHelperBase> _proxies = new java.util.HashSet<Ice.ObjectPrxHelperBase>(); - private final boolean _batchAutoFlush; - private Ice.ConnectionI _connection; private boolean _compress; private Ice.LocalException _exception; @@ -570,7 +556,6 @@ public class ConnectRequestHandler private java.util.List<Request> _requests = new java.util.LinkedList<Request>(); private boolean _batchRequestInProgress; - private int _batchRequestsSize; private BasicStream _batchStream; private RequestHandler _connectionRequestHandler; diff --git a/java/src/Ice/src/main/java/IceInternal/EndpointFactoryManager.java b/java/src/Ice/src/main/java/IceInternal/EndpointFactoryManager.java index a0b2b1511d2..ef1b5646e4d 100644 --- a/java/src/Ice/src/main/java/IceInternal/EndpointFactoryManager.java +++ b/java/src/Ice/src/main/java/IceInternal/EndpointFactoryManager.java @@ -127,7 +127,7 @@ public final class EndpointFactoryManager // and ask the factory to read the endpoint data from that stream to create // the actual endpoint. // - BasicStream bs = new BasicStream(_instance, Protocol.currentProtocolEncoding, true, false); + BasicStream bs = new BasicStream(_instance, Protocol.currentProtocolEncoding, false); bs.writeShort(ue.type()); ue.streamWrite(bs); Buffer buf = bs.getBuffer(); diff --git a/java/src/Ice/src/main/java/IceInternal/Instance.java b/java/src/Ice/src/main/java/IceInternal/Instance.java index 0160d6564d4..8085635ad04 100644 --- a/java/src/Ice/src/main/java/IceInternal/Instance.java +++ b/java/src/Ice/src/main/java/IceInternal/Instance.java @@ -396,6 +396,13 @@ public final class Instance } public int + batchAutoFlushSize() + { + // No mutex lock, immutable. + return _batchAutoFlushSize; + } + + public int cacheMessageBuffers() { // No mutex lock, immutable. @@ -899,6 +906,34 @@ public final class Instance } } + if(_initData.properties.getProperty("Ice.BatchAutoFlushSize").isEmpty() && + !_initData.properties.getProperty("Ice.BatchAutoFlush").isEmpty()) + { + if(_initData.properties.getPropertyAsInt("Ice.BatchAutoFlush") > 0) + { + _batchAutoFlushSize = _messageSizeMax; + } + else + { + _batchAutoFlushSize = 0; + } + } + else + { + int num = _initData.properties.getPropertyAsIntWithDefault("Ice.BatchAutoFlushSize", 1024); // 1MB + if(num < 1) + { + _batchAutoFlushSize = num; + } + else if(num > 0x7fffffff / 1024) + { + _batchAutoFlushSize = 0x7fffffff; + } + else + { + _batchAutoFlushSize = num * 1024; // Property is in kilobytes, _batchAutoFlushSize in bytes + } + } _implicitContext = Ice.ImplicitContextI.create(_initData.properties.getProperty("Ice.ImplicitContext")); @@ -1612,6 +1647,7 @@ public final class Instance private final TraceLevels _traceLevels; // Immutable, not reset by destroy(). private final DefaultsAndOverrides _defaultsAndOverrides; // Immutable, not reset by destroy(). private final int _messageSizeMax; // Immutable, not reset by destroy(). + private final int _batchAutoFlushSize; // Immutable, not reset by destroy(). private final int _cacheMessageBuffers; // Immutable, not reset by destroy(). private final ACMConfig _clientACM; // Immutable, not reset by destroy(). private final ACMConfig _serverACM; // Immutable, not reset by destroy(). diff --git a/java/src/Ice/src/main/java/IceInternal/PropertyNames.java b/java/src/Ice/src/main/java/IceInternal/PropertyNames.java index c7800e61d62..32eba2e3ff8 100644 --- a/java/src/Ice/src/main/java/IceInternal/PropertyNames.java +++ b/java/src/Ice/src/main/java/IceInternal/PropertyNames.java @@ -6,7 +6,7 @@ // ICE_LICENSE file included in this distribution. // // ********************************************************************** -// Generated by makeprops.py from file ../config/PropertyNames.xml, Thu Oct 9 11:53:58 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! @@ -75,7 +75,8 @@ public final class PropertyNames new Property("Ice\\.Admin\\.Logger\\.Properties", false, null), new Property("Ice\\.Admin\\.ServerId", false, null), new Property("Ice\\.BackgroundLocatorCacheUpdates", false, null), - new Property("Ice\\.BatchAutoFlush", false, null), + new Property("Ice\\.BatchAutoFlush", true, null), + new Property("Ice\\.BatchAutoFlushSize", false, null), new Property("Ice\\.ChangeUser", false, null), new Property("Ice\\.ClientAccessPolicyProtocol", false, null), new Property("Ice\\.Compression\\.Level", false, null), @@ -934,11 +935,8 @@ public final class PropertyNames new Property("IcePatch2\\.ThreadPool\\.Serialize", false, null), new Property("IcePatch2\\.ThreadPool\\.ThreadIdleTime", false, null), new Property("IcePatch2\\.ThreadPool\\.ThreadPriority", false, null), - new Property("IcePatch2\\.ChunkSize", true, "IcePatch2Client.ChunkSize"), new Property("IcePatch2\\.Directory", false, null), new Property("IcePatch2\\.InstanceName", false, null), - new Property("IcePatch2\\.Remove", true, "IcePatch2Client.Remove"), - new Property("IcePatch2\\.Thorough", true, "IcePatch2Client.Thorough"), null }; diff --git a/java/src/Ice/src/main/java/IceInternal/TcpTransceiver.java b/java/src/Ice/src/main/java/IceInternal/TcpTransceiver.java index 5e8d33fb672..b58f9d03677 100644 --- a/java/src/Ice/src/main/java/IceInternal/TcpTransceiver.java +++ b/java/src/Ice/src/main/java/IceInternal/TcpTransceiver.java @@ -94,12 +94,8 @@ final class TcpTransceiver implements Transceiver } @Override - public void checkSendSize(Buffer buf, int messageSizeMax) + public void checkSendSize(Buffer buf) { - if(buf.size() > messageSizeMax) - { - Ex.throwMemoryLimitException(buf.size(), messageSizeMax); - } } TcpTransceiver(ProtocolInstance instance, StreamSocket stream) diff --git a/java/src/Ice/src/main/java/IceInternal/Transceiver.java b/java/src/Ice/src/main/java/IceInternal/Transceiver.java index f9889df74f8..f40444e84c9 100644 --- a/java/src/Ice/src/main/java/IceInternal/Transceiver.java +++ b/java/src/Ice/src/main/java/IceInternal/Transceiver.java @@ -26,5 +26,5 @@ public interface Transceiver String toString(); String toDetailedString(); Ice.ConnectionInfo getInfo(); - void checkSendSize(Buffer buf, int messageSizeMax); + void checkSendSize(Buffer buf); } diff --git a/java/src/Ice/src/main/java/IceInternal/UdpTransceiver.java b/java/src/Ice/src/main/java/IceInternal/UdpTransceiver.java index c8de356ea6e..e0690efacd9 100644 --- a/java/src/Ice/src/main/java/IceInternal/UdpTransceiver.java +++ b/java/src/Ice/src/main/java/IceInternal/UdpTransceiver.java @@ -325,13 +325,8 @@ final class UdpTransceiver implements Transceiver } @Override - public void checkSendSize(Buffer buf, int messageSizeMax) + public void checkSendSize(Buffer buf) { - if(buf.size() > messageSizeMax) - { - Ex.throwMemoryLimitException(buf.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/java/src/Ice/src/main/java/IceInternal/WSTransceiver.java b/java/src/Ice/src/main/java/IceInternal/WSTransceiver.java index 43560c51945..7451d818389 100644 --- a/java/src/Ice/src/main/java/IceInternal/WSTransceiver.java +++ b/java/src/Ice/src/main/java/IceInternal/WSTransceiver.java @@ -482,9 +482,9 @@ final class WSTransceiver implements Transceiver } @Override - public void checkSendSize(Buffer buf, int messageSizeMax) + public void checkSendSize(Buffer buf) { - _delegate.checkSendSize(buf, messageSizeMax); + _delegate.checkSendSize(buf); } WSTransceiver(ProtocolInstance instance, Transceiver del, String host, int port, String resource) @@ -532,7 +532,7 @@ final class WSTransceiver implements Transceiver _state = StateInitializeDelegate; _parser = new HttpParser(); _readState = ReadStateOpcode; - _readBuffer = new Buffer(0, false, java.nio.ByteOrder.BIG_ENDIAN); // Use network byte order. + _readBuffer = new Buffer(false, java.nio.ByteOrder.BIG_ENDIAN); // Use network byte order. _readBufferSize = 1024; _readLastFrame = false; _readOpCode = 0; @@ -540,7 +540,7 @@ final class WSTransceiver implements Transceiver _readPayloadLength = 0; _readMask = new byte[4]; _writeState = WriteStateHeader; - _writeBuffer = new Buffer(0, false, java.nio.ByteOrder.BIG_ENDIAN); // Use network byte order. + _writeBuffer = new Buffer(false, java.nio.ByteOrder.BIG_ENDIAN); // Use network byte order. _writeBufferSize = 1024; _readMask = new byte[4]; _writeMask = new byte[4]; diff --git a/java/src/Ice/src/main/java/IceSSL/TransceiverI.java b/java/src/Ice/src/main/java/IceSSL/TransceiverI.java index c2a63efaf0b..937d6cea068 100644 --- a/java/src/Ice/src/main/java/IceSSL/TransceiverI.java +++ b/java/src/Ice/src/main/java/IceSSL/TransceiverI.java @@ -249,12 +249,8 @@ final class TransceiverI implements IceInternal.Transceiver } @Override - public void checkSendSize(IceInternal.Buffer buf, int messageSizeMax) + public void checkSendSize(IceInternal.Buffer buf) { - if(buf.size() > messageSizeMax) - { - IceInternal.Ex.throwMemoryLimitException(buf.size(), messageSizeMax); - } } TransceiverI(Instance instance, javax.net.ssl.SSLEngine engine, IceInternal.StreamSocket stream, String host, diff --git a/java/test/src/main/java/test/Ice/background/Transceiver.java b/java/test/src/main/java/test/Ice/background/Transceiver.java index 738c7ef1f10..bba1f011335 100644 --- a/java/test/src/main/java/test/Ice/background/Transceiver.java +++ b/java/test/src/main/java/test/Ice/background/Transceiver.java @@ -174,9 +174,9 @@ final class Transceiver implements IceInternal.Transceiver @Override public void - checkSendSize(IceInternal.Buffer buf, int messageSizeMax) + checkSendSize(IceInternal.Buffer buf) { - _transceiver.checkSendSize(buf, messageSizeMax); + _transceiver.checkSendSize(buf); } public IceInternal.Transceiver @@ -194,7 +194,7 @@ final class Transceiver implements IceInternal.Transceiver _configuration = configuration; _initialized = false; _buffered = _configuration.buffered(); - _readBuffer = new IceInternal.Buffer(100 * 1024, false); + _readBuffer = new IceInternal.Buffer(false); _readBuffer.resize(1024 * 8, true); // 8KB buffer _readBufferPos = 0; } diff --git a/java/test/src/main/java/test/Ice/exceptions/AMDServer.java b/java/test/src/main/java/test/Ice/exceptions/AMDServer.java index afd5450bffc..2863c0fa5dc 100644 --- a/java/test/src/main/java/test/Ice/exceptions/AMDServer.java +++ b/java/test/src/main/java/test/Ice/exceptions/AMDServer.java @@ -34,6 +34,7 @@ public class AMDServer extends test.Util.Application initData.properties = Ice.Util.createProperties(argsH); initData.properties.setProperty("Ice.Warn.Dispatch", "0"); + initData.properties.setProperty("Ice.Warn.Connections", "0"); initData.properties.setProperty("Ice.Package.Test", "test.Ice.exceptions.AMD"); initData.properties.setProperty("TestAdapter.Endpoints", "default -p 12010:udp"); initData.properties.setProperty("Ice.MessageSizeMax", "10"); // 10KB max diff --git a/java/test/src/main/java/test/Ice/exceptions/AllTests.java b/java/test/src/main/java/test/Ice/exceptions/AllTests.java index 7d68606047e..e66e96cbda5 100644 --- a/java/test/src/main/java/test/Ice/exceptions/AllTests.java +++ b/java/test/src/main/java/test/Ice/exceptions/AllTests.java @@ -1103,28 +1103,15 @@ public class AllTests out.println("ok"); } - out.print("testing memory limit marshal exception..."); - out.flush(); + if(thrower.ice_getConnection() != null) { + out.print("testing memory limit marshal exception..."); + out.flush(); try { thrower.throwMemoryLimitException(null); test(false); } - catch(Ice.UnknownLocalException ex) - { - } - catch(Throwable ex) - { - ex.printStackTrace(); - test(false); - } - - try - { - thrower.throwMemoryLimitException(new byte[20 * 1024]); // 20KB - test(false); - } catch(Ice.MemoryLimitException ex) { } @@ -1136,11 +1123,10 @@ public class AllTests try { - thrower.end_throwMemoryLimitException( - thrower.begin_throwMemoryLimitException(new byte[20 * 1024])); // 20KB + thrower.throwMemoryLimitException(new byte[20 * 1024]); // 20KB test(false); } - catch(Ice.MemoryLimitException ex) + catch(Ice.ConnectionLostException ex) { } catch(Throwable ex) @@ -1148,8 +1134,8 @@ public class AllTests ex.printStackTrace(); test(false); } + out.println("ok"); } - out.println("ok"); out.print("catching object not exist exception... "); out.flush(); diff --git a/java/test/src/main/java/test/Ice/exceptions/Collocated.java b/java/test/src/main/java/test/Ice/exceptions/Collocated.java index b85ca002b94..2ba65669947 100644 --- a/java/test/src/main/java/test/Ice/exceptions/Collocated.java +++ b/java/test/src/main/java/test/Ice/exceptions/Collocated.java @@ -37,6 +37,7 @@ public class Collocated extends test.Util.Application initData.properties = Ice.Util.createProperties(argsH); initData.properties.setProperty("Ice.Warn.Dispatch", "0"); + initData.properties.setProperty("Ice.Warn.Connections", "0"); initData.properties.setProperty("Ice.Package.Test", "test.Ice.exceptions"); initData.properties.setProperty("Ice.MessageSizeMax", "10"); // 10KB max initData.properties.setProperty("TestAdapter.Endpoints", "default -p 12010"); diff --git a/java/test/src/main/java/test/Ice/exceptions/Server.java b/java/test/src/main/java/test/Ice/exceptions/Server.java index 539ac3bc304..6ecdc901099 100644 --- a/java/test/src/main/java/test/Ice/exceptions/Server.java +++ b/java/test/src/main/java/test/Ice/exceptions/Server.java @@ -34,6 +34,7 @@ public class Server extends test.Util.Application initData.properties = Ice.Util.createProperties(argsH); initData.properties.setProperty("Ice.Warn.Dispatch", "0"); + initData.properties.setProperty("Ice.Warn.Connections", "0"); initData.properties.setProperty("Ice.Package.Test", "test.Ice.exceptions"); initData.properties.setProperty("TestAdapter.Endpoints", "default -p 12010:udp"); initData.properties.setProperty("Ice.MessageSizeMax", "10"); // 10KB max diff --git a/java/test/src/main/java/test/Ice/operations/AMDMyDerivedClassI.java b/java/test/src/main/java/test/Ice/operations/AMDMyDerivedClassI.java index f577db345c1..68b2373f090 100644 --- a/java/test/src/main/java/test/Ice/operations/AMDMyDerivedClassI.java +++ b/java/test/src/main/java/test/Ice/operations/AMDMyDerivedClassI.java @@ -16,6 +16,7 @@ import test.Ice.operations.AMD.Test.AMD_MyClass_opByte; import test.Ice.operations.AMD.Test.AMD_MyClass_opByteBoolD; import test.Ice.operations.AMD.Test.AMD_MyClass_opByteS; import test.Ice.operations.AMD.Test.AMD_MyClass_opByteSOneway; +import test.Ice.operations.AMD.Test.AMD_MyClass_opByteSOnewayCallCount; import test.Ice.operations.AMD.Test.AMD_MyClass_opByteSS; import test.Ice.operations.AMD.Test.AMD_MyClass_opContext; import test.Ice.operations.AMD.Test.AMD_MyClass_opDoubleMarshaling; @@ -479,13 +480,23 @@ public final class AMDMyDerivedClassI extends MyDerivedClass } @Override - public void + public synchronized void opByteSOneway_async(AMD_MyClass_opByteSOneway cb, byte[] s, Ice.Current current) { + ++_opByteSOnewayCallCount; cb.ice_response(); } @Override + public synchronized void + opByteSOnewayCallCount_async(AMD_MyClass_opByteSOnewayCallCount cb, Ice.Current current) + { + int count = _opByteSOnewayCallCount; + _opByteSOnewayCallCount = 0; + cb.ice_response(count); + } + + @Override public void opContext_async(AMD_MyClass_opContext cb, Ice.Current current) { @@ -610,4 +621,5 @@ public final class AMDMyDerivedClassI extends MyDerivedClass } private Thread _opVoidThread; + private int _opByteSOnewayCallCount = 0; } diff --git a/java/test/src/main/java/test/Ice/operations/AMDTieMyDerivedClassI.java b/java/test/src/main/java/test/Ice/operations/AMDTieMyDerivedClassI.java index 8d2e26b48d1..fdca9ccf99d 100644 --- a/java/test/src/main/java/test/Ice/operations/AMDTieMyDerivedClassI.java +++ b/java/test/src/main/java/test/Ice/operations/AMDTieMyDerivedClassI.java @@ -16,6 +16,7 @@ import test.Ice.operations.AMD.Test.AMD_MyClass_opByte; import test.Ice.operations.AMD.Test.AMD_MyClass_opByteBoolD; import test.Ice.operations.AMD.Test.AMD_MyClass_opByteS; import test.Ice.operations.AMD.Test.AMD_MyClass_opByteSOneway; +import test.Ice.operations.AMD.Test.AMD_MyClass_opByteSOnewayCallCount; import test.Ice.operations.AMD.Test.AMD_MyClass_opByteSS; import test.Ice.operations.AMD.Test.AMD_MyClass_opContext; import test.Ice.operations.AMD.Test.AMD_MyClass_opDoubleMarshaling; @@ -443,13 +444,23 @@ public final class AMDTieMyDerivedClassI implements _MyDerivedClassOperations } @Override - public void + public synchronized void opByteSOneway_async(AMD_MyClass_opByteSOneway cb, byte[] s, Ice.Current current) { + ++_opByteSOnewayCallCount; cb.ice_response(); } @Override + public synchronized void + opByteSOnewayCallCount_async(AMD_MyClass_opByteSOnewayCallCount cb, Ice.Current current) + { + int count = _opByteSOnewayCallCount; + _opByteSOnewayCallCount = 0; + cb.ice_response(count); + } + + @Override public void opContext_async(AMD_MyClass_opContext cb, Ice.Current current) { @@ -574,4 +585,5 @@ public final class AMDTieMyDerivedClassI implements _MyDerivedClassOperations } private Thread _opVoidThread; + private int _opByteSOnewayCallCount = 0; } diff --git a/java/test/src/main/java/test/Ice/operations/BatchOneways.java b/java/test/src/main/java/test/Ice/operations/BatchOneways.java index fc20955e9d2..b5498c53b17 100644 --- a/java/test/src/main/java/test/Ice/operations/BatchOneways.java +++ b/java/test/src/main/java/test/Ice/operations/BatchOneways.java @@ -30,7 +30,6 @@ class BatchOneways { final byte[] bs1 = new byte[10 * 1024]; final byte[] bs2 = new byte[99 * 1024]; - final byte[] bs3 = new byte[100 * 1024]; try { @@ -50,18 +49,11 @@ class BatchOneways test(false); } - try - { - p.opByteSOneway(bs3); - test(false); - } - catch(Ice.MemoryLimitException ex) - { - } - MyClassPrx batch = MyClassPrxHelper.uncheckedCast(p.ice_batchOneway()); batch.ice_flushBatchRequests(); + p.opByteSOnewayCallCount(); // Reset the call count + for(int i = 0 ; i < 30 ; ++i) { try @@ -74,6 +66,19 @@ class BatchOneways } } + int count = 0; + while(count != 27) // 3 * 9 requests auto-flushed. + { + count += p.opByteSOnewayCallCount(); + try + { + Thread.sleep(10); + } + catch(InterruptedException ex) + { + } + } + if(batch.ice_getConnection() != null) { batch.ice_getConnection().flushBatchRequests(); diff --git a/java/test/src/main/java/test/Ice/operations/BatchOnewaysAMI.java b/java/test/src/main/java/test/Ice/operations/BatchOnewaysAMI.java index f11df72b019..a4188ff13ce 100644 --- a/java/test/src/main/java/test/Ice/operations/BatchOnewaysAMI.java +++ b/java/test/src/main/java/test/Ice/operations/BatchOnewaysAMI.java @@ -63,7 +63,6 @@ class BatchOnewaysAMI { final byte[] bs1 = new byte[10 * 1024]; final byte[] bs2 = new byte[99 * 1024]; - final byte[] bs3 = new byte[100 * 1024]; final Callback cb = new Callback(); p.begin_opByteSOneway(bs1, new Callback_MyClass_opByteSOneway() @@ -97,23 +96,6 @@ class BatchOnewaysAMI }); cb.check(); - p.begin_opByteSOneway(bs3, new Callback_MyClass_opByteSOneway() - { - @Override - public void exception(LocalException ex) - { - test(ex instanceof Ice.MemoryLimitException); - cb.called(); - } - - @Override - public void response() - { - test(false); - } - }); - cb.check(); - MyClassPrx batch = MyClassPrxHelper.uncheckedCast(p.ice_batchOneway()); batch.end_ice_flushBatchRequests(batch.begin_ice_flushBatchRequests()); diff --git a/java/test/src/main/java/test/Ice/operations/Client.java b/java/test/src/main/java/test/Ice/operations/Client.java index 2c957a13e34..f0177c41adb 100644 --- a/java/test/src/main/java/test/Ice/operations/Client.java +++ b/java/test/src/main/java/test/Ice/operations/Client.java @@ -43,12 +43,7 @@ public class Client extends test.Util.Application initData.properties.setProperty("Ice.ThreadPool.Client.Size", "2"); initData.properties.setProperty("Ice.ThreadPool.Client.SizeWarn", "0"); initData.properties.setProperty("Ice.Package.Test", "test.Ice.operations"); - // - // 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"); return initData; } diff --git a/java/test/src/main/java/test/Ice/operations/Collocated.java b/java/test/src/main/java/test/Ice/operations/Collocated.java index 8f04dd42052..276eed6e03a 100644 --- a/java/test/src/main/java/test/Ice/operations/Collocated.java +++ b/java/test/src/main/java/test/Ice/operations/Collocated.java @@ -41,12 +41,7 @@ public class Collocated extends test.Util.Application } initData.properties.setProperty("Ice.Package.Test", "test.Ice.operations"); - // - // 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"); // // Its possible to have batch oneway requests dispatched diff --git a/java/test/src/main/java/test/Ice/operations/MyDerivedClassI.java b/java/test/src/main/java/test/Ice/operations/MyDerivedClassI.java index 5fddb73a3d5..5d55088c270 100644 --- a/java/test/src/main/java/test/Ice/operations/MyDerivedClassI.java +++ b/java/test/src/main/java/test/Ice/operations/MyDerivedClassI.java @@ -424,9 +424,19 @@ public final class MyDerivedClassI extends MyDerivedClass } @Override - public void + public synchronized void opByteSOneway(byte[] s, Ice.Current current) { + ++_opByteSOnewayCallCount; + } + + @Override + public synchronized int + opByteSOnewayCallCount(Ice.Current current) + { + int count = _opByteSOnewayCallCount; + _opByteSOnewayCallCount = 0; + return count; } @Override @@ -544,4 +554,6 @@ public final class MyDerivedClassI extends MyDerivedClass opDerived(Ice.Current current) { } + + private int _opByteSOnewayCallCount = 0; } diff --git a/java/test/src/main/java/test/Ice/operations/Test.ice b/java/test/src/main/java/test/Ice/operations/Test.ice index 38ab55f5909..a62fa2585a5 100644 --- a/java/test/src/main/java/test/Ice/operations/Test.ice +++ b/java/test/src/main/java/test/Ice/operations/Test.ice @@ -163,6 +163,8 @@ class MyClass void opByteSOneway(ByteS s); + int opByteSOnewayCallCount(); + Ice::Context opContext(); void opDoubleMarshaling(double p1, DoubleS p2); diff --git a/java/test/src/main/java/test/Ice/operations/TestAMD.ice b/java/test/src/main/java/test/Ice/operations/TestAMD.ice index edcb970b236..a5eaedcd78f 100644 --- a/java/test/src/main/java/test/Ice/operations/TestAMD.ice +++ b/java/test/src/main/java/test/Ice/operations/TestAMD.ice @@ -162,6 +162,8 @@ dictionary<MyStruct, MyEnum> MyStructMyEnumD; IntS opIntS(IntS s); void opByteSOneway(ByteS s); + + int opByteSOnewayCallCount(); Ice::Context opContext(); diff --git a/java/test/src/main/java/test/Ice/operations/TieMyDerivedClassI.java b/java/test/src/main/java/test/Ice/operations/TieMyDerivedClassI.java index cbd7a833f15..b3a849ac655 100644 --- a/java/test/src/main/java/test/Ice/operations/TieMyDerivedClassI.java +++ b/java/test/src/main/java/test/Ice/operations/TieMyDerivedClassI.java @@ -388,9 +388,19 @@ public final class TieMyDerivedClassI implements _MyDerivedClassOperations } @Override - public void + public synchronized void opByteSOneway(byte[] s, Ice.Current current) { + ++_opByteSOnewayCallCount; + } + + @Override + public synchronized int + opByteSOnewayCallCount(Ice.Current current) + { + int count = _opByteSOnewayCallCount; + _opByteSOnewayCallCount = 0; + return count; } @Override @@ -508,4 +518,6 @@ public final class TieMyDerivedClassI implements _MyDerivedClassOperations opDerived(Ice.Current current) { } + + private int _opByteSOnewayCallCount = 0; } diff --git a/js/src/Ice/AsyncResult.js b/js/src/Ice/AsyncResult.js index 082b73b689a..dc87e74f18e 100644 --- a/js/src/Ice/AsyncResult.js +++ b/js/src/Ice/AsyncResult.js @@ -41,7 +41,7 @@ var AsyncResult = Ice.Class(AsyncResultBase, { this._completed = completedFn; this._is = null; - this._os = com !== null ? new BasicStream(this._instance, Protocol.currentProtocolEncoding, false) : null; + this._os = com !== null ? new BasicStream(this._instance, Protocol.currentProtocolEncoding) : null; this._state = 0; this._exception = null; this._sentSynchronously = false; diff --git a/js/src/Ice/BasicStream.js b/js/src/Ice/BasicStream.js index 1fd7eae3567..3328cc3a727 100644 --- a/js/src/Ice/BasicStream.js +++ b/js/src/Ice/BasicStream.js @@ -1626,7 +1626,7 @@ var WriteEncaps = Class({ }); var BasicStream = Class({ - __init__: function(instance, encoding, unlimited, data) + __init__: function(instance, encoding, data) { this._instance = instance; this._closure = null; @@ -1639,9 +1639,6 @@ var BasicStream = Class({ this._sliceObjects = true; - this._messageSizeMax = this._instance.messageSizeMax(); // Cached for efficiency. - this._unlimited = unlimited !== undefined ? unlimited : false; - this._startSeq = -1; this._sizePos = -1; @@ -1689,7 +1686,7 @@ var BasicStream = Class({ { Debug.assert(this._instance === other._instance); - var tmpBuf, tmpClosure, tmpUnlimited, tmpStartSeq, tmpMinSeqSize, tmpSizePos; + var tmpBuf, tmpClosure, tmpStartSeq, tmpMinSeqSize, tmpSizePos; tmpBuf = other._buf; other._buf = this._buf; @@ -1707,10 +1704,6 @@ var BasicStream = Class({ this.resetEncaps(); other.resetEncaps(); - tmpUnlimited = other._unlimited; - other._unlimited = this._unlimited; - this._unlimited = tmpUnlimited; - tmpStartSeq = other._startSeq; other._startSeq = this._startSeq; this._startSeq = tmpStartSeq; @@ -1730,14 +1723,6 @@ var BasicStream = Class({ }, resize: function(sz) { - // - // Check memory limit if stream is not unlimited. - // - if(!this._unlimited && sz > this._messageSizeMax) - { - ExUtil.throwMemoryLimitException(sz, this._messageSizeMax); - } - this._buf.resize(sz); this._buf.position = sz; }, @@ -2758,10 +2743,6 @@ var BasicStream = Class({ }, expand: function(n) { - if(!this._unlimited && this._buf && this._buf.position + n > this._messageSizeMax) - { - ExUtil.throwMemoryLimitException(this._buf.position + n, this._messageSizeMax); - } this._buf.expand(n); }, createObject: function(id) diff --git a/js/src/Ice/ConnectRequestHandler.js b/js/src/Ice/ConnectRequestHandler.js index 62d7210d8cf..9bbd94e9610 100644 --- a/js/src/Ice/ConnectRequestHandler.js +++ b/js/src/Ice/ConnectRequestHandler.js @@ -46,13 +46,9 @@ var ConnectRequestHandler = Ice.Class({ this._response = ref.getMode() === ReferenceMode.ModeTwoway; this._proxy = proxy; this._proxies = []; - this._batchAutoFlush = ref.getInstance().initializationData().properties.getPropertyAsIntWithDefault( - "Ice.BatchAutoFlush", 1) > 0 ? true : false; this._initialized = false; this._batchRequestInProgress = false; - this._batchRequestsSize = Protocol.requestBatchHdr.length; - this._batchStream = - new BasicStream(ref.getInstance(), Protocol.currentProtocolEncoding, this._batchAutoFlush); + this._batchStream = new BasicStream(ref.getInstance(), Protocol.currentProtocolEncoding); this._connection = null; this._compress = false; @@ -128,13 +124,6 @@ var ConnectRequestHandler = Ice.Class({ this._batchStream.swap(os); - if(!this._batchAutoFlush && - this._batchStream.size + this._batchRequestsSize > this._reference.getInstance().messageSizeMax()) - { - ExUtil.throwMemoryLimitException(this._batchStream.size + this._batchRequestsSize, - this._reference.getInstance().messageSizeMax()); - } - this._requests.push(new Request(this._batchStream)); return; } @@ -147,10 +136,8 @@ var ConnectRequestHandler = Ice.Class({ Debug.assert(this._batchRequestInProgress); this._batchRequestInProgress = false; - var dummy = new BasicStream(this._reference.getInstance(), Protocol.currentProtocolEncoding, - this._batchAutoFlush); + var dummy = new BasicStream(this._reference.getInstance(), Protocol.currentProtocolEncoding); this._batchStream.swap(dummy); - this._batchRequestsSize = Protocol.requestBatchHdr.length; return; } this._connection.abortBatchRequest(); diff --git a/js/src/Ice/ConnectionI.js b/js/src/Ice/ConnectionI.js index 5b3d1697cdc..0a44caa195a 100644 --- a/js/src/Ice/ConnectionI.js +++ b/js/src/Ice/ConnectionI.js @@ -59,7 +59,7 @@ var StateFinished = 6; var MessageInfo = function(instance) { - this.stream = new BasicStream(instance, Protocol.currentProtocolEncoding, false); + this.stream = new BasicStream(instance, Protocol.currentProtocolEncoding); this.invokeNum = 0; this.requestId = 0; @@ -99,9 +99,8 @@ var ConnectionI = Class({ this._warnUdp = instance.initializationData().properties.getPropertyAsInt("Ice.Warn.Datagrams") > 0; this._acmLastActivity = this._monitor !== null && this._monitor.getACM().timeout > 0 ? Date.now() : -1; this._nextRequestId = 1; - this._batchAutoFlush = - initData.properties.getPropertyAsIntWithDefault("Ice.BatchAutoFlush", 1) > 0 ? true : false; - this._batchStream = new BasicStream(instance, Protocol.currentProtocolEncoding, this._batchAutoFlush); + this._batchAutoFlushSize = instance.batchAutoFlushSize(); + this._batchStream = new BasicStream(instance, Protocol.currentProtocolEncoding); this._batchStreamInUse = false; this._batchRequestNum = 0; this._batchRequestCompress = false; @@ -397,7 +396,7 @@ var ConnectionI = Class({ // Ensure the message isn't bigger than what we can send with the // transport. // - this._transceiver.checkSendSize(os, this._instance.messageSizeMax()); + this._transceiver.checkSendSize(os); // // Notify the request that it's cancelable with this connection. @@ -515,15 +514,20 @@ var ConnectionI = Class({ } var flush = false; - if(this._batchAutoFlush) + if(this._batchAutoFlushSize > 0) { + if(this._batchStream.size > this._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 limit to be // exceeded and rollback stream to the marker. try { - this._transceiver.checkSendSize(this._batchStream.buffer, this._instance.messageSizeMax()); + this._transceiver.checkSendSize(this._batchStream.buffer); } catch(ex) { @@ -564,7 +568,7 @@ var ConnectionI = Class({ this._batchStream.writeInt(this._batchRequestNum); this.sendMessage(OutgoingMessage.createForStream(this._batchStream, this._batchRequestCompress, - true)); + true)); } catch(ex) { @@ -583,23 +587,12 @@ var ConnectionI = Class({ // // Reset the batch stream. // - this._batchStream = - new BasicStream(this._instance, Protocol.currentProtocolEncoding, this._batchAutoFlush); + this._batchStream = new BasicStream(this._instance, Protocol.currentProtocolEncoding); this._batchRequestNum = 0; this._batchRequestCompress = false; this._batchMarker = 0; // - // Check again if the last request doesn't exceed the maximum message size. - // - if(Protocol.requestBatchHdr.length + lastRequest.length > this._instance.messageSizeMax()) - { - ExUtil.throwMemoryLimitException( - Protocol.requestBatchHdr.length + lastRequest.length, - this._instance.messageSizeMax()); - } - - // // Start a new batch with the last message that caused us to go over the limit. // this._batchStream.writeBlob(Protocol.requestBatchHdr); @@ -637,7 +630,7 @@ var ConnectionI = Class({ }, abortBatchRequest: function() { - this._batchStream = new BasicStream(this._instance, Protocol.currentProtocolEncoding, this._batchAutoFlush); + this._batchStream = new BasicStream(this._instance, Protocol.currentProtocolEncoding); this._batchRequestNum = 0; this._batchRequestCompress = false; this._batchMarker = 0; @@ -700,7 +693,7 @@ var ConnectionI = Class({ // // Reset the batch stream. // - this._batchStream = new BasicStream(this._instance, Protocol.currentProtocolEncoding, this._batchAutoFlush); + this._batchStream = new BasicStream(this._instance, Protocol.currentProtocolEncoding); this._batchRequestNum = 0; this._batchRequestCompress = false; this._batchMarker = 0; @@ -1614,7 +1607,7 @@ var ConnectionI = Class({ // Before we shut down, we send a close connection // message. // - var os = new BasicStream(this._instance, Protocol.currentProtocolEncoding, false); + var os = new BasicStream(this._instance, Protocol.currentProtocolEncoding); os.writeBlob(Protocol.magic); Protocol.currentProtocol.__write(os); Protocol.currentProtocolEncoding.__write(os); diff --git a/js/src/Ice/EndpointFactoryManager.js b/js/src/Ice/EndpointFactoryManager.js index 288a4d886a3..9b94b033794 100644 --- a/js/src/Ice/EndpointFactoryManager.js +++ b/js/src/Ice/EndpointFactoryManager.js @@ -113,7 +113,7 @@ var EndpointFactoryManager = Ice.Class({ // and ask the factory to read the endpoint data from that stream to create // the actual endpoint. // - var bs = new BasicStream(this._instance, Protocol.currentProtocolEncoding, true); + var bs = new BasicStream(this._instance, Protocol.currentProtocolEncoding); bs.writeShort(ue.type()); ue.streamWrite(bs); bs.pos = 0; diff --git a/js/src/Ice/Instance.js b/js/src/Ice/Instance.js index 78c148e2729..38587bb2b2d 100644 --- a/js/src/Ice/Instance.js +++ b/js/src/Ice/Instance.js @@ -80,7 +80,8 @@ var Instance = Ice.Class({ this._traceLevels = null; this._defaultsAndOverrides = null; - this._messageSizeMax = null; + this._messageSizeMax = 0; + this._batchAutoFlushSize = 0; this._clientACM = null; this._implicitContext = null; this._routerManager = null; @@ -246,6 +247,11 @@ var Instance = Ice.Class({ // This value is immutable. return this._messageSizeMax; }, + batchAutoFlushSize: function() + { + // This value is immutable. + return this._batchAutoFlushSize; + }, clientACM: function() { // This value is immutable. @@ -332,6 +338,31 @@ var Instance = Ice.Class({ this._messageSizeMax = num * 1024; // Property is in kilobytes, _messageSizeMax in bytes } + if(this._initData.properties.getProperty("Ice.BatchAutoFlushSize").length === 0 && + this._initData.properties.getProperty("Ice.BatchAutoFlush").length > 0) + { + if(this._initData.properties.getPropertyAsInt("Ice.BatchAutoFlush") > 0) + { + this._batchAutoFlushSize = this._messageSizeMax; + } + } + else + { + var num = this._initData.properties.getPropertyAsIntWithDefault("Ice.BatchAutoFlushSize", 1024); // 1MB + if(num < 1) + { + this._batchAutoFlushSize = num; + } + else if(num > 0x7fffffff / 1024) + { + this._batchAutoFlushSize = 0x7fffffff; + } + else + { + this._batchAutoFlushSize = num * 1024; // Property is in kilobytes, _batchAutoFlushSize in bytes + } + } + this._clientACM = new ACMConfig(this._initData.properties, this._initData.logger, "Ice.ACM.Client", new ACMConfig(this._initData.properties, this._initData.logger, "Ice.ACM", new ACMConfig())); @@ -504,6 +535,7 @@ var Instance = Ice.Class({ self._endpointFactoryManager.destroy(); } + var i; if(self._initData.properties.getPropertyAsInt("Ice.Warn.UnusedProperties") > 0) { var unusedProperties = self._initData.properties.getUnusedProperties(); @@ -511,7 +543,7 @@ var Instance = Ice.Class({ { var message = []; message.push("The following properties were set but never read:"); - for(var i = 0; i < unusedProperties.length; ++i) + for(i = 0; i < unusedProperties.length; ++i) { message.push("\n "); message.push(unusedProperties[i]); @@ -537,7 +569,7 @@ var Instance = Ice.Class({ if(this._destroyPromises) { - for(var i = 0; i < this._destroyPromises.length; ++i) + for(i = 0; i < this._destroyPromises.length; ++i) { this._destroyPromises[i].succeed(this._destroyPromises[i]); } diff --git a/js/src/Ice/OutgoingAsync.js b/js/src/Ice/OutgoingAsync.js index cb83b4578d7..b2ec025175a 100644 --- a/js/src/Ice/OutgoingAsync.js +++ b/js/src/Ice/OutgoingAsync.js @@ -41,7 +41,7 @@ var OutgoingAsyncBase = Ice.Class(AsyncResult, { if(communicator !== undefined) { AsyncResult.call(this, communicator, operation, connection, proxy, adapter); - this._os = new BasicStream(this._instance, Protocol.currentProtocolEncoding, false); + this._os = new BasicStream(this._instance, Protocol.currentProtocolEncoding); } else { @@ -345,7 +345,7 @@ var OutgoingAsync = Ice.Class(ProxyOutgoingAsyncBase, { { if(this._is === null) // _is can already be initialized if the invocation is retried { - this._is = new BasicStream(this._instance, Protocol.currentProtocolEncoding, false); + this._is = new BasicStream(this._instance, Protocol.currentProtocolEncoding); } this._is.swap(istr); replyStatus = this._is.readByte(); diff --git a/js/src/Ice/PropertyNames.js b/js/src/Ice/PropertyNames.js index 89758e4ce5a..7bcaf0fd3bb 100644 --- a/js/src/Ice/PropertyNames.js +++ b/js/src/Ice/PropertyNames.js @@ -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! @@ -76,7 +76,8 @@ PropertyNames.IceProps = new Property("/^Ice\.Admin\.Logger\.Properties/", false, null), new Property("/^Ice\.Admin\.ServerId/", false, null), new Property("/^Ice\.BackgroundLocatorCacheUpdates/", false, null), - new Property("/^Ice\.BatchAutoFlush/", false, null), + new Property("/^Ice\.BatchAutoFlush/", true, null), + new Property("/^Ice\.BatchAutoFlushSize/", false, null), new Property("/^Ice\.ChangeUser/", false, null), new Property("/^Ice\.ClientAccessPolicyProtocol/", false, null), new Property("/^Ice\.Compression\.Level/", false, null), diff --git a/js/src/Ice/TcpTransceiver.js b/js/src/Ice/TcpTransceiver.js index 2e79719c8b2..52c9a313ce5 100644 --- a/js/src/Ice/TcpTransceiver.js +++ b/js/src/Ice/TcpTransceiver.js @@ -279,12 +279,8 @@ var TcpTransceiver = Ice.Class({ { return new Ice.TCPConnectionInfo(); }, - checkSendSize: function(stream, messageSizeMax) + checkSendSize: function(stream) { - if(stream.size > messageSizeMax) - { - ExUtil.throwMemoryLimitException(stream.size, messageSizeMax); - } }, toString: function() { diff --git a/js/src/Ice/browser/WSTransceiver.js b/js/src/Ice/browser/WSTransceiver.js index dc07ff6f323..a12516d30f3 100644 --- a/js/src/Ice/browser/WSTransceiver.js +++ b/js/src/Ice/browser/WSTransceiver.js @@ -297,12 +297,8 @@ var WSTransceiver = Ice.Class({ { return new Ice.WSConnectionInfo(); }, - checkSendSize: function(stream, messageSizeMax) + checkSendSize: function(stream) { - if(stream.size > messageSizeMax) - { - ExUtil.throwMemoryLimitException(stream.size, messageSizeMax); - } }, toString: function() { diff --git a/js/test/Ice/exceptions/Client.js b/js/test/Ice/exceptions/Client.js index ecb23e4d560..ebfd35e6549 100644 --- a/js/test/Ice/exceptions/Client.js +++ b/js/test/Ice/exceptions/Client.js @@ -14,7 +14,7 @@ var Promise = Ice.Promise; - var allTests = function(out, communicator, Test) + var allTests = function(out, communicator, Test, bidir) { var EmptyI = function() { @@ -369,22 +369,29 @@ ).then( function() { - out.write("testing memory limit marshal exception..."); - return thrower.throwMemoryLimitException(null); - } - ).then( - failCB, - function(ex) - { - test(ex instanceof Ice.UnknownLocalException); - return thrower.throwMemoryLimitException(new Array(20 * 1024)); + if(!bidir) + { + out.write("testing memory limit marshal exception..."); + return thrower.throwMemoryLimitException(null).then( + failCB, + function(ex) + { + test(ex instanceof Ice.MemoryLimitException); + return thrower.throwMemoryLimitException(Ice.Buffer.createNative(20 * 1024)); + } + ).then( + failCB, + function(ex) + { + test(ex instanceof Ice.ConnectionLostException); + out.writeLine("ok"); + } + ); + } } ).then( - failCB, - function(ex) + function() { - test(ex instanceof Ice.MemoryLimitException); - out.writeLine("ok"); out.write("catching object not exist exception... "); var id = communicator.stringToIdentity("does not exist"); var thrower2 = Test.ThrowerPrx.uncheckedCast(thrower.ice_identity(id)); @@ -477,6 +484,7 @@ var run = function(out, id) { id.properties.setProperty("Ice.MessageSizeMax", "10"); + id.properties.setProperty("Ice.Warn.Connections", "0"); var c = Ice.initialize(id); return Promise.try( function() diff --git a/js/test/Ice/exceptionsBidir/Client.js b/js/test/Ice/exceptionsBidir/Client.js index 0c73f3928fc..2cda879f0c0 100644 --- a/js/test/Ice/exceptionsBidir/Client.js +++ b/js/test/Ice/exceptionsBidir/Client.js @@ -41,7 +41,7 @@ function(conn) { conn.setAdapter(adapter); - return Client.__clientAllTests__(out, communicator, amd ? TestAMD : Test); + return Client.__clientAllTests__(out, communicator, amd ? TestAMD : Test, true); }); }); }); @@ -51,6 +51,7 @@ { id.properties.setProperty("Ice.MessageSizeMax", "10"); id.properties.setProperty("Ice.Warn.Dispatch", "0"); + id.properties.setProperty("Ice.Warn.Connections", "0"); var communicator = Ice.initialize(id); return Promise.try( function() diff --git a/js/test/Ice/exceptionsBidir/run.py b/js/test/Ice/exceptionsBidir/run.py index d40340f6d10..9d71627b8b4 100755 --- a/js/test/Ice/exceptionsBidir/run.py +++ b/js/test/Ice/exceptionsBidir/run.py @@ -21,12 +21,14 @@ sys.path.append(os.path.join(path[0], "scripts")) import TestUtil print("Running test with compact (default) format.") -TestUtil.clientEchoTest(additionalServerOptions="--Ice.Warn.Dispatch=0") +TestUtil.clientEchoTest(additionalServerOptions="--Ice.Warn.Dispatch=0 --Ice.Warn.Connections=0") print("Running test with sliced format.") TestUtil.clientEchoTest(additionalClientOptions="--Ice.Default.SlicedFormat", - additionalServerOptions="--Ice.Default.SlicedFormat --Ice.Warn.Dispatch=0") + additionalServerOptions="--Ice.Default.SlicedFormat" + + " --Ice.Warn.Dispatch=0 --Ice.Warn.Connections=0") print("Running test with 1.0 encoding.") TestUtil.clientEchoTest(additionalClientOptions="--Ice.Default.EncodingVersion=1.0", - additionalServerOptions="--Ice.Default.EncodingVersion=1.0 --Ice.Warn.Dispatch=0") + additionalServerOptions="--Ice.Default.EncodingVersion=1.0" + + " --Ice.Warn.Dispatch=0 --Ice.Warn.Connections=0") diff --git a/js/test/Ice/operations/BatchOneways.js b/js/test/Ice/operations/BatchOneways.js index 7711fe49ef2..2e2bb748c5d 100644 --- a/js/test/Ice/operations/BatchOneways.js +++ b/js/test/Ice/operations/BatchOneways.js @@ -15,7 +15,7 @@ var run = function(communicator, prx, Test, bidir) { var Promise = Ice.Promise; - var bs1, bs2, bs3, batch, batch2, batch3; + var bs1, bs2, batch, batch2, batch3; var p = new Promise(); var test = function(b) { @@ -47,11 +47,6 @@ { bs2[i] = 0; } - bs3 = Ice.Buffer.createNative(new Array(100 * 1024)); - for(i = 0; i < bs3.length; ++i) - { - bs3[i] = 0; - } return prx.opByteSOneway(bs1); } @@ -63,17 +58,11 @@ ).then( function() { - return prx.opByteSOneway(bs3); + return prx.opByteSOnewayCallCount(); } ).then( - function() - { - test(false); - }, - function(ex) + function(count) { - test(ex instanceof Ice.MemoryLimitException); - batch = prx.ice_batchOneway(); var all = []; @@ -85,6 +74,28 @@ return Promise.all(all).then( function() { + var wait = function(count) + { + if(count != 27) // 3 * 9 requests auto-flushed. + { + return Promise.delay(10).then( + function() + { + return prx.opByteSOnewayCallCount(); + } + ).then( + function(count) + { + return wait(count); + } + ); + } + } + return wait(0); + } + ).then( + function() + { return batch.ice_getConnection(); } ).then( diff --git a/js/test/Ice/operations/Client.js b/js/test/Ice/operations/Client.js index 66a8d8b5273..12fbbadb04a 100644 --- a/js/test/Ice/operations/Client.js +++ b/js/test/Ice/operations/Client.js @@ -71,12 +71,7 @@ var run = function(out, id) { - // - // We must set MessageSizeMax to an explicit value, - // because we run tests to check whether - // Ice.MemoryLimitException is raised as expected. - // - id.properties.setProperty("Ice.MessageSizeMax", "100"); + id.properties.setProperty("Ice.BatchAutoFlushSize", "100"); var c = Ice.initialize(id); return Promise.try( function() @@ -91,7 +86,6 @@ ).finally( function() { - c.destroy(); // Test concurrent destroy() calls return c.destroy(); } ); diff --git a/js/test/Ice/operations/Makefile b/js/test/Ice/operations/Makefile index 8f81ea44140..bfddcfe50ed 100644 --- a/js/test/Ice/operations/Makefile +++ b/js/test/Ice/operations/Makefile @@ -20,4 +20,3 @@ SRCS = Client.js include $(top_srcdir)/config/Make.rules.js SLICE2JSFLAGS := $(SLICE2JSFLAGS) -I$(slicedir) - diff --git a/js/test/Ice/operations/Test.ice b/js/test/Ice/operations/Test.ice index 5027b5de6b6..494cafe69b7 100644 --- a/js/test/Ice/operations/Test.ice +++ b/js/test/Ice/operations/Test.ice @@ -161,6 +161,7 @@ class MyClass IntS opIntS(IntS s); void opByteSOneway(ByteS s); + int opByteSOnewayCallCount(); Ice::Context opContext(); diff --git a/js/test/Ice/operationsBidir/AMDMyDerivedClassI.js b/js/test/Ice/operationsBidir/AMDMyDerivedClassI.js index a4a0f5e1c23..521b436bf97 100644 --- a/js/test/Ice/operationsBidir/AMDMyDerivedClassI.js +++ b/js/test/Ice/operationsBidir/AMDMyDerivedClassI.js @@ -26,6 +26,10 @@ // // Override the Object "pseudo" operations to verify the operation mode. // + __init__: function() + { + this._opByteSOnewayCount = 0; + }, ice_isA: function(id, current) { @@ -223,9 +227,17 @@ opByteSOneway_async: function(cb, s, current) { + this._opByteSOnewayCount += 1; cb.ice_response(); }, + opByteSOnewayCallCount_async: function(cb, current) + { + var count = this._opByteSOnewayCount; + this._opByteSOnewayCount = 0; + cb.ice_response(count); + }, + opContext_async: function(cb, current) { cb.ice_response(current.ctx); diff --git a/js/test/Ice/operationsBidir/Client.js b/js/test/Ice/operationsBidir/Client.js index daeba069c21..76ceabbf769 100644 --- a/js/test/Ice/operationsBidir/Client.js +++ b/js/test/Ice/operationsBidir/Client.js @@ -43,12 +43,7 @@ var run = function(out, id) { - // - // We must set MessageSizeMax to an explicit value, - // because we run tests to check whether - // Ice.MemoryLimitException is raised as expected. - // - id.properties.setProperty("Ice.MessageSizeMax", "100"); + id.properties.setProperty("Ice.BatchAutoFlushSize", "100"); var communicator = Ice.initialize(id); return Promise.try( function() diff --git a/js/test/Ice/operationsBidir/MyDerivedClassI.js b/js/test/Ice/operationsBidir/MyDerivedClassI.js index 181adf4279b..0663d292544 100644 --- a/js/test/Ice/operationsBidir/MyDerivedClassI.js +++ b/js/test/Ice/operationsBidir/MyDerivedClassI.js @@ -26,6 +26,10 @@ // // Override the Object "pseudo" operations to verify the operation mode. // + __init__: function() + { + this._opByteSOnewayCount = 0; + }, ice_isA: function(id, current) { @@ -221,6 +225,14 @@ opByteSOneway: function(s, current) { + this._opByteSOnewayCount += 1; + }, + + opByteSOnewayCallCount: function(current) + { + var count = this._opByteSOnewayCount; + this._opByteSOnewayCount = 0; + return count; }, opContext: function(current) diff --git a/js/test/Ice/operationsBidir/Test.ice b/js/test/Ice/operationsBidir/Test.ice index 3163de99915..9a699fa94da 100644 --- a/js/test/Ice/operationsBidir/Test.ice +++ b/js/test/Ice/operationsBidir/Test.ice @@ -161,6 +161,7 @@ class MyClass IntS opIntS(IntS s); void opByteSOneway(ByteS s); + int opByteSOnewayCallCount(); Ice::Context opContext(); diff --git a/js/test/Ice/operationsBidir/TestAMD.ice b/js/test/Ice/operationsBidir/TestAMD.ice index 11719b8c247..4a673f57c12 100644 --- a/js/test/Ice/operationsBidir/TestAMD.ice +++ b/js/test/Ice/operationsBidir/TestAMD.ice @@ -161,6 +161,7 @@ dictionary<MyStruct, MyEnum> MyStructMyEnumD; IntS opIntS(IntS s); void opByteSOneway(ByteS s); + int opByteSOnewayCallCount(); Ice::Context opContext(); diff --git a/py/test/Ice/operations/BatchOneways.py b/py/test/Ice/operations/BatchOneways.py index c5e80c9bdd6..12cb3f9f5ce 100644 --- a/py/test/Ice/operations/BatchOneways.py +++ b/py/test/Ice/operations/BatchOneways.py @@ -7,7 +7,7 @@ # # ********************************************************************** -import Ice, Test, array, sys +import Ice, Test, array, sys, time def test(b): if not b: @@ -25,15 +25,9 @@ def batchOneways(p): bs2[0:99 * 1024] = range(0, 99 * 1024) # add 100,000 entries. bs2 = ['\x00' for x in bs2] # set them all to \x00 bs2 = ''.join(bs2) # make into a byte array - - bs3 = [] - bs3[0:100 * 1024] = range(0, 100 * 1024) # add 100,000 entries. - bs3 = ['\x00' for x in bs3] # set them all to \x00 - bs3 = ''.join(bs3) # make into a byte array else: bs1 = bytes([0 for x in range(0, 10 * 1024)]) bs2 = bytes([0 for x in range(0, 99 * 1024)]) - bs3 = bytes([0 for x in range(0, 100 * 1024)]) try: p.opByteSOneway(bs1) @@ -45,19 +39,17 @@ def batchOneways(p): except Ice.MemoryLimitException: test(False) - try: - p.opByteSOneway(bs3) - test(False) - except Ice.MemoryLimitException: - pass - batch = Test.MyClassPrx.uncheckedCast(p.ice_batchOneway()) + p.opByteSOnewayCallCount() # Reset the call count + for i in range(30): - try: - batch.opByteSOneway(bs1) - except Ice.MemoryLimitException: - test(False) + batch.opByteSOneway(bs1) + + count = 0 + while count != 27: # 3 * 9 requests auto-flushed. + count += p.opByteSOnewayCallCount() + time.sleep(0.01) if p.ice_getConnection(): batch.ice_getConnection().flushBatchRequests() diff --git a/py/test/Ice/operations/BatchOnewaysAMI.py b/py/test/Ice/operations/BatchOnewaysAMI.py index 84e77de3043..b1424a5a483 100644 --- a/py/test/Ice/operations/BatchOnewaysAMI.py +++ b/py/test/Ice/operations/BatchOnewaysAMI.py @@ -45,26 +45,15 @@ def batchOneways(p): bs2[0:99 * 1024] = range(0, 99 * 1024) # add 100,000 entries. bs2 = ['\x00' for x in bs2] # set them all to \x00 bs2 = ''.join(bs2) # make into a byte array - - bs3 = [] - bs3[0:100 * 1024] = range(0, 100 * 1024) # add 100,000 entries. - bs3 = ['\x00' for x in bs3] # set them all to \x00 - bs3 = ''.join(bs3) # make into a byte array else: bs1 = bytes([0 for x in range(0, 10 * 1024)]) bs2 = bytes([0 for x in range(0, 99 * 1024)]) - bs3 = bytes([0 for x in range(0, 100 * 1024)]) cb = Callback() p.begin_opByteSOneway(bs1, lambda: cb.called(), lambda ex: test(False) ) cb.check() p.begin_opByteSOneway(bs2, lambda: cb.called(), lambda ex: test(False) ) cb.check() - def checkMemoryLimit(ex): - test(isinstance(ex, Ice.MemoryLimitException)) - cb.called() - p.begin_opByteSOneway(bs3, lambda: test(False), lambda ex: checkMemoryLimit(ex) ) - cb.check() batch = Test.MyClassPrx.uncheckedCast(p.ice_batchOneway()) diff --git a/py/test/Ice/operations/Client.py b/py/test/Ice/operations/Client.py index e9eaf2797bb..00f1a038b62 100755 --- a/py/test/Ice/operations/Client.py +++ b/py/test/Ice/operations/Client.py @@ -47,13 +47,7 @@ try: initData.properties = Ice.createProperties(sys.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(sys.argv, initData) status = run(sys.argv, communicator) diff --git a/py/test/Ice/operations/Collocated.py b/py/test/Ice/operations/Collocated.py index 3a89f62fd7a..15741eb0f9c 100755 --- a/py/test/Ice/operations/Collocated.py +++ b/py/test/Ice/operations/Collocated.py @@ -36,12 +36,7 @@ try: initData = Ice.InitializationData() initData.properties = Ice.createProperties(sys.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(sys.argv, initData) status = run(sys.argv, communicator) diff --git a/py/test/Ice/operations/ServerAMD.py b/py/test/Ice/operations/ServerAMD.py index b888f48eea5..b32f7f1acf0 100755 --- a/py/test/Ice/operations/ServerAMD.py +++ b/py/test/Ice/operations/ServerAMD.py @@ -35,6 +35,8 @@ class MyDerivedClassI(Test.MyDerivedClass): def __init__(self): self.opVoidThread = None self.opVoidThreadLock = threading.Lock() + self.lock = threading.Lock() + self.opByteSOnewayCount = 0 def ice_isA(self, id, current=None): test(current.mode == Ice.OperationMode.Nonmutating) @@ -233,8 +235,18 @@ class MyDerivedClassI(Test.MyDerivedClass): cb.ice_response([-x for x in s]) def opByteSOneway_async(self, cb, s, current=None): + self.lock.acquire() + self.opByteSOnewayCount += 1 + self.lock.release() cb.ice_response() + def opByteSOnewayCallCount_async(self, cb, current=None): + self.lock.acquire() + count = self.opByteSOnewayCount + self.opByteSOnewayCount = 0 + self.lock.release() + cb.ice_response(count) + def opDoubleMarshaling_async(self, cb, p1, p2, current=None): d = 1278312346.0 / 13.0; test(p1 == d) diff --git a/py/test/Ice/operations/Test.ice b/py/test/Ice/operations/Test.ice index 7839b36cd28..00d2ba4dd6d 100644 --- a/py/test/Ice/operations/Test.ice +++ b/py/test/Ice/operations/Test.ice @@ -160,6 +160,8 @@ class MyClass void opByteSOneway(ByteS s); + int opByteSOnewayCallCount(); + Ice::Context opContext(); void opDoubleMarshaling(double p1, DoubleS p2); diff --git a/py/test/Ice/operations/TestAMD.ice b/py/test/Ice/operations/TestAMD.ice index 6866d6fb72b..9dff4277063 100644 --- a/py/test/Ice/operations/TestAMD.ice +++ b/py/test/Ice/operations/TestAMD.ice @@ -158,6 +158,8 @@ dictionary<MyStruct, MyEnum> MyStructMyEnumD; void opByteSOneway(ByteS s); + int opByteSOnewayCallCount(); + StringStringD opContext(); void opDoubleMarshaling(double p1, DoubleS p2); diff --git a/py/test/Ice/operations/TestI.py b/py/test/Ice/operations/TestI.py index 2a69c0e9366..f243e08bfb3 100644 --- a/py/test/Ice/operations/TestI.py +++ b/py/test/Ice/operations/TestI.py @@ -7,13 +7,17 @@ # # ********************************************************************** -import Ice, Test, sys +import Ice, Test, sys, threading def test(b): if not b: raise RuntimeError('test assertion failed') class MyDerivedClassI(Test.MyDerivedClass): + def __init__(self): + self.lock = threading.Lock() + self.opByteSOnewayCount = 0 + def ice_isA(self, id, current=None): test(current.mode == Ice.OperationMode.Nonmutating) return Test.MyDerivedClass.ice_isA(self, id, current) @@ -194,7 +198,16 @@ class MyDerivedClassI(Test.MyDerivedClass): return [-x for x in s] def opByteSOneway(self, s, current=None): - pass + self.lock.acquire() + self.opByteSOnewayCount += 1 + self.lock.release() + + def opByteSOnewayCallCount(self, current=None): + self.lock.acquire() + count = self.opByteSOnewayCount + self.opByteSOnewayCount = 0 + self.lock.release() + return count def opContext(self, current=None): return current.ctx diff --git a/rb/test/Ice/operations/BatchOneways.rb b/rb/test/Ice/operations/BatchOneways.rb index bb7d70787c4..3bfa4aff162 100644 --- a/rb/test/Ice/operations/BatchOneways.rb +++ b/rb/test/Ice/operations/BatchOneways.rb @@ -10,7 +10,6 @@ def batchOneways(p) bs1 = "\0" * (10 * 1024); bs2 = "\0" * (99 * 1024); - bs3 = "\0" * (100 * 1024); begin p.opByteSOneway(bs1) @@ -24,20 +23,18 @@ def batchOneways(p) test(false) end - begin - p.opByteSOneway(bs3) - test(false) - rescue Ice::MemoryLimitException - end - batch = Test::MyClassPrx::uncheckedCast(p.ice_batchOneway()) + p.opByteSOnewayCallCount() # Reset the call count + for i in (0...30) - begin - batch.opByteSOneway(bs1) - rescue Ice::MemoryLimitException - test(false) - end + batch.opByteSOneway(bs1) + end + + count = 0 + while (count != 27) # 3 * 9 requests auto-flushed. + count += p.opByteSOnewayCallCount() + sleep(0.01) end batch.ice_getConnection().flushBatchRequests() diff --git a/rb/test/Ice/operations/Client.rb b/rb/test/Ice/operations/Client.rb index d40035670a4..9d6f19da5bd 100755 --- a/rb/test/Ice/operations/Client.rb +++ b/rb/test/Ice/operations/Client.rb @@ -46,12 +46,7 @@ begin #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(ARGV, initData) status = run(ARGV, communicator) diff --git a/rb/test/Ice/operations/Test.ice b/rb/test/Ice/operations/Test.ice index 37ff3c5ef66..28787c699df 100644 --- a/rb/test/Ice/operations/Test.ice +++ b/rb/test/Ice/operations/Test.ice @@ -160,6 +160,8 @@ class MyClass void opByteSOneway(ByteS s); + int opByteSOnewayCallCount(); + Ice::Context opContext(); idempotent void opIdempotent(); diff --git a/scripts/TestUtil.py b/scripts/TestUtil.py index 6156084f7c5..877fb9b0ce5 100755 --- a/scripts/TestUtil.py +++ b/scripts/TestUtil.py @@ -1276,11 +1276,10 @@ def clientServerTest(additionalServerOptions = "", additionalClientOptions = "", else: serverenv = getTestEnv(lang, serverdir) - global cross if len(cross) > 0: - if lang == "js": - print("** skipping js cross test") + if lang == "js" and cross[0] != lang: + print("** skipping js cross test ") return elif len(cross) == 0: cross.append(lang) |