diff options
author | Marc Laukien <marc@zeroc.com> | 2002-07-01 18:03:44 +0000 |
---|---|---|
committer | Marc Laukien <marc@zeroc.com> | 2002-07-01 18:03:44 +0000 |
commit | 35486b505c44e937115759d29ecf12ca470951d5 (patch) | |
tree | 0cec36d62b0d08465598b79e5c207568daf6602e /cpp/src | |
parent | Added additional check to make sure that no exception is mentioned more (diff) | |
download | ice-35486b505c44e937115759d29ecf12ca470951d5.tar.bz2 ice-35486b505c44e937115759d29ecf12ca470951d5.tar.xz ice-35486b505c44e937115759d29ecf12ca470951d5.zip |
validation fixes
Diffstat (limited to 'cpp/src')
-rw-r--r-- | cpp/src/Ice/Connection.cpp | 19 | ||||
-rw-r--r-- | cpp/src/Ice/ConnectionFactory.cpp | 79 | ||||
-rw-r--r-- | cpp/src/Ice/ConnectionFactory.h | 2 | ||||
-rw-r--r-- | cpp/src/Slice/Scanner.l | 2 |
4 files changed, 43 insertions, 59 deletions
diff --git a/cpp/src/Ice/Connection.cpp b/cpp/src/Ice/Connection.cpp index f30bd36759c..5b39e960feb 100644 --- a/cpp/src/Ice/Connection.cpp +++ b/cpp/src/Ice/Connection.cpp @@ -833,10 +833,25 @@ IceInternal::Connection::Connection(const InstancePtr& instance, { // // Incoming connections play the active role with respect - // to connection validation. + // to connection validation, and are implicitly validated. // + try + { + validateConnection(); + } + catch(const LocalException& ex) + { + if(_warn) + { + Warning out(_logger); + out << "connection exception:\n" << ex << '\n' << _transceiver->toString(); + } + _transceiver->close(); + _state = StateClosed; + ex.ice_throw(); + } + _connectionValidated = true; - validateConnection(); } else { diff --git a/cpp/src/Ice/ConnectionFactory.cpp b/cpp/src/Ice/ConnectionFactory.cpp index 0645e0dee39..f9cc9d234f4 100644 --- a/cpp/src/Ice/ConnectionFactory.cpp +++ b/cpp/src/Ice/ConnectionFactory.cpp @@ -331,30 +331,15 @@ IceInternal::IncomingConnectionFactory::message(BasicStream&, const ThreadPoolPt // // Now accept a new connection. // + TransceiverPtr transceiver; try { - TransceiverPtr transceiver = _acceptor->accept(0); - // Test code: We drop every 2nd connection we accept. -/* - if(++_testCount % 2) - { - transceiver->close(); - } - else -*/ { - ConnectionPtr connection = new Connection(_instance, transceiver, _endpoint, _adapter); - connection->activate(); - _connections.push_back(connection); - } - } - catch(const SocketException&) - { - // TODO: bandaid. Takes care of SSL Handshake problems during - // creation of a Transceiver. Ignore, nothing we can do here. + transceiver = _acceptor->accept(0); } catch(const TimeoutException&) { // Ignore timeouts. + return; } catch(const LocalException& ex) { @@ -364,6 +349,27 @@ IceInternal::IncomingConnectionFactory::message(BasicStream&, const ThreadPoolPt out << "connection exception:\n" << ex << '\n' << _acceptor->toString(); } setState(StateClosed); + return; + } + + // + // Create and activate a connection object for the connection. + // + try + { + assert(transceiver); + ConnectionPtr connection = new Connection(_instance, transceiver, _endpoint, _adapter); + connection->activate(); + _connections.push_back(connection); + } + catch(const LocalException&) + { + // + // Ignore all exceptions while creating or activating the + // connection object. Warning or error messages for such + // exceptions must be printed directly in the connection + // object code. + // } } @@ -380,41 +386,6 @@ IceInternal::IncomingConnectionFactory::finished(const ThreadPoolPtr& threadPool } else if(_state == StateClosed) { -// -// With the new connection validation, this code is not needed -// anymore. -// -/* - try - { - // - // Clear listen() backlog properly by accepting all queued - // connections, and then shutting them down. - // - while(true) - { - try - { - TransceiverPtr transceiver = _acceptor->accept(0); - ConnectionPtr connection = new Connection(_instance, transceiver, _endpoint, _adapter); - connection->destroy(Connection::ObjectAdapterDeactivated); - } - catch(const TimeoutException&) - { - break; // Exit loop on timeout. - } - } - } - catch(const LocalException& ex) - { - if(_warn) - { - Warning out(_instance->logger()); - out << "connection exception:\n" << ex << '\n' << _acceptor->toString(); - } - } -*/ - _acceptor->close(); // @@ -478,7 +449,7 @@ IceInternal::IncomingConnectionFactory::IncomingConnectionFactory(const Instance _acceptor->listen(); } } - catch (...) + catch(...) { setState(StateClosed); throw; diff --git a/cpp/src/Ice/ConnectionFactory.h b/cpp/src/Ice/ConnectionFactory.h index 72fe7c4508d..15fadcf3ca8 100644 --- a/cpp/src/Ice/ConnectionFactory.h +++ b/cpp/src/Ice/ConnectionFactory.h @@ -101,8 +101,6 @@ private: State _state; bool _warn; bool _registeredWithPool; - - int _testCount; // TODO: For test only. }; } diff --git a/cpp/src/Slice/Scanner.l b/cpp/src/Slice/Scanner.l index 0e0b878b21a..4fdc7b58d59 100644 --- a/cpp/src/Slice/Scanner.l +++ b/cpp/src/Slice/Scanner.l @@ -25,7 +25,7 @@ namespace Slice typedef std::map<std::string, int, Slice::CICompare> StringTokenMap; static StringTokenMap keywordMap; -void Slice::initScanner(); +void initScanner(); } |