diff options
author | Dwayne Boone <dwayne@zeroc.com> | 2014-09-17 13:50:35 -0230 |
---|---|---|
committer | Dwayne Boone <dwayne@zeroc.com> | 2014-09-17 13:50:35 -0230 |
commit | a3d676c4199ff53edd458abf7ce52f6cf83213b4 (patch) | |
tree | d6975ba5b7c3d9e58b5378f2e27ec536e4157517 /cpp/src | |
parent | Simplified creation of Admin facets in IceBox; simplified test for Admin enab... (diff) | |
download | ice-a3d676c4199ff53edd458abf7ce52f6cf83213b4.tar.bz2 ice-a3d676c4199ff53edd458abf7ce52f6cf83213b4.tar.xz ice-a3d676c4199ff53edd458abf7ce52f6cf83213b4.zip |
ICE-4891 some minor improvements
Diffstat (limited to 'cpp/src')
32 files changed, 175 insertions, 130 deletions
diff --git a/cpp/src/Ice/Acceptor.h b/cpp/src/Ice/Acceptor.h index 0b7342ad88f..64c88447cd0 100644 --- a/cpp/src/Ice/Acceptor.h +++ b/cpp/src/Ice/Acceptor.h @@ -25,7 +25,7 @@ public: virtual NativeInfoPtr getNativeInfo() = 0; virtual void close() = 0; - virtual EndpointIPtr listen(const EndpointIPtr& endp) = 0; + virtual EndpointIPtr listen() = 0; #if defined(ICE_USE_IOCP) || defined(ICE_OS_WINRT) virtual void startAccept() = 0; virtual void finishAccept() = 0; diff --git a/cpp/src/Ice/AcceptorF.h b/cpp/src/Ice/AcceptorF.h index 9c1c879beb5..0345c10fc2b 100644 --- a/cpp/src/Ice/AcceptorF.h +++ b/cpp/src/Ice/AcceptorF.h @@ -21,6 +21,10 @@ class Acceptor; ICE_API IceUtil::Shared* upCast(Acceptor*); typedef Handle<Acceptor> AcceptorPtr; +class TcpAcceptor; +ICE_API IceUtil::Shared* upCast(TcpAcceptor*); +typedef Handle<TcpAcceptor> TcpAcceptorPtr; + } #endif diff --git a/cpp/src/Ice/ConnectionFactory.cpp b/cpp/src/Ice/ConnectionFactory.cpp index 064dd10f0a6..44401760b4f 100644 --- a/cpp/src/Ice/ConnectionFactory.cpp +++ b/cpp/src/Ice/ConnectionFactory.cpp @@ -1630,7 +1630,7 @@ IceInternal::IncomingConnectionFactory::initialize(const string& oaName) Trace out(_instance->initializationData().logger, _instance->traceLevels()->networkCat); out << "attempting to bind to " << _endpoint->protocol() << " socket\n" << _transceiver->toString(); } - const_cast<EndpointIPtr&>(_endpoint) = _transceiver->bind(_endpoint); + const_cast<EndpointIPtr&>(_endpoint) = _transceiver->bind(); ConnectionIPtr connection = new ConnectionI(_adapter->getCommunicator(), _instance, 0, _transceiver, 0, _endpoint, _adapter); @@ -1648,7 +1648,7 @@ IceInternal::IncomingConnectionFactory::initialize(const string& oaName) out << "attempting to bind to " << _endpoint->protocol() << " socket " << _acceptor->toString(); } - const_cast<EndpointIPtr&>(_endpoint) = _acceptor->listen(_endpoint); + const_cast<EndpointIPtr&>(_endpoint) = _acceptor->listen(); if(_instance->traceLevels()->network >= 1) { diff --git a/cpp/src/Ice/EndpointI.h b/cpp/src/Ice/EndpointI.h index 68aa622bc1a..8806e0790ea 100644 --- a/cpp/src/Ice/EndpointI.h +++ b/cpp/src/Ice/EndpointI.h @@ -119,14 +119,6 @@ public: virtual AcceptorPtr acceptor(const std::string&) const = 0; // - // Return (potentially) new endpoint based on info from associated - // Transceiver or Acceptor, which might differ from this endpoint, - // for example, if a dynamic port number was assigned. - // - virtual EndpointIPtr endpoint(const TransceiverPtr&) const = 0; - virtual EndpointIPtr endpoint(const AcceptorPtr&) const = 0; - - // // Expand endpoint out in to separate endpoints for each local // host if listening on INADDR_ANY on server side. // diff --git a/cpp/src/Ice/EndpointIF.h b/cpp/src/Ice/EndpointIF.h index c12ec9bbb63..3295500aefa 100644 --- a/cpp/src/Ice/EndpointIF.h +++ b/cpp/src/Ice/EndpointIF.h @@ -20,6 +20,18 @@ class EndpointI; ICE_API IceUtil::Shared* upCast(EndpointI*); typedef Handle<EndpointI> EndpointIPtr; +class TcpEndpointI; +ICE_API IceUtil::Shared* upCast(TcpEndpointI*); +typedef Handle<TcpEndpointI> TcpEndpointIPtr; + +class UdpEndpointI; +ICE_API IceUtil::Shared* upCast(UdpEndpointI*); +typedef Handle<UdpEndpointI> UdpEndpointIPtr; + +class WSEndpoint; +ICE_API IceUtil::Shared* upCast(WSEndpoint*); +typedef Handle<WSEndpoint> WSEndpointPtr; + class EndpointI_connectors; ICE_API IceUtil::Shared* upCast(EndpointI_connectors*); typedef Handle<EndpointI_connectors> EndpointI_connectorsPtr; diff --git a/cpp/src/Ice/OpaqueEndpointI.cpp b/cpp/src/Ice/OpaqueEndpointI.cpp index efc5170d4cd..c7dab1d1f63 100644 --- a/cpp/src/Ice/OpaqueEndpointI.cpp +++ b/cpp/src/Ice/OpaqueEndpointI.cpp @@ -194,18 +194,6 @@ IceInternal::OpaqueEndpointI::acceptor(const string&) const return 0; } -EndpointIPtr -IceInternal::OpaqueEndpointI::endpoint(const TransceiverPtr&) const -{ - return const_cast<OpaqueEndpointI*>(this); -} - -EndpointIPtr -IceInternal::OpaqueEndpointI::endpoint(const AcceptorPtr&) const -{ - return const_cast<OpaqueEndpointI*>(this); -} - vector<EndpointIPtr> IceInternal::OpaqueEndpointI::expand() const { diff --git a/cpp/src/Ice/OpaqueEndpointI.h b/cpp/src/Ice/OpaqueEndpointI.h index 99e7815e846..03fe3066f06 100644 --- a/cpp/src/Ice/OpaqueEndpointI.h +++ b/cpp/src/Ice/OpaqueEndpointI.h @@ -41,8 +41,6 @@ public: virtual std::vector<ConnectorPtr> connectors(Ice::EndpointSelectionType) const; virtual void connectors_async(Ice::EndpointSelectionType, const EndpointI_connectorsPtr&) const; virtual AcceptorPtr acceptor(const std::string&) const; - virtual EndpointIPtr endpoint(const TransceiverPtr&) const; - virtual EndpointIPtr endpoint(const AcceptorPtr&) const; virtual std::vector<EndpointIPtr> expand() const; virtual bool equivalent(const EndpointIPtr&) const; virtual Ice::Int hash() const; diff --git a/cpp/src/Ice/TcpAcceptor.cpp b/cpp/src/Ice/TcpAcceptor.cpp index 10605b1c5dc..a2e1d164cff 100644 --- a/cpp/src/Ice/TcpAcceptor.cpp +++ b/cpp/src/Ice/TcpAcceptor.cpp @@ -9,7 +9,7 @@ #include <Ice/TcpAcceptor.h> #include <Ice/TcpTransceiver.h> -#include <Ice/EndpointI.h> +#include <Ice/TcpEndpointI.h> #include <Ice/ProtocolInstance.h> #include <Ice/LoggerUtil.h> #include <Ice/LocalException.h> @@ -25,6 +25,8 @@ using namespace std; using namespace Ice; using namespace IceInternal; +IceUtil::Shared* IceInternal::upCast(TcpAcceptor* p) { return p; } + NativeInfoPtr IceInternal::TcpAcceptor::getNativeInfo() { @@ -53,7 +55,7 @@ IceInternal::TcpAcceptor::close() } EndpointIPtr -IceInternal::TcpAcceptor::listen(const EndpointIPtr& endp) +IceInternal::TcpAcceptor::listen() { const_cast<Address&>(_addr) = doBind(_fd, _addr); @@ -67,7 +69,8 @@ IceInternal::TcpAcceptor::listen(const EndpointIPtr& endp) throw; } - return endp->endpoint(this); + _endpoint = _endpoint->endpoint(this); + return _endpoint; } #ifdef ICE_USE_IOCP @@ -180,7 +183,11 @@ IceInternal::TcpAcceptor::effectivePort() const return getPort(_addr); } -IceInternal::TcpAcceptor::TcpAcceptor(const ProtocolInstancePtr& instance, const string& host, int port) : +IceInternal::TcpAcceptor::TcpAcceptor(const TcpEndpointIPtr& endpoint, + const ProtocolInstancePtr& instance, + const string& host, + int port) : + _endpoint(endpoint), _instance(instance), _addr(getAddressForServer(host, port, _instance->protocolSupport(), instance->preferIPv6())) #ifdef ICE_USE_IOCP diff --git a/cpp/src/Ice/TcpAcceptor.h b/cpp/src/Ice/TcpAcceptor.h index 7248bb5a533..96a65b99f6d 100644 --- a/cpp/src/Ice/TcpAcceptor.h +++ b/cpp/src/Ice/TcpAcceptor.h @@ -30,7 +30,7 @@ public: #endif virtual void close(); - virtual EndpointIPtr listen(const EndpointIPtr&); + virtual EndpointIPtr listen(); #ifdef ICE_USE_IOCP virtual void startAccept(); virtual void finishAccept(); @@ -45,10 +45,11 @@ public: private: - TcpAcceptor(const ProtocolInstancePtr&, const std::string&, int); + TcpAcceptor(const TcpEndpointIPtr&, const ProtocolInstancePtr&, const std::string&, int); virtual ~TcpAcceptor(); friend class TcpEndpointI; + TcpEndpointIPtr _endpoint; const ProtocolInstancePtr _instance; const Address _addr; diff --git a/cpp/src/Ice/TcpEndpointI.cpp b/cpp/src/Ice/TcpEndpointI.cpp index 49b44649038..68f24ebb917 100644 --- a/cpp/src/Ice/TcpEndpointI.cpp +++ b/cpp/src/Ice/TcpEndpointI.cpp @@ -21,6 +21,8 @@ using namespace std; using namespace Ice; using namespace IceInternal; +IceUtil::Shared* IceInternal::upCast(TcpEndpointI* p) { return p; } + IceInternal::TcpEndpointI::TcpEndpointI(const ProtocolInstancePtr& instance, const string& host, Int port, const Address& sourceAddr, Int timeout, const string& connectionId, bool compress) : @@ -144,20 +146,14 @@ IceInternal::TcpEndpointI::transceiver() const AcceptorPtr IceInternal::TcpEndpointI::acceptor(const string&) const { - return new TcpAcceptor(_instance, _host, _port); -} - -EndpointIPtr -IceInternal::TcpEndpointI::endpoint(const TransceiverPtr& transceiver) const -{ - return const_cast<TcpEndpointI*>(this); + return new TcpAcceptor(const_cast<TcpEndpointI*>(this), _instance, _host, _port); } -EndpointIPtr -IceInternal::TcpEndpointI::endpoint(const AcceptorPtr& acceptor) const +TcpEndpointIPtr +IceInternal::TcpEndpointI::endpoint(const TcpAcceptorPtr& acceptor) const { - TcpAcceptor* p = dynamic_cast<TcpAcceptor*>(acceptor.get()); - return createEndpoint(_host, p->effectivePort(), _connectionId); + return new TcpEndpointI(_instance, _host, acceptor->effectivePort(), _sourceAddr, _timeout, _connectionId, + _compress); } string diff --git a/cpp/src/Ice/TcpEndpointI.h b/cpp/src/Ice/TcpEndpointI.h index fd566bd2235..07d0be0b59a 100644 --- a/cpp/src/Ice/TcpEndpointI.h +++ b/cpp/src/Ice/TcpEndpointI.h @@ -38,13 +38,13 @@ public: virtual TransceiverPtr transceiver() const; virtual AcceptorPtr acceptor(const std::string&) const; - virtual EndpointIPtr endpoint(const TransceiverPtr&) const; - virtual EndpointIPtr endpoint(const AcceptorPtr&) const; virtual std::string options() const; virtual bool operator==(const Ice::LocalObject&) const; virtual bool operator<(const Ice::LocalObject&) const; + TcpEndpointIPtr endpoint(const TcpAcceptorPtr&) const; + using IPEndpointI::connectionId; protected: diff --git a/cpp/src/Ice/Transceiver.cpp b/cpp/src/Ice/Transceiver.cpp index 7dc7723490c..7e8802467b4 100644 --- a/cpp/src/Ice/Transceiver.cpp +++ b/cpp/src/Ice/Transceiver.cpp @@ -16,7 +16,7 @@ using namespace IceInternal; IceUtil::Shared* IceInternal::upCast(Transceiver* p) { return p; } EndpointIPtr -IceInternal::Transceiver::bind(const EndpointIPtr&) +IceInternal::Transceiver::bind() { assert(false); return 0; diff --git a/cpp/src/Ice/Transceiver.h b/cpp/src/Ice/Transceiver.h index 377f99b8f82..d650ac94472 100644 --- a/cpp/src/Ice/Transceiver.h +++ b/cpp/src/Ice/Transceiver.h @@ -30,7 +30,7 @@ public: virtual SocketOperation initialize(Buffer&, Buffer&, bool&) = 0; virtual SocketOperation closing(bool, const Ice::LocalException&) = 0; virtual void close() = 0; - virtual EndpointIPtr bind(const EndpointIPtr&); + virtual EndpointIPtr bind(); virtual SocketOperation write(Buffer&) = 0; virtual SocketOperation read(Buffer&, bool&) = 0; #if defined(ICE_USE_IOCP) || defined(ICE_OS_WINRT) diff --git a/cpp/src/Ice/TransceiverF.h b/cpp/src/Ice/TransceiverF.h index 9196c40d293..7ea6eedefa8 100644 --- a/cpp/src/Ice/TransceiverF.h +++ b/cpp/src/Ice/TransceiverF.h @@ -21,6 +21,18 @@ class Transceiver; ICE_API IceUtil::Shared* upCast(Transceiver*); typedef Handle<Transceiver> TransceiverPtr; +class TcpTransceiver; +ICE_API IceUtil::Shared* upCast(TcpTransceiver*); +typedef Handle<TcpTransceiver> TcpTransceiverPtr; + +class UdpTransceiver; +ICE_API IceUtil::Shared* upCast(UdpTransceiver*); +typedef Handle<UdpTransceiver> UdpTransceiverPtr; + +class WSTransceiver; +ICE_API IceUtil::Shared* upCast(Transceiver*); +typedef Handle<Transceiver> TransceiverPtr; + } #endif diff --git a/cpp/src/Ice/UdpEndpointI.cpp b/cpp/src/Ice/UdpEndpointI.cpp index dacaef1adb9..dba2e663dbb 100644 --- a/cpp/src/Ice/UdpEndpointI.cpp +++ b/cpp/src/Ice/UdpEndpointI.cpp @@ -22,6 +22,8 @@ using namespace std; using namespace Ice; using namespace IceInternal; +IceUtil::Shared* IceInternal::upCast(UdpEndpointI* p) { return p; } + IceInternal::UdpEndpointI::UdpEndpointI(const ProtocolInstancePtr& instance, const string& host, Int port, const Address& sourceAddr, const string& mcastInterface, Int mttl, bool conn, const string& conId, bool co) : @@ -146,7 +148,7 @@ IceInternal::UdpEndpointI::secure() const TransceiverPtr IceInternal::UdpEndpointI::transceiver() const { - return new UdpTransceiver(_instance, _host, _port, _mcastInterface, _connect); + return new UdpTransceiver(const_cast<UdpEndpointI*>(this), _instance, _host, _port, _mcastInterface, _connect); } AcceptorPtr @@ -155,17 +157,11 @@ IceInternal::UdpEndpointI::acceptor(const string&) const return 0; } -EndpointIPtr -IceInternal::UdpEndpointI::endpoint(const TransceiverPtr& transceiver) const +UdpEndpointIPtr +IceInternal::UdpEndpointI::endpoint(const UdpTransceiverPtr& transceiver) const { - UdpTransceiver* p = dynamic_cast<UdpTransceiver*>(transceiver.get()); - return createEndpoint(_host, p->effectivePort(), _connectionId); -} - -EndpointIPtr -IceInternal::UdpEndpointI::endpoint(const AcceptorPtr& acceptor) const -{ - return const_cast<UdpEndpointI*>(this); + return new UdpEndpointI(_instance, _host, transceiver->effectivePort(), _sourceAddr, _mcastInterface, _mcastTtl, + _connect, _connectionId, _compress); } string diff --git a/cpp/src/Ice/UdpEndpointI.h b/cpp/src/Ice/UdpEndpointI.h index d2531fce206..022ec6092ee 100644 --- a/cpp/src/Ice/UdpEndpointI.h +++ b/cpp/src/Ice/UdpEndpointI.h @@ -38,13 +38,13 @@ public: virtual TransceiverPtr transceiver() const; virtual AcceptorPtr acceptor(const std::string&) const; - virtual EndpointIPtr endpoint(const TransceiverPtr&) const; - virtual EndpointIPtr endpoint(const AcceptorPtr&) const; virtual std::string options() const; virtual bool operator==(const Ice::LocalObject&) const; virtual bool operator<(const Ice::LocalObject&) const; + UdpEndpointIPtr endpoint(const UdpTransceiverPtr&) const; + using IPEndpointI::connectionId; protected: diff --git a/cpp/src/Ice/UdpTransceiver.cpp b/cpp/src/Ice/UdpTransceiver.cpp index 418c2528285..a54fd179d95 100644 --- a/cpp/src/Ice/UdpTransceiver.cpp +++ b/cpp/src/Ice/UdpTransceiver.cpp @@ -8,7 +8,7 @@ // ********************************************************************** #include <Ice/UdpTransceiver.h> -#include <Ice/EndpointI.h> +#include <Ice/UdpEndpointI.h> #include <Ice/Connection.h> #include <Ice/ProtocolInstance.h> #include <Ice/LoggerUtil.h> @@ -34,6 +34,8 @@ using namespace Windows::Networking; using namespace Windows::Networking::Sockets; #endif +IceUtil::Shared* IceInternal::upCast(UdpTransceiver* p) { return p; } + NativeInfoPtr IceInternal::UdpTransceiver::getNativeInfo() { @@ -132,7 +134,7 @@ IceInternal::UdpTransceiver::close() } EndpointIPtr -IceInternal::UdpTransceiver::bind(const EndpointIPtr& endp) +IceInternal::UdpTransceiver::bind() { if(isMulticast(_addr)) { @@ -178,7 +180,9 @@ IceInternal::UdpTransceiver::bind(const EndpointIPtr& endp) } _bound = true; - return endp->endpoint(this); + + _endpoint = _endpoint->endpoint(this); + return _endpoint; } SocketOperation @@ -964,8 +968,9 @@ IceInternal::UdpTransceiver::UdpTransceiver(const ProtocolInstancePtr& instance, #endif } -IceInternal::UdpTransceiver::UdpTransceiver(const ProtocolInstancePtr& instance, const string& host, int port, - const string& mcastInterface, bool connect) : +IceInternal::UdpTransceiver::UdpTransceiver(const UdpEndpointIPtr& endpoint, const ProtocolInstancePtr& instance, + const string& host, int port, const string& mcastInterface, bool connect) : + _endpoint(endpoint), _instance(instance), _incoming(true), _bound(false), diff --git a/cpp/src/Ice/UdpTransceiver.h b/cpp/src/Ice/UdpTransceiver.h index e9f4b6b1b55..c43e7a636a4 100644 --- a/cpp/src/Ice/UdpTransceiver.h +++ b/cpp/src/Ice/UdpTransceiver.h @@ -47,7 +47,7 @@ public: virtual SocketOperation initialize(Buffer&, Buffer&, bool&); virtual SocketOperation closing(bool, const Ice::LocalException&); virtual void close(); - virtual EndpointIPtr bind(const EndpointIPtr&); + virtual EndpointIPtr bind(); virtual SocketOperation write(Buffer&); virtual SocketOperation read(Buffer&, bool&); #if defined(ICE_USE_IOCP) || defined(ICE_OS_WINRT) @@ -67,7 +67,8 @@ public: private: UdpTransceiver(const ProtocolInstancePtr&, const Address&, const Address&, const std::string&, int); - UdpTransceiver(const ProtocolInstancePtr&, const std::string&, int, const std::string&, bool); + UdpTransceiver(const UdpEndpointIPtr&, const ProtocolInstancePtr&, const std::string&, int, const std::string&, + bool); virtual ~UdpTransceiver(); @@ -82,6 +83,7 @@ private: friend class UdpEndpointI; friend class UdpConnector; + UdpEndpointIPtr _endpoint; const ProtocolInstancePtr _instance; const bool _incoming; bool _bound; diff --git a/cpp/src/Ice/WSAcceptor.cpp b/cpp/src/Ice/WSAcceptor.cpp index 8aa995a028d..012363c400f 100644 --- a/cpp/src/Ice/WSAcceptor.cpp +++ b/cpp/src/Ice/WSAcceptor.cpp @@ -42,11 +42,10 @@ IceInternal::WSAcceptor::close() } EndpointIPtr -IceInternal::WSAcceptor::listen(const EndpointIPtr& endp) +IceInternal::WSAcceptor::listen() { - WSEndpoint* p = dynamic_cast<WSEndpoint*>(endp.get()); - EndpointIPtr endpoint = _delegate->listen(p->delegate()); - return endp->endpoint(this); + _endpoint = _endpoint->endpoint(_delegate->listen()); + return _endpoint; } #if defined(ICE_USE_IOCP) || defined(ICE_OS_WINRT) @@ -91,8 +90,11 @@ IceInternal::WSAcceptor::toDetailedString() const return _delegate->toDetailedString(); } -IceInternal::WSAcceptor::WSAcceptor(const ProtocolInstancePtr& instance, const IceInternal::AcceptorPtr& del) : - _instance(instance), _delegate(del) +IceInternal::WSAcceptor::WSAcceptor(const WSEndpointPtr& endpoint, const ProtocolInstancePtr& instance, + const AcceptorPtr& del) : + _endpoint(endpoint), + _instance(instance), + _delegate(del) { } diff --git a/cpp/src/Ice/WSAcceptor.h b/cpp/src/Ice/WSAcceptor.h index a58cb496046..46a3d18a017 100644 --- a/cpp/src/Ice/WSAcceptor.h +++ b/cpp/src/Ice/WSAcceptor.h @@ -33,7 +33,7 @@ public: #endif virtual void close(); - virtual EndpointIPtr listen(const EndpointIPtr&); + virtual EndpointIPtr listen(); #if defined(ICE_USE_IOCP) || defined(ICE_OS_WINRT) virtual void startAccept(); virtual void finishAccept(); @@ -47,10 +47,11 @@ public: private: - WSAcceptor(const ProtocolInstancePtr&, const AcceptorPtr&); + WSAcceptor(const WSEndpointPtr&, const ProtocolInstancePtr&, const AcceptorPtr&); virtual ~WSAcceptor(); friend class WSEndpoint; + WSEndpointPtr _endpoint; const ProtocolInstancePtr _instance; const AcceptorPtr _delegate; }; diff --git a/cpp/src/Ice/WSEndpoint.cpp b/cpp/src/Ice/WSEndpoint.cpp index b128fe13cc2..b6290f1774a 100644 --- a/cpp/src/Ice/WSEndpoint.cpp +++ b/cpp/src/Ice/WSEndpoint.cpp @@ -19,6 +19,8 @@ using namespace std; using namespace Ice; using namespace IceInternal; +IceUtil::Shared* IceInternal::upCast(WSEndpoint* p) { return p; } + IceInternal::WSEndpoint::WSEndpoint(const ProtocolInstancePtr& instance, const EndpointIPtr& del, const string& res) : _instance(instance), _delegate(IPEndpointIPtr::dynamicCast(del)), _resource(res) { @@ -236,20 +238,12 @@ AcceptorPtr IceInternal::WSEndpoint::acceptor(const string& adapterName) const { AcceptorPtr delAcc = _delegate->acceptor(adapterName); - return new WSAcceptor(_instance, delAcc); -} - -EndpointIPtr -IceInternal::WSEndpoint::endpoint(const TransceiverPtr& transceiver) const -{ - return const_cast<WSEndpoint*>(this); + return new WSAcceptor(const_cast<WSEndpoint*>(this), _instance, delAcc); } -EndpointIPtr -IceInternal::WSEndpoint::endpoint(const AcceptorPtr& acceptor) const +WSEndpointPtr +IceInternal::WSEndpoint::endpoint(const EndpointIPtr& delEndp) const { - WSAcceptor* p = dynamic_cast<WSAcceptor*>(acceptor.get()); - EndpointIPtr delEndp = _delegate->endpoint(p->delegate()); return new WSEndpoint(_instance, delEndp, _resource); } diff --git a/cpp/src/Ice/WSEndpoint.h b/cpp/src/Ice/WSEndpoint.h index c344c614575..a5aa3af5908 100644 --- a/cpp/src/Ice/WSEndpoint.h +++ b/cpp/src/Ice/WSEndpoint.h @@ -46,14 +46,14 @@ public: virtual std::vector<ConnectorPtr> connectors(Ice::EndpointSelectionType) const; virtual void connectors_async(Ice::EndpointSelectionType, const EndpointI_connectorsPtr&) const; virtual AcceptorPtr acceptor(const std::string&) const; - virtual EndpointIPtr endpoint(const TransceiverPtr&) const; - virtual EndpointIPtr endpoint(const AcceptorPtr&) const; + virtual std::vector<EndpointIPtr> expand() const; virtual bool equivalent(const EndpointIPtr&) const; virtual ::Ice::Int hash() const; virtual std::string options() const; EndpointIPtr delegate() const; + WSEndpointPtr endpoint(const EndpointIPtr&) const; virtual bool operator==(const Ice::LocalObject&) const; virtual bool operator<(const Ice::LocalObject&) const; diff --git a/cpp/src/Ice/winrt/StreamAcceptor.cpp b/cpp/src/Ice/winrt/StreamAcceptor.cpp index a30a7f4fae6..7506e45916e 100644 --- a/cpp/src/Ice/winrt/StreamAcceptor.cpp +++ b/cpp/src/Ice/winrt/StreamAcceptor.cpp @@ -9,8 +9,8 @@ #include <Ice/winrt/StreamAcceptor.h> #include <Ice/winrt/StreamTransceiver.h> +#include <Ice/winrt/StreamEndpointI.h> -#include <Ice/EndpointI.h> #include <Ice/ProtocolInstance.h> #include <Ice/LocalException.h> #include <Ice/LoggerUtil.h> @@ -65,10 +65,11 @@ IceInternal::StreamAcceptor::close() } EndpointIPtr -IceInternal::StreamAcceptor::listen(const EndpointIPtr& endp) +IceInternal::StreamAcceptor::listen() { const_cast<Address&>(_addr) = doBind(_fd, _addr); - return endp->endpoint(this); + _endpoint = _endpoint->endpoint(this); + return _endpoint; } void @@ -158,7 +159,11 @@ IceInternal::StreamAcceptor::effectivePort() const return getPort(_addr); } -IceInternal::StreamAcceptor::StreamAcceptor(const ProtocolInstancePtr& instance, const string& host, int port) : +IceInternal::StreamAcceptor::StreamAcceptor(const StreamEndpointIPtr& endpoint, + const ProtocolInstancePtr& instance, + const string& host, + int port) : + _endpoint(endpoint), _instance(instance), _addr(getAddressForServer(host, port, _instance->protocolSupport(), instance->preferIPv6())), _acceptPending(false) diff --git a/cpp/src/Ice/winrt/StreamAcceptor.h b/cpp/src/Ice/winrt/StreamAcceptor.h index f798ceee7f5..9a08d2815e9 100644 --- a/cpp/src/Ice/winrt/StreamAcceptor.h +++ b/cpp/src/Ice/winrt/StreamAcceptor.h @@ -14,6 +14,7 @@ #include <Ice/ProtocolInstanceF.h> #include <Ice/Acceptor.h> #include <Ice/Network.h> +#include <Ice/winrt/StreamF.h> #include <IceUtil/Mutex.h> @@ -22,8 +23,6 @@ namespace IceInternal { -class StreamEndpoint; - class StreamAcceptor : public Acceptor, public NativeInfo { public: @@ -32,7 +31,7 @@ public: virtual void setCompletedHandler(SocketOperationCompletedHandler^); virtual void close(); - virtual EndpointIPtr listen(const EndpointIPtr&); + virtual EndpointIPtr listen(); virtual void startAccept(); virtual void finishAccept(); @@ -46,12 +45,13 @@ public: private: - StreamAcceptor(const ProtocolInstancePtr&, const std::string&, int); + StreamAcceptor(const StreamEndpointIPtr&, const ProtocolInstancePtr&, const std::string&, int); virtual ~StreamAcceptor(); friend class StreamEndpointI; virtual void queueAcceptedSocket(Windows::Networking::Sockets::StreamSocket^); + StreamEndpointIPtr _endpoint; const ProtocolInstancePtr _instance; const Address _addr; diff --git a/cpp/src/Ice/winrt/StreamEndpointI.cpp b/cpp/src/Ice/winrt/StreamEndpointI.cpp index 927e4a3c063..32b0bd39038 100644 --- a/cpp/src/Ice/winrt/StreamEndpointI.cpp +++ b/cpp/src/Ice/winrt/StreamEndpointI.cpp @@ -173,20 +173,13 @@ IceInternal::StreamEndpointI::transceiver() const AcceptorPtr IceInternal::StreamEndpointI::acceptor(const string&) const { - return new StreamAcceptor(_instance, _host, _port); + return new StreamAcceptor(const_cast<StreamEndpointI*>(this), _instance, _host, _port); } -EndpointIPtr -IceInternal::StreamEndpointI::endpoint(const TransceiverPtr&) const -{ - return const_cast<StreamEndpointI*>(this); -} - -EndpointIPtr -IceInternal::StreamEndpointI::endpoint(const AcceptorPtr& acceptor) const +StreamEndpointIPtr +IceInternal::StreamEndpointI::endpoint(const StreamAcceptorPtr& acceptor) const { - StreamAcceptor* p = dynamic_cast<StreamAcceptor*>(acceptor.get()); - return createEndpoint(_host, p->effectivePort(), _connectionId); + return new StreamEndpointI(_instance, _host, acceptor->effectivePort(), _timeout, _connectionId, _compress); } string diff --git a/cpp/src/Ice/winrt/StreamEndpointI.h b/cpp/src/Ice/winrt/StreamEndpointI.h index 6fc35c8f9e9..d3c4ce8480e 100644 --- a/cpp/src/Ice/winrt/StreamEndpointI.h +++ b/cpp/src/Ice/winrt/StreamEndpointI.h @@ -14,6 +14,7 @@ #include <Ice/IPEndpointI.h> #include <Ice/EndpointFactory.h> #include <Ice/Network.h> // for IceIternal::Address +#include <Ice/winrt/StreamF.h> namespace IceInternal { @@ -38,13 +39,13 @@ public: virtual TransceiverPtr transceiver() const; virtual AcceptorPtr acceptor(const std::string&) const; - virtual EndpointIPtr endpoint(const TransceiverPtr&) const; - virtual EndpointIPtr endpoint(const AcceptorPtr&) const; virtual std::string options() const; virtual bool operator==(const Ice::LocalObject&) const; virtual bool operator<(const Ice::LocalObject&) const; + StreamEndpointIPtr endpoint(const StreamAcceptorPtr&) const; + using IPEndpointI::connectionId; protected: diff --git a/cpp/src/Ice/winrt/StreamF.h b/cpp/src/Ice/winrt/StreamF.h new file mode 100644 index 00000000000..d0be68e81cd --- /dev/null +++ b/cpp/src/Ice/winrt/StreamF.h @@ -0,0 +1,29 @@ +// ********************************************************************** +// +// Copyright (c) 2003-2014 ZeroC, Inc. All rights reserved. +// +// This copy of Ice is licensed to you under the terms described in the +// ICE_LICENSE file included in this distribution. +// +// ********************************************************************** + +#ifndef ICE_WINRT_STREAM_F_H +#define ICE_WINRT_STREAM_F_H + +#include <IceUtil/Shared.h> +#include <Ice/Handle.h> + +namespace IceInternal +{ + +class StreamEndpointI; +ICE_API IceUtil::Shared* upCast(StreamEndpointI*); +typedef IceInternal::Handle<StreamEndpointI> StreamEndpointIPtr; + +class StreamAcceptor; +ICE_API IceUtil::Shared* upCast(StreamAcceptor*); +typedef IceInternal::Handle<StreamAcceptor> StreamAcceptorPtr; + +} + +#endif diff --git a/cpp/src/IceSSL/AcceptorI.cpp b/cpp/src/IceSSL/AcceptorI.cpp index 2cb3f19515b..8cdcde82366 100644 --- a/cpp/src/IceSSL/AcceptorI.cpp +++ b/cpp/src/IceSSL/AcceptorI.cpp @@ -8,6 +8,7 @@ // ********************************************************************** #include <IceSSL/AcceptorI.h> +#include <IceSSL/EndpointI.h> #include <IceSSL/Instance.h> #include <IceSSL/OpenSSLTransceiverI.h> @@ -16,7 +17,6 @@ #include <IceSSL/Util.h> -#include <Ice/EndpointI.h> #include <Ice/Communicator.h> #include <Ice/Exception.h> #include <Ice/LocalException.h> @@ -33,6 +33,8 @@ using namespace std; using namespace Ice; using namespace IceSSL; +IceUtil::Shared* IceSSL::upCast(AcceptorI* p) { return p; } + IceInternal::NativeInfoPtr IceSSL::AcceptorI::getNativeInfo() { @@ -57,7 +59,7 @@ IceSSL::AcceptorI::close() } IceInternal::EndpointIPtr -IceSSL::AcceptorI::listen(const IceInternal::EndpointIPtr& endp) +IceSSL::AcceptorI::listen() { const_cast<IceInternal::Address&>(_addr) = IceInternal::doBind(_fd, _addr); @@ -71,7 +73,8 @@ IceSSL::AcceptorI::listen(const IceInternal::EndpointIPtr& endp) throw; } - return endp->endpoint(this); + _endpoint = _endpoint->endpoint(this); + return _endpoint; } #ifdef ICE_USE_IOCP @@ -205,7 +208,9 @@ IceSSL::AcceptorI::effectivePort() const } } -IceSSL::AcceptorI::AcceptorI(const InstancePtr& instance, const string& adapterName, const string& host, int port) : +IceSSL::AcceptorI::AcceptorI(const EndpointIPtr& endpoint, const InstancePtr& instance, const string& adapterName, + const string& host, int port) : + _endpoint(endpoint), _instance(instance), _adapterName(adapterName), _addr(IceInternal::getAddressForServer(host, port, instance->protocolSupport(), instance->preferIPv6())) diff --git a/cpp/src/IceSSL/AcceptorI.h b/cpp/src/IceSSL/AcceptorI.h index e86e73897d6..1c6d26fc624 100644 --- a/cpp/src/IceSSL/AcceptorI.h +++ b/cpp/src/IceSSL/AcceptorI.h @@ -20,8 +20,6 @@ namespace IceSSL { -class EndpointI; - class AcceptorI : public IceInternal::Acceptor, public IceInternal::NativeInfo { public: @@ -32,7 +30,7 @@ public: #endif virtual void close(); - virtual IceInternal::EndpointIPtr listen(const IceInternal::EndpointIPtr&); + virtual IceInternal::EndpointIPtr listen(); #ifdef ICE_USE_IOCP virtual void startAccept(); virtual void finishAccept(); @@ -46,10 +44,11 @@ public: private: - AcceptorI(const InstancePtr&, const std::string&, const std::string&, int); + AcceptorI(const EndpointIPtr&, const InstancePtr&, const std::string&, const std::string&, int); virtual ~AcceptorI(); friend class EndpointI; + EndpointIPtr _endpoint; const InstancePtr _instance; const std::string _adapterName; const IceInternal::Address _addr; diff --git a/cpp/src/IceSSL/EndpointI.cpp b/cpp/src/IceSSL/EndpointI.cpp index cf395733097..71f1db1a675 100644 --- a/cpp/src/IceSSL/EndpointI.cpp +++ b/cpp/src/IceSSL/EndpointI.cpp @@ -21,6 +21,8 @@ using namespace std; using namespace Ice; using namespace IceSSL; +IceUtil::Shared* IceSSL::upCast(EndpointI* p) { return p; } + IceSSL::EndpointI::EndpointI(const InstancePtr& instance, const string& ho, Int po, const IceInternal::Address& sourceAddr, Int ti, const string& conId, bool co) : IceInternal::IPEndpointI(instance, ho, po, sourceAddr, conId), @@ -146,20 +148,13 @@ IceSSL::EndpointI::transceiver() const IceInternal::AcceptorPtr IceSSL::EndpointI::acceptor(const string& adapterName) const { - return new AcceptorI(_instance, adapterName, _host, _port); -} - -IceInternal::EndpointIPtr -IceSSL::EndpointI::endpoint(const IceInternal::TransceiverPtr& transceiver) const -{ - return const_cast<EndpointI*>(this); + return new AcceptorI(const_cast<EndpointI*>(this), _instance, adapterName, _host, _port); } -IceInternal::EndpointIPtr -IceSSL::EndpointI::endpoint(const IceInternal::AcceptorPtr& acceptor) const +EndpointIPtr +IceSSL::EndpointI::endpoint(const AcceptorIPtr& acceptor) const { - AcceptorI* p = dynamic_cast<AcceptorI*>(acceptor.get()); - return new EndpointI(_instance, _host, p->effectivePort(), _sourceAddr, _timeout, _connectionId, _compress); + return new EndpointI(_instance, _host, acceptor->effectivePort(), _sourceAddr, _timeout, _connectionId, _compress); } string diff --git a/cpp/src/IceSSL/EndpointI.h b/cpp/src/IceSSL/EndpointI.h index 1d69bba838a..ae97bd3ecf6 100644 --- a/cpp/src/IceSSL/EndpointI.h +++ b/cpp/src/IceSSL/EndpointI.h @@ -39,13 +39,13 @@ public: virtual IceInternal::TransceiverPtr transceiver() const; virtual IceInternal::AcceptorPtr acceptor(const std::string&) const; - virtual IceInternal::EndpointIPtr endpoint(const IceInternal::TransceiverPtr&) const; - virtual IceInternal::EndpointIPtr endpoint(const IceInternal::AcceptorPtr&) const; virtual std::string options() const; virtual bool operator==(const Ice::LocalObject&) const; virtual bool operator<(const Ice::LocalObject&) const; + virtual EndpointIPtr endpoint(const AcceptorIPtr&) const; + using IceInternal::IPEndpointI::connectionId; protected: diff --git a/cpp/src/IceSSL/InstanceF.h b/cpp/src/IceSSL/InstanceF.h index 6c8f7f33d92..47599dd0a4b 100644 --- a/cpp/src/IceSSL/InstanceF.h +++ b/cpp/src/IceSSL/InstanceF.h @@ -18,9 +18,17 @@ namespace IceSSL { class Instance; -IceUtil::Shared* upCast(IceSSL::Instance*); +IceUtil::Shared* upCast(Instance*); typedef IceInternal::Handle<Instance> InstancePtr; +class EndpointI; +IceUtil::Shared* upCast(EndpointI*); +typedef IceInternal::Handle<EndpointI> EndpointIPtr; + +class AcceptorI; +IceUtil::Shared* upCast(AcceptorI*); +typedef IceInternal::Handle<AcceptorI> AcceptorIPtr; + } #endif |