summaryrefslogtreecommitdiff
path: root/cpp/src
diff options
context:
space:
mode:
Diffstat (limited to 'cpp/src')
-rw-r--r--cpp/src/Ice/DefaultsAndOverrides.cpp9
-rw-r--r--cpp/src/Ice/DefaultsAndOverrides.h1
-rw-r--r--cpp/src/Ice/IPEndpointI.h2
-rw-r--r--cpp/src/Ice/PropertyNames.cpp1
-rw-r--r--cpp/src/Ice/ProtocolInstance.cpp7
-rw-r--r--cpp/src/Ice/ProtocolInstance.h1
-rw-r--r--cpp/src/Ice/TcpEndpointI.cpp37
-rw-r--r--cpp/src/Ice/TcpEndpointI.h1
-rw-r--r--cpp/src/Ice/winrt/StreamEndpointI.cpp37
-rw-r--r--cpp/src/Ice/winrt/StreamEndpointI.h1
-rw-r--r--cpp/src/IceSSL/EndpointI.cpp37
-rw-r--r--cpp/src/IceSSL/EndpointI.h1
12 files changed, 113 insertions, 22 deletions
diff --git a/cpp/src/Ice/DefaultsAndOverrides.cpp b/cpp/src/Ice/DefaultsAndOverrides.cpp
index 8df552d9d20..fc4cf920a7f 100644
--- a/cpp/src/Ice/DefaultsAndOverrides.cpp
+++ b/cpp/src/Ice/DefaultsAndOverrides.cpp
@@ -110,6 +110,15 @@ IceInternal::DefaultsAndOverrides::DefaultsAndOverrides(const PropertiesPtr& pro
throw ex;
}
+ const_cast<int&>(defaultTimeout) =
+ properties->getPropertyAsIntWithDefault("Ice.Default.Timeout", 60000);
+ if(defaultTimeout < 1 && defaultTimeout != -1)
+ {
+ InitializationException ex(__FILE__, __LINE__);
+ ex.reason = "invalid value for Ice.Default.Timeout: `" + properties->getProperty("Ice.Default.Timeout") + "'";
+ throw ex;
+ }
+
const_cast<int&>(defaultInvocationTimeout) =
properties->getPropertyAsIntWithDefault("Ice.Default.InvocationTimeout", -1);
diff --git a/cpp/src/Ice/DefaultsAndOverrides.h b/cpp/src/Ice/DefaultsAndOverrides.h
index 5ce55469c31..01d6ec345c7 100644
--- a/cpp/src/Ice/DefaultsAndOverrides.h
+++ b/cpp/src/Ice/DefaultsAndOverrides.h
@@ -33,6 +33,7 @@ public:
std::string defaultProtocol;
bool defaultCollocationOptimization;
Ice::EndpointSelectionType defaultEndpointSelection;
+ int defaultTimeout;
int defaultInvocationTimeout;
int defaultLocatorCacheTimeout;
bool defaultPreferSecure;
diff --git a/cpp/src/Ice/IPEndpointI.h b/cpp/src/Ice/IPEndpointI.h
index 06cb405e5da..f63a137f3b3 100644
--- a/cpp/src/Ice/IPEndpointI.h
+++ b/cpp/src/Ice/IPEndpointI.h
@@ -76,7 +76,7 @@ public:
using EndpointI::connectors;
using EndpointI::connectionId;
- void initWithOptions(std::vector<std::string>&, bool);
+ virtual void initWithOptions(std::vector<std::string>&, bool);
protected:
diff --git a/cpp/src/Ice/PropertyNames.cpp b/cpp/src/Ice/PropertyNames.cpp
index 44c32e9e96b..78e3ce143ec 100644
--- a/cpp/src/Ice/PropertyNames.cpp
+++ b/cpp/src/Ice/PropertyNames.cpp
@@ -106,6 +106,7 @@ const IceInternal::Property IcePropsData[] =
IceInternal::Property("Ice.Default.Router", false, 0),
IceInternal::Property("Ice.Default.SlicedFormat", false, 0),
IceInternal::Property("Ice.Default.SourceAddress", false, 0),
+ IceInternal::Property("Ice.Default.Timeout", false, 0),
IceInternal::Property("Ice.IPv4", false, 0),
IceInternal::Property("Ice.IPv6", false, 0),
IceInternal::Property("Ice.EventLog.Source", false, 0),
diff --git a/cpp/src/Ice/ProtocolInstance.cpp b/cpp/src/Ice/ProtocolInstance.cpp
index b643a0c7020..363de0cb1b0 100644
--- a/cpp/src/Ice/ProtocolInstance.cpp
+++ b/cpp/src/Ice/ProtocolInstance.cpp
@@ -72,6 +72,13 @@ IceInternal::ProtocolInstance::defaultEncoding() const
return _instance->defaultsAndOverrides()->defaultEncoding;
}
+int
+IceInternal::ProtocolInstance::defaultTimeout() const
+{
+ return _instance->defaultsAndOverrides()->defaultTimeout;
+}
+
+
NetworkProxyPtr
IceInternal::ProtocolInstance::networkProxy() const
{
diff --git a/cpp/src/Ice/ProtocolInstance.h b/cpp/src/Ice/ProtocolInstance.h
index 6a356af9a87..9a0ebec59b9 100644
--- a/cpp/src/Ice/ProtocolInstance.h
+++ b/cpp/src/Ice/ProtocolInstance.h
@@ -65,6 +65,7 @@ public:
const Ice::EncodingVersion& defaultEncoding() const;
NetworkProxyPtr networkProxy() const;
size_t messageSizeMax() const;
+ int defaultTimeout() const;
std::vector<ConnectorPtr> resolve(const std::string&, int, Ice::EndpointSelectionType, const IPEndpointIPtr&) const;
void resolve(const std::string&, int, Ice::EndpointSelectionType, const IPEndpointIPtr&,
diff --git a/cpp/src/Ice/TcpEndpointI.cpp b/cpp/src/Ice/TcpEndpointI.cpp
index 7d593d6203a..a47c956c6c2 100644
--- a/cpp/src/Ice/TcpEndpointI.cpp
+++ b/cpp/src/Ice/TcpEndpointI.cpp
@@ -32,7 +32,7 @@ IceInternal::TcpEndpointI::TcpEndpointI(const ProtocolInstancePtr& instance, con
IceInternal::TcpEndpointI::TcpEndpointI(const ProtocolInstancePtr& instance) :
IPEndpointI(instance),
- _timeout(-1),
+ _timeout(-2),
_compress(false)
{
}
@@ -164,7 +164,11 @@ IceInternal::TcpEndpointI::options() const
s << IPEndpointI::options();
- if(_timeout != -1)
+ if(_timeout == -1)
+ {
+ s << " -t infinite";
+ }
+ else
{
s << " -t " << _timeout;
}
@@ -277,6 +281,17 @@ IceInternal::TcpEndpointI::fillEndpointInfo(IPEndpointInfo* info) const
}
}
+void
+IceInternal::TcpEndpointI::initWithOptions(vector<string>& args, bool oaEndpoint)
+{
+ IPEndpointI::initWithOptions(args, oaEndpoint);
+
+ if(_timeout == -2)
+ {
+ const_cast<Int&>(_timeout) = _instance->defaultTimeout();
+ }
+}
+
bool
IceInternal::TcpEndpointI::checkOption(const string& option, const string& argument, const string& endpoint)
{
@@ -295,12 +310,20 @@ IceInternal::TcpEndpointI::checkOption(const string& option, const string& argum
ex.str = "no argument provided for -t option in endpoint " + endpoint;
throw ex;
}
- istringstream t(argument);
- if(!(t >> const_cast<Int&>(_timeout)) || !t.eof())
+
+ if(argument == "infinite")
+ {
+ const_cast<Int&>(_timeout) = -1;
+ }
+ else
{
- EndpointParseException ex(__FILE__, __LINE__);
- ex.str = "invalid timeout value `" + argument + "' in endpoint " + endpoint;
- throw ex;
+ istringstream t(argument);
+ if(!(t >> const_cast<Int&>(_timeout)) || !t.eof() || _timeout < 1)
+ {
+ EndpointParseException ex(__FILE__, __LINE__);
+ ex.str = "invalid timeout value `" + argument + "' in endpoint " + endpoint;
+ throw ex;
+ }
}
return true;
}
diff --git a/cpp/src/Ice/TcpEndpointI.h b/cpp/src/Ice/TcpEndpointI.h
index 3dba15da6f4..0e94a1d1de7 100644
--- a/cpp/src/Ice/TcpEndpointI.h
+++ b/cpp/src/Ice/TcpEndpointI.h
@@ -50,6 +50,7 @@ protected:
virtual void streamWriteImpl(BasicStream*) const;
virtual void hashInit(Ice::Int&) const;
virtual void fillEndpointInfo(Ice::IPEndpointInfo*) const;
+ virtual void initWithOptions(std::vector<std::string>&, bool);
virtual bool checkOption(const std::string&, const std::string&, const std::string&);
virtual ConnectorPtr createConnector(const Address&, const NetworkProxyPtr&) const;
diff --git a/cpp/src/Ice/winrt/StreamEndpointI.cpp b/cpp/src/Ice/winrt/StreamEndpointI.cpp
index b58f9e826ce..5bb59dea33b 100644
--- a/cpp/src/Ice/winrt/StreamEndpointI.cpp
+++ b/cpp/src/Ice/winrt/StreamEndpointI.cpp
@@ -72,7 +72,7 @@ IceInternal::StreamEndpointI::StreamEndpointI(const ProtocolInstancePtr& instanc
IceInternal::StreamEndpointI::StreamEndpointI(const ProtocolInstancePtr& instance) :
IPEndpointI(instance),
- _timeout(-1),
+ _timeout(-2),
_compress(false)
{
}
@@ -193,7 +193,11 @@ IceInternal::StreamEndpointI::options() const
s << IPEndpointI::options();
- if(_timeout != -1)
+ if(_timeout == -1)
+ {
+ s << " -t infinite";
+ }
+ else
{
s << " -t " << _timeout;
}
@@ -294,6 +298,17 @@ IceInternal::StreamEndpointI::hashInit(Ice::Int& h) const
hashAdd(h, _compress);
}
+void
+IceInternal::StreamEndpointI::initWithOptions(vector<string>& args, bool oaEndpoint)
+{
+ IPEndpointI::initWithOptions(args, oaEndpoint);
+
+ if(_timeout == -2)
+ {
+ const_cast<Int&>(_timeout) = _instance->defaultTimeout();
+ }
+}
+
bool
IceInternal::StreamEndpointI::checkOption(const string& option, const string& argument, const string& endpoint)
{
@@ -312,12 +327,20 @@ IceInternal::StreamEndpointI::checkOption(const string& option, const string& ar
ex.str = "no argument provided for -t option in endpoint " + endpoint;
throw ex;
}
- istringstream t(argument);
- if(!(t >> const_cast<Int&>(_timeout)) || !t.eof())
+
+ if(argument == "infinite")
{
- EndpointParseException ex(__FILE__, __LINE__);
- ex.str = "invalid timeout value `" + argument + "' in endpoint " + endpoint;
- throw ex;
+ const_cast<Int&>(_timeout) = -1;
+ }
+ else
+ {
+ istringstream t(argument);
+ if(!(t >> const_cast<Int&>(_timeout)) || !t.eof() || _timeout < 1)
+ {
+ EndpointParseException ex(__FILE__, __LINE__);
+ ex.str = "invalid timeout value `" + argument + "' in endpoint " + endpoint;
+ throw ex;
+ }
}
return true;
}
diff --git a/cpp/src/Ice/winrt/StreamEndpointI.h b/cpp/src/Ice/winrt/StreamEndpointI.h
index 59ebc442417..58de59fd410 100644
--- a/cpp/src/Ice/winrt/StreamEndpointI.h
+++ b/cpp/src/Ice/winrt/StreamEndpointI.h
@@ -49,6 +49,7 @@ protected:
virtual void streamWriteImpl(BasicStream*) const;
virtual void hashInit(Ice::Int&) const;
+ virtual void initWithOptions(std::vector<std::string>&, bool);
virtual bool checkOption(const std::string&, const std::string&, const std::string&);
virtual ConnectorPtr createConnector(const Address&, const NetworkProxyPtr&) const;
diff --git a/cpp/src/IceSSL/EndpointI.cpp b/cpp/src/IceSSL/EndpointI.cpp
index 7782e11f517..aab9bb2efc6 100644
--- a/cpp/src/IceSSL/EndpointI.cpp
+++ b/cpp/src/IceSSL/EndpointI.cpp
@@ -33,7 +33,7 @@ IceSSL::EndpointI::EndpointI(const InstancePtr& instance, const string& ho, Int
IceSSL::EndpointI::EndpointI(const InstancePtr& instance) :
IceInternal::IPEndpointI(instance),
_instance(instance),
- _timeout(-1),
+ _timeout(-2),
_compress(false)
{
}
@@ -165,7 +165,11 @@ IceSSL::EndpointI::options() const
ostringstream s;
s << IPEndpointI::options();
- if(_timeout != -1)
+ if(_timeout == -1)
+ {
+ s << " -t infinite";
+ }
+ else
{
s << " -t " << _timeout;
}
@@ -278,6 +282,17 @@ IceSSL::EndpointI::fillEndpointInfo(IPEndpointInfo* info) const
}
}
+void
+IceSSL::EndpointI::initWithOptions(vector<string>& args, bool oaEndpoint)
+{
+ IPEndpointI::initWithOptions(args, oaEndpoint);
+
+ if(_timeout == -2)
+ {
+ const_cast<Int&>(_timeout) = _instance->defaultTimeout();
+ }
+}
+
bool
IceSSL::EndpointI::checkOption(const string& option, const string& argument, const string& endpoint)
{
@@ -296,12 +311,20 @@ IceSSL::EndpointI::checkOption(const string& option, const string& argument, con
ex.str = "no argument provided for -t option in endpoint " + endpoint;
throw ex;
}
- istringstream t(argument);
- if(!(t >> const_cast<Int&>(_timeout)) || !t.eof())
+
+ if(argument == "infinite")
+ {
+ const_cast<Int&>(_timeout) = -1;
+ }
+ else
{
- EndpointParseException ex(__FILE__, __LINE__);
- ex.str = "invalid timeout value `" + argument + "' in endpoint " + endpoint;
- throw ex;
+ istringstream t(argument);
+ if(!(t >> const_cast<Int&>(_timeout)) || !t.eof() || _timeout < 1)
+ {
+ EndpointParseException ex(__FILE__, __LINE__);
+ ex.str = "invalid timeout value `" + argument + "' in endpoint " + endpoint;
+ throw ex;
+ }
}
return true;
}
diff --git a/cpp/src/IceSSL/EndpointI.h b/cpp/src/IceSSL/EndpointI.h
index 5d797d2dfe7..a760e8d3ae8 100644
--- a/cpp/src/IceSSL/EndpointI.h
+++ b/cpp/src/IceSSL/EndpointI.h
@@ -51,6 +51,7 @@ protected:
virtual void streamWriteImpl(IceInternal::BasicStream*) const;
virtual void hashInit(Ice::Int&) const;
virtual void fillEndpointInfo(Ice::IPEndpointInfo*) const;
+ virtual void initWithOptions(std::vector<std::string>&, bool);
virtual bool checkOption(const std::string&, const std::string&, const std::string&);
virtual IceInternal::ConnectorPtr createConnector(const IceInternal::Address&,