diff options
74 files changed, 325 insertions, 417 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 diff --git a/cpp/test/Ice/background/Acceptor.cpp b/cpp/test/Ice/background/Acceptor.cpp index 71ac8a1899c..dded32b7933 100644 --- a/cpp/test/Ice/background/Acceptor.cpp +++ b/cpp/test/Ice/background/Acceptor.cpp @@ -26,11 +26,10 @@ Acceptor::close() } IceInternal::EndpointIPtr -Acceptor::listen(const IceInternal::EndpointIPtr& endp) +Acceptor::listen() { - EndpointI* p = dynamic_cast<EndpointI*>(endp.get()); - IceInternal::EndpointIPtr endpoint = _acceptor->listen(p->delegate()); - return endp->endpoint(this); + _endpoint = _endpoint->endpoint(_acceptor->listen()); + return _endpoint; } #ifdef ICE_USE_IOCP @@ -71,6 +70,8 @@ Acceptor::toDetailedString() const return _acceptor->toDetailedString(); } -Acceptor::Acceptor(const IceInternal::AcceptorPtr& acceptor) : _acceptor(acceptor) +Acceptor::Acceptor(const EndpointIPtr& endpoint, const IceInternal::AcceptorPtr& acceptor) : + _endpoint(endpoint), + _acceptor(acceptor) { } diff --git a/cpp/test/Ice/background/Acceptor.h b/cpp/test/Ice/background/Acceptor.h index 8b20bad5054..66cb1e62e62 100644 --- a/cpp/test/Ice/background/Acceptor.h +++ b/cpp/test/Ice/background/Acceptor.h @@ -11,6 +11,7 @@ #define TEST_ACCEPTOR_H #include <Ice/Acceptor.h> +#include <EndpointI.h> class Acceptor : public IceInternal::Acceptor { @@ -19,7 +20,7 @@ public: virtual IceInternal::NativeInfoPtr getNativeInfo(); virtual void close(); - virtual IceInternal::EndpointIPtr listen(const IceInternal::EndpointIPtr&); + virtual IceInternal::EndpointIPtr listen(); #ifdef ICE_USE_IOCP virtual void startAccept(); virtual void finishAccept(); @@ -33,9 +34,10 @@ public: private: - Acceptor(const IceInternal::AcceptorPtr&); + Acceptor(const EndpointIPtr&, const IceInternal::AcceptorPtr&); friend class EndpointI; + EndpointIPtr _endpoint; const IceInternal::AcceptorPtr _acceptor; }; diff --git a/cpp/test/Ice/background/EndpointI.cpp b/cpp/test/Ice/background/EndpointI.cpp index 56ce855c485..55ed99e5f26 100644 --- a/cpp/test/Ice/background/EndpointI.cpp +++ b/cpp/test/Ice/background/EndpointI.cpp @@ -198,10 +198,10 @@ EndpointI::connectors_async(Ice::EndpointSelectionType selType, const IceInterna IceInternal::AcceptorPtr EndpointI::acceptor(const string& adapterName) const { - return new Acceptor(_endpoint->acceptor(adapterName)); + return new Acceptor(const_cast<EndpointI*>(this), _endpoint->acceptor(adapterName)); } -IceInternal::EndpointIPtr +/*IceInternal::EndpointIPtr EndpointI::endpoint(const IceInternal::TransceiverPtr& transceiver) const { Transceiver* p = dynamic_cast<Transceiver*>(transceiver.get()); @@ -214,13 +214,12 @@ EndpointI::endpoint(const IceInternal::TransceiverPtr& transceiver) const { return new EndpointI(endpt); } -} +}*/ -IceInternal::EndpointIPtr -EndpointI::endpoint(const IceInternal::AcceptorPtr& acceptor) const +EndpointIPtr +EndpointI::endpoint(const IceInternal::EndpointIPtr& delEndp) const { - Acceptor* p = dynamic_cast<Acceptor*>(acceptor.get()); - return new EndpointI(_endpoint->endpoint(p->delegate())); + return new EndpointI(delEndp); } vector<IceInternal::EndpointIPtr> diff --git a/cpp/test/Ice/background/EndpointI.h b/cpp/test/Ice/background/EndpointI.h index 7073858e194..a3b3e74b3d0 100644 --- a/cpp/test/Ice/background/EndpointI.h +++ b/cpp/test/Ice/background/EndpointI.h @@ -14,6 +14,10 @@ #include <Test.h> #include <Configuration.h> + +class EndpointI; +typedef IceUtil::Handle<EndpointI> EndpointIPtr; + class EndpointI : public IceInternal::EndpointI { public: @@ -31,8 +35,7 @@ public: virtual std::vector<IceInternal::ConnectorPtr> connectors(Ice::EndpointSelectionType) const; virtual void connectors_async(Ice::EndpointSelectionType, const IceInternal::EndpointI_connectorsPtr&) 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::vector<IceInternal::EndpointIPtr> expand() const; virtual bool equivalent(const IceInternal::EndpointIPtr&) const; @@ -52,6 +55,7 @@ public: virtual std::string options() const; IceInternal::EndpointIPtr delegate() const; + EndpointIPtr endpoint(const IceInternal::EndpointIPtr&) const; using IceInternal::EndpointI::connectionId; using IceInternal::EndpointI::connectors; diff --git a/cs/src/Ice/Acceptor.cs b/cs/src/Ice/Acceptor.cs index a2e5c41e7ae..83742abface 100644 --- a/cs/src/Ice/Acceptor.cs +++ b/cs/src/Ice/Acceptor.cs @@ -16,7 +16,7 @@ namespace IceInternal public interface Acceptor { void close(); - EndpointI listen(EndpointI endp); + EndpointI listen(); bool startAccept(AsyncCallback callback, object state); void finishAccept(); Transceiver accept(); diff --git a/cs/src/Ice/ConnectionFactory.cs b/cs/src/Ice/ConnectionFactory.cs index 477de9a632a..61bc661e4d7 100644 --- a/cs/src/Ice/ConnectionFactory.cs +++ b/cs/src/Ice/ConnectionFactory.cs @@ -1711,7 +1711,7 @@ namespace IceInternal s.Append(_transceiver.ToString()); _instance.initializationData().logger.trace(_instance.traceLevels().networkCat, s.ToString()); } - _endpoint = _transceiver.bind(_endpoint); + _endpoint = _transceiver.bind(); Ice.ConnectionI connection = new Ice.ConnectionI(_adapter.getCommunicator(), _instance, null, _transceiver, null, _endpoint, _adapter); @@ -1731,7 +1731,7 @@ namespace IceInternal s.Append(_acceptor.ToString()); _instance.initializationData().logger.trace(_instance.traceLevels().networkCat, s.ToString()); } - _endpoint = _acceptor.listen(_endpoint); + _endpoint = _acceptor.listen(); if(_instance.traceLevels().network >= 1) { diff --git a/cs/src/Ice/EndpointI.cs b/cs/src/Ice/EndpointI.cs index e0b48c8f542..ad3dffe4382 100644 --- a/cs/src/Ice/EndpointI.cs +++ b/cs/src/Ice/EndpointI.cs @@ -138,14 +138,6 @@ namespace IceInternal public abstract Acceptor acceptor(string adapterName); // - // 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. - // - public abstract EndpointI endpoint(Transceiver transceiver); - public abstract EndpointI endpoint(Acceptor acceptor); - - // // Expand endpoint out in to separate endpoints for each local // host if listening on INADDR_ANY on server side or if no host // was specified on client side. diff --git a/cs/src/Ice/OpaqueEndpointI.cs b/cs/src/Ice/OpaqueEndpointI.cs index cb929bae04f..b99499ccd9e 100644 --- a/cs/src/Ice/OpaqueEndpointI.cs +++ b/cs/src/Ice/OpaqueEndpointI.cs @@ -224,21 +224,6 @@ namespace IceInternal } // - // 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. - // - public override EndpointI endpoint(Transceiver transceiver) - { - return null; - } - - public override EndpointI endpoint(Acceptor acceptor) - { - return null; - } - - // // Expand endpoint out in to separate endpoints for each local // host if listening on INADDR_ANY on server side or if no host // was specified on client side. diff --git a/cs/src/Ice/TcpAcceptor.cs b/cs/src/Ice/TcpAcceptor.cs index 253ff1d7d49..11fbcc66133 100644 --- a/cs/src/Ice/TcpAcceptor.cs +++ b/cs/src/Ice/TcpAcceptor.cs @@ -27,11 +27,12 @@ namespace IceInternal _fd = null; } - public virtual EndpointI listen(EndpointI endp) + public virtual EndpointI listen() { _addr = Network.doBind(_fd, _addr); Network.doListen(_fd, _backlog); - return endp.endpoint(this); + _endpoint = _endpoint.endpoint(this); + return _endpoint; } public virtual bool startAccept(AsyncCallback callback, object state) @@ -112,8 +113,9 @@ namespace IceInternal return _addr.Port; } - internal TcpAcceptor(ProtocolInstance instance, string host, int port) + internal TcpAcceptor(TcpEndpointI endpoint, ProtocolInstance instance, string host, int port) { + _endpoint = endpoint; _instance = instance; _backlog = instance.properties().getPropertyAsIntWithDefault("Ice.TCP.Backlog", 511); @@ -150,6 +152,7 @@ namespace IceInternal } } + private TcpEndpointI _endpoint; private ProtocolInstance _instance; private Socket _fd; private Socket _acceptFd; diff --git a/cs/src/Ice/TcpEndpointI.cs b/cs/src/Ice/TcpEndpointI.cs index a2b14c6c336..c0243ed4d5e 100644 --- a/cs/src/Ice/TcpEndpointI.cs +++ b/cs/src/Ice/TcpEndpointI.cs @@ -125,20 +125,14 @@ namespace IceInternal #if SILVERLIGHT throw new Ice.FeatureNotSupportedException("server endpoint not supported for `" + ToString() + "'"); #else - return new TcpAcceptor(instance_, host_, port_); + return new TcpAcceptor(this, instance_, host_, port_); #endif } - public override EndpointI endpoint(Transceiver transceiver) + public TcpEndpointI endpoint(TcpAcceptor acceptor) { - return this; - } - - public override EndpointI endpoint(Acceptor acceptor) - { - Debug.Assert(acceptor is TcpAcceptor); - TcpAcceptor p = (TcpAcceptor)acceptor; - return createEndpoint(host_, p.effectivePort(), connectionId_); + return new TcpEndpointI(instance_, host_, acceptor.effectivePort(), sourceAddr_, _timeout, connectionId_, + _compress); } public override string options() diff --git a/cs/src/Ice/TcpTransceiver.cs b/cs/src/Ice/TcpTransceiver.cs index e628ecd0661..55e36e75ee2 100644 --- a/cs/src/Ice/TcpTransceiver.cs +++ b/cs/src/Ice/TcpTransceiver.cs @@ -39,7 +39,7 @@ namespace IceInternal _stream.close(); } - public EndpointI bind(EndpointI endp) + public EndpointI bind() { Debug.Assert(false); return null; diff --git a/cs/src/Ice/Transceiver.cs b/cs/src/Ice/Transceiver.cs index 4bcb23343d5..4a3fd4af609 100644 --- a/cs/src/Ice/Transceiver.cs +++ b/cs/src/Ice/Transceiver.cs @@ -20,7 +20,7 @@ namespace IceInternal void close(); void destroy(); - EndpointI bind(EndpointI endp); + EndpointI bind(); int write(Buffer buf); int read(Buffer buf, ref bool hasMoreData); diff --git a/cs/src/Ice/UdpEndpointI.cs b/cs/src/Ice/UdpEndpointI.cs index 1c4a97c68a7..0192ad0c364 100644 --- a/cs/src/Ice/UdpEndpointI.cs +++ b/cs/src/Ice/UdpEndpointI.cs @@ -155,7 +155,7 @@ namespace IceInternal // public override Transceiver transceiver() { - return new UdpTransceiver(instance_, host_, port_, _mcastInterface, _connect); + return new UdpTransceiver(this, instance_, host_, port_, _mcastInterface, _connect); } // @@ -167,21 +167,10 @@ namespace IceInternal return null; } - // - // 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. - // - public override EndpointI endpoint(Transceiver transceiver) - { - Debug.Assert(transceiver is UdpTransceiver); - UdpTransceiver p = (UdpTransceiver)transceiver; - return createEndpoint(host_, p.effectivePort(), connectionId_); - } - - public override EndpointI endpoint(Acceptor acceptor) + public UdpEndpointI endpoint(UdpTransceiver transceiver) { - return this; + return new UdpEndpointI(instance_, host_, transceiver.effectivePort(), sourceAddr_, _mcastInterface, + _mcastTtl, _connect, connectionId_, _compress); } public override string options() diff --git a/cs/src/Ice/UdpTransceiver.cs b/cs/src/Ice/UdpTransceiver.cs index 362aafb95d3..22adc75bfa7 100644 --- a/cs/src/Ice/UdpTransceiver.cs +++ b/cs/src/Ice/UdpTransceiver.cs @@ -113,7 +113,7 @@ namespace IceInternal } } - public EndpointI bind(EndpointI endp) + public EndpointI bind() { #if !SILVERLIGHT if(Network.isMulticast((IPEndPoint)_addr)) @@ -167,7 +167,8 @@ namespace IceInternal } #endif _bound = true; - return endp.endpoint(this); + _endpoint = _endpoint.endpoint(this); + return _endpoint; } public void destroy() @@ -887,8 +888,10 @@ namespace IceInternal // // Only for use by UdpEndpoint. // - internal UdpTransceiver(ProtocolInstance instance, string host, int port, string mcastInterface, bool connect) + internal UdpTransceiver(UdpEndpointI endpoint, ProtocolInstance instance, string host, int port, + string mcastInterface, bool connect) { + _endpoint = endpoint; _instance = instance; _state = connect ? StateNeedConnect : StateNotConnected; _mcastInterface = mcastInterface; @@ -1037,6 +1040,7 @@ namespace IceInternal } #endif + private UdpEndpointI _endpoint; private ProtocolInstance _instance; private int _state; private bool _incoming; diff --git a/cs/src/Ice/WSAcceptor.cs b/cs/src/Ice/WSAcceptor.cs index fcde3be57d7..bae56f92465 100644 --- a/cs/src/Ice/WSAcceptor.cs +++ b/cs/src/Ice/WSAcceptor.cs @@ -18,12 +18,10 @@ namespace IceInternal _delegate.close(); } - public EndpointI listen(EndpointI endp) + public EndpointI listen() { - Debug.Assert(endp is WSEndpoint); - WSEndpoint p = (WSEndpoint)endp; - EndpointI endpoint = _delegate.listen(p.getDelegate()); - return endp.endpoint(this); + _endpoint = _endpoint.endpoint(_delegate.listen()); + return _endpoint; } public bool startAccept(AsyncCallback callback, object state) @@ -61,12 +59,14 @@ namespace IceInternal return _delegate; } - internal WSAcceptor(ProtocolInstance instance, Acceptor del) + internal WSAcceptor(WSEndpoint endpoint, ProtocolInstance instance, Acceptor del) { + _endpoint = endpoint; _instance = instance; _delegate = del; } + private WSEndpoint _endpoint; private ProtocolInstance _instance; private Acceptor _delegate; } diff --git a/cs/src/Ice/WSEndpoint.cs b/cs/src/Ice/WSEndpoint.cs index 71f410e023f..6d46c0559a1 100644 --- a/cs/src/Ice/WSEndpoint.cs +++ b/cs/src/Ice/WSEndpoint.cs @@ -219,19 +219,11 @@ namespace IceInternal public override Acceptor acceptor(string adapterName) { Acceptor delAcc = _delegate.acceptor(adapterName); - return new WSAcceptor(_instance, delAcc); + return new WSAcceptor(this, _instance, delAcc); } - public override EndpointI endpoint(Transceiver transceiver) + public WSEndpoint endpoint(EndpointI delEndp) { - return this; - } - - public override EndpointI endpoint(Acceptor acceptor) - { - Debug.Assert(acceptor is WSAcceptor); - WSAcceptor p = (WSAcceptor)acceptor; - EndpointI delEndp = _delegate.endpoint(p.getDelegate()); return new WSEndpoint(_instance, delEndp, _resource); } diff --git a/cs/src/Ice/WSTransceiver.cs b/cs/src/Ice/WSTransceiver.cs index d91a3a0aa4b..d055d1c95b4 100644 --- a/cs/src/Ice/WSTransceiver.cs +++ b/cs/src/Ice/WSTransceiver.cs @@ -307,7 +307,7 @@ namespace IceInternal _state = StateClosed; } - public EndpointI bind(EndpointI endp) + public EndpointI bind() { Debug.Assert(false); return null; @@ -642,7 +642,7 @@ namespace IceInternal return _delegate.toDetailedString(); } - internal + internal WSTransceiver(ProtocolInstance instance, IceInternal.Transceiver del, string host, int port, string resource) { init(instance, del); diff --git a/cs/src/IceSSL/AcceptorI.cs b/cs/src/IceSSL/AcceptorI.cs index d12a656328e..3a2c15f8464 100644 --- a/cs/src/IceSSL/AcceptorI.cs +++ b/cs/src/IceSSL/AcceptorI.cs @@ -36,11 +36,12 @@ namespace IceSSL } } - public IceInternal.EndpointI listen(IceInternal.EndpointI endp) + public IceInternal.EndpointI listen() { _addr = IceInternal.Network.doBind(_fd, _addr); IceInternal.Network.doListen(_fd, _backlog); - return endp.endpoint(this); + _endpoint = _endpoint.endpoint(this); + return _endpoint; } public bool startAccept(IceInternal.AsyncCallback callback, object state) @@ -118,7 +119,7 @@ namespace IceSSL s.Append(ToString()); List<string> intfs = IceInternal.Network.getHostsForEndpointExpand(_addr.Address.ToString(), - _instance.protocolSupport(), + _instance.protocolSupport(), true); if(intfs.Count != 0) { @@ -133,8 +134,9 @@ namespace IceSSL return _addr.Port; } - internal AcceptorI(Instance instance, string adapterName, string host, int port) + internal AcceptorI(EndpointI endpoint, Instance instance, string adapterName, string host, int port) { + _endpoint = endpoint; _instance = instance; _adapterName = adapterName; _backlog = instance.properties().getPropertyAsIntWithDefault("Ice.TCP.Backlog", 511); @@ -183,6 +185,7 @@ namespace IceSSL } } + private EndpointI _endpoint; private Instance _instance; private string _adapterName; private Socket _fd; diff --git a/cs/src/IceSSL/EndpointI.cs b/cs/src/IceSSL/EndpointI.cs index c8553f6c014..5636ef296d7 100644 --- a/cs/src/IceSSL/EndpointI.cs +++ b/cs/src/IceSSL/EndpointI.cs @@ -159,24 +159,13 @@ namespace IceSSL // public override IceInternal.Acceptor acceptor(string adapterName) { - return new AcceptorI(_instance, adapterName, host_, port_); + return new AcceptorI(this, _instance, adapterName, host_, port_); } - // - // 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. - // - public override IceInternal.EndpointI endpoint(IceInternal.Transceiver transceiver) - { - return this; - } - - public override IceInternal.EndpointI endpoint(IceInternal.Acceptor acceptor) + public IceInternal.EndpointI endpoint(IceInternal.Acceptor acceptor) { - Debug.Assert(acceptor is AcceptorI); - AcceptorI p = (AcceptorI)acceptor; - return new EndpointI(_instance, host_, p.effectivePort(), sourceAddr_, _timeout, connectionId_, _compress); + return new EndpointI(_instance, host_, acceptor.effectivePort(), sourceAddr_, _timeout, connectionId_, + _compress); } public override string options() diff --git a/cs/src/IceSSL/TransceiverI.cs b/cs/src/IceSSL/TransceiverI.cs index 2964274d167..a55af5bca81 100644 --- a/cs/src/IceSSL/TransceiverI.cs +++ b/cs/src/IceSSL/TransceiverI.cs @@ -38,11 +38,11 @@ namespace IceSSL } _stream.setBlock(true); // SSL requires a blocking socket - + if(_sslStream == null) { NetworkStream ns = new NetworkStream(_stream.fd(), false); - _sslStream = new SslStream(ns, false, new RemoteCertificateValidationCallback(validationCallback), + _sslStream = new SslStream(ns, false, new RemoteCertificateValidationCallback(validationCallback), null); return IceInternal.SocketOperation.Connect; } @@ -76,7 +76,7 @@ namespace IceSSL _stream.close(); } - public IceInternal.EndpointI bind(IceInternal.EndpointI endp) + public IceInternal.EndpointI bind() { Debug.Assert(false); return null; @@ -214,7 +214,7 @@ namespace IceSSL try { _writeCallback = callback; - _writeResult = _sslStream.BeginWrite(buf.b.rawBytes(), buf.b.position(), packetSize, writeCompleted, + _writeResult = _sslStream.BeginWrite(buf.b.rawBytes(), buf.b.position(), packetSize, writeCompleted, state); completed = packetSize == buf.b.remaining(); return _writeResult.CompletedSynchronously; @@ -262,7 +262,7 @@ namespace IceSSL finishAuthenticate(); return; } - + Debug.Assert(_sslStream != null && _writeResult != null); int sent = _stream.getSendPacketSize(buf.b.remaining()); try @@ -359,7 +359,7 @@ namespace IceSSL { _chainEngine.ChainPolicy.RevocationMode = X509RevocationMode.NoCheck; } - + foreach(X509Certificate2 cert in caCerts) { _chainEngine.ChainPolicy.ExtraStore.Add(cert); @@ -415,7 +415,7 @@ namespace IceSSL // // Client authentication. // - _writeResult = _sslStream.BeginAuthenticateAsClient(_host, + _writeResult = _sslStream.BeginAuthenticateAsClient(_host, _instance.certs(), _instance.protocols(), _instance.checkCRL() > 0, @@ -436,8 +436,8 @@ namespace IceSSL cert = certs[0]; } - _writeResult = _sslStream.BeginAuthenticateAsServer(cert, - _verifyPeer > 1, + _writeResult = _sslStream.BeginAuthenticateAsServer(cert, + _verifyPeer > 1, _instance.protocols(), _instance.checkCRL() > 0, writeCompleted, @@ -526,7 +526,7 @@ namespace IceSSL } } - X509Chain chain = _chainEngine == null ? chainEngine : _chainEngine; + X509Chain chain = _chainEngine == null ? chainEngine : _chainEngine; // // The certificate chain is not available via SslStream, and it is destroyed @@ -595,7 +595,7 @@ namespace IceSSL if(status.Status == X509ChainStatusFlags.UntrustedRoot && _chainEngine != null && valid) { // - // Untrusted root is OK when using our custom chain engine if + // Untrusted root is OK when using our custom chain engine if // the CA certificate is present in the chain policy extra store. // X509ChainElement e = chain.ChainElements[chain.ChainElements.Count - 1]; diff --git a/cs/test/Ice/background/Acceptor.cs b/cs/test/Ice/background/Acceptor.cs index 6fed12ae626..770f09f330a 100644 --- a/cs/test/Ice/background/Acceptor.cs +++ b/cs/test/Ice/background/Acceptor.cs @@ -18,12 +18,10 @@ internal class Acceptor : IceInternal.Acceptor _acceptor.close(); } - public IceInternal.EndpointI listen(IceInternal.EndpointI endp) + public IceInternal.EndpointI listen() { - Debug.Assert(endp is EndpointI); - EndpointI p = (EndpointI)endp; - _acceptor.listen(p.getDelegate()); - return endp.endpoint(this); + _endpoint = _endpoint.endpoint(_acceptor.listen()); + return _endpoint; } public bool startAccept(IceInternal.AsyncCallback callback, object state) @@ -61,10 +59,12 @@ internal class Acceptor : IceInternal.Acceptor return _acceptor; } - internal Acceptor(IceInternal.Acceptor acceptor) + internal Acceptor(EndpointI endpoint, IceInternal.Acceptor acceptor) { + _endpoint = endpoint; _acceptor = acceptor; } + private EndpointI _endpoint; private IceInternal.Acceptor _acceptor; } diff --git a/cs/test/Ice/background/EndpointI.cs b/cs/test/Ice/background/EndpointI.cs index d1fb9b319e8..ddd153b4ea1 100644 --- a/cs/test/Ice/background/EndpointI.cs +++ b/cs/test/Ice/background/EndpointI.cs @@ -176,29 +176,12 @@ internal class EndpointI : IceInternal.EndpointI public override IceInternal.Acceptor acceptor(string adapterName) { - return new Acceptor(_endpoint.acceptor(adapterName)); + return new Acceptor(this, _endpoint.acceptor(adapterName)); } - public override IceInternal.EndpointI endpoint(IceInternal.Transceiver transceiver) + public EndpointI endpoint(IceInternal.EndpointI delEndp) { - Debug.Assert(transceiver is Transceiver); - Transceiver p = (Transceiver)transceiver; - IceInternal.EndpointI endpt = _endpoint.endpoint(p.getDelegate()); - if(endpt == _endpoint) - { - return this; - } - else - { - return new EndpointI(endpt); - } - } - - public override IceInternal.EndpointI endpoint(IceInternal.Acceptor acceptor) - { - Debug.Assert(acceptor is Acceptor); - Acceptor p = (Acceptor)acceptor; - return new EndpointI(_endpoint.endpoint(p.getDelegate())); + return new EndpointI(delEndp); } public override List<IceInternal.EndpointI> expand() diff --git a/cs/test/Ice/background/Transceiver.cs b/cs/test/Ice/background/Transceiver.cs index d240ad05b5b..e1b4eb353a8 100644 --- a/cs/test/Ice/background/Transceiver.cs +++ b/cs/test/Ice/background/Transceiver.cs @@ -43,9 +43,9 @@ internal class Transceiver : IceInternal.Transceiver _transceiver.close(); } - public IceInternal.EndpointI bind(IceInternal.EndpointI endp) + public IceInternal.EndpointI bind() { - return _transceiver.bind(endp); + return _transceiver.bind(); } public int write(IceInternal.Buffer buf) diff --git a/java/src/IceInternal/Acceptor.java b/java/src/IceInternal/Acceptor.java index 1adc2349db7..8efcc04dcb3 100644 --- a/java/src/IceInternal/Acceptor.java +++ b/java/src/IceInternal/Acceptor.java @@ -13,7 +13,7 @@ public interface Acceptor { java.nio.channels.ServerSocketChannel fd(); void close(); - EndpointI listen(EndpointI endp); + EndpointI listen(); Transceiver accept(); String protocol(); @Override diff --git a/java/src/IceInternal/EndpointI.java b/java/src/IceInternal/EndpointI.java index f752291c6f3..7e6d487f7f2 100644 --- a/java/src/IceInternal/EndpointI.java +++ b/java/src/IceInternal/EndpointI.java @@ -111,14 +111,6 @@ abstract public class EndpointI implements Ice.Endpoint, java.lang.Comparable<En public abstract Acceptor acceptor(String adapterName); // - // 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. - // - public abstract EndpointI endpoint(Transceiver transceiver); - public abstract EndpointI endpoint(Acceptor acceptor); - - // // Expand endpoint out in to separate endpoints for each local // host if listening on INADDR_ANY. // diff --git a/java/src/IceInternal/IncomingConnectionFactory.java b/java/src/IceInternal/IncomingConnectionFactory.java index e0ecfcc2fc3..b66b100bfff 100644 --- a/java/src/IceInternal/IncomingConnectionFactory.java +++ b/java/src/IceInternal/IncomingConnectionFactory.java @@ -388,7 +388,7 @@ public final class IncomingConnectionFactory extends EventHandler implements Ice s.append(_transceiver.toString()); _instance.initializationData().logger.trace(_instance.traceLevels().networkCat, s.toString()); } - _endpoint = _transceiver.bind(_endpoint); + _endpoint = _transceiver.bind(); Ice.ConnectionI connection = new Ice.ConnectionI(_adapter.getCommunicator(), _instance, null, _transceiver, null, _endpoint, @@ -410,7 +410,7 @@ public final class IncomingConnectionFactory extends EventHandler implements Ice _instance.initializationData().logger.trace(_instance.traceLevels().networkCat, s.toString()); } - _endpoint = _acceptor.listen(_endpoint); + _endpoint = _acceptor.listen(); if(_instance.traceLevels().network >= 1) { diff --git a/java/src/IceInternal/OpaqueEndpointI.java b/java/src/IceInternal/OpaqueEndpointI.java index 8932c41c7de..3a3ab472863 100644 --- a/java/src/IceInternal/OpaqueEndpointI.java +++ b/java/src/IceInternal/OpaqueEndpointI.java @@ -210,23 +210,6 @@ final class OpaqueEndpointI extends EndpointI } // - // 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. - // - @Override - public EndpointI endpoint(Transceiver transceiver) - { - return null; - } - - @Override - public EndpointI endpoint(Acceptor acceptor) - { - return null; - } - - // // Expand endpoint out in to separate endpoints for each local // host if listening on INADDR_ANY on server side or if no host // was specified on client side. diff --git a/java/src/IceInternal/TcpAcceptor.java b/java/src/IceInternal/TcpAcceptor.java index 5bb1b1c79da..3f593624188 100644 --- a/java/src/IceInternal/TcpAcceptor.java +++ b/java/src/IceInternal/TcpAcceptor.java @@ -26,10 +26,11 @@ class TcpAcceptor implements Acceptor } @Override - public EndpointI listen(EndpointI endp) + public EndpointI listen() { _addr = Network.doBind(_fd, _addr, _backlog); - return endp.endpoint(this); + _endpoint = _endpoint.endpoint(this); + return _endpoint; } @Override @@ -71,8 +72,9 @@ class TcpAcceptor implements Acceptor return _addr.getPort(); } - TcpAcceptor(ProtocolInstance instance, String host, int port) + TcpAcceptor(TcpEndpointI endpoint, ProtocolInstance instance, String host, int port) { + _endpoint = endpoint; _instance = instance; _backlog = instance.properties().getPropertyAsIntWithDefault("Ice.TCP.Backlog", 511); @@ -124,6 +126,7 @@ class TcpAcceptor implements Acceptor } } + private TcpEndpointI _endpoint; private ProtocolInstance _instance; private java.nio.channels.ServerSocketChannel _fd; private int _backlog; diff --git a/java/src/IceInternal/TcpEndpointI.java b/java/src/IceInternal/TcpEndpointI.java index 9678e59803d..4f8fa51c9ac 100644 --- a/java/src/IceInternal/TcpEndpointI.java +++ b/java/src/IceInternal/TcpEndpointI.java @@ -155,25 +155,13 @@ final class TcpEndpointI extends IPEndpointI @Override public Acceptor acceptor(String adapterName) { - return new TcpAcceptor(_instance, _host, _port); + return new TcpAcceptor(this, _instance, _host, _port); } - // - // 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. - // - @Override - public EndpointI endpoint(Transceiver transceiver) - { - return this; - } - - @Override - public EndpointI endpoint(Acceptor acceptor) + public TcpEndpointI endpoint(TcpAcceptor acceptor) { - TcpAcceptor p = (TcpAcceptor)acceptor; - return createEndpoint(_host, p.effectivePort(), _connectionId); + return new TcpEndpointI(_instance, _host, acceptor.effectivePort(), _sourceAddr, _timeout, + _connectionId, _compress); } @Override diff --git a/java/src/IceInternal/TcpTransceiver.java b/java/src/IceInternal/TcpTransceiver.java index 625ab8ce448..5e8d33fb672 100644 --- a/java/src/IceInternal/TcpTransceiver.java +++ b/java/src/IceInternal/TcpTransceiver.java @@ -39,7 +39,7 @@ final class TcpTransceiver implements Transceiver } @Override - public EndpointI bind(EndpointI endp) + public EndpointI bind() { assert(false); return null; diff --git a/java/src/IceInternal/Transceiver.java b/java/src/IceInternal/Transceiver.java index c7c1fbd3a71..f9889df74f8 100644 --- a/java/src/IceInternal/Transceiver.java +++ b/java/src/IceInternal/Transceiver.java @@ -17,7 +17,7 @@ public interface Transceiver int closing(boolean initiator, Ice.LocalException ex); void close(); - EndpointI bind(EndpointI endp); + EndpointI bind(); int write(Buffer buf); int read(Buffer buf, Ice.Holder<Boolean> moreData); diff --git a/java/src/IceInternal/UdpEndpointI.java b/java/src/IceInternal/UdpEndpointI.java index b5bab1f3bfb..797f5f25138 100644 --- a/java/src/IceInternal/UdpEndpointI.java +++ b/java/src/IceInternal/UdpEndpointI.java @@ -150,7 +150,7 @@ final class UdpEndpointI extends IPEndpointI @Override public Transceiver transceiver() { - return new UdpTransceiver(_instance, _host, _port, _mcastInterface, _connect); + return new UdpTransceiver(this, _instance, _host, _port, _mcastInterface, _connect); } // @@ -163,22 +163,10 @@ final class UdpEndpointI extends IPEndpointI return null; } - // - // 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. - // - @Override - public EndpointI endpoint(Transceiver transceiver) - { - UdpTransceiver p = (UdpTransceiver)transceiver; - return createEndpoint(_host, p.effectivePort(), _connectionId); - } - - @Override - public EndpointI endpoint(Acceptor acceptor) + public UdpEndpointI endpoint(UdpTransceiver transceiver) { - return this; + return new UdpEndpointI(_instance, _host, transceiver.effectivePort(), _sourceAddr, _mcastInterface,_mcastTtl, + _connect, _connectionId, _compress); } // diff --git a/java/src/IceInternal/UdpTransceiver.java b/java/src/IceInternal/UdpTransceiver.java index 0ac66b0a366..78e1de99371 100644 --- a/java/src/IceInternal/UdpTransceiver.java +++ b/java/src/IceInternal/UdpTransceiver.java @@ -52,7 +52,7 @@ final class UdpTransceiver implements Transceiver } @Override - public EndpointI bind(EndpointI endp) + public EndpointI bind() { if(_addr.getAddress().isMulticastAddress()) { @@ -103,7 +103,8 @@ final class UdpTransceiver implements Transceiver } _bound = true; - return endp.endpoint(this); + _endpoint = _endpoint.endpoint(this); + return _endpoint; } @Override @@ -393,8 +394,10 @@ final class UdpTransceiver implements Transceiver // // Only for use by UdpEndpoint // - UdpTransceiver(ProtocolInstance instance, String host, int port, String mcastInterface, boolean connect) + UdpTransceiver(UdpEndpointI endpoint, ProtocolInstance instance, String host, int port, String mcastInterface, + boolean connect) { + _endpoint = endpoint; _instance = instance; _state = connect ? StateNeedConnect : StateNotConnected; _mcastInterface = mcastInterface; @@ -601,6 +604,7 @@ final class UdpTransceiver implements Transceiver } } + private UdpEndpointI _endpoint = null; private ProtocolInstance _instance; private int _state; diff --git a/java/src/IceInternal/WSAcceptor.java b/java/src/IceInternal/WSAcceptor.java index 65ef46623fb..cc11b1ff8e8 100644 --- a/java/src/IceInternal/WSAcceptor.java +++ b/java/src/IceInternal/WSAcceptor.java @@ -24,11 +24,10 @@ final class WSAcceptor implements IceInternal.Acceptor } @Override - public EndpointI listen(EndpointI endp) + public EndpointI listen() { - WSEndpoint p = (WSEndpoint)endp; - EndpointI endpoint = _delegate.listen(p.delegate()); - return endp.endpoint(this); + _endpoint = _endpoint.endpoint(_delegate.listen()); + return _endpoint; } @Override @@ -64,12 +63,14 @@ final class WSAcceptor implements IceInternal.Acceptor return _delegate; } - WSAcceptor(ProtocolInstance instance, IceInternal.Acceptor del) + WSAcceptor(WSEndpoint endpoint, ProtocolInstance instance, IceInternal.Acceptor del) { + _endpoint = endpoint; _instance = instance; _delegate = del; } + private WSEndpoint _endpoint; private ProtocolInstance _instance; private IceInternal.Acceptor _delegate; } diff --git a/java/src/IceInternal/WSEndpoint.java b/java/src/IceInternal/WSEndpoint.java index 7170d68e252..14f64906f42 100644 --- a/java/src/IceInternal/WSEndpoint.java +++ b/java/src/IceInternal/WSEndpoint.java @@ -207,20 +207,11 @@ final class WSEndpoint extends IceInternal.EndpointI public Acceptor acceptor(String adapterName) { Acceptor delAcc = _delegate.acceptor(adapterName); - return new WSAcceptor(_instance, delAcc); + return new WSAcceptor(this, _instance, delAcc); } - @Override - public EndpointI endpoint(Transceiver transceiver) - { - return this; - } - - @Override - public EndpointI endpoint(Acceptor acceptor) + public WSEndpoint endpoint(EndpointI delEndp) { - WSAcceptor p = (WSAcceptor)acceptor; - EndpointI delEndp = _delegate.endpoint(p.delegate()); return new WSEndpoint(_instance, delEndp, _resource); } diff --git a/java/src/IceInternal/WSTransceiver.java b/java/src/IceInternal/WSTransceiver.java index c34a1f65e1b..8cf6b96813e 100644 --- a/java/src/IceInternal/WSTransceiver.java +++ b/java/src/IceInternal/WSTransceiver.java @@ -306,7 +306,7 @@ final class WSTransceiver implements Transceiver } @Override - public EndpointI bind(EndpointI endp) + public EndpointI bind() { assert(false); return null; diff --git a/java/src/IceSSL/AcceptorI.java b/java/src/IceSSL/AcceptorI.java index 186d7988c30..4a853cc73da 100644 --- a/java/src/IceSSL/AcceptorI.java +++ b/java/src/IceSSL/AcceptorI.java @@ -26,11 +26,11 @@ final class AcceptorI implements IceInternal.Acceptor } @Override - public IceInternal.EndpointI listen(IceInternal.EndpointI endp) + public IceInternal.EndpointI listen() { _addr = IceInternal.Network.doBind(_fd, _addr, _backlog); - - return endp.endpoint(this); + _endpoint = _endpoint.endpoint(this); + return _endpoint; } @Override @@ -49,7 +49,7 @@ final class AcceptorI implements IceInternal.Acceptor IceInternal.StreamSocket stream = new IceInternal.StreamSocket(_instance, IceInternal.Network.doAccept(_fd)); try { - java.net.InetSocketAddress peerAddr = + java.net.InetSocketAddress peerAddr = (java.net.InetSocketAddress)stream.fd().socket().getRemoteSocketAddress(); return new TransceiverI(_instance, _instance.createSSLEngine(true, peerAddr), stream, "", _adapterName); } @@ -94,8 +94,9 @@ final class AcceptorI implements IceInternal.Acceptor return _addr.getPort(); } - AcceptorI(Instance instance, String adapterName, String host, int port) + AcceptorI(EndpointI endpoint, Instance instance, String adapterName, String host, int port) { + _endpoint = endpoint; _instance = instance; _adapterName = adapterName; _backlog = instance.properties().getPropertyAsIntWithDefault("Ice.TCP.Backlog", 511); @@ -149,6 +150,7 @@ final class AcceptorI implements IceInternal.Acceptor } } + private EndpointI _endpoint; private Instance _instance; private String _adapterName; private java.nio.channels.ServerSocketChannel _fd; diff --git a/java/src/IceSSL/EndpointI.java b/java/src/IceSSL/EndpointI.java index 1b42777d3c7..cce1479e1ff 100644 --- a/java/src/IceSSL/EndpointI.java +++ b/java/src/IceSSL/EndpointI.java @@ -158,25 +158,13 @@ final class EndpointI extends IceInternal.IPEndpointI @Override public IceInternal.Acceptor acceptor(String adapterName) { - return new AcceptorI(_instance, adapterName, _host, _port); + return new AcceptorI(this, _instance, adapterName, _host, _port); } - // - // 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. - // - @Override - public IceInternal.EndpointI endpoint(IceInternal.Transceiver transceiver) - { - return this; - } - - @Override - public IceInternal.EndpointI endpoint(IceInternal.Acceptor acceptor) + public EndpointI endpoint(AcceptorI acceptor) { - AcceptorI p = (AcceptorI)acceptor; - return new EndpointI(_instance, _host, p.effectivePort(), _sourceAddr, _timeout, _connectionId, _compress); + return new EndpointI(_instance, _host, acceptor.effectivePort(), _sourceAddr, _timeout, _connectionId, + _compress); } diff --git a/java/src/IceSSL/TransceiverI.java b/java/src/IceSSL/TransceiverI.java index fb1d4c947ff..40bd7e6fab1 100644 --- a/java/src/IceSSL/TransceiverI.java +++ b/java/src/IceSSL/TransceiverI.java @@ -138,7 +138,7 @@ final class TransceiverI implements IceInternal.Transceiver } @Override - public IceInternal.EndpointI bind(IceInternal.EndpointI endp) + public IceInternal.EndpointI bind() { assert(false); return null; diff --git a/java/test/Ice/background/Acceptor.java b/java/test/Ice/background/Acceptor.java index 41d36f4759b..598ff348fb2 100644 --- a/java/test/Ice/background/Acceptor.java +++ b/java/test/Ice/background/Acceptor.java @@ -27,11 +27,10 @@ class Acceptor implements IceInternal.Acceptor @Override public IceInternal.EndpointI - listen(IceInternal.EndpointI endp) + listen() { - EndpointI p = (EndpointI)endp; - IceInternal.EndpointI endpoint = _acceptor.listen(p.delegate()); - return endp.endpoint(this); + _endpoint = _endpoint.endpoint(_acceptor.listen()); + return _endpoint; } @Override @@ -68,12 +67,14 @@ class Acceptor implements IceInternal.Acceptor return _acceptor; } - Acceptor(Configuration configuration, IceInternal.Acceptor acceptor) + Acceptor(EndpointI endpoint, Configuration configuration, IceInternal.Acceptor acceptor) { + _endpoint = endpoint; _configuration = configuration; _acceptor = acceptor; } + private EndpointI _endpoint; final private IceInternal.Acceptor _acceptor; private Configuration _configuration; } diff --git a/java/test/Ice/background/EndpointI.java b/java/test/Ice/background/EndpointI.java index 865ce44e10c..bed906911d6 100644 --- a/java/test/Ice/background/EndpointI.java +++ b/java/test/Ice/background/EndpointI.java @@ -206,31 +206,13 @@ final class EndpointI extends IceInternal.EndpointI public IceInternal.Acceptor acceptor(String adapterName) { - return new Acceptor(_configuration, _endpoint.acceptor(adapterName)); + return new Acceptor(this, _configuration, _endpoint.acceptor(adapterName)); } - @Override - public IceInternal.EndpointI - endpoint(IceInternal.Transceiver transceiver) - { - Transceiver p = (Transceiver)transceiver; - IceInternal.EndpointI endpt = _endpoint.endpoint(p.delegate()); - if(endpt == _endpoint) - { - return this; - } - else - { - return new EndpointI(_configuration, endpt); - } - } - - @Override - public IceInternal.EndpointI - endpoint(IceInternal.Acceptor acceptor) + public EndpointI + endpoint(IceInternal.EndpointI delEndp) { - Acceptor p = (Acceptor)acceptor; - return new EndpointI(_configuration, _endpoint.endpoint(p.delegate())); + return new EndpointI(_configuration, delEndp); } @Override diff --git a/java/test/Ice/background/Transceiver.java b/java/test/Ice/background/Transceiver.java index 26d3ab648d0..738c7ef1f10 100644 --- a/java/test/Ice/background/Transceiver.java +++ b/java/test/Ice/background/Transceiver.java @@ -74,9 +74,9 @@ final class Transceiver implements IceInternal.Transceiver @Override public IceInternal.EndpointI - bind(IceInternal.EndpointI endp) + bind() { - return _transceiver.bind(endp); + return _transceiver.bind(); } @Override |