summaryrefslogtreecommitdiff
path: root/cpp
diff options
context:
space:
mode:
authorDwayne Boone <dwayne@zeroc.com>2015-03-05 15:44:08 -0330
committerDwayne Boone <dwayne@zeroc.com>2015-03-05 15:44:08 -0330
commitb96b045ecc6e034307ba8065af73c252e0093bbb (patch)
treec3f22df1c67a7de3c435c4be31ef2adfb300b1e8 /cpp
parentFixed linux php build (diff)
downloadice-b96b045ecc6e034307ba8065af73c252e0093bbb.tar.bz2
ice-b96b045ecc6e034307ba8065af73c252e0093bbb.tar.xz
ice-b96b045ecc6e034307ba8065af73c252e0093bbb.zip
ICE-6082 No way to discover send/recv buffer sizes
Diffstat (limited to 'cpp')
-rw-r--r--cpp/src/Ice/ConnectionI.cpp46
-rw-r--r--cpp/src/Ice/ConnectionI.h2
-rw-r--r--cpp/src/Ice/Network.cpp37
-rw-r--r--cpp/src/Ice/Network.h1
-rw-r--r--cpp/src/Ice/StreamSocket.cpp16
-rw-r--r--cpp/src/Ice/StreamSocket.h9
-rw-r--r--cpp/src/Ice/TcpTransceiver.cpp10
-rw-r--r--cpp/src/Ice/TcpTransceiver.h1
-rw-r--r--cpp/src/Ice/Transceiver.h1
-rw-r--r--cpp/src/Ice/UdpTransceiver.cpp28
-rw-r--r--cpp/src/Ice/UdpTransceiver.h3
-rw-r--r--cpp/src/Ice/WSTransceiver.cpp8
-rw-r--r--cpp/src/Ice/WSTransceiver.h1
-rw-r--r--cpp/src/Ice/winrt/StreamTransceiver.cpp13
-rw-r--r--cpp/src/Ice/winrt/StreamTransceiver.h1
-rw-r--r--cpp/src/IceSSL/OpenSSLTransceiverI.cpp10
-rw-r--r--cpp/src/IceSSL/OpenSSLTransceiverI.h1
-rw-r--r--cpp/src/IceSSL/SChannelTransceiverI.cpp8
-rw-r--r--cpp/src/IceSSL/SChannelTransceiverI.h1
-rw-r--r--cpp/src/IceSSL/SecureTransportTransceiverI.cpp18
-rw-r--r--cpp/src/IceSSL/SecureTransportTransceiverI.h1
-rw-r--r--cpp/test/Ice/background/Transceiver.cpp12
-rw-r--r--cpp/test/Ice/background/Transceiver.h1
-rw-r--r--cpp/test/Ice/info/AllTests.cpp14
24 files changed, 184 insertions, 59 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;