diff options
author | Dwayne Boone <dwayne@zeroc.com> | 2015-03-05 15:44:08 -0330 |
---|---|---|
committer | Dwayne Boone <dwayne@zeroc.com> | 2015-03-05 15:44:08 -0330 |
commit | b96b045ecc6e034307ba8065af73c252e0093bbb (patch) | |
tree | c3f22df1c67a7de3c435c4be31ef2adfb300b1e8 | |
parent | Fixed linux php build (diff) | |
download | ice-b96b045ecc6e034307ba8065af73c252e0093bbb.tar.bz2 ice-b96b045ecc6e034307ba8065af73c252e0093bbb.tar.xz ice-b96b045ecc6e034307ba8065af73c252e0093bbb.zip |
ICE-6082 No way to discover send/recv buffer sizes
57 files changed, 618 insertions, 138 deletions
diff --git a/cpp/src/Ice/ConnectionI.cpp b/cpp/src/Ice/ConnectionI.cpp index 45b80883a56..1c22af06bb8 100644 --- a/cpp/src/Ice/ConnectionI.cpp +++ b/cpp/src/Ice/ConnectionI.cpp @@ -115,7 +115,7 @@ class FinishCall : public DispatchWorkItem { public: - FinishCall(const Ice::ConnectionIPtr& connection, bool close) : + FinishCall(const Ice::ConnectionIPtr& connection, bool close) : DispatchWorkItem(connection), _connection(connection), _close(close) { } @@ -127,7 +127,7 @@ public: } private: - + const ConnectionIPtr _connection; const bool _close; }; @@ -712,10 +712,10 @@ Ice::ConnectionI::sendAsyncRequest(const OutgoingAsyncPtr& out, bool compress, b _transceiver->checkSendSize(*os); // - // Notify the request that it's cancelable with this connection. + // Notify the request that it's cancelable with this connection. // This will throw if the request is canceled. // - out->cancelable(this); + out->cancelable(this); Int requestId = 0; if(response) @@ -847,7 +847,7 @@ Ice::ConnectionI::finishBatchRequest(BasicStream* os, bool compress) { 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 @@ -1026,16 +1026,16 @@ Ice::ConnectionI::begin_flushBatchRequests(const IceInternal::Function<void (con #else assert(false); // Ice not built with C++11 support. return 0; -#endif +#endif } AsyncResultPtr Ice::ConnectionI::__begin_flushBatchRequests(const CallbackBasePtr& cb, const LocalObjectPtr& cookie) { - ConnectionFlushBatchPtr result = new ConnectionFlushBatch(this, - _communicator, - _instance, - __flushBatchRequests_name, + ConnectionFlushBatchPtr result = new ConnectionFlushBatch(this, + _communicator, + _instance, + __flushBatchRequests_name, cb, cookie); result->invoke(); @@ -1134,10 +1134,10 @@ Ice::ConnectionI::flushAsyncBatchRequests(const OutgoingAsyncBasePtr& outAsync) } // - // Notify the request that it's cancelable with this connection. + // Notify the request that it's cancelable with this connection. // This will throw if the request is canceled. // - outAsync->cancelable(this); + outAsync->cancelable(this); // // Fill in the number of requests in the batch. @@ -1383,7 +1383,7 @@ Ice::ConnectionI::asyncRequestCanceled(const OutgoingAsyncBasePtr& outAsync, con { return; // The request has already been or will be shortly notified of the failure. } - + for(deque<OutgoingMessage>::iterator o = _sendStreams.begin(); o != _sendStreams.end(); ++o) { if(o->outAsync.get() == outAsync.get()) @@ -1401,7 +1401,7 @@ Ice::ConnectionI::asyncRequestCanceled(const OutgoingAsyncBasePtr& outAsync, con _asyncRequests.erase(o->requestId); } } - + if(dynamic_cast<const Ice::ConnectionTimeoutException*>(&ex)) { setState(StateClosed, ex); @@ -1429,7 +1429,7 @@ Ice::ConnectionI::asyncRequestCanceled(const OutgoingAsyncBasePtr& outAsync, con return; } } - + OutgoingAsyncPtr o = OutgoingAsyncPtr::dynamicCast(outAsync); if(o) { @@ -1444,7 +1444,7 @@ Ice::ConnectionI::asyncRequestCanceled(const OutgoingAsyncBasePtr& outAsync, con else { _asyncRequests.erase(_asyncRequestsHint); - _asyncRequestsHint = _asyncRequests.end(); + _asyncRequestsHint = _asyncRequests.end(); if(outAsync->completed(ex)) { outAsync->invokeCompletedAsync(); @@ -1453,7 +1453,7 @@ Ice::ConnectionI::asyncRequestCanceled(const OutgoingAsyncBasePtr& outAsync, con return; } } - + for(map<Int, OutgoingAsyncPtr>::iterator p = _asyncRequests.begin(); p != _asyncRequests.end(); ++p) { if(p->second.get() == o.get()) @@ -2380,6 +2380,18 @@ Ice::ConnectionI::getInfo() const } void +Ice::ConnectionI::setBufferSize(Ice::Int rcvSize, Ice::Int sndSize) +{ + IceUtil::Monitor<IceUtil::Mutex>::Lock sync(*this); + if(_state >= StateClosed) + { + _exception->ice_throw(); + } + _transceiver->setBufferSize(rcvSize, sndSize); + _info = 0; // Invalidate the cached connection info +} + +void Ice::ConnectionI::exception(const LocalException& ex) { IceUtil::Monitor<IceUtil::Mutex>::Lock sync(*this); diff --git a/cpp/src/Ice/ConnectionI.h b/cpp/src/Ice/ConnectionI.h index 7dc0db9a2b4..adcdd8ea318 100644 --- a/cpp/src/Ice/ConnectionI.h +++ b/cpp/src/Ice/ConnectionI.h @@ -230,6 +230,8 @@ public: virtual Ice::Int timeout() const; // From Connection. virtual ConnectionInfoPtr getInfo() const; // From Connection + virtual void setBufferSize(Ice::Int rcvSize, Ice::Int sndSize); // From Connection + void exception(const LocalException&); void dispatch(const StartCallbackPtr&, const std::vector<OutgoingMessage>&, Byte, Int, Int, diff --git a/cpp/src/Ice/Network.cpp b/cpp/src/Ice/Network.cpp index 584f31561f3..c151c4b9af6 100644 --- a/cpp/src/Ice/Network.cpp +++ b/cpp/src/Ice/Network.cpp @@ -1647,50 +1647,59 @@ IceInternal::setTcpBufSize(SOCKET fd, const ProtocolInstancePtr& instance) #else const int dfltBufSize = 0; #endif - Int sizeRequested = instance->properties()->getPropertyAsIntWithDefault("Ice.TCP.RcvSize", dfltBufSize); - if(sizeRequested > 0) + Int rcvSize = instance->properties()->getPropertyAsIntWithDefault("Ice.TCP.RcvSize", dfltBufSize); + Int sndSize = instance->properties()->getPropertyAsIntWithDefault("Ice.TCP.SndSize", dfltBufSize); + + setTcpBufSize(fd, rcvSize, sndSize, instance); +} + +void +IceInternal::setTcpBufSize(SOCKET fd, int rcvSize, int sndSize, const ProtocolInstancePtr& instance) +{ + assert(fd != INVALID_SOCKET); + + if(rcvSize > 0) { // // Try to set the buffer size. The kernel will silently adjust // the size to an acceptable value. Then read the size back to // get the size that was actually set. // - setRecvBufferSize(fd, sizeRequested); + setRecvBufferSize(fd, rcvSize); int size = getRecvBufferSize(fd); - if(size > 0 && size < sizeRequested) + if(size > 0 && size < rcvSize) { // Warn if the size that was set is less than the requested size and // we have not already warned. BufSizeWarnInfo winfo = instance->getBufSizeWarn(TCPEndpointType); - if(!winfo.rcvWarn || sizeRequested != winfo.rcvSize) + if(!winfo.rcvWarn || rcvSize != winfo.rcvSize) { Ice::Warning out(instance->logger()); - out << "TCP receive buffer size: requested size of " << sizeRequested << " adjusted to " << size; - instance->setRcvBufSizeWarn(TCPEndpointType, sizeRequested); + out << "TCP receive buffer size: requested size of " << rcvSize << " adjusted to " << size; + instance->setRcvBufSizeWarn(TCPEndpointType, rcvSize); } } } - sizeRequested = instance->properties()->getPropertyAsIntWithDefault("Ice.TCP.SndSize", dfltBufSize); - if(sizeRequested > 0) + if(sndSize > 0) { // // Try to set the buffer size. The kernel will silently adjust // the size to an acceptable value. Then read the size back to // get the size that was actually set. // - setSendBufferSize(fd, sizeRequested); + setSendBufferSize(fd, sndSize); int size = getSendBufferSize(fd); - if(size > 0 && size < sizeRequested) + if(size > 0 && size < sndSize) { // Warn if the size that was set is less than the requested size and // we have not already warned. BufSizeWarnInfo winfo = instance->getBufSizeWarn(TCPEndpointType); - if(!winfo.sndWarn || sizeRequested != winfo.sndSize) + if(!winfo.sndWarn || sndSize != winfo.sndSize) { Ice::Warning out(instance->logger()); - out << "TCP send buffer size: requested size of " << sizeRequested << " adjusted to " << size; - instance->setSndBufSizeWarn(TCPEndpointType, sizeRequested); + out << "TCP send buffer size: requested size of " << sndSize << " adjusted to " << size; + instance->setSndBufSizeWarn(TCPEndpointType, sndSize); } } } diff --git a/cpp/src/Ice/Network.h b/cpp/src/Ice/Network.h index eb15092fe51..a731a49db3d 100644 --- a/cpp/src/Ice/Network.h +++ b/cpp/src/Ice/Network.h @@ -240,6 +240,7 @@ ICE_API void setPort(Address&, int); ICE_API bool isMulticast(const Address&); ICE_API void setTcpBufSize(SOCKET, const ProtocolInstancePtr&); +ICE_API void setTcpBufSize(SOCKET, int, int, const ProtocolInstancePtr&); ICE_API void setBlock(SOCKET, bool); ICE_API void setSendBufferSize(SOCKET, int); diff --git a/cpp/src/Ice/StreamSocket.cpp b/cpp/src/Ice/StreamSocket.cpp index 3c9bbf1afcc..7ade8172ba4 100644 --- a/cpp/src/Ice/StreamSocket.cpp +++ b/cpp/src/Ice/StreamSocket.cpp @@ -18,6 +18,7 @@ StreamSocket::StreamSocket(const ProtocolInstancePtr& instance, const Address& addr, const Address& sourceAddr) : NativeInfo(createSocket(false, proxy ? proxy->getAddress() : addr)), + _instance(instance), _proxy(proxy), _addr(addr), _sourceAddr(sourceAddr), @@ -27,7 +28,7 @@ StreamSocket::StreamSocket(const ProtocolInstancePtr& instance, _write(SocketOperationWrite) #endif { - init(instance); + init(); #ifndef ICE_USE_IOCP if(doConnect(_fd, _proxy ? _proxy->getAddress() : _addr, sourceAddr)) { @@ -39,13 +40,14 @@ StreamSocket::StreamSocket(const ProtocolInstancePtr& instance, StreamSocket::StreamSocket(const ProtocolInstancePtr& instance, SOCKET fd) : NativeInfo(fd), + _instance(instance), _state(StateConnected) #ifdef ICE_USE_IOCP , _read(SocketOperationRead), _write(SocketOperationWrite) #endif { - init(instance); + init(); _desc = fdToString(fd); } @@ -126,6 +128,12 @@ StreamSocket::getRecvPacketSize(size_t length) #endif } +void +StreamSocket::setBufferSize(int rcvSize, int sndSize) +{ + setTcpBufSize(_fd, rcvSize, sndSize, _instance); +} + SocketOperation StreamSocket::read(Buffer& buf) { @@ -486,10 +494,10 @@ StreamSocket::toString() const } void -StreamSocket::init(const ProtocolInstancePtr& instance) +StreamSocket::init() { setBlock(_fd, false); - setTcpBufSize(_fd, instance); + setTcpBufSize(_fd, _instance); #ifdef ICE_USE_IOCP // diff --git a/cpp/src/Ice/StreamSocket.h b/cpp/src/Ice/StreamSocket.h index a8e4b4cbd7f..de47e32c9d9 100644 --- a/cpp/src/Ice/StreamSocket.h +++ b/cpp/src/Ice/StreamSocket.h @@ -25,15 +25,17 @@ public: StreamSocket(const ProtocolInstancePtr&, const NetworkProxyPtr&, const Address&, const Address&); StreamSocket(const ProtocolInstancePtr&, SOCKET); virtual ~StreamSocket(); - + SocketOperation connect(Buffer&, Buffer&); bool isConnected(); size_t getSendPacketSize(size_t); size_t getRecvPacketSize(size_t); + void setBufferSize(int rcvSize, int sndSize); + SocketOperation read(Buffer&); SocketOperation write(Buffer&); - + ssize_t read(char*, size_t); ssize_t write(const char*, size_t); @@ -50,7 +52,7 @@ public: private: - void init(const ProtocolInstancePtr&); + void init(); enum State { @@ -63,6 +65,7 @@ private: }; State toState(SocketOperation) const; + const ProtocolInstancePtr _instance; const NetworkProxyPtr _proxy; const Address _addr; const Address _sourceAddr; diff --git a/cpp/src/Ice/TcpTransceiver.cpp b/cpp/src/Ice/TcpTransceiver.cpp index 4b72860c619..af456168cf5 100644 --- a/cpp/src/Ice/TcpTransceiver.cpp +++ b/cpp/src/Ice/TcpTransceiver.cpp @@ -107,6 +107,8 @@ IceInternal::TcpTransceiver::getInfo() const { Ice::TCPConnectionInfoPtr info = new Ice::TCPConnectionInfo(); fdToAddressAndPort(_stream->fd(), info->localAddress, info->localPort, info->remoteAddress, info->remotePort); + info->rcvSize = getRecvBufferSize(_stream->fd()); + info->sndSize = getSendBufferSize(_stream->fd()); return info; } @@ -115,8 +117,14 @@ IceInternal::TcpTransceiver::checkSendSize(const Buffer&) { } +void +IceInternal::TcpTransceiver::setBufferSize(int rcvSize, int sndSize) +{ + _stream->setBufferSize(rcvSize, sndSize); +} + IceInternal::TcpTransceiver::TcpTransceiver(const ProtocolInstancePtr& instance, const StreamSocketPtr& stream) : - _instance(instance), + _instance(instance), _stream(stream) { } diff --git a/cpp/src/Ice/TcpTransceiver.h b/cpp/src/Ice/TcpTransceiver.h index 0d82d1c419c..ee6c57214d9 100644 --- a/cpp/src/Ice/TcpTransceiver.h +++ b/cpp/src/Ice/TcpTransceiver.h @@ -43,6 +43,7 @@ public: virtual std::string toDetailedString() const; virtual Ice::ConnectionInfoPtr getInfo() const; virtual void checkSendSize(const Buffer&); + virtual void setBufferSize(int rcvSize, int sndSize); private: diff --git a/cpp/src/Ice/Transceiver.h b/cpp/src/Ice/Transceiver.h index 78ce0106900..b330cab5f4b 100644 --- a/cpp/src/Ice/Transceiver.h +++ b/cpp/src/Ice/Transceiver.h @@ -45,6 +45,7 @@ public: virtual std::string toDetailedString() const = 0; virtual Ice::ConnectionInfoPtr getInfo() const = 0; virtual void checkSendSize(const Buffer&) = 0; + virtual void setBufferSize(int rcvSize, int sndSize) = 0; }; } diff --git a/cpp/src/Ice/UdpTransceiver.cpp b/cpp/src/Ice/UdpTransceiver.cpp index 7458567aceb..daf1a051456 100644 --- a/cpp/src/Ice/UdpTransceiver.cpp +++ b/cpp/src/Ice/UdpTransceiver.cpp @@ -853,6 +853,9 @@ IceInternal::UdpTransceiver::getInfo() const fdToAddressAndPort(_fd, info->localAddress, info->localPort, info->remoteAddress, info->remotePort); } + info->rcvSize = _rcvSize; + info->sndSize = _sndSize; + if(isAddressValid(_mcastAddr)) { addrToAddressAndPort(_mcastAddr, info->mcastAddress, info->mcastPort); @@ -878,6 +881,12 @@ IceInternal::UdpTransceiver::checkSendSize(const Buffer& buf) } } +void +IceInternal::UdpTransceiver::setBufferSize(int rcvSize, int sndSize) +{ + setBufSize(rcvSize, sndSize); +} + int IceInternal::UdpTransceiver::effectivePort() const { @@ -909,7 +918,7 @@ IceInternal::UdpTransceiver::UdpTransceiver(const ProtocolInstancePtr& instance, #endif { _fd = createSocket(true, _addr); - setBufSize(); + setBufSize(-1, -1); setBlock(_fd, false); #ifndef ICE_OS_WINRT @@ -982,7 +991,7 @@ IceInternal::UdpTransceiver::UdpTransceiver(const UdpEndpointIPtr& endpoint, con #endif { _fd = createServerSocket(true, _addr, instance->protocolSupport()); - setBufSize(); + setBufSize(-1, -1); setBlock(_fd, false); #ifndef ICE_OS_WINRT @@ -1009,7 +1018,7 @@ IceInternal::UdpTransceiver::~UdpTransceiver() // Set UDP receive and send buffer sizes. // void -IceInternal::UdpTransceiver::setBufSize() +IceInternal::UdpTransceiver::setBufSize(int rcvSize, int sndSize) { assert(_fd != INVALID_SOCKET); @@ -1020,6 +1029,7 @@ IceInternal::UdpTransceiver::setBufSize() string prop; int* addr; int dfltSize; + int sizeRequested; if(i == 0) { isSnd = false; @@ -1027,6 +1037,7 @@ IceInternal::UdpTransceiver::setBufSize() prop = "Ice.UDP.RcvSize"; addr = &_rcvSize; dfltSize = getRecvBufferSize(_fd); + sizeRequested = rcvSize; } else { @@ -1035,6 +1046,7 @@ IceInternal::UdpTransceiver::setBufSize() prop = "Ice.UDP.SndSize"; addr = &_sndSize; dfltSize = getSendBufferSize(_fd); + sizeRequested = sndSize; } if(dfltSize <= 0) @@ -1044,9 +1056,15 @@ IceInternal::UdpTransceiver::setBufSize() *addr = dfltSize; // - // Get property for buffer size and check for sanity. + // Get property for buffer size if size not passed in. + // + if(sizeRequested == -1) + { + sizeRequested = _instance->properties()->getPropertyAsIntWithDefault(prop, dfltSize); + } + // + // Check for sanity. // - Int sizeRequested = _instance->properties()->getPropertyAsIntWithDefault(prop, dfltSize); if(sizeRequested < (_udpOverhead + headerSize)) { Warning out(_instance->logger()); diff --git a/cpp/src/Ice/UdpTransceiver.h b/cpp/src/Ice/UdpTransceiver.h index a6faac20bb4..83921ad54a5 100644 --- a/cpp/src/Ice/UdpTransceiver.h +++ b/cpp/src/Ice/UdpTransceiver.h @@ -61,6 +61,7 @@ public: virtual std::string toDetailedString() const; virtual Ice::ConnectionInfoPtr getInfo() const; virtual void checkSendSize(const Buffer&); + virtual void setBufferSize(int rcvSize, int sndSize); int effectivePort() const; @@ -72,7 +73,7 @@ private: virtual ~UdpTransceiver(); - void setBufSize(); + void setBufSize(int, int); #ifdef ICE_OS_WINRT bool checkIfErrorOrCompleted(SocketOperation, Windows::Foundation::IAsyncInfo^); diff --git a/cpp/src/Ice/WSTransceiver.cpp b/cpp/src/Ice/WSTransceiver.cpp index d83e553308d..d476b52a67e 100644 --- a/cpp/src/Ice/WSTransceiver.cpp +++ b/cpp/src/Ice/WSTransceiver.cpp @@ -810,6 +810,8 @@ IceInternal::WSTransceiver::getInfo() const info->localPort = di->localPort; info->remoteAddress = di->remoteAddress; info->remotePort = di->remotePort; + info->rcvSize = di->rcvSize; + info->sndSize = di->sndSize; info->headers = _parser->getHeaders(); return info; } @@ -820,6 +822,12 @@ IceInternal::WSTransceiver::checkSendSize(const Buffer& buf) _delegate->checkSendSize(buf); } +void +IceInternal::WSTransceiver::setBufferSize(int rcvSize, int sndSize) +{ + _delegate->setBufferSize(rcvSize, sndSize); +} + IceInternal::WSTransceiver::WSTransceiver(const ProtocolInstancePtr& instance, const TransceiverPtr& del, const string& host, int port, const string& resource) : _instance(instance), diff --git a/cpp/src/Ice/WSTransceiver.h b/cpp/src/Ice/WSTransceiver.h index 64d9fd3f945..2273f51a683 100644 --- a/cpp/src/Ice/WSTransceiver.h +++ b/cpp/src/Ice/WSTransceiver.h @@ -51,6 +51,7 @@ public: virtual std::string toDetailedString() const; virtual Ice::ConnectionInfoPtr getInfo() const; virtual void checkSendSize(const Buffer&); + virtual void setBufferSize(int rcvSize, int sndSize); private: diff --git a/cpp/src/Ice/winrt/StreamTransceiver.cpp b/cpp/src/Ice/winrt/StreamTransceiver.cpp index d2697418895..3c4a30f8cc6 100644 --- a/cpp/src/Ice/winrt/StreamTransceiver.cpp +++ b/cpp/src/Ice/winrt/StreamTransceiver.cpp @@ -303,6 +303,8 @@ IceInternal::StreamTransceiver::getInfo() const info = new Ice::TCPConnectionInfo(); } fdToAddressAndPort(_fd, info->localAddress, info->localPort, info->remoteAddress, info->remotePort); + info->rcvSize = getRecvBufferSize(_fd); + info->sndSize = getSendBufferSize(_fd); return info; } @@ -311,6 +313,12 @@ IceInternal::StreamTransceiver::checkSendSize(const Buffer&) { } + void + IceInternal::StreamTransceiver::setBufferSize(int rcvSize, int sndSize) + { + setTcpBufSize(_fd, rcvSize, sndSize, _instance); + } + IceInternal::StreamTransceiver::StreamTransceiver(const ProtocolInstancePtr& instance, SOCKET fd, bool connected) : NativeInfo(fd), _instance(instance), @@ -322,8 +330,7 @@ IceInternal::StreamTransceiver::StreamTransceiver(const ProtocolInstancePtr& ins _reader = ref new DataReader(streamSocket->InputStream); _reader->InputStreamOptions = InputStreamOptions::Partial; - Ice::PropertiesPtr properties = instance->properties(); - setTcpBufSize(_fd, properties, _instance->logger()); + setTcpBufSize(_fd, _instance); _maxSendPacketSize = streamSocket->Control->OutboundBufferSizeInBytes / 2; if(_maxSendPacketSize < 512) @@ -331,7 +338,7 @@ IceInternal::StreamTransceiver::StreamTransceiver(const ProtocolInstancePtr& ins _maxSendPacketSize = 0; } - _maxReceivePacketSize = properties->getPropertyAsIntWithDefault("Ice.TCP.RcvSize", 128 * 1024); + _maxReceivePacketSize = instance->properties()->getPropertyAsIntWithDefault("Ice.TCP.RcvSize", 128 * 1024); } IceInternal::StreamTransceiver::~StreamTransceiver() diff --git a/cpp/src/Ice/winrt/StreamTransceiver.h b/cpp/src/Ice/winrt/StreamTransceiver.h index a683094d84e..4a32cfd10e8 100644 --- a/cpp/src/Ice/winrt/StreamTransceiver.h +++ b/cpp/src/Ice/winrt/StreamTransceiver.h @@ -50,6 +50,7 @@ public: virtual std::string toDetailedString() const; virtual Ice::ConnectionInfoPtr getInfo() const; virtual void checkSendSize(const Buffer&); + virtual void setBufferSize(int rcvSize, int sndSize); private: diff --git a/cpp/src/IceSSL/OpenSSLTransceiverI.cpp b/cpp/src/IceSSL/OpenSSLTransceiverI.cpp index ea9dfb6b4c1..24762938607 100644 --- a/cpp/src/IceSSL/OpenSSLTransceiverI.cpp +++ b/cpp/src/IceSSL/OpenSSLTransceiverI.cpp @@ -537,6 +537,12 @@ IceSSL::TransceiverI::checkSendSize(const IceInternal::Buffer&) { } +void +IceSSL::TransceiverI::setBufferSize(int rcvSize, int sndSize) +{ + _stream->setBufferSize(rcvSize, sndSize); +} + IceSSL::TransceiverI::TransceiverI(const InstancePtr& instance, const IceInternal::StreamSocketPtr& stream, const string& hostOrAdapterName, bool incoming) : _instance(instance), @@ -557,8 +563,10 @@ NativeConnectionInfoPtr IceSSL::TransceiverI::getNativeConnectionInfo() const { NativeConnectionInfoPtr info = new NativeConnectionInfo(); - IceInternal::fdToAddressAndPort(_stream->fd(), info->localAddress, info->localPort, info->remoteAddress, + IceInternal::fdToAddressAndPort(_stream->fd(), info->localAddress, info->localPort, info->remoteAddress, info->remotePort); + info->rcvSize = IceInternal::getRecvBufferSize(_stream->fd()); + info->sndSize = IceInternal::getSendBufferSize(_stream->fd()); if(_ssl != 0) { diff --git a/cpp/src/IceSSL/OpenSSLTransceiverI.h b/cpp/src/IceSSL/OpenSSLTransceiverI.h index 9640e0577f5..43c43d1214f 100644 --- a/cpp/src/IceSSL/OpenSSLTransceiverI.h +++ b/cpp/src/IceSSL/OpenSSLTransceiverI.h @@ -46,6 +46,7 @@ public: virtual std::string toDetailedString() const; virtual Ice::ConnectionInfoPtr getInfo() const; virtual void checkSendSize(const IceInternal::Buffer&); + virtual void setBufferSize(int rcvSize, int sndSize); private: diff --git a/cpp/src/IceSSL/SChannelTransceiverI.cpp b/cpp/src/IceSSL/SChannelTransceiverI.cpp index 3caee7f1fba..bce721eec79 100644 --- a/cpp/src/IceSSL/SChannelTransceiverI.cpp +++ b/cpp/src/IceSSL/SChannelTransceiverI.cpp @@ -952,6 +952,12 @@ IceSSL::TransceiverI::checkSendSize(const IceInternal::Buffer&) { } +void +IceSSL::TransceiverI::setBufferSize(int rcvSize, int sndSize) +{ + _stream->setBufferSize(rcvSize, sndSize); +} + IceSSL::TransceiverI::TransceiverI(const InstancePtr& instance, const IceInternal::StreamSocketPtr& stream, const string& hostOrAdapterName, @@ -979,6 +985,8 @@ IceSSL::TransceiverI::getNativeConnectionInfo() const NativeConnectionInfoPtr info = new NativeConnectionInfo(); IceInternal::fdToAddressAndPort(_stream->fd(), info->localAddress, info->localPort, info->remoteAddress, info->remotePort); + info->rcvSize = IceInternal::getRecvBufferSize(_stream->fd()); + info->sndSize = IceInternal::getSendBufferSize(_stream->fd()); if(_sslInitialized) { diff --git a/cpp/src/IceSSL/SChannelTransceiverI.h b/cpp/src/IceSSL/SChannelTransceiverI.h index 312db4b4a5c..bfc1b0e020f 100644 --- a/cpp/src/IceSSL/SChannelTransceiverI.h +++ b/cpp/src/IceSSL/SChannelTransceiverI.h @@ -64,6 +64,7 @@ public: virtual std::string toDetailedString() const; virtual Ice::ConnectionInfoPtr getInfo() const; virtual void checkSendSize(const IceInternal::Buffer&); + virtual void setBufferSize(int rcvSize, int sndSize); private: diff --git a/cpp/src/IceSSL/SecureTransportTransceiverI.cpp b/cpp/src/IceSSL/SecureTransportTransceiverI.cpp index c9b5b3c5414..1e5c824ed1d 100644 --- a/cpp/src/IceSSL/SecureTransportTransceiverI.cpp +++ b/cpp/src/IceSSL/SecureTransportTransceiverI.cpp @@ -197,7 +197,7 @@ IceSSL::TransceiverI::initialize(IceInternal::Buffer& readBuffer, IceInternal::B if((err = SSLSetConnection(_ssl, reinterpret_cast<SSLConnectionRef>(this)))) { - throw SecurityException(__FILE__, __LINE__, "IceSSL: setting SSL connection failed\n" + + throw SecurityException(__FILE__, __LINE__, "IceSSL: setting SSL connection failed\n" + errorToString(err)); } } @@ -489,9 +489,15 @@ IceSSL::TransceiverI::checkSendSize(const IceInternal::Buffer&) { } -IceSSL::TransceiverI::TransceiverI(const InstancePtr& instance, - const IceInternal::StreamSocketPtr& stream, - const string& hostOrAdapterName, +void +IceSSL::TransceiverI::setBufferSize(int rcvSize, int sndSize) +{ + _stream->setBufferSize(rcvSize, sndSize); +} + +IceSSL::TransceiverI::TransceiverI(const InstancePtr& instance, + const IceInternal::StreamSocketPtr& stream, + const string& hostOrAdapterName, bool incoming) : _instance(instance), _engine(SecureTransportEnginePtr::dynamicCast(instance->engine())), @@ -519,8 +525,10 @@ NativeConnectionInfoPtr IceSSL::TransceiverI::getNativeConnectionInfo() const { NativeConnectionInfoPtr info = new NativeConnectionInfo(); - IceInternal::fdToAddressAndPort(_stream->fd(), info->localAddress, info->localPort, info->remoteAddress, + IceInternal::fdToAddressAndPort(_stream->fd(), info->localAddress, info->localPort, info->remoteAddress, info->remotePort); + info->rcvSize = IceInternal::getRecvBufferSize(_stream->fd()); + info->sndSize = IceInternal::getSendBufferSize(_stream->fd()); if(_ssl) { diff --git a/cpp/src/IceSSL/SecureTransportTransceiverI.h b/cpp/src/IceSSL/SecureTransportTransceiverI.h index 4b56da00caa..afdcccc2018 100644 --- a/cpp/src/IceSSL/SecureTransportTransceiverI.h +++ b/cpp/src/IceSSL/SecureTransportTransceiverI.h @@ -47,6 +47,7 @@ public: virtual std::string toDetailedString() const; virtual Ice::ConnectionInfoPtr getInfo() const; virtual void checkSendSize(const IceInternal::Buffer&); + virtual void setBufferSize(int rcvSize, int sndSize); OSStatus writeRaw(const char*, size_t*) const; OSStatus readRaw(char*, size_t*) const; diff --git a/cpp/test/Ice/background/Transceiver.cpp b/cpp/test/Ice/background/Transceiver.cpp index 1422be86998..fc639d39e41 100644 --- a/cpp/test/Ice/background/Transceiver.cpp +++ b/cpp/test/Ice/background/Transceiver.cpp @@ -58,7 +58,7 @@ Transceiver::initialize(IceInternal::Buffer& readBuffer, IceInternal::Buffer& wr return IceInternal::SocketOperationNone; } -IceInternal::SocketOperation +IceInternal::SocketOperation Transceiver::closing(bool initiator, const Ice::LocalException& ex) { return _transceiver->closing(initiator, ex); @@ -158,7 +158,7 @@ Transceiver::startRead(IceInternal::Buffer& buf) { available = requested; } - + memcpy(buf.i, _readBufferPos, available); _readBufferPos += available; buf.i += available; @@ -199,7 +199,7 @@ Transceiver::finishRead(IceInternal::Buffer& buf, bool& hasMoreData) { available = requested; } - + memcpy(buf.i, _readBufferPos, available); _readBufferPos += available; buf.i += available; @@ -243,6 +243,12 @@ Transceiver::checkSendSize(const IceInternal::Buffer& buf) _transceiver->checkSendSize(buf); } +void +Transceiver::setBufferSize(int rcvSize, int sndSize) +{ + _transceiver->setBufferSize(rcvSize, sndSize); +} + // // Only for use by Connector, Acceptor // diff --git a/cpp/test/Ice/background/Transceiver.h b/cpp/test/Ice/background/Transceiver.h index 59fbd7e0bb0..d6e203f087f 100644 --- a/cpp/test/Ice/background/Transceiver.h +++ b/cpp/test/Ice/background/Transceiver.h @@ -35,6 +35,7 @@ public: virtual Ice::ConnectionInfoPtr getInfo() const; virtual IceInternal::SocketOperation initialize(IceInternal::Buffer&, IceInternal::Buffer&, bool&); virtual void checkSendSize(const IceInternal::Buffer&); + virtual void setBufferSize(int rcvSize, int sndSize); IceInternal::TransceiverPtr delegate() const { return _transceiver; } diff --git a/cpp/test/Ice/info/AllTests.cpp b/cpp/test/Ice/info/AllTests.cpp index da312fb83d8..81dcb89239d 100644 --- a/cpp/test/Ice/info/AllTests.cpp +++ b/cpp/test/Ice/info/AllTests.cpp @@ -151,7 +151,10 @@ allTests(const Ice::CommunicatorPtr& communicator) cout << "testing connection information... " << flush; { - Ice::IPConnectionInfoPtr info = Ice::IPConnectionInfoPtr::dynamicCast(base->ice_getConnection()->getInfo()); + Ice::ConnectionPtr connection = base->ice_getConnection(); + connection->setBufferSize(1024, 2048); + + Ice::IPConnectionInfoPtr info = Ice::IPConnectionInfoPtr::dynamicCast(connection->getInfo()); test(info); test(!info->incoming); test(info->adapterName.empty()); @@ -162,6 +165,8 @@ allTests(const Ice::CommunicatorPtr& communicator) test(info->remoteAddress == defaultHost); test(info->localAddress == defaultHost); } + test(info->rcvSize = 1024); + test(info->sndSize = 2048); ostringstream os; @@ -194,7 +199,10 @@ allTests(const Ice::CommunicatorPtr& communicator) test(ctx.find("ws.Sec-WebSocket-Key") != ctx.end()); } - info = Ice::IPConnectionInfoPtr::dynamicCast(base->ice_datagram()->ice_getConnection()->getInfo()); + connection = base->ice_datagram()->ice_getConnection(); + connection->setBufferSize(2048, 1024); + + info = Ice::IPConnectionInfoPtr::dynamicCast(connection->getInfo()); test(!info->incoming); test(info->adapterName.empty()); test(info->localPort > 0); @@ -204,6 +212,8 @@ allTests(const Ice::CommunicatorPtr& communicator) test(info->remoteAddress == defaultHost); test(info->localAddress == defaultHost); } + test(info->rcvSize = 2048); + test(info->sndSize = 1024); } cout << "ok" << endl; diff --git a/cs/src/Ice/ConnectionI.cs b/cs/src/Ice/ConnectionI.cs index bf771235f7b..71bd08ac3f9 100644 --- a/cs/src/Ice/ConnectionI.cs +++ b/cs/src/Ice/ConnectionI.cs @@ -17,7 +17,7 @@ namespace Ice using System.Threading; using Ice.Instrumentation; - public sealed class ConnectionI : + public sealed class ConnectionI : IceInternal.EventHandler, IceInternal.ResponseHandler, IceInternal.CancellationHandler, Connection { public interface StartCallback @@ -338,7 +338,7 @@ namespace Ice // called every (timeout / 2) period. // if(acm.heartbeat == ACMHeartbeat.HeartbeatAlways || - (acm.heartbeat != ACMHeartbeat.HeartbeatOff && _writeStream.isEmpty() && + (acm.heartbeat != ACMHeartbeat.HeartbeatOff && _writeStream.isEmpty() && now >= (_acmLastActivity + acm.timeout / 4))) { if(acm.heartbeat != ACMHeartbeat.HeartbeatOnInvocation || _dispatchCount > 0) @@ -409,7 +409,7 @@ namespace Ice _transceiver.checkSendSize(os.getBuffer()); // - // Notify the request that it's cancelable with this connection. + // Notify the request that it's cancelable with this connection. // This will throw if the request is canceled. // og.cancelable(this); @@ -671,7 +671,7 @@ namespace Ice public void end_flushBatchRequests(AsyncResult r) { - IceInternal.ConnectionFlushBatch outAsync = + IceInternal.ConnectionFlushBatch outAsync = IceInternal.ConnectionFlushBatch.check(r, this, __flushBatchRequests_name); outAsync.wait(); } @@ -680,7 +680,7 @@ namespace Ice private AsyncResult begin_flushBatchRequestsInternal(AsyncCallback cb, object cookie) { - IceInternal.ConnectionFlushBatch result = + IceInternal.ConnectionFlushBatch result = new IceInternal.ConnectionFlushBatch(this, _communicator, _instance, __flushBatchRequests_name, cookie); if(cb != null) { @@ -711,7 +711,7 @@ namespace Ice } // - // Notify the request that it's cancelable with this connection. + // Notify the request that it's cancelable with this connection. // This will throw if the request is canceled. // outAsync.cancelable(this); @@ -742,7 +742,7 @@ namespace Ice Debug.Assert(_exception != null); throw _exception; } - + // // Reset the batch stream. // @@ -826,7 +826,7 @@ namespace Ice // // NOTE: This isn't called from a thread pool thread. // - + lock(this) { if(_state >= StateClosed) @@ -1625,7 +1625,7 @@ namespace Ice s.Append("\n"); s.Append(_exception); } - + _instance.initializationData().logger.trace(_instance.traceLevels().networkCat, s.ToString()); } } @@ -1766,6 +1766,19 @@ namespace Ice } } + public void setBufferSize(int rcvSize, int sndSize) + { + lock(this) + { + if(_state >= StateClosed) + { + throw _exception; + } + _transceiver.setBufferSize(rcvSize, sndSize); + _info = null; // Invalidate the cached connection info + } + } + public string ice_toString_() { return ToString(); diff --git a/cs/src/Ice/Network.cs b/cs/src/Ice/Network.cs index f1e1580d7bb..413679340a4 100644 --- a/cs/src/Ice/Network.cs +++ b/cs/src/Ice/Network.cs @@ -1036,50 +1036,57 @@ namespace IceInternal dfltBufSize = 128 * 1024; } - int sizeRequested = instance.properties().getPropertyAsIntWithDefault("Ice.TCP.RcvSize", dfltBufSize); - if(sizeRequested > 0) + int rcvSize = instance.properties().getPropertyAsIntWithDefault("Ice.TCP.RcvSize", dfltBufSize); + int sndSize = instance.properties().getPropertyAsIntWithDefault("Ice.TCP.SndSize", dfltBufSize); + + setTcpBufSize(socket, rcvSize, sndSize, instance); + } + + public static void + setTcpBufSize(Socket socket, int rcvSize, int sndSize, ProtocolInstance instance) + { + if(rcvSize > 0) { // // Try to set the buffer size. The kernel will silently adjust // the size to an acceptable value. Then read the size back to // get the size that was actually set. // - setRecvBufferSize(socket, sizeRequested); + setRecvBufferSize(socket, rcvSize); int size = getRecvBufferSize(socket); - if(size < sizeRequested) + if(size < rcvSize) { // Warn if the size that was set is less than the requested size and // we have not already warned. BufSizeWarnInfo winfo = instance.getBufSizeWarn(Ice.TCPEndpointType.value); - if(!winfo.rcvWarn || sizeRequested != winfo.rcvSize) + if(!winfo.rcvWarn || rcvSize != winfo.rcvSize) { - instance.logger().warning("TCP receive buffer size: requested size of " + sizeRequested + + instance.logger().warning("TCP receive buffer size: requested size of " + rcvSize + " adjusted to " + size); - instance.setRcvBufSizeWarn(Ice.TCPEndpointType.value, sizeRequested); + instance.setRcvBufSizeWarn(Ice.TCPEndpointType.value, rcvSize); } } } - sizeRequested = instance.properties().getPropertyAsIntWithDefault("Ice.TCP.SndSize", dfltBufSize); - if(sizeRequested > 0) + if(sndSize > 0) { // // Try to set the buffer size. The kernel will silently adjust // the size to an acceptable value. Then read the size back to // get the size that was actually set. // - setSendBufferSize(socket, sizeRequested); + setSendBufferSize(socket, sndSize); int size = getSendBufferSize(socket); - if(size < sizeRequested) // Warn if the size that was set is less than the requested size. + if(size < sndSize) // Warn if the size that was set is less than the requested size. { // Warn if the size that was set is less than the requested size and // we have not already warned. BufSizeWarnInfo winfo = instance.getBufSizeWarn(Ice.TCPEndpointType.value); - if(!winfo.sndWarn || sizeRequested != winfo.sndSize) + if(!winfo.sndWarn || sndSize != winfo.sndSize) { - instance.logger().warning("TCP send buffer size: requested size of " + sizeRequested + + instance.logger().warning("TCP send buffer size: requested size of " + sndSize + " adjusted to " + size); - instance.setSndBufSizeWarn(Ice.TCPEndpointType.value, sizeRequested); + instance.setSndBufSizeWarn(Ice.TCPEndpointType.value, sndSize); } } } diff --git a/cs/src/Ice/StreamSocket.cs b/cs/src/Ice/StreamSocket.cs index b6f75545222..789a6323c47 100644 --- a/cs/src/Ice/StreamSocket.cs +++ b/cs/src/Ice/StreamSocket.cs @@ -26,21 +26,23 @@ namespace IceInternal { public StreamSocket(ProtocolInstance instance, NetworkProxy proxy, EndPoint addr, EndPoint sourceAddr) { + _instance = instance; _proxy = proxy; _addr = addr; _sourceAddr = sourceAddr; _fd = Network.createSocket(false, (_proxy != null ? _proxy.getAddress() : _addr).AddressFamily); _state = StateNeedConnect; - init(instance); + init(); } public StreamSocket(ProtocolInstance instance, Socket fd) { + _instance = instance; _fd = fd; _state = StateConnected; _desc = IceInternal.Network.fdToString(_fd); - init(instance); + init(); } #if !SILVERLIGHT @@ -124,6 +126,11 @@ namespace IceInternal return _maxRecvPacketSize > 0 ? System.Math.Min(length, _maxRecvPacketSize) : length; } + public void setBufferSize(int rcvSize, int sndSize) + { + Network.setTcpBufSize(_fd, rcvSize, sndSize, _instance); + } + public int read(Buffer buf) { if(_state == StateProxyRead) @@ -553,12 +560,12 @@ namespace IceInternal } #endif - private void init(ProtocolInstance instance) + private void init() { #if !SILVERLIGHT Network.setBlock(_fd, false); #endif - Network.setTcpBufSize(_fd, instance); + Network.setTcpBufSize(_fd, _instance); #if ICE_SOCKET_ASYNC_API _readEventArgs = new SocketAsyncEventArgs(); @@ -575,7 +582,7 @@ namespace IceInternal } else if(!String.IsNullOrEmpty(policy)) { - instance.logger().warning("Ignoring invalid Ice.ClientAccessPolicyProtocol value `" + policy + "'"); + _instance.logger().warning("Ignoring invalid Ice.ClientAccessPolicyProtocol value `" + policy + "'"); } # endif #endif @@ -604,6 +611,7 @@ namespace IceInternal } } + private readonly ProtocolInstance _instance; private readonly IceInternal.NetworkProxy _proxy; private readonly EndPoint _addr; private readonly EndPoint _sourceAddr; diff --git a/cs/src/Ice/TcpTransceiver.cs b/cs/src/Ice/TcpTransceiver.cs index 935468e0c9b..11f7fd49578 100644 --- a/cs/src/Ice/TcpTransceiver.cs +++ b/cs/src/Ice/TcpTransceiver.cs @@ -96,6 +96,8 @@ namespace IceInternal EndPoint remoteEndpoint = Network.getRemoteAddress(_stream.fd()); info.remoteAddress = Network.endpointAddressToString(remoteEndpoint); info.remotePort = Network.endpointPort(remoteEndpoint); + info.rcvSize = Network.getRecvBufferSize(_stream.fd()); + info.sndSize = Network.getSendBufferSize(_stream.fd()); } return info; } @@ -104,6 +106,11 @@ namespace IceInternal { } + public void setBufferSize(int rcvSize, int sndSize) + { + _stream.setBufferSize(rcvSize, sndSize); + } + public override string ToString() { return _stream.ToString(); diff --git a/cs/src/Ice/Transceiver.cs b/cs/src/Ice/Transceiver.cs index b3a10763303..4208c96dfc1 100644 --- a/cs/src/Ice/Transceiver.cs +++ b/cs/src/Ice/Transceiver.cs @@ -53,6 +53,7 @@ namespace IceInternal string toDetailedString(); Ice.ConnectionInfo getInfo(); void checkSendSize(Buffer buf); + void setBufferSize(int rcvSize, int sndSize); } } diff --git a/cs/src/Ice/UdpTransceiver.cs b/cs/src/Ice/UdpTransceiver.cs index 167794ac963..e9a7531340a 100644 --- a/cs/src/Ice/UdpTransceiver.cs +++ b/cs/src/Ice/UdpTransceiver.cs @@ -741,6 +741,10 @@ namespace IceInternal } } } + + info.rcvSize = Network.getRecvBufferSize(_fd); + info.sndSize = Network.getSendBufferSize(_fd); + #if !SILVERLIGHT if(_mcastAddr != null) { @@ -764,6 +768,11 @@ namespace IceInternal } } + public void setBufferSize(int rcvSize, int sndSize) + { + setBufSize(rcvSize, sndSize); + } + public override string ToString() { if(_fd == null) @@ -856,7 +865,7 @@ namespace IceInternal try { _fd = Network.createSocket(true, _addr.AddressFamily); - setBufSize(); + setBufSize(-1, -1); #if !SILVERLIGHT Network.setBlock(_fd, false); if(AssemblyUtil.osx_) @@ -912,7 +921,7 @@ namespace IceInternal #endif _fd = Network.createServerSocket(true, _addr.AddressFamily, instance.protocolSupport()); - setBufSize(); + setBufSize(-1, -1); #if !SILVERLIGHT Network.setBlock(_fd, false); #endif @@ -934,7 +943,7 @@ namespace IceInternal } } - private void setBufSize() + private void setBufSize(int rcvSize, int sndSize) { Debug.Assert(_fd != null); @@ -944,12 +953,14 @@ namespace IceInternal string direction; string prop; int dfltSize; + int sizeRequested; if(i == 0) { isSnd = false; direction = "receive"; prop = "Ice.UDP.RcvSize"; dfltSize = Network.getRecvBufferSize(_fd); + sizeRequested = rcvSize; _rcvSize = dfltSize; } else @@ -958,13 +969,20 @@ namespace IceInternal direction = "send"; prop = "Ice.UDP.SndSize"; dfltSize = Network.getSendBufferSize(_fd); + sizeRequested = sndSize; _sndSize = dfltSize; } // - // Get property for buffer size and check for sanity. + // Get property for buffer size if size not passed in. + // + if(sizeRequested == -1) + { + sizeRequested = _instance.properties().getPropertyAsIntWithDefault(prop, dfltSize); + } + // + // Check for sanity. // - int sizeRequested = _instance.properties().getPropertyAsIntWithDefault(prop, dfltSize); if(sizeRequested < (_udpOverhead + IceInternal.Protocol.headerSize)) { _instance.logger().warning("Invalid " + prop + " value of " + sizeRequested + " adjusted to " + diff --git a/cs/src/Ice/WSTransceiver.cs b/cs/src/Ice/WSTransceiver.cs index 4316b4c6b7f..7218027bdc2 100644 --- a/cs/src/Ice/WSTransceiver.cs +++ b/cs/src/Ice/WSTransceiver.cs @@ -635,6 +635,8 @@ namespace IceInternal info.localPort = di.localPort; info.remoteAddress = di.remoteAddress; info.remotePort = di.remotePort; + info.rcvSize = di.rcvSize; + info.sndSize = di.sndSize; info.headers = _parser.getHeaders(); return info; } @@ -644,6 +646,11 @@ namespace IceInternal _delegate.checkSendSize(buf); } + public void setBufferSize(int rcvSize, int sndSize) + { + _delegate.setBufferSize(rcvSize, sndSize); + } + public override string ToString() { return _delegate.ToString(); diff --git a/cs/src/IceSSL/TransceiverI.cs b/cs/src/IceSSL/TransceiverI.cs index 715cb5b240c..84902367dc9 100644 --- a/cs/src/IceSSL/TransceiverI.cs +++ b/cs/src/IceSSL/TransceiverI.cs @@ -309,6 +309,11 @@ namespace IceSSL { } + public void setBufferSize(int rcvSize, int sndSize) + { + _stream.setBufferSize(rcvSize, sndSize); + } + public override string ToString() { return _stream.ToString(); @@ -387,6 +392,8 @@ namespace IceSSL info.remoteAddress = remoteEndpoint.Address.ToString(); info.remotePort = remoteEndpoint.Port; } + info.rcvSize = IceInternal.Network.getRecvBufferSize(_stream.fd()); + info.sndSize = IceInternal.Network.getSendBufferSize(_stream.fd()); } if(_sslStream != null) { @@ -540,9 +547,9 @@ namespace IceSSL private X509Certificate selectCertificate( object sender, - string targetHost, - X509CertificateCollection localCertificates, - X509Certificate remoteCertificate, + string targetHost, + X509CertificateCollection localCertificates, + X509Certificate remoteCertificate, string[] acceptableIssuers) { X509Certificate2Collection certs = _instance.engine().certs(); @@ -629,7 +636,7 @@ namespace IceSSL int errorCount = _chain.ChainStatus.Length; foreach(X509ChainStatus status in _chain.ChainStatus) { - if(status.Status == X509ChainStatusFlags.UntrustedRoot && + if(status.Status == X509ChainStatusFlags.UntrustedRoot && _instance.engine().caCerts() != null && valid) { // diff --git a/cs/test/Ice/background/Transceiver.cs b/cs/test/Ice/background/Transceiver.cs index 7de22ef1dd4..e4fc04b8f33 100644 --- a/cs/test/Ice/background/Transceiver.cs +++ b/cs/test/Ice/background/Transceiver.cs @@ -225,6 +225,11 @@ internal class Transceiver : IceInternal.Transceiver _transceiver.checkSendSize(buf); } + public void setBufferSize(int rcvSize, int sndSize) + { + _transceiver.setBufferSize(rcvSize, sndSize); + } + public void destroy() { _transceiver.destroy(); diff --git a/cs/test/Ice/info/AllTests.cs b/cs/test/Ice/info/AllTests.cs index 8ae5dfa078a..25f990fab92 100644 --- a/cs/test/Ice/info/AllTests.cs +++ b/cs/test/Ice/info/AllTests.cs @@ -178,7 +178,10 @@ public class AllTests : TestCommon.TestApp Write("testing connection information... "); Flush(); { - Ice.IPConnectionInfo info = (Ice.IPConnectionInfo)@base.ice_getConnection().getInfo(); + Ice.Connection connection = @base.ice_getConnection(); + connection.setBufferSize(1024, 2048); + + Ice.IPConnectionInfo info = (Ice.IPConnectionInfo)connection.getInfo(); test(!info.incoming); test(info.adapterName.Length == 0); test(info.remotePort == 12010); @@ -192,6 +195,8 @@ public class AllTests : TestCommon.TestApp #endif test(info.remoteAddress.Equals(defaultHost)); } + test(info.rcvSize == 1024); + test(info.sndSize == 2048); Dictionary<string, string> ctx = testIntf.getConnectionInfoAsContext(); test(ctx["incoming"].Equals("true")); @@ -218,7 +223,10 @@ public class AllTests : TestCommon.TestApp test(ctx["ws.Sec-WebSocket-Key"] != null); } - info = (Ice.IPConnectionInfo)@base.ice_datagram().ice_getConnection().getInfo(); + connection = @base.ice_datagram().ice_getConnection(); + connection.setBufferSize(2048, 1024); + + info = (Ice.IPConnectionInfo)connection.getInfo(); test(!info.incoming); test(info.adapterName.Length == 0); test(info.localPort > 0); @@ -231,6 +239,8 @@ public class AllTests : TestCommon.TestApp test(info.localAddress.Equals(defaultHost)); #endif } + test(info.rcvSize == 2048); + test(info.sndSize == 1024); } WriteLine("ok"); diff --git a/java/src/Ice/src/main/java/Ice/ConnectionI.java b/java/src/Ice/src/main/java/Ice/ConnectionI.java index 51835eb4bd2..bfe8715e339 100644 --- a/java/src/Ice/src/main/java/Ice/ConnectionI.java +++ b/java/src/Ice/src/main/java/Ice/ConnectionI.java @@ -287,7 +287,7 @@ public final class ConnectionI extends IceInternal.EventHandler // is sill only called every (timeout / 2) period. // if(acm.heartbeat == ACMHeartbeat.HeartbeatAlways || - (acm.heartbeat != ACMHeartbeat.HeartbeatOff && _writeStream.isEmpty() && + (acm.heartbeat != ACMHeartbeat.HeartbeatOff && _writeStream.isEmpty() && now >= (_acmLastActivity + acm.timeout / 4))) { if(acm.heartbeat != ACMHeartbeat.HeartbeatOnInvocation || _dispatchCount > 0) @@ -354,11 +354,11 @@ public final class ConnectionI extends IceInternal.EventHandler _transceiver.checkSendSize(os.getBuffer()); // - // Notify the request that it's cancelable with this connection. + // Notify the request that it's cancelable with this connection. // This will throw if the request is canceled. // out.cancelable(this); - + int requestId = 0; if(response) { @@ -638,7 +638,7 @@ public final class ConnectionI extends IceInternal.EventHandler private Ice.AsyncResult begin_flushBatchRequestsInternal(IceInternal.CallbackBase cb) { - IceInternal.ConnectionFlushBatch result = + IceInternal.ConnectionFlushBatch result = new IceInternal.ConnectionFlushBatch(this, _communicator, _instance, __flushBatchRequests_name, cb); result.invoke(); return result; @@ -647,7 +647,7 @@ public final class ConnectionI extends IceInternal.EventHandler @Override public void end_flushBatchRequests(AsyncResult ir) { - IceInternal.ConnectionFlushBatch r = + IceInternal.ConnectionFlushBatch r = IceInternal.ConnectionFlushBatch.check(ir, this, __flushBatchRequests_name); r.__wait(); } @@ -672,7 +672,7 @@ public final class ConnectionI extends IceInternal.EventHandler } // - // Notify the request that it's cancelable with this connection. + // Notify the request that it's cancelable with this connection. // This will throw if the request is canceled. // outAsync.cancelable(this); @@ -1626,6 +1626,17 @@ public final class ConnectionI extends IceInternal.EventHandler } @Override + public synchronized void setBufferSize(int rcvSize, int sndSize) + { + if(_state >= StateClosed) + { + throw (Ice.LocalException) _exception.fillInStackTrace(); + } + _transceiver.setBufferSize(rcvSize, sndSize); + _info = null; // Invalidate the cached connection info + } + + @Override public String _toString() { return _desc; // No mutex lock, _desc is immutable. @@ -1637,7 +1648,7 @@ public final class ConnectionI extends IceInternal.EventHandler } public ConnectionI(Communicator communicator, IceInternal.Instance instance, IceInternal.ACMMonitor monitor, - IceInternal.Transceiver transceiver, IceInternal.Connector connector, + IceInternal.Transceiver transceiver, IceInternal.Connector connector, IceInternal.EndpointI endpoint, ObjectAdapterI adapter) { _communicator = communicator; @@ -1901,7 +1912,7 @@ public final class ConnectionI extends IceInternal.EventHandler { return; } - + // // Don't need to close now for connections so only close the transceiver // if the selector request it. @@ -1979,7 +1990,7 @@ public final class ConnectionI extends IceInternal.EventHandler _exception instanceof ForcedCloseConnectionException || _exception instanceof ConnectionTimeoutException || _exception instanceof CommunicatorDestroyedException || - _exception instanceof ObjectAdapterDeactivatedException || + _exception instanceof ObjectAdapterDeactivatedException || (_exception instanceof ConnectionLostException && _state >= StateClosing))) { _observer.failed(_exception.ice_name()); @@ -3129,7 +3140,7 @@ public final class ConnectionI extends IceInternal.EventHandler private int _nextRequestId; - private java.util.Map<Integer, IceInternal.OutgoingAsync> _asyncRequests = + private java.util.Map<Integer, IceInternal.OutgoingAsync> _asyncRequests = new java.util.HashMap<Integer, IceInternal.OutgoingAsync>(); private LocalException _exception; diff --git a/java/src/Ice/src/main/java/IceInternal/Network.java b/java/src/Ice/src/main/java/IceInternal/Network.java index 0c7a9475fc4..94ca324227a 100644 --- a/java/src/Ice/src/main/java/IceInternal/Network.java +++ b/java/src/Ice/src/main/java/IceInternal/Network.java @@ -1000,52 +1000,57 @@ public final class Network dfltBufSize = 128 * 1024; } - System.err.println("XXX"); + int rcvSize = instance.properties().getPropertyAsIntWithDefault("Ice.TCP.RcvSize", dfltBufSize); + int sndSize = instance.properties().getPropertyAsIntWithDefault("Ice.TCP.SndSize", dfltBufSize); - int sizeRequested = instance.properties().getPropertyAsIntWithDefault("Ice.TCP.RcvSize", dfltBufSize); - if(sizeRequested > 0) + setTcpBufSize(socket, rcvSize, sndSize, instance); + } + + public static void + setTcpBufSize(java.nio.channels.SocketChannel socket, int rcvSize, int sndSize, ProtocolInstance instance) + { + if(rcvSize > 0) { // // Try to set the buffer size. The kernel will silently adjust // the size to an acceptable value. Then read the size back to // get the size that was actually set. // - setRecvBufferSize(socket, sizeRequested); + setRecvBufferSize(socket, rcvSize); int size = getRecvBufferSize(socket); - //if(size < sizeRequested) + if(size < rcvSize) { // Warn if the size that was set is less than the requested size and // we have not already warned. BufSizeWarnInfo winfo = instance.getBufSizeWarn(Ice.TCPEndpointType.value); - if(!winfo.rcvWarn || sizeRequested != winfo.rcvSize) + if(!winfo.rcvWarn || rcvSize != winfo.rcvSize) { - instance.logger().warning("TCP receive buffer size: requested size of " + sizeRequested + + instance.logger().warning("TCP receive buffer size: requested size of " + rcvSize + " adjusted to " + size); - instance.setRcvBufSizeWarn(Ice.TCPEndpointType.value, sizeRequested); + instance.setRcvBufSizeWarn(Ice.TCPEndpointType.value, rcvSize); } } } - sizeRequested = instance.properties().getPropertyAsIntWithDefault("Ice.TCP.SndSize", dfltBufSize); - if(sizeRequested > 0) + if(sndSize > 0) { // // Try to set the buffer size. The kernel will silently adjust // the size to an acceptable value. Then read the size back to // get the size that was actually set. // - setSendBufferSize(socket, sizeRequested); + setSendBufferSize(socket, sndSize); int size = getSendBufferSize(socket); - //if(size < sizeRequested) + if(size < sndSize) { // Warn if the size that was set is less than the requested size and // we have not already warned. BufSizeWarnInfo winfo = instance.getBufSizeWarn(Ice.TCPEndpointType.value); - if(!winfo.sndWarn || sizeRequested != winfo.sndSize) + if(!winfo.sndWarn || sndSize != winfo.sndSize) { - instance.logger().warning("TCP send buffer size: requested size of " + sizeRequested + + instance.logger().warning("TCP send buffer size: requested size of " + sndSize + " adjusted to " + size); - instance.setSndBufSizeWarn(Ice.TCPEndpointType.value, sizeRequested); + instance.setSndBufSizeWarn(Ice.TCPEndpointType.value, sndSize); } } } @@ -1077,7 +1082,7 @@ public final class Network // setRecvBufferSize(socket, sizeRequested); int size = getRecvBufferSize(socket); - //if(size < sizeRequested) + if(size < sizeRequested) { // Warn if the size that was set is less than the requested size and // we have not already warned. diff --git a/java/src/Ice/src/main/java/IceInternal/StreamSocket.java b/java/src/Ice/src/main/java/IceInternal/StreamSocket.java index 61b546400b0..6fce7962576 100644 --- a/java/src/Ice/src/main/java/IceInternal/StreamSocket.java +++ b/java/src/Ice/src/main/java/IceInternal/StreamSocket.java @@ -79,6 +79,11 @@ public class StreamSocket } } + public void setBufferSize(int rcvSize, int sndSize) + { + Network.setTcpBufSize(_fd, rcvSize, sndSize, _instance); + } + public int connect(Buffer readBuffer, Buffer writeBuffer) { if(_state == StateNeedConnect) diff --git a/java/src/Ice/src/main/java/IceInternal/TcpTransceiver.java b/java/src/Ice/src/main/java/IceInternal/TcpTransceiver.java index 7f640059036..3e6cd059cd6 100644 --- a/java/src/Ice/src/main/java/IceInternal/TcpTransceiver.java +++ b/java/src/Ice/src/main/java/IceInternal/TcpTransceiver.java @@ -89,6 +89,8 @@ final class TcpTransceiver implements Transceiver info.remoteAddress = socket.getInetAddress().getHostAddress(); info.remotePort = socket.getPort(); } + info.rcvSize = Network.getRecvBufferSize(_stream.fd()); + info.sndSize = Network.getSendBufferSize(_stream.fd()); } return info; } @@ -98,6 +100,12 @@ final class TcpTransceiver implements Transceiver { } + @Override + public void setBufferSize(int rcvSize, int sndSize) + { + _stream.setBufferSize(rcvSize, sndSize); + } + TcpTransceiver(ProtocolInstance instance, StreamSocket stream) { _instance = instance; diff --git a/java/src/Ice/src/main/java/IceInternal/Transceiver.java b/java/src/Ice/src/main/java/IceInternal/Transceiver.java index 6029b6cbd95..577a5b99941 100644 --- a/java/src/Ice/src/main/java/IceInternal/Transceiver.java +++ b/java/src/Ice/src/main/java/IceInternal/Transceiver.java @@ -27,4 +27,5 @@ public interface Transceiver String toDetailedString(); Ice.ConnectionInfo getInfo(); void checkSendSize(Buffer buf); + void setBufferSize(int rcvSize, int sndSize); } diff --git a/java/src/Ice/src/main/java/IceInternal/UdpTransceiver.java b/java/src/Ice/src/main/java/IceInternal/UdpTransceiver.java index bffbeb3ce82..88800a78a2b 100644 --- a/java/src/Ice/src/main/java/IceInternal/UdpTransceiver.java +++ b/java/src/Ice/src/main/java/IceInternal/UdpTransceiver.java @@ -315,6 +315,8 @@ final class UdpTransceiver implements Transceiver info.remotePort = socket.getPort(); } } + info.rcvSize = Network.getRecvBufferSize(_fd); + info.sndSize = Network.getSendBufferSize(_fd); } if(_mcastAddr != null) { @@ -338,6 +340,12 @@ final class UdpTransceiver implements Transceiver } } + @Override + public void setBufferSize(int rcvSize, int sndSize) + { + setBufSize(rcvSize, sndSize); + } + public final int effectivePort() { return _addr.getPort(); @@ -356,7 +364,7 @@ final class UdpTransceiver implements Transceiver try { _fd = Network.createUdpSocket(_addr); - setBufSize(); + setBufSize(-1, -1); Network.setBlock(_fd, false); // // NOTE: setting the multicast interface before performing the @@ -393,7 +401,7 @@ final class UdpTransceiver implements Transceiver { _addr = Network.getAddressForServer(host, port, instance.protocolSupport(), instance.preferIPv6()); _fd = Network.createUdpSocket(_addr); - setBufSize(); + setBufSize(-1, -1); Network.setBlock(_fd, false); } catch(Ice.LocalException ex) @@ -403,7 +411,7 @@ final class UdpTransceiver implements Transceiver } } - private synchronized void setBufSize() + private synchronized void setBufSize(int rcvSize, int sndSize) { assert(_fd != null); @@ -413,12 +421,14 @@ final class UdpTransceiver implements Transceiver String direction; String prop; int dfltSize; + int sizeRequested; if(i == 0) { isSnd = false; direction = "receive"; prop = "Ice.UDP.RcvSize"; dfltSize = Network.getRecvBufferSize(_fd); + sizeRequested = rcvSize; _rcvSize = dfltSize; } else @@ -427,13 +437,20 @@ final class UdpTransceiver implements Transceiver direction = "send"; prop = "Ice.UDP.SndSize"; dfltSize = Network.getSendBufferSize(_fd); + sizeRequested = sndSize; _sndSize = dfltSize; } // - // Get property for buffer size and check for sanity. + // Get property for buffer size if size not passed in. + // + if(sizeRequested == -1) + { + sizeRequested = _instance.properties().getPropertyAsIntWithDefault(prop, dfltSize); + } + // + // Check for sanity. // - int sizeRequested = _instance.properties().getPropertyAsIntWithDefault(prop, dfltSize); if(sizeRequested < (_udpOverhead + IceInternal.Protocol.headerSize)) { _instance.logger().warning("Invalid " + prop + " value of " + sizeRequested + " adjusted to " + diff --git a/java/src/Ice/src/main/java/IceInternal/WSTransceiver.java b/java/src/Ice/src/main/java/IceInternal/WSTransceiver.java index bfa0d65e5a7..fa8e1279fb2 100644 --- a/java/src/Ice/src/main/java/IceInternal/WSTransceiver.java +++ b/java/src/Ice/src/main/java/IceInternal/WSTransceiver.java @@ -484,6 +484,8 @@ final class WSTransceiver implements Transceiver info.localPort = di.localPort; info.remoteAddress = di.remoteAddress; info.remotePort = di.remotePort; + info.rcvSize = di.rcvSize; + info.sndSize = di.sndSize; info.headers = _parser.getHeaders(); return info; } @@ -494,6 +496,12 @@ final class WSTransceiver implements Transceiver _delegate.checkSendSize(buf); } + @Override + public void setBufferSize(int rcvSize, int sndSize) + { + _delegate.setBufferSize(rcvSize, sndSize); + } + WSTransceiver(ProtocolInstance instance, Transceiver del, String host, int port, String resource) { init(instance, del); diff --git a/java/src/Ice/src/main/java/IceSSL/TransceiverI.java b/java/src/Ice/src/main/java/IceSSL/TransceiverI.java index f388e58ac60..128f890e690 100644 --- a/java/src/Ice/src/main/java/IceSSL/TransceiverI.java +++ b/java/src/Ice/src/main/java/IceSSL/TransceiverI.java @@ -257,6 +257,12 @@ final class TransceiverI implements IceInternal.Transceiver } @Override + public void setBufferSize(int rcvSize, int sndSize) + { + _stream.setBufferSize(rcvSize, sndSize); + } + + @Override public void checkSendSize(IceInternal.Buffer buf) { } @@ -306,6 +312,9 @@ final class TransceiverI implements IceInternal.Transceiver info.remotePort = socket.getPort(); } + info.rcvSize = IceInternal.Network.getRecvBufferSize(_stream.fd()); + info.sndSize = IceInternal.Network.getSendBufferSize(_stream.fd()); + SSLSession session = _engine.getSession(); info.cipher = session.getCipherSuite(); try @@ -516,7 +525,7 @@ final class TransceiverI implements IceInternal.Transceiver { throw new Ice.ConnectionLostException(ex); } - + if(_netOutput.hasRemaining()) { _netOutput.compact(); 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 f7c419ce38e..bcd11994621 100644 --- a/java/test/src/main/java/test/Ice/background/Transceiver.java +++ b/java/test/src/main/java/test/Ice/background/Transceiver.java @@ -179,6 +179,12 @@ final class Transceiver implements IceInternal.Transceiver _transceiver.checkSendSize(buf); } + @Override + public void setBufferSize(int rcvSize, int sndSize) + { + _transceiver.setBufferSize(rcvSize, sndSize); + } + public IceInternal.Transceiver delegate() { diff --git a/java/test/src/main/java/test/Ice/info/AllTests.java b/java/test/src/main/java/test/Ice/info/AllTests.java index 3b1c6eca50b..da32674fc1e 100644 --- a/java/test/src/main/java/test/Ice/info/AllTests.java +++ b/java/test/src/main/java/test/Ice/info/AllTests.java @@ -149,7 +149,10 @@ public class AllTests out.print("testing connection information... "); out.flush(); { - Ice.IPConnectionInfo info = (Ice.IPConnectionInfo)base.ice_getConnection().getInfo(); + Ice.Connection connection = base.ice_getConnection(); + connection.setBufferSize(1024, 2048); + + Ice.IPConnectionInfo info = (Ice.IPConnectionInfo)connection.getInfo(); test(!info.incoming); test(info.adapterName.length() == 0); test(info.localPort > 0); @@ -159,6 +162,8 @@ public class AllTests test(info.remoteAddress.equals(defaultHost)); test(info.localAddress.equals(defaultHost)); } + test(info.rcvSize == 1024); + test(info.sndSize == 2048); java.util.Map<String, String> ctx = testIntf.getConnectionInfoAsContext(); test(ctx.get("incoming").equals("true")); @@ -184,7 +189,10 @@ public class AllTests test(ctx.get("ws.Sec-WebSocket-Key") != null); } - info = (Ice.IPConnectionInfo)base.ice_datagram().ice_getConnection().getInfo(); + connection = base.ice_datagram().ice_getConnection(); + connection.setBufferSize(2048, 1024); + + info = (Ice.IPConnectionInfo)connection.getInfo(); test(!info.incoming); test(info.adapterName.length() == 0); test(info.localPort > 0); @@ -194,6 +202,8 @@ public class AllTests test(info.remoteAddress.equals(defaultHost)); test(info.localAddress.equals(defaultHost)); } + test(info.rcvSize == 2048); + test(info.sndSize == 1024); } out.println("ok"); diff --git a/js/src/Ice/ConnectionI.js b/js/src/Ice/ConnectionI.js index 12515cc3451..02039717b91 100644 --- a/js/src/Ice/ConnectionI.js +++ b/js/src/Ice/ConnectionI.js @@ -334,7 +334,7 @@ var ConnectionI = Class({ // called every (timeout / 2) period. // if(acm.heartbeat == Ice.ACMHeartbeat.HeartbeatAlways || - (acm.heartbeat != Ice.ACMHeartbeat.HeartbeatOff && this._writeStream.isEmpty() && + (acm.heartbeat != Ice.ACMHeartbeat.HeartbeatOff && this._writeStream.isEmpty() && now >= (this._acmLastActivity + acm.timeout / 4))) { if(acm.heartbeat != Ice.ACMHeartbeat.HeartbeatOnInvocation || this._dispatchCount > 0) @@ -1351,6 +1351,14 @@ var ConnectionI = Class({ info.incoming = this._incoming; return info; }, + setBufferSize: function(rcvSize, sndSize) + { + if(this._state >= StateClosed) + { + throw this._exception; + } + this._transceiver.setBufferSize(rcvSize, sndSize); + }, exception: function(ex) { this.setState(StateClosed, ex); diff --git a/js/src/Ice/TcpTransceiver.js b/js/src/Ice/TcpTransceiver.js index 5c3d98e1c7e..aad52d2a44a 100644 --- a/js/src/Ice/TcpTransceiver.js +++ b/js/src/Ice/TcpTransceiver.js @@ -284,11 +284,17 @@ var TcpTransceiver = Ice.Class({ info.localPort = this._fd.localPort; info.remoteAddress = this._fd.remoteAddress; info.remotePort = this._fd.remotePort; + info.rcvSize = -1; + info.sndSize = this._maxSendPacketSize; return info; }, checkSendSize: function(stream) { }, + setBufferSize: function(rcvSize, sndSize) + { + this._maxSendPacketSize = sndSize; + }, toString: function() { return this._desc; diff --git a/js/src/Ice/browser/WSTransceiver.js b/js/src/Ice/browser/WSTransceiver.js index 0a7052a16d7..e0a16ed45cb 100644 --- a/js/src/Ice/browser/WSTransceiver.js +++ b/js/src/Ice/browser/WSTransceiver.js @@ -293,12 +293,18 @@ var WSTransceiver = Ice.Class({ info.localPort = -1; info.remoteAddress = this._addr.host; info.remotePort = this._addr.port; + info.rcvSize = -1; + info.sndSize = this._maxSendPacketSize; info.headers = {}; return info; }, checkSendSize: function(stream) { }, + setBUfferSze: function(rcvSize, sndSize) + { + this._maxSendPacketSize = sndSize; + }, toString: function() { return this._desc; diff --git a/objc/src/Ice/ConnectionI.mm b/objc/src/Ice/ConnectionI.mm index 06d317333c2..21b4ce742f8 100644 --- a/objc/src/Ice/ConnectionI.mm +++ b/objc/src/Ice/ConnectionI.mm @@ -29,6 +29,8 @@ self->incoming = connectionInfo->incoming; self->adapterName = [[NSString alloc] initWithUTF8String:connectionInfo->adapterName.c_str()]; self->connectionId = [[NSString alloc] initWithUTF8String:connectionInfo->connectionId.c_str()]; + self->rcvSize = connectionInfo->rcvSize; + self->sndSize = connectionInfo->sndSize; } return self; } @@ -369,6 +371,23 @@ private: return nil; } +-(void) setBufferSize:(int)rcvSize sndSize:(int)sndSize +{ + NSException* nsex = nil; + try + { + CONNECTION->setBufferSize(rcvSize, sndSize); + } + catch(const std::exception& ex) + { + nsex = toObjCException(ex); + } + if(nsex != nil) + { + @throw nsex; + } +} + -(ICEEndpoint*) getEndpoint { NSException* nsex = nil; diff --git a/objc/test/Ice/info/AllTests.m b/objc/test/Ice/info/AllTests.m index dcdb944506e..5f719f3bf61 100644 --- a/objc/test/Ice/info/AllTests.m +++ b/objc/test/Ice/info/AllTests.m @@ -146,7 +146,10 @@ infoAllTests(id<ICECommunicator> communicator) tprintf("testing connection information... "); { - ICEIPConnectionInfo* info = (ICEIPConnectionInfo*)[[base ice_getConnection] getInfo]; + id<ICEConnection> connection = [base ice_getConnection]; + [connection setBufferSize:1024 sndSize:2048]; + + ICEIPConnectionInfo* info = (ICEIPConnectionInfo*)[connection getInfo]; test([info isKindOfClass:[ICEIPConnectionInfo class]]); test(!info.incoming); test([info.adapterName isEqualToString:@""]); @@ -157,6 +160,8 @@ infoAllTests(id<ICECommunicator> communicator) test([info.remoteAddress isEqualToString:defaultHost]); test([info.localAddress isEqualToString:defaultHost]); } + test(info.rcvSize == 1024); + test(info.sndSize == 2048); ICEContext* ctx = [testIntf getConnectionInfoAsContext]; test([[ctx objectForKey:@"incoming"] isEqualToString:@"true"]); @@ -181,7 +186,10 @@ infoAllTests(id<ICECommunicator> communicator) test([ctx objectForKey:@"ws.Sec-WebSocket-Key"] != nil); } - info = (ICEIPConnectionInfo*)[[[base ice_datagram] ice_getConnection] getInfo]; + connection = [[base ice_datagram] ice_getConnection]; + [connection setBufferSize:2048 sndSize:1024]; + + info = (ICEIPConnectionInfo*)[connection getInfo]; test([info isKindOfClass:[ICEIPConnectionInfo class]]); test(!info.incoming); test([info.adapterName isEqualToString:@""]); @@ -192,6 +200,8 @@ infoAllTests(id<ICECommunicator> communicator) test([info.remoteAddress isEqualToString:defaultHost]); test([info.localAddress isEqualToString:defaultHost]); } + test(info.rcvSize == 2048); + test(info.sndSize == 1024); } tprintf("ok\n"); diff --git a/php/src/IcePHP/Connection.cpp b/php/src/IcePHP/Connection.cpp index 1847dd9124b..e04d7123ea6 100644 --- a/php/src/IcePHP/Connection.cpp +++ b/php/src/IcePHP/Connection.cpp @@ -303,6 +303,32 @@ ZEND_METHOD(Ice_Connection, getInfo) } } +ZEND_METHOD(Ice_Connection, setBufferSize) +{ + Ice::ConnectionPtr _this = Wrapper<Ice::ConnectionPtr>::value(getThis() TSRMLS_CC); + assert(_this); + + zval* r; + zval* s; + if(zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, const_cast<char*>("zz"), &r, &s TSRMLS_CC) != SUCCESS) + { + RETURN_NULL(); + } + + int rcvSize = static_cast<int>(Z_LVAL_P(r)); + int sndSize = static_cast<int>(Z_LVAL_P(s)); + + try + { + _this->setBufferSize(rcvSize, sndSize); + } + catch(const IceUtil::Exception& ex) + { + throwException(ex TSRMLS_CC); + RETURN_NULL(); + } +} + #ifdef _WIN32 extern "C" #endif @@ -389,6 +415,7 @@ static zend_function_entry _connectionClassMethods[] = ZEND_ME(Ice_Connection, timeout, NULL, ZEND_ACC_PUBLIC) ZEND_ME(Ice_Connection, toString, NULL, ZEND_ACC_PUBLIC) ZEND_ME(Ice_Connection, getInfo, NULL, ZEND_ACC_PUBLIC) + ZEND_ME(Ice_Connection, setBufferSize, NULL, ZEND_ACC_PUBLIC) {0, 0, 0} }; @@ -650,6 +677,8 @@ IcePHP::createConnectionInfo(zval* zv, const Ice::ConnectionInfoPtr& p TSRMLS_DC add_property_bool(zv, STRCAST("incoming"), p->incoming ? 1 : 0); add_property_string(zv, STRCAST("adapterName"), const_cast<char*>(p->adapterName.c_str()), 1); + add_property_long(zv, STRCAST("rcvSize"), static_cast<long>(p->rcvSize)); + add_property_long(zv, STRCAST("sndSize"), static_cast<long>(p->sndSize)); Wrapper<Ice::ConnectionInfoPtr>* obj = Wrapper<Ice::ConnectionInfoPtr>::extract(zv TSRMLS_CC); assert(obj); diff --git a/php/test/Ice/info/Client.php b/php/test/Ice/info/Client.php index 1e9b275b064..23e296acdba 100644 --- a/php/test/Ice/info/Client.php +++ b/php/test/Ice/info/Client.php @@ -121,7 +121,10 @@ function allTests($communicator) $ipConnectionInfoClass = $NS ? "Ice\\IPConnectionInfo" : "Ice_IPConnectionInfo"; $wsConnectionInfoClass = $NS ? "Ice\\WSConnectionInfo" : "Ice_WSConnectionInfo"; - $info = $base->ice_getConnection()->getInfo(); + $connection = $base->ice_getConnection(); + $connection->setBufferSize(1024, 2048); + + $info = $connection->getInfo(); test($info instanceof $ipConnectionInfoClass); test(!$info->incoming); test(strlen($info->adapterName) == 0); @@ -131,6 +134,8 @@ function allTests($communicator) test($info->remoteAddress == $defaultHost); test($info->localAddress == $defaultHost); } + test($info->rcvSize == 1024); + test($info->sndSize == 2048); $ctx = $testIntf->getConnectionInfoAsContext(); test($ctx["incoming"] == "true"); diff --git a/py/modules/IcePy/Connection.cpp b/py/modules/IcePy/Connection.cpp index 70e03ee5260..c761419993a 100644 --- a/py/modules/IcePy/Connection.cpp +++ b/py/modules/IcePy/Connection.cpp @@ -710,6 +710,34 @@ connectionGetEndpoint(ConnectionObject* self) } } +#ifdef WIN32 +extern "C" +#endif +static PyObject* +connectionSetBufferSize(ConnectionObject* self, PyObject* args) +{ + int rcvSize; + int sndSize; + if(!PyArg_ParseTuple(args, STRCAST("ii"), &rcvSize, &sndSize)) + { + return 0; + } + + assert(self->connection); + try + { + (*self->connection)->setBufferSize(rcvSize, sndSize); + } + catch(const Ice::Exception& ex) + { + setPythonException(ex); + return 0; + } + + Py_INCREF(Py_None); + return Py_None; +} + static PyMethodDef ConnectionMethods[] = { { STRCAST("close"), reinterpret_cast<PyCFunction>(connectionClose), METH_VARARGS, @@ -742,6 +770,8 @@ static PyMethodDef ConnectionMethods[] = PyDoc_STR(STRCAST("getInfo() -> Ice.ConnectionInfo")) }, { STRCAST("getEndpoint"), reinterpret_cast<PyCFunction>(connectionGetEndpoint), METH_NOARGS, PyDoc_STR(STRCAST("getEndpoint() -> Ice.Endpoint")) }, + { STRCAST("setBufferSize"), reinterpret_cast<PyCFunction>(connectionSetBufferSize), METH_VARARGS, + PyDoc_STR(STRCAST("setBufferSize(int, int) -> None")) }, { 0, 0 } /* sentinel */ }; diff --git a/py/modules/IcePy/ConnectionInfo.cpp b/py/modules/IcePy/ConnectionInfo.cpp index d8c34789b63..2381bb303ba 100644 --- a/py/modules/IcePy/ConnectionInfo.cpp +++ b/py/modules/IcePy/ConnectionInfo.cpp @@ -73,6 +73,24 @@ connectionInfoGetAdapterName(ConnectionInfoObject* self) extern "C" #endif static PyObject* +connectionInfoGetRcvSize(ConnectionInfoObject* self) +{ + return PyLong_FromLong((*self->connectionInfo)->rcvSize); +} + +#ifdef WIN32 +extern "C" +#endif +static PyObject* +connectionInfoGetSndSize(ConnectionInfoObject* self) +{ + return PyLong_FromLong((*self->connectionInfo)->sndSize); +} + +#ifdef WIN32 +extern "C" +#endif +static PyObject* ipConnectionInfoGetLocalAddress(ConnectionInfoObject* self) { Ice::IPConnectionInfoPtr info = Ice::IPConnectionInfoPtr::dynamicCast(*self->connectionInfo); @@ -167,6 +185,10 @@ static PyGetSetDef ConnectionInfoGetters[] = PyDoc_STR(STRCAST("whether connection is incoming")), 0 }, { STRCAST("adapterName"), reinterpret_cast<getter>(connectionInfoGetAdapterName), 0, PyDoc_STR(STRCAST("adapter associated the connection")), 0 }, + { STRCAST("rcvSize"), reinterpret_cast<getter>(connectionInfoGetRcvSize), 0, + PyDoc_STR(STRCAST("receive buffer size")), 0 }, + { STRCAST("sndSize"), reinterpret_cast<getter>(connectionInfoGetSndSize), 0, + PyDoc_STR(STRCAST("send buffer size")), 0 }, { 0, 0 } /* sentinel */ }; diff --git a/py/test/Ice/info/AllTests.py b/py/test/Ice/info/AllTests.py index 43094e7f271..4a29ac2603f 100644 --- a/py/test/Ice/info/AllTests.py +++ b/py/test/Ice/info/AllTests.py @@ -132,13 +132,18 @@ def allTests(communicator): sys.stdout.write("testing connection information... ") sys.stdout.flush() - info = base.ice_getConnection().getInfo() + connection = base.ice_getConnection() + connection.setBufferSize(1024, 2048) + + info = connection.getInfo() test(not info.incoming) test(len(info.adapterName) == 0) test(info.remotePort == 12010) if defaultHost == '127.0.0.1': test(info.remoteAddress == defaultHost) test(info.localAddress == defaultHost) + test(info.rcvSize == 1024) + test(info.sndSize == 2048) ctx = testIntf.getConnectionInfoAsContext() test(ctx["incoming"] == "true") diff --git a/rb/src/IceRuby/Connection.cpp b/rb/src/IceRuby/Connection.cpp index be856f508e2..ecc5209c0d5 100644 --- a/rb/src/IceRuby/Connection.cpp +++ b/rb/src/IceRuby/Connection.cpp @@ -219,6 +219,23 @@ IceRuby_Connection_getEndpoint(VALUE self) ICE_RUBY_CATCH return Qnil; } +extern "C" +VALUE +IceRuby_Connection_setBufferSize(VALUE self, VALUE r, VALUE s) +{ + ICE_RUBY_TRY + { + Ice::ConnectionPtr* p = reinterpret_cast<Ice::ConnectionPtr*>(DATA_PTR(self)); + assert(p); + + int rcvSize = static_cast<int>(getInteger(r)); + int sndSize = static_cast<int>(getInteger(s)); + + (*p)->setBufferSize(rcvSize, sndSize); + } + ICE_RUBY_CATCH + return Qnil; +} extern "C" VALUE @@ -331,6 +348,8 @@ IceRuby::createConnectionInfo(const Ice::ConnectionInfoPtr& p) } rb_ivar_set(info, rb_intern("@incoming"), p->incoming ? Qtrue : Qfalse); rb_ivar_set(info, rb_intern("@adapterName"), createString(p->adapterName)); + rb_ivar_set(info, rb_intern("@rcvSize"), INT2FIX(p->rcvSize)); + rb_ivar_set(info, rb_intern("@sndSize"), INT2FIX(p->sndSize)); return info; } @@ -353,6 +372,7 @@ IceRuby::initConnection(VALUE iceModule) rb_define_method(_connectionClass, "timeout", CAST_METHOD(IceRuby_Connection_timeout), 0); rb_define_method(_connectionClass, "getInfo", CAST_METHOD(IceRuby_Connection_getInfo), 0); rb_define_method(_connectionClass, "getEndpoint", CAST_METHOD(IceRuby_Connection_getEndpoint), 0); + rb_define_method(_connectionClass, "setBufferSize", CAST_METHOD(IceRuby_Connection_setBufferSize), 2); rb_define_method(_connectionClass, "toString", CAST_METHOD(IceRuby_Connection_toString), 0); rb_define_method(_connectionClass, "to_s", CAST_METHOD(IceRuby_Connection_toString), 0); rb_define_method(_connectionClass, "inspect", CAST_METHOD(IceRuby_Connection_toString), 0); @@ -369,6 +389,8 @@ IceRuby::initConnection(VALUE iceModule) // rb_define_attr(_connectionInfoClass, "incoming", 1, 0); rb_define_attr(_connectionInfoClass, "adapterName", 1, 0); + rb_define_attr(_connectionInfoClass, "rcvSize", 1, 0); + rb_define_attr(_connectionInfoClass, "sndSize", 1, 0); // // IPConnectionInfo diff --git a/rb/test/Ice/info/AllTests.rb b/rb/test/Ice/info/AllTests.rb index e0847a529bf..c0ccec7110f 100644 --- a/rb/test/Ice/info/AllTests.rb +++ b/rb/test/Ice/info/AllTests.rb @@ -80,7 +80,10 @@ def allTests(communicator) print "testing connection information..." STDOUT.flush - info = base.ice_getConnection().getInfo() + connection = base.ice_getConnection() + connection.setBufferSize(1024, 2048) + + info = connection.getInfo() test(!info.incoming) test(info.adapterName.length == 0) test(info.remotePort == 12010) @@ -88,6 +91,8 @@ def allTests(communicator) test(info.remoteAddress == defaultHost) test(info.localAddress == defaultHost) end + test(info.rcvSize == 1024) + test(info.sndSize == 2048) ctx = testIntf.getConnectionInfoAsContext() test(ctx["incoming"] == "true") diff --git a/slice/Ice/Connection.ice b/slice/Ice/Connection.ice index b20f5c15141..c03b1c373c7 100644 --- a/slice/Ice/Connection.ice +++ b/slice/Ice/Connection.ice @@ -48,6 +48,20 @@ local class ConnectionInfo * **/ string connectionId; + + /** + * + * The connection buffer receive size. + * + **/ + int rcvSize; + + /** + * + * The connection buffer send size. + * + **/ + int sndSize; }; local interface Connection; @@ -266,6 +280,17 @@ local interface Connection * **/ ["cpp:const"] ConnectionInfo getInfo(); + + + /** + * + * Set the connectiion buffer receive/send size. + * + * @rcvSize The connection receive buffer size. + * @sndSize The connection send buffer size. + * + **/ + void setBufferSize(int rcvSize, int sndSize); }; /** |