summaryrefslogtreecommitdiff
path: root/cpp/src
diff options
context:
space:
mode:
authorMarc Laukien <marc@zeroc.com>2002-06-27 21:02:54 +0000
committerMarc Laukien <marc@zeroc.com>2002-06-27 21:02:54 +0000
commite6b02c9be09773e58cbaec175fb180d58b8c4984 (patch)
tree5a4bf4277e5f8af1aea0ec10fe23b58c11b8de4e /cpp/src
parentfile IcePackAdmin.py was initially added on branch location. (diff)
downloadice-e6b02c9be09773e58cbaec175fb180d58b8c4984.tar.bz2
ice-e6b02c9be09773e58cbaec175fb180d58b8c4984.tar.xz
ice-e6b02c9be09773e58cbaec175fb180d58b8c4984.zip
started with connection verification
Diffstat (limited to 'cpp/src')
-rw-r--r--cpp/src/Ice/Connection.cpp78
-rw-r--r--cpp/src/Ice/Connection.h1
-rw-r--r--cpp/src/Ice/EventHandler.h7
3 files changed, 40 insertions, 46 deletions
diff --git a/cpp/src/Ice/Connection.cpp b/cpp/src/Ice/Connection.cpp
index 8fe9ea0036b..e25f1c98fb3 100644
--- a/cpp/src/Ice/Connection.cpp
+++ b/cpp/src/Ice/Connection.cpp
@@ -171,7 +171,8 @@ IceInternal::Connection::sendRequest(Outgoing* out, bool oneway, bool comp)
catch(const LocalException& ex)
{
setState(StateClosed, ex);
- ex.ice_throw();
+ assert(_exception.get());
+ _exception->ice_throw();
}
//
@@ -318,7 +319,8 @@ IceInternal::Connection::flushBatchRequest(bool comp)
catch(const LocalException& ex)
{
setState(StateClosed, ex);
- ex.ice_throw();
+ assert(_exception.get());
+ _exception->ice_throw();
}
}
@@ -344,7 +346,7 @@ IceInternal::Connection::setAdapter(const ObjectAdapterPtr& adapter)
//
// 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.k
+ // mode, and thus ignore closing mode here.
//
if(_state == StateActive)
{
@@ -417,8 +419,8 @@ IceInternal::Connection::message(BasicStream& stream, const ThreadPoolPtr& threa
// Uncompress if necessary.
//
if(messageType == compressedRequestMsg ||
- messageType == compressedRequestBatchMsg ||
- messageType == compressedReplyMsg)
+ messageType == compressedRequestBatchMsg ||
+ messageType == compressedReplyMsg)
{
BasicStream ustream(_instance);
uncompress(stream, ustream);
@@ -637,7 +639,7 @@ IceInternal::Connection::message(BasicStream& stream, const ThreadPoolPtr& threa
out << "unknown user exception:\n" << ex << '\n' << _transceiver->toString();
}
}
- catch (...)
+ catch(...)
{
IceUtil::RecMutex::Lock sync(*this);
if(_warn)
@@ -759,33 +761,6 @@ IceInternal::Connection::exception(const LocalException& ex)
setState(StateClosed, ex);
}
-/*
-bool
-IceInternal::Connection::tryDestroy(const ThreadPoolPtr& threadPool)
-{
- bool isLocked = trylock();
- if(!isLocked)
- {
- return false;
- }
-
- threadPool->promoteFollower();
-
- try
- {
- setState(StateClosing, CloseConnectionException(__FILE__, __LINE__));
- }
- catch (...)
- {
- unlock();
- throw;
- }
-
- unlock();
- return true;
-}
-*/
-
IceInternal::Connection::Connection(const InstancePtr& instance,
const TransceiverPtr& transceiver,
const EndpointPtr& endpoint,
@@ -806,6 +781,24 @@ IceInternal::Connection::Connection(const InstancePtr& instance,
_registeredWithPool(false)
{
_warn = _instance->properties()->getPropertyAsInt("Ice.ConnectionWarnings") > 0;
+
+ if(_adapter)
+ {
+ //
+ // Incoming connections are always implicitly validated.
+ //
+ _connectionValidated = true;
+ }
+ else
+ {
+ //
+ // Outoging datagram connections are always validated
+ // implicitly. Outgoing non-datagram connections must receive a
+ // message from the server for connection validation.
+ //
+ //_connectionValidated = _endpoint->datagram();
+ _connectionValidated = true; // TODO: Not finished yet.
+ }
}
IceInternal::Connection::~Connection()
@@ -844,20 +837,27 @@ IceInternal::Connection::setState(State state, const LocalException& ex)
if(!_exception.get())
{
- _exception = auto_ptr<LocalException>(dynamic_cast<LocalException*>(ex.ice_clone()));
+ if(_connectionValidated)
+ {
+ _exception = auto_ptr<LocalException>(dynamic_cast<LocalException*>(ex.ice_clone()));
+ }
+ else
+ {
+ _exception = auto_ptr<LocalException>(new CloseConnectionException(__FILE__, __LINE__));
+ }
if(_warn)
{
//
// Don't warn about certain expected exceptions.
//
- if(!(dynamic_cast<const CloseConnectionException*>(&ex) ||
- dynamic_cast<const CommunicatorDestroyedException*>(&ex) ||
- dynamic_cast<const ObjectAdapterDeactivatedException*>(&ex) ||
- (dynamic_cast<const ConnectionLostException*>(&ex) && _state == StateClosing)))
+ if(!(dynamic_cast<const CloseConnectionException*>(_exception.get()) ||
+ dynamic_cast<const CommunicatorDestroyedException*>(_exception.get()) ||
+ dynamic_cast<const ObjectAdapterDeactivatedException*>(_exception.get()) ||
+ (dynamic_cast<const ConnectionLostException*>(_exception.get()) && _state == StateClosing)))
{
Warning out(_logger);
- out << "connection exception:\n" << ex << '\n' << _transceiver->toString();
+ out << "connection exception:\n" << *_exception.get() << '\n' << _transceiver->toString();
}
}
}
diff --git a/cpp/src/Ice/Connection.h b/cpp/src/Ice/Connection.h
index 0128cd029f8..102012f6378 100644
--- a/cpp/src/Ice/Connection.h
+++ b/cpp/src/Ice/Connection.h
@@ -114,6 +114,7 @@ private:
State _state;
bool _warn;
bool _registeredWithPool;
+ bool _connectionValidated;
};
}
diff --git a/cpp/src/Ice/EventHandler.h b/cpp/src/Ice/EventHandler.h
index 3205f077489..db4700bd15d 100644
--- a/cpp/src/Ice/EventHandler.h
+++ b/cpp/src/Ice/EventHandler.h
@@ -59,13 +59,6 @@ public:
//
virtual void exception(const ::Ice::LocalException&) = 0;
- //
- // Try to destroy the event handler. Returns false if the event
- // handler cannot be destroyed because it is in use, or true
- // otherwise.
- //
-// virtual bool tryDestroy(const ThreadPoolPtr&) = 0;
-
protected:
EventHandler(const InstancePtr&);