Skip to content

Commit

Permalink
Remove udp -c option in C++ and Java (#3220)
Browse files Browse the repository at this point in the history
  • Loading branch information
bernardnormier authored Dec 3, 2024
1 parent 71b8054 commit e657245
Show file tree
Hide file tree
Showing 8 changed files with 44 additions and 192 deletions.
89 changes: 12 additions & 77 deletions cpp/src/Ice/UdpEndpointI.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -42,29 +42,25 @@ IceInternal::UdpEndpointI::UdpEndpointI(
const Address& sourceAddr,
const string& mcastInterface,
int32_t mttl,
bool conn,
const string& conId,
bool co)
: IPEndpointI(instance, host, port, sourceAddr, conId),
const string& connectionId,
bool compress)
: IPEndpointI(instance, host, port, sourceAddr, connectionId),
_mcastTtl(mttl),
_mcastInterface(mcastInterface),
_connect(conn),
_compress(co)
_compress(compress)
{
}

IceInternal::UdpEndpointI::UdpEndpointI(const ProtocolInstancePtr& instance)
: IPEndpointI(instance),
_mcastTtl(-1),
_connect(false),
_compress(false)
{
}

IceInternal::UdpEndpointI::UdpEndpointI(const ProtocolInstancePtr& instance, InputStream* s)
: IPEndpointI(instance, s),
_mcastTtl(-1),
_connect(false),
_compress(false)
{
if (s->getEncoding() == Ice::Encoding_1_0)
Expand All @@ -75,8 +71,6 @@ IceInternal::UdpEndpointI::UdpEndpointI(const ProtocolInstancePtr& instance, Inp
s->read(b);
s->read(b);
}
// Not transmitted.
// s->read(const_cast<bool&>(_connect));
s->read(const_cast<bool&>(_compress));
}

Expand All @@ -89,8 +83,6 @@ IceInternal::UdpEndpointI::streamWriteImpl(OutputStream* s) const
s->write(Ice::Protocol_1_0);
s->write(Ice::Encoding_1_0);
}
// Not transmitted.
// s->write(_connect);
s->write(_compress);
}

Expand Down Expand Up @@ -133,16 +125,8 @@ IceInternal::UdpEndpointI::compress(bool compress) const
}
else
{
return make_shared<UdpEndpointI>(
_instance,
_host,
_port,
_sourceAddr,
_mcastInterface,
_mcastTtl,
_connect,
_connectionId,
compress);
return make_shared<
UdpEndpointI>(_instance, _host, _port, _sourceAddr, _mcastInterface, _mcastTtl, _connectionId, compress);
}
}

Expand All @@ -162,7 +146,6 @@ IceInternal::UdpEndpointI::toPublishedEndpoint(string publishedHost) const
Address{},
"",
-1,
false, // for "connect"
"",
_compress);
}
Expand All @@ -175,8 +158,7 @@ IceInternal::UdpEndpointI::transceiver() const
_instance,
_host,
_port,
_mcastInterface,
_connect);
_mcastInterface);
}

AcceptorPtr
Expand All @@ -195,16 +177,8 @@ IceInternal::UdpEndpointI::endpoint(const UdpTransceiverPtr& transceiver) const
}
else
{
return make_shared<UdpEndpointI>(
_instance,
_host,
port,
_sourceAddr,
_mcastInterface,
_mcastTtl,
_connect,
_connectionId,
_compress);
return make_shared<
UdpEndpointI>(_instance, _host, port, _sourceAddr, _mcastInterface, _mcastTtl, _connectionId, _compress);
}
}

Expand Down Expand Up @@ -263,11 +237,6 @@ IceInternal::UdpEndpointI::options() const
s << " --ttl " << to_string(_mcastTtl);
}

if (_connect)
{
s << " -c";
}

if (_compress)
{
s << " -z";
Expand Down Expand Up @@ -300,11 +269,6 @@ IceInternal::UdpEndpointI::operator==(const Endpoint& r) const
return false;
}

if (_connect != p->_connect)
{
return false;
}

if (_mcastTtl != p->_mcastTtl)
{
return false;
Expand Down Expand Up @@ -346,15 +310,6 @@ IceInternal::UdpEndpointI::operator<(const Endpoint& r) const
return false;
}

if (!_connect && p->_connect)
{
return true;
}
else if (!p->_connect && _connect)
{
return false;
}

if (_mcastTtl < p->_mcastTtl)
{
return true;
Expand Down Expand Up @@ -382,7 +337,6 @@ IceInternal::UdpEndpointI::hash() const noexcept
size_t h = IPEndpointI::hash();
hashAdd(h, _mcastInterface);
hashAdd(h, _mcastTtl);
hashAdd(h, _connect);
hashAdd(h, _compress);
return h;
}
Expand All @@ -395,18 +349,7 @@ IceInternal::UdpEndpointI::checkOption(const string& option, const string& argum
return true;
}

