diff options
Diffstat (limited to 'cpp/src')
-rw-r--r-- | cpp/src/Ice/Endpoint.cpp | 69 | ||||
-rw-r--r-- | cpp/src/Ice/Endpoint.h | 9 | ||||
-rw-r--r-- | cpp/src/Ice/ProxyFactory.cpp | 2 | ||||
-rw-r--r-- | cpp/src/Ice/Reference.cpp | 61 | ||||
-rw-r--r-- | cpp/src/Ice/Reference.h | 8 | ||||
-rw-r--r-- | cpp/src/IcePack/Activator.cpp | 6 | ||||
-rw-r--r-- | cpp/src/IcePack/Client.cpp | 2 | ||||
-rw-r--r-- | cpp/src/IcePack/Forward.cpp | 24 | ||||
-rw-r--r-- | cpp/src/IcePack/Forward.h | 1 | ||||
-rw-r--r-- | cpp/src/IcePack/Server.cpp | 6 |
10 files changed, 168 insertions, 20 deletions
diff --git a/cpp/src/Ice/Endpoint.cpp b/cpp/src/Ice/Endpoint.cpp index 2038dbdfb14..833af74472b 100644 --- a/cpp/src/Ice/Endpoint.cpp +++ b/cpp/src/Ice/Endpoint.cpp @@ -19,6 +19,7 @@ #include <Ice/UdpTransceiver.h> #include <Ice/Stream.h> #include <Ice/LocalException.h> +#include <sstream> using namespace std; using namespace Ice; @@ -117,6 +118,12 @@ IceInternal::UnknownEndpoint::streamWrite(Stream* s) const s->write(_rawBytes); } +string +IceInternal::UnknownEndpoint::toString() const +{ + return string(); +} + Short IceInternal::UnknownEndpoint::type() const { @@ -251,7 +258,7 @@ IceInternal::TcpEndpoint::TcpEndpoint(const string& ho, Int po, Int ti) : } IceInternal::TcpEndpoint::TcpEndpoint(const string& str) : - _port(10000), + _port(0), _timeout(-1) { const string delim = " \t\n\r"; @@ -352,6 +359,26 @@ IceInternal::TcpEndpoint::streamWrite(Stream* s) const s->endWriteEncaps(); } +string +IceInternal::TcpEndpoint::toString() const +{ + ostringstream s; + s << "tcp"; + if (_host != getLocalHost(true)) // TODO: Whether numeric or not should be configurable + { + s << " -h " << _host; + } + if (_port != 0) + { + s << " -p " << _port; + } + if (_timeout != -1) + { + s << " -t " << _timeout; + } + return s.str(); +} + Short IceInternal::TcpEndpoint::type() const { @@ -551,7 +578,7 @@ IceInternal::SslEndpoint::SslEndpoint(const string& ho, Int po, Int ti) : } IceInternal::SslEndpoint::SslEndpoint(const string& str) : - _port(10000), + _port(0), _timeout(-1) { const string delim = " \t\n\r"; @@ -652,6 +679,26 @@ IceInternal::SslEndpoint::streamWrite(Stream* s) const s->endWriteEncaps(); } +string +IceInternal::SslEndpoint::toString() const +{ + ostringstream s; + s << "tcp"; + if (_host != getLocalHost(true)) // TODO: Whether numeric or not should be configurable + { + s << " -h " << _host; + } + if (_port != 0) + { + s << " -p " << _port; + } + if (_timeout != -1) + { + s << " -t " << _timeout; + } + return s.str(); +} + Short IceInternal::SslEndpoint::type() const { @@ -850,7 +897,7 @@ IceInternal::UdpEndpoint::UdpEndpoint(const string& ho, Int po) : } IceInternal::UdpEndpoint::UdpEndpoint(const string& str) : - _port(10000) + _port(0) { const string delim = " \t\n\r"; @@ -941,6 +988,22 @@ IceInternal::UdpEndpoint::streamWrite(Stream* s) const s->endWriteEncaps(); } +string +IceInternal::UdpEndpoint::toString() const +{ + ostringstream s; + s << "tcp"; + if (_host != getLocalHost(true)) // TODO: Whether numeric or not should be configurable + { + s << " -h " << _host; + } + if (_port != 0) + { + s << " -p " << _port; + } + return s.str(); +} + Short IceInternal::UdpEndpoint::type() const { diff --git a/cpp/src/Ice/Endpoint.h b/cpp/src/Ice/Endpoint.h index 279b209b76a..c364099fe2f 100644 --- a/cpp/src/Ice/Endpoint.h +++ b/cpp/src/Ice/Endpoint.h @@ -50,6 +50,11 @@ public: virtual void streamWrite(Stream*) const = 0; // + // Convert the endpoint to its string form + // + virtual std::string toString() const = 0; + + // // Return the endpoint type // virtual ::Ice::Short type() const = 0; @@ -124,6 +129,7 @@ public: UnknownEndpoint(Stream*); virtual void streamWrite(Stream*) const; + virtual std::string toString() const; virtual ::Ice::Short type() const; virtual bool oneway() const; virtual ::Ice::Int timeout() const; @@ -158,6 +164,7 @@ public: TcpEndpoint(Stream*); virtual void streamWrite(Stream*) const; + virtual std::string toString() const; virtual ::Ice::Short type() const; virtual bool oneway() const; virtual ::Ice::Int timeout() const; @@ -194,6 +201,7 @@ public: SslEndpoint(Stream*); virtual void streamWrite(Stream*) const; + virtual std::string toString() const; virtual ::Ice::Short type() const; virtual bool oneway() const; virtual ::Ice::Int timeout() const; @@ -230,6 +238,7 @@ public: UdpEndpoint(Stream*); virtual void streamWrite(Stream*) const; + virtual std::string toString() const; virtual ::Ice::Short type() const; virtual bool oneway() const; virtual ::Ice::Int timeout() const; diff --git a/cpp/src/Ice/ProxyFactory.cpp b/cpp/src/Ice/ProxyFactory.cpp index 4ed07a562f6..eacfce7e27c 100644 --- a/cpp/src/Ice/ProxyFactory.cpp +++ b/cpp/src/Ice/ProxyFactory.cpp @@ -32,7 +32,7 @@ IceInternal::ProxyFactory::stringToProxy(const string& s) string IceInternal::ProxyFactory::proxyToString(const ObjectPrx& proxy) { - return "blahblah"; // TODO + return proxy->__reference()->toString(); } ObjectPrx diff --git a/cpp/src/Ice/Reference.cpp b/cpp/src/Ice/Reference.cpp index eee6feee1ee..ca779b73ef3 100644 --- a/cpp/src/Ice/Reference.cpp +++ b/cpp/src/Ice/Reference.cpp @@ -12,6 +12,7 @@ #include <Ice/Endpoint.h> #include <Ice/Stream.h> #include <Ice/LocalException.h> +#include <sstream> using namespace std; using namespace Ice; @@ -119,6 +120,7 @@ IceInternal::Reference::Reference(const InstancePtr& inst, const string& str) : } } + bool orig = true; while (end < s.length() && s[end] == ':') { beg = end + 1; @@ -128,18 +130,40 @@ IceInternal::Reference::Reference(const InstancePtr& inst, const string& str) : { end = s.length(); } + + if (beg == end) // "::" + { + if (!orig) + { + throw ReferenceParseException(__FILE__, __LINE__); + } + + orig = false; + continue; + } string es = s.substr(beg, end - beg); EndpointPtr endp = Endpoint::endpointFromString(es); - const_cast<vector<EndpointPtr>&>(origEndpoints).push_back(endp); + + if(orig) + { + const_cast<vector<EndpointPtr>&>(origEndpoints).push_back(endp); + } + else + { + const_cast<vector<EndpointPtr>&>(endpoints).push_back(endp); + } } - if (!origEndpoints.size()) + if (orig) { - throw ReferenceParseException(__FILE__, __LINE__); + const_cast<vector<EndpointPtr>&>(endpoints) = origEndpoints; } - const_cast<vector<EndpointPtr>&>(endpoints) = origEndpoints; + if (!origEndpoints.size() || !endpoints.size()) + { + throw ReferenceParseException(__FILE__, __LINE__); + } } IceInternal::Reference::Reference(Stream* s) : @@ -180,8 +204,9 @@ IceInternal::Reference::streamWrite(Stream* s) const { s->write(identity); - s->write(Ice::Int(origEndpoints.size())); vector<EndpointPtr>::const_iterator p; + + s->write(Ice::Int(origEndpoints.size())); for (p = origEndpoints.begin(); p != origEndpoints.end(); ++p) { (*p)->streamWrite(s); @@ -194,7 +219,6 @@ IceInternal::Reference::streamWrite(Stream* s) const else { s->write(Ice::Int(endpoints.size())); - vector<EndpointPtr>::const_iterator p; for (p = endpoints.begin(); p != endpoints.end(); ++p) { (*p)->streamWrite(s); @@ -202,6 +226,31 @@ IceInternal::Reference::streamWrite(Stream* s) const } } +string +IceInternal::Reference::toString() const +{ + ostringstream s; + s << identity; + + vector<EndpointPtr>::const_iterator p; + + for (p = origEndpoints.begin(); p != origEndpoints.end(); ++p) + { + s << ':' << (*p)->toString(); + } + + if(endpoints != origEndpoints) + { + s << ':'; + for (p = endpoints.begin(); p != endpoints.end(); ++p) + { + s << ':' << (*p)->toString(); + } + } + + return s.str(); +} + ReferencePtr IceInternal::Reference::changeIdentity(const string& newIdentity) const { diff --git a/cpp/src/Ice/Reference.h b/cpp/src/Ice/Reference.h index bac2d947c17..3fc659beaff 100644 --- a/cpp/src/Ice/Reference.h +++ b/cpp/src/Ice/Reference.h @@ -30,9 +30,17 @@ public: Reference(const InstancePtr&, const std::string&); Reference(Stream*); + // + // Marshal the reference + // void streamWrite(Stream*) const; // + // Convert the reference to its string form + // + std::string toString() const; + + // // All members are const, because References are immutable. // const InstancePtr instance; diff --git a/cpp/src/IcePack/Activator.cpp b/cpp/src/IcePack/Activator.cpp index d3900db798e..ecc3a84da62 100644 --- a/cpp/src/IcePack/Activator.cpp +++ b/cpp/src/IcePack/Activator.cpp @@ -163,6 +163,10 @@ IcePack::Activator::activate(const ServerDescriptionPtr& desc) if (execvp(argv[0], argv) == -1) { + // + // Send any errors to the parent process, using the write + // end of the pipe. + // SystemException ex(__FILE__, __LINE__); ostringstream s; s << "can't execute `" << path << "':\n" << ex; @@ -262,7 +266,7 @@ IcePack::Activator::terminationListener() { // // If the pipe was closed, the process has - // terminated + // terminated. // map<string, Process>::iterator q = p; ++p; diff --git a/cpp/src/IcePack/Client.cpp b/cpp/src/IcePack/Client.cpp index 4f27f3ad5cc..0afafd6c561 100644 --- a/cpp/src/IcePack/Client.cpp +++ b/cpp/src/IcePack/Client.cpp @@ -124,7 +124,7 @@ run(int argc, char* argv[], CommunicatorPtr communicator) PropertiesPtr properties = communicator->getProperties(); string adminEndpoints = properties->getProperty("Ice.Adapter.Admin.Endpoints"); - if(adminEndpoints.length() == 0) + if (adminEndpoints.length() == 0) { cerr << argv[0] << ": `Ice.Adapter.Admin.Endpoints' property is not set" << endl; return EXIT_FAILURE; diff --git a/cpp/src/IcePack/Forward.cpp b/cpp/src/IcePack/Forward.cpp index a5bbc9197df..390cdc7945c 100644 --- a/cpp/src/IcePack/Forward.cpp +++ b/cpp/src/IcePack/Forward.cpp @@ -24,6 +24,23 @@ IcePack::Forward::Forward(const CommunicatorPtr& communicator, const AdminPtr& a #ifndef WIN32 _activator = new Activator(_communicator); _activator->start(); + + PropertiesPtr properties = communicator->getProperties(); + string value; + + value = properties->getProperty("IcePack.Activator.WaitTime"); + if (value.length()) + { + _waitTime = atoi(value); + if (_waitTime < 0) + { + _waitTime = 0; + } + } + else + { + _waitTime = 10; + } #endif } @@ -83,7 +100,7 @@ IcePack::Forward::locate(const ObjectAdapterPtr& adapter, const string& identity if (doSleep) { - sleep(1); // TODO: Make sleep time configurable + sleep(1); } // @@ -117,10 +134,7 @@ IcePack::Forward::locate(const ObjectAdapterPtr& adapter, const string& identity // to give the server more time before we try // again. // - // TODO: Make number of retries configurable, - // ideally in Ice itself. - // - if (++count >= 10) + if (++count >= _waitTime) { throw; } diff --git a/cpp/src/IcePack/Forward.h b/cpp/src/IcePack/Forward.h index fdfb330000b..7ba5bd7022b 100644 --- a/cpp/src/IcePack/Forward.h +++ b/cpp/src/IcePack/Forward.h @@ -37,6 +37,7 @@ private: AdminPtr _admin; #ifndef WIN32 ActivatorHandle _activator; + int _waitTime; #endif }; diff --git a/cpp/src/IcePack/Server.cpp b/cpp/src/IcePack/Server.cpp index 2bec82292cb..c8e0f966372 100644 --- a/cpp/src/IcePack/Server.cpp +++ b/cpp/src/IcePack/Server.cpp @@ -44,7 +44,7 @@ run(int argc, char* argv[], CommunicatorPtr communicator) cout << ICE_STRING_VERSION << endl; return EXIT_SUCCESS; } - else if(strcmp(argv[i], "--nowarn") == 0) + else if (strcmp(argv[i], "--nowarn") == 0) { nowarn = true; } @@ -59,13 +59,13 @@ run(int argc, char* argv[], CommunicatorPtr communicator) PropertiesPtr properties = communicator->getProperties(); string adminEndpoints = properties->getProperty("Ice.Adapter.Admin.Endpoints"); - if(adminEndpoints.length() != 0 && !nowarn) + if (adminEndpoints.length() != 0 && !nowarn) { cerr << argv[0] << ": warning: administrative endpoints `Ice.Adapter.Admin.Endpoints' enabled" << endl; } string forwardEndpoints = properties->getProperty("Ice.Adapter.Forward.Endpoints"); - if(forwardEndpoints.length() == 0) + if (forwardEndpoints.length() == 0) { cerr << argv[0] << ": `Ice.Adapter.Forward.Endpoints' property is not set" << endl; return EXIT_FAILURE; |