summaryrefslogtreecommitdiff
path: root/cpp/src
diff options
context:
space:
mode:
Diffstat (limited to 'cpp/src')
-rw-r--r--cpp/src/Ice/Connection.cpp50
-rw-r--r--cpp/src/Ice/Connection.h2
-rw-r--r--cpp/src/Ice/Instance.cpp7
-rw-r--r--cpp/src/Ice/ThreadPool.h2
-rw-r--r--cpp/src/Ice/UdpTransceiver.cpp21
-rw-r--r--cpp/src/Ice/UdpTransceiver.h2
6 files changed, 30 insertions, 54 deletions
diff --git a/cpp/src/Ice/Connection.cpp b/cpp/src/Ice/Connection.cpp
index d23fa6ce8f7..9c1a28ff1da 100644
--- a/cpp/src/Ice/Connection.cpp
+++ b/cpp/src/Ice/Connection.cpp
@@ -890,28 +890,9 @@ IceInternal::Connection::setAdapter(const ObjectAdapterPtr& adapter)
IceUtil::Monitor<IceUtil::RecMutex>::Lock sync(*this);
//
- // We are registered with a thread pool in active and closing
- // mode. However, we only change subscription if we're in active
- // mode, and thus ignore closing mode here.
+ // We never change the thread pool with which we were initially
+ // registered, even if we add or remove an object adapter.
//
- if(_state == StateActive)
- {
- if(adapter && !_adapter)
- {
- //
- // Client is now server.
- //
- unregisterWithPool();
- }
-
- if(!adapter && _adapter)
- {
- //
- // Server is now client.
- //
- unregisterWithPool();
- }
- }
_adapter = adapter;
if(_adapter)
@@ -1299,6 +1280,7 @@ IceInternal::Connection::finished(const ThreadPoolPtr& threadPool)
{
_transceiver->close();
_transceiver = 0;
+ _threadPool = 0; // We don't need the thread pool anymore.
notifyAll();
}
}
@@ -1363,10 +1345,12 @@ IceInternal::Connection::Connection(const InstancePtr& instance,
{
if(_adapter)
{
+ _threadPool = dynamic_cast<ObjectAdapterI*>(_adapter.get())->getThreadPool();
_servantManager = dynamic_cast<ObjectAdapterI*>(_adapter.get())->getServantManager();
}
else
{
+ _threadPool = _instance->clientThreadPool();
_servantManager = 0;
}
@@ -1405,8 +1389,6 @@ IceInternal::Connection::Connection(const InstancePtr& instance,
replyHdr[7] = encodingMinor;
replyHdr[8] = replyMsg;
replyHdr[9] = 1; // Default compression status: compression supported but not used.
-
- _warnUdp = _instance->properties()->getPropertyAsInt("Ice.Warn.Datagrams") > 0;
}
IceInternal::Connection::~Connection()
@@ -1606,15 +1588,8 @@ IceInternal::Connection::registerWithPool()
{
if(!_registeredWithPool)
{
- if(_adapter)
- {
- dynamic_cast<ObjectAdapterI*>(_adapter.get())->getThreadPool()->_register(_transceiver->fd(), this);
- }
- else
- {
- _instance->clientThreadPool()->_register(_transceiver->fd(), this);
- }
-
+ assert(_threadPool);
+ _threadPool->_register(_transceiver->fd(), this);
_registeredWithPool = true;
ConnectionMonitorPtr connectionMonitor = _instance->connectionMonitor();
@@ -1630,15 +1605,8 @@ IceInternal::Connection::unregisterWithPool()
{
if(_registeredWithPool)
{
- if(_adapter)
- {
- dynamic_cast<ObjectAdapterI*>(_adapter.get())->getThreadPool()->unregister(_transceiver->fd());
- }
- else
- {
- _instance->clientThreadPool()->unregister(_transceiver->fd());
- }
-
+ assert(_threadPool);
+ _threadPool->unregister(_transceiver->fd());
_registeredWithPool = false;
ConnectionMonitorPtr connectionMonitor = _instance->connectionMonitor();
diff --git a/cpp/src/Ice/Connection.h b/cpp/src/Ice/Connection.h
index 107d92a3f9a..72834bdcbb0 100644
--- a/cpp/src/Ice/Connection.h
+++ b/cpp/src/Ice/Connection.h
@@ -144,9 +144,9 @@ private:
const TraceLevelsPtr _traceLevels;
bool _registeredWithPool;
+ ThreadPoolPtr _threadPool;
bool _warn;
- bool _warnUdp;
int _acmTimeout;
IceUtil::Time _acmAbsoluteTimeout;
diff --git a/cpp/src/Ice/Instance.cpp b/cpp/src/Ice/Instance.cpp
index 770e7aef0cf..306af207e6d 100644
--- a/cpp/src/Ice/Instance.cpp
+++ b/cpp/src/Ice/Instance.cpp
@@ -365,12 +365,19 @@ IceInternal::Instance::flushBatchRequests()
{
OutgoingConnectionFactoryPtr connectionFactory;
ObjectAdapterFactoryPtr adapterFactory;
+
{
IceUtil::RecMutex::Lock sync(*this);
+ if(_destroyed)
+ {
+ throw CommunicatorDestroyedException(__FILE__, __LINE__);
+ }
+
connectionFactory = _outgoingConnectionFactory;
adapterFactory = _objectAdapterFactory;
}
+
connectionFactory->flushBatchRequests();
adapterFactory->flushBatchRequests();
}
diff --git a/cpp/src/Ice/ThreadPool.h b/cpp/src/Ice/ThreadPool.h
index 3b22c508400..35b445b667b 100644
--- a/cpp/src/Ice/ThreadPool.h
+++ b/cpp/src/Ice/ThreadPool.h
@@ -100,7 +100,7 @@ private:
int _inUse; // Number of threads that are currently in use.
double _load; // Current load in number of threads.
- bool _warnUdp;
+ const bool _warnUdp;
IceUtil::Mutex _promoteMutex;
};
diff --git a/cpp/src/Ice/UdpTransceiver.cpp b/cpp/src/Ice/UdpTransceiver.cpp
index 9e7af7bc5ad..6ee05d8d2b6 100644
--- a/cpp/src/Ice/UdpTransceiver.cpp
+++ b/cpp/src/Ice/UdpTransceiver.cpp
@@ -128,15 +128,15 @@ IceInternal::UdpTransceiver::read(Buffer& buf, int)
const int packetSize = min(_maxPacketSize, _rcvSize - _udpOverhead);
if(packetSize < static_cast<int>(buf.b.size()))
{
- //
- // We log a warning here because this is the server side -- without the
- // the warning, there would only be silence.
- //
- if(_warn)
- {
- Warning out(_logger);
- out << "DatagramLimitException: maximum size of " << packetSize << " exceeded";
- }
+ //
+ // We log a warning here because this is the server side -- without the
+ // the warning, there would only be silence.
+ //
+ if(_warn)
+ {
+ Warning out(_logger);
+ out << "DatagramLimitException: maximum size of " << packetSize << " exceeded";
+ }
throw Ice::DatagramLimitException(__FILE__, __LINE__);
}
buf.b.resize(packetSize);
@@ -261,7 +261,8 @@ IceInternal::UdpTransceiver::UdpTransceiver(const InstancePtr& instance, const s
_traceLevels(instance->traceLevels()),
_logger(instance->logger()),
_incoming(false),
- _connect(true)
+ _connect(true),
+ _warn(instance->properties()->getPropertyAsInt("Ice.Warn.Datagrams") > 0)
{
try
{
diff --git a/cpp/src/Ice/UdpTransceiver.h b/cpp/src/Ice/UdpTransceiver.h
index 852eed16990..e54b034d3bd 100644
--- a/cpp/src/Ice/UdpTransceiver.h
+++ b/cpp/src/Ice/UdpTransceiver.h
@@ -69,7 +69,7 @@ private:
bool _connect;
int _rcvSize;
int _sndSize;
- bool _warn;
+ const bool _warn;
static const int _udpOverhead;
static const int _maxPacketSize;
};