summaryrefslogtreecommitdiff
path: root/cpp
diff options
context:
space:
mode:
Diffstat (limited to 'cpp')
-rw-r--r--cpp/config/TestUtil.py4
-rw-r--r--cpp/src/Ice/Connection.cpp19
-rw-r--r--cpp/src/Ice/ConnectionFactory.cpp79
-rw-r--r--cpp/src/Ice/ConnectionFactory.h2
-rw-r--r--cpp/src/Slice/Scanner.l2
5 files changed, 45 insertions, 61 deletions
diff --git a/cpp/config/TestUtil.py b/cpp/config/TestUtil.py
index 1631ae35fec..005ef58c5f0 100644
--- a/cpp/config/TestUtil.py
+++ b/cpp/config/TestUtil.py
@@ -16,8 +16,8 @@ import sys, os
# protocol. Otherwise TCP is used.
#
-#protocol = "ssl"
-protocol = ""
+protocol = "ssl"
+#protocol = ""
#
# Set compressed to 1 in case you want to run the tests with
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();
}