Skip to content

Commit

Permalink
Remove udp -c option in C++ and Java
Browse files Browse the repository at this point in the history
  • Loading branch information
bernardnormier committed Dec 3, 2024
1 parent 71b8054 commit bf15b01
Show file tree
Hide file tree
Showing 8 changed files with 38 additions and 158 deletions.
56 changes: 6 additions & 50 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 @@ -140,7 +132,6 @@ IceInternal::UdpEndpointI::compress(bool compress) const
_sourceAddr,
_mcastInterface,
_mcastTtl,
_connect,
_connectionId,
compress);
}
Expand All @@ -162,7 +153,6 @@ IceInternal::UdpEndpointI::toPublishedEndpoint(string publishedHost) const
Address{},
"",
-1,
false, // for "connect"
"",
_compress);
}
Expand All @@ -175,8 +165,7 @@ IceInternal::UdpEndpointI::transceiver() const
_instance,
_host,
_port,
_mcastInterface,
_connect);
_mcastInterface);
}

AcceptorPtr
Expand All @@ -202,7 +191,6 @@ IceInternal::UdpEndpointI::endpoint(const UdpTransceiverPtr& transceiver) const
_sourceAddr,
_mcastInterface,
_mcastTtl,
_connect,
_connectionId,
_compress);
}
Expand Down Expand Up @@ -263,11 +251,6 @@ IceInternal::UdpEndpointI::options() const
s << " --ttl " << to_string(_mcastTtl);
}

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

if (_compress)
{
s << " -z";
Expand Down Expand Up @@ -300,11 +283,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 +324,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 +351,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 +363,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 @@ -495,7 +452,6 @@ IceInternal::UdpEndpointI::createEndpoint(const string& host, int port, const st
_sourceAddr,
_mcastInterface,
_mcastTtl,
_connect,
connectionId,
_compress);
}
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
3 changes: 1 addition & 2 deletions cpp/src/Ice/UdpTransceiver.h
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,7 @@ namespace IceInternal
const ProtocolInstancePtr&,
const std::string&,
int,
const std::string&,
bool);
const std::string&);

~UdpTransceiver() final;

Expand Down
2 changes: 1 addition & 1 deletion cpp/test/Ice/info/AllTests.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -167,7 +167,7 @@ allTests(Test::TestHelper* helper)
int port = helper->getTestPort();
TestIntfPrx testIntf(
communicator,
"test:" + helper->getTestEndpoint() + ":" + helper->getTestEndpoint("udp") + " -c");
"test:" + helper->getTestEndpoint() + ":" + helper->getTestEndpoint("udp"));

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

0 comments on commit bf15b01

Please sign in to comment.