if (option == "-c")
{
if (!argument.empty())
{
throw ParseException(
__FILE__,
__LINE__,
"unexpected argument '" + argument + "' provided for -c option in endpoint '" + endpoint + "'");
}
const_cast<bool&>(_connect) = true;
}
else if (option == "-z")
if (option == "-z")
{
if (!argument.empty())
{
Expand Down Expand Up @@ -488,16 +431,8 @@ IceInternal::UdpEndpointI::createConnector(const Address& address, const Network
IPEndpointIPtr
IceInternal::UdpEndpointI::createEndpoint(const string& host, int port, const string& connectionId) const
{
return make_shared<UdpEndpointI>(
_instance,
host,
port,
_sourceAddr,
_mcastInterface,
_mcastTtl,
_connect,
connectionId,
_compress);
return make_shared<
UdpEndpointI>(_instance, host, port, _sourceAddr, _mcastInterface, _mcastTtl, connectionId, _compress);
}

IceInternal::UdpEndpointFactory::UdpEndpointFactory(const ProtocolInstancePtr& instance) : _instance(instance) {}
Expand Down
2 changes: 0 additions & 2 deletions cpp/src/Ice/UdpEndpointI.h
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@ namespace IceInternal
const Address&,
const std::string&,
std::int32_t,
bool,
const std::string&,
bool);
UdpEndpointI(const ProtocolInstancePtr&);
Expand Down Expand Up @@ -71,7 +70,6 @@ namespace IceInternal
//
const std::int32_t _mcastTtl;
const std::string _mcastInterface;
const bool _connect;
const bool _compress;
};

Expand Down
52 changes: 12 additions & 40 deletions cpp/src/Ice/UdpTransceiver.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -280,27 +280,8 @@ IceInternal::UdpTransceiver::read(Buffer& buf)
}
}

if (_state == StateNeedConnect)
{
//
// If we must connect, we connect to the first peer that sends us a packet.
//
assert(_incoming); // Client connections should always be connected at this point.

#ifndef NDEBUG
bool connected = doConnect(_fd, _peerAddr, Address());
assert(connected);
#else
doConnect(_fd, _peerAddr, Address());
#endif
_state = StateConnected;

if (_instance->traceLevel() >= 1)
{
Trace out(_instance->logger(), _instance->traceCategory());
out << "connected " << _instance->protocol() << " socket\n" << toString();
}
}
// Client connections are connected at this point, and server connections are never connected.
assert(_state != StateNeedConnect);

buf.b.resize(static_cast<size_t>(ret));
buf.i = buf.b.end();
Expand Down Expand Up @@ -541,13 +522,18 @@ IceInternal::UdpTransceiver::getInfo(bool incoming, string adapterName, string c
}
else
{
// TODO: remove these states
string mcastAddress;
int mcastPort = 0;
if (isAddressValid(_mcastAddr))
{
addrToAddressAndPort(_mcastAddr, mcastAddress, mcastPort);
}

if (_state == StateNotConnected)
{
assert(_incoming);
Address localAddr;
fdToLocalAddress(_fd, localAddr);

string localAddress;
int localPort;
addrToAddressAndPort(localAddr, localAddress, localPort);
Expand All @@ -559,13 +545,6 @@ IceInternal::UdpTransceiver::getInfo(bool incoming, string adapterName, string c
addrToAddressAndPort(_peerAddr, remoteAddress, remotePort);
}

string mcastAddress;
int mcastPort = 0;
if (isAddressValid(_mcastAddr))
{
addrToAddressAndPort(_mcastAddr, mcastAddress, mcastPort);
}

return make_shared<UDPConnectionInfo>(
incoming,
std::move(adapterName),
Expand All @@ -581,19 +560,13 @@ IceInternal::UdpTransceiver::getInfo(bool incoming, string adapterName, string c
}
else
{
assert(!_incoming);
string localAddress;
int localPort;
string remoteAddress;
int remotePort;
fdToAddressAndPort(_fd, localAddress, localPort, remoteAddress, remotePort);

string mcastAddress;
int mcastPort = 0;
if (isAddressValid(_mcastAddr))
{
addrToAddressAndPort(_mcastAddr, mcastAddress, mcastPort);
}

return make_shared<UDPConnectionInfo>(
incoming,
std::move(adapterName),
Expand Down Expand Up @@ -704,8 +677,7 @@ IceInternal::UdpTransceiver::UdpTransceiver(
const ProtocolInstancePtr& instance,
const string& host,
int port,
const string& mcastInterface,
bool connect)
const string& mcastInterface)
: _endpoint(endpoint),
_instance(instance),
_incoming(true),
Expand All @@ -715,7 +687,7 @@ IceInternal::UdpTransceiver::UdpTransceiver(
#ifdef _WIN32
_port(port),
#endif
_state(connect ? StateNeedConnect : StateNotConnected)
_state(StateNotConnected)
#if defined(ICE_USE_IOCP)
,
_read(SocketOperationRead),
Expand Down
8 changes: 1 addition & 7 deletions cpp/src/Ice/UdpTransceiver.h
Original file line number Diff line number Diff line change
Expand Up @@ -27,13 +27,7 @@ namespace IceInternal

public:
UdpTransceiver(const ProtocolInstancePtr&, const Address&, const Address&, const std::string&, int);
UdpTransceiver(
const UdpEndpointIPtr&,
const ProtocolInstancePtr&,
const std::string&,
int,
const std::string&,
bool);
UdpTransceiver(const UdpEndpointIPtr&, const ProtocolInstancePtr&, const std::string&, int, const std::string&);

~UdpTransceiver() final;

Expand Down
4 changes: 1 addition & 3 deletions cpp/test/Ice/info/AllTests.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -165,9 +165,7 @@ allTests(Test::TestHelper* helper)
}

int port = helper->getTestPort();
TestIntfPrx testIntf(
communicator,
"test:" + helper->getTestEndpoint() + ":" + helper->getTestEndpoint("udp") + " -c");
TestIntfPrx testIntf(communicator, "test:" + helper->getTestEndpoint() + ":" + helper->getTestEndpoint("udp"));

cout << "test connection endpoint information... " << flush;
{
Expand Down
Loading

0 comments on commit e657245

Please sign in to comment.