Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/main' into cpp-property-validation
Browse files Browse the repository at this point in the history
  • Loading branch information
externl committed Oct 2, 2024
2 parents e82f588 + 0f5a361 commit 8248f45
Show file tree
Hide file tree
Showing 93 changed files with 515 additions and 639 deletions.
2 changes: 1 addition & 1 deletion cpp/include/Ice/LocalExceptions.h
Original file line number Diff line number Diff line change
Expand Up @@ -481,7 +481,7 @@ namespace Ice
SocketException(const char* file, int line, std::string messagePrefix, ErrorCode error);

/**
* Constructs a SocketException without a generic message.
* Constructs a SocketException with a generic message.
* @param file The file where this exception is constructed. This C string is not copied.
* @param line The line where this exception is constructed.
* @param error The error code.
Expand Down
22 changes: 3 additions & 19 deletions cpp/src/Ice/ConnectionFactory.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -239,9 +239,10 @@ IceInternal::OutgoingConnectionFactory::setRouterInfo(const RouterInfoPtr& route
// other sources. In order to allow connection sharing for
// endpoints that differ in the value of the compression flag
// only, we always set the compression flag to false here in
// this connection factory.
// this connection factory. We also clear the timeout as it is
// no longer used for Ice 3.8.
//
endpoint = endpoint->compress(false);
endpoint = endpoint->compress(false)->timeout(-1);

for (multimap<ConnectorPtr, ConnectionIPtr>::const_iterator q = _connections.begin(); q != _connections.end();
++q)
Expand Down Expand Up @@ -1223,24 +1224,9 @@ IceInternal::IncomingConnectionFactory::waitUntilFinished()
}
}

bool
IceInternal::IncomingConnectionFactory::isLocal(const EndpointIPtr& endpoint) const
{
if (_publishedEndpoint && endpoint->equivalent(_publishedEndpoint))
{
return true;
}
lock_guard lock(_mutex);
return endpoint->equivalent(_endpoint);
}

EndpointIPtr
IceInternal::IncomingConnectionFactory::endpoint() const
{
if (_publishedEndpoint)
{
return _publishedEndpoint;
}
lock_guard lock(_mutex);
return _endpoint;
}
Expand Down Expand Up @@ -1609,7 +1595,6 @@ IceInternal::IncomingConnectionFactory::connectionStartFailed(const Ice::Connect
IceInternal::IncomingConnectionFactory::IncomingConnectionFactory(
const InstancePtr& instance,
const EndpointIPtr& endpoint,
const EndpointIPtr& publishedEndpoint,
const shared_ptr<ObjectAdapterI>& adapter)
: _instance(instance),
_connectionOptions(instance->serverConnectionOptions(adapter->getName())),
Expand All @@ -1618,7 +1603,6 @@ IceInternal::IncomingConnectionFactory::IncomingConnectionFactory(
? 0
: instance->initializationData().properties->getPropertyAsInt(adapter->getName() + ".MaxConnections")),
_endpoint(endpoint),
_publishedEndpoint(publishedEndpoint),
_acceptorStarted(false),
_acceptorStopped(false),
_adapter(adapter),
Expand Down
8 changes: 1 addition & 7 deletions cpp/src/Ice/ConnectionFactory.h
Original file line number Diff line number Diff line change
Expand Up @@ -167,11 +167,7 @@ namespace IceInternal
class IncomingConnectionFactory final : public EventHandler
{
public:
IncomingConnectionFactory(
const InstancePtr&,
const EndpointIPtr&,
const EndpointIPtr&,
const std::shared_ptr<Ice::ObjectAdapterI>&);
IncomingConnectionFactory(const InstancePtr&, const EndpointIPtr&, const std::shared_ptr<Ice::ObjectAdapterI>&);
void activate();
void hold();
void destroy();
Expand All @@ -184,7 +180,6 @@ namespace IceInternal
void waitUntilHolding() const;
void waitUntilFinished();

bool isLocal(const EndpointIPtr&) const;
EndpointIPtr endpoint() const;
std::list<Ice::ConnectionIPtr> connections() const;
void removeConnection(const Ice::ConnectionIPtr&) noexcept;
Expand Down Expand Up @@ -242,7 +237,6 @@ namespace IceInternal
AcceptorPtr _acceptor;
const TransceiverPtr _transceiver;
EndpointIPtr _endpoint;
EndpointIPtr _publishedEndpoint;

bool _acceptorStarted;
bool _acceptorStopped;
Expand Down
20 changes: 0 additions & 20 deletions cpp/src/Ice/EndpointFactory.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -94,16 +94,6 @@ IceInternal::EndpointFactoryWithUnderlying::read(InputStream* s) const
return readWithUnderlying(_underlying->read(s), s);
}

void
IceInternal::EndpointFactoryWithUnderlying::destroy()
{
if (_underlying)
{
_underlying->destroy();
}
_instance = nullptr;
}

EndpointFactoryPtr
IceInternal::EndpointFactoryWithUnderlying::clone(const ProtocolInstancePtr& instance) const
{
Expand Down Expand Up @@ -172,16 +162,6 @@ IceInternal::UnderlyingEndpointFactory::read(InputStream* s) const
return _factory->read(s);
}

void
IceInternal::UnderlyingEndpointFactory::destroy()
{
if (_factory)
{
_factory->destroy();
}
_instance = nullptr;
}

EndpointFactoryPtr
IceInternal::UnderlyingEndpointFactory::clone(const ProtocolInstancePtr& instance) const
{
Expand Down
7 changes: 2 additions & 5 deletions cpp/src/Ice/EndpointFactory.h
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@ namespace IceInternal
virtual std::string protocol() const = 0;
virtual EndpointIPtr create(std::vector<std::string>&, bool) const = 0;
virtual EndpointIPtr read(Ice::InputStream*) const = 0;
virtual void destroy() = 0;

virtual EndpointFactoryPtr clone(const ProtocolInstancePtr&) const = 0;
};
Expand All @@ -49,7 +48,6 @@ namespace IceInternal
virtual std::string protocol() const;
virtual EndpointIPtr create(std::vector<std::string>&, bool) const;
virtual EndpointIPtr read(Ice::InputStream*) const;
virtual void destroy();

virtual EndpointFactoryPtr clone(const ProtocolInstancePtr&) const;

Expand All @@ -59,7 +57,7 @@ namespace IceInternal
virtual EndpointIPtr createWithUnderlying(const EndpointIPtr&, std::vector<std::string>&, bool) const = 0;
virtual EndpointIPtr readWithUnderlying(const EndpointIPtr&, Ice::InputStream*) const = 0;

ProtocolInstancePtr _instance;
const ProtocolInstancePtr _instance;
const std::int16_t _type;
EndpointFactoryPtr _underlying;
};
Expand All @@ -80,12 +78,11 @@ namespace IceInternal
virtual std::string protocol() const;
virtual EndpointIPtr create(std::vector<std::string>&, bool) const;
virtual EndpointIPtr read(Ice::InputStream*) const;
virtual void destroy();

virtual EndpointFactoryPtr clone(const ProtocolInstancePtr&) const;

private:
ProtocolInstancePtr _instance;
const ProtocolInstancePtr _instance;
const std::int16_t _type;
const std::int16_t _underlying;
EndpointFactoryPtr _factory;
Expand Down
19 changes: 3 additions & 16 deletions cpp/src/Ice/EndpointFactoryManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,7 @@ IceInternal::EndpointFactoryManager::initialize() const
void
IceInternal::EndpointFactoryManager::add(const EndpointFactoryPtr& factory)
{
lock_guard lock(_mutex); // TODO: Necessary?

lock_guard lock(_mutex);
//
// TODO: Optimize with a map?
//
Expand All @@ -49,8 +48,7 @@ IceInternal::EndpointFactoryManager::add(const EndpointFactoryPtr& factory)
EndpointFactoryPtr
IceInternal::EndpointFactoryManager::get(int16_t type) const
{
lock_guard lock(_mutex); // TODO: Necessary?

lock_guard lock(_mutex);
//
// TODO: Optimize with a map?
//
Expand Down Expand Up @@ -89,8 +87,7 @@ IceInternal::EndpointFactoryManager::create(const string& str, bool oaEndpoint)

EndpointFactoryPtr factory;
{
lock_guard lock(_mutex); // TODO: Necessary?

lock_guard lock(_mutex);
//
// TODO: Optimize with a map?
//
Expand Down Expand Up @@ -185,13 +182,3 @@ IceInternal::EndpointFactoryManager::read(InputStream* s) const

return e;
}

void
IceInternal::EndpointFactoryManager::destroy()
{
for (vector<EndpointFactoryPtr>::size_type i = 0; i < _factories.size(); i++)
{
_factories[i]->destroy();
}
_factories.clear();
}
3 changes: 1 addition & 2 deletions cpp/src/Ice/EndpointFactoryManager.h
Original file line number Diff line number Diff line change
Expand Up @@ -32,10 +32,9 @@ namespace IceInternal
EndpointIPtr read(Ice::InputStream*) const;

private:
void destroy();
friend class Instance;

InstancePtr _instance;
const InstancePtr _instance;
std::vector<EndpointFactoryPtr> _factories;
mutable std::mutex _mutex;
};
Expand Down
22 changes: 7 additions & 15 deletions cpp/src/Ice/EndpointI.h
Original file line number Diff line number Diff line change
Expand Up @@ -112,23 +112,15 @@ namespace IceInternal
virtual AcceptorPtr
acceptor(const std::string&, const std::optional<Ice::SSL::ServerAuthenticationOptions>&) const = 0;

//
// Expand endpoint out into separate endpoints for each local
// host if listening on INADDR_ANY on server side.
//
virtual std::vector<EndpointIPtr> expandIfWildcard() const = 0;
// Expand endpoint into separate endpoints for each IP address returned by the DNS resolver.
// Used only for server endpoints.
virtual std::vector<EndpointIPtr> expandHost() const = 0;

//
// Expand endpoint out into separate endpoints for each IP
// address returned by the DNS resolver. Also returns the
// endpoint which can be used to connect to the returned
// endpoints or null if no specific endpoint can be used to
// connect to these endpoints (e.g.: with the IP endpoint,
// it returns this endpoint if it uses a fixed port, null
// otherwise).
//
virtual std::vector<EndpointIPtr> expandHost(IceInternal::EndpointIPtr&) const = 0;
// Returns true when the most underlying endpoint is an IP endpoint with a loopback address.
virtual bool isLoopback() const = 0;

// Returns a new endpoint with the specified host; returns this when this operation is not applicable.
virtual std::shared_ptr<EndpointI> withPublishedHost(std::string host) const = 0;
//
// Check whether the endpoint is equivalent to another one.
//
Expand Down
65 changes: 19 additions & 46 deletions cpp/src/Ice/IPEndpointI.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -107,48 +107,16 @@ IceInternal::IPEndpointI::connectorsAsync(
}

vector<EndpointIPtr>
IceInternal::IPEndpointI::expandIfWildcard() const
IceInternal::IPEndpointI::expandHost() const
{
vector<EndpointIPtr> endpoints;
vector<string> hosts = getHostsForEndpointExpand(_host, _instance->protocolSupport(), false);
if (hosts.empty())
{
endpoints.push_back(const_cast<IPEndpointI*>(this)->shared_from_this());
}
else
{
for (const auto& host : hosts)
{
endpoints.push_back(createEndpoint(host, _port, _connectionId));
}
}
return endpoints;
}

vector<EndpointIPtr>
IceInternal::IPEndpointI::expandHost(EndpointIPtr& publish) const
{
//
// If this endpoint has an empty host (wildcard address), don't expand, just return
// this endpoint.
//
// If this endpoint has an empty host (wildcard address), don't expand, just return this endpoint.
if (_host.empty())
{
vector<EndpointIPtr> endpoints;
endpoints.push_back(const_cast<IPEndpointI*>(this)->shared_from_this());
return endpoints;
}

//
// If using a fixed port, this endpoint can be used as the published endpoint to
// access the returned endpoints. Otherwise, we'll publish each individual expanded
// endpoint.
//
if (_port > 0)
{
publish = const_cast<IPEndpointI*>(this)->shared_from_this();
}

vector<Address> addrs = getAddresses(
_host,
_port,
Expand All @@ -158,23 +126,28 @@ IceInternal::IPEndpointI::expandHost(EndpointIPtr& publish) const
true);

vector<EndpointIPtr> endpoints;
if (addrs.size() == 1)
for (const auto& address : addrs)
{
endpoints.push_back(const_cast<IPEndpointI*>(this)->shared_from_this());
}
else
{
for (vector<Address>::const_iterator p = addrs.begin(); p != addrs.end(); ++p)
{
string host;
int port;
addrToAddressAndPort(*p, host, port);
endpoints.push_back(createEndpoint(host, port, _connectionId));
}
string host;
int port;
addrToAddressAndPort(address, host, port);
endpoints.push_back(createEndpoint(host, port, _connectionId));
}
return endpoints;
}

bool
IceInternal::IPEndpointI::isLoopback() const
{
return _host.empty() ? false : isLoopbackAddress(_host);
}

shared_ptr<EndpointI>
IceInternal::IPEndpointI::withPublishedHost(string host) const
{
return createEndpoint(host, _port, _connectionId);
}

bool
IceInternal::IPEndpointI::equivalent(const EndpointIPtr& endpoint) const
{
Expand Down
5 changes: 3 additions & 2 deletions cpp/src/Ice/IPEndpointI.h
Original file line number Diff line number Diff line change
Expand Up @@ -48,8 +48,9 @@ namespace IceInternal
Ice::EndpointSelectionType,
std::function<void(std::vector<ConnectorPtr>)>,
std::function<void(std::exception_ptr)>) const override;
std::vector<EndpointIPtr> expandIfWildcard() const override;
std::vector<EndpointIPtr> expandHost(EndpointIPtr&) const override;
std::vector<EndpointIPtr> expandHost() const override;
bool isLoopback() const override;
std::shared_ptr<EndpointI> withPublishedHost(std::string host) const override;
bool equivalent(const EndpointIPtr&) const override;
std::size_t hash() const noexcept override;
std::string options() const override;
Expand Down
5 changes: 0 additions & 5 deletions cpp/src/Ice/Instance.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1674,11 +1674,6 @@ IceInternal::Instance::destroy()
_locatorManager->destroy();
}

if (_endpointFactoryManager)
{
_endpointFactoryManager->destroy();
}

if (_initData.properties->getIcePropertyAsInt("Ice.Warn.UnusedProperties") > 0)
{
set<string> unusedProperties = _initData.properties.get()->getUnusedProperties();
Expand Down
Loading

0 comments on commit 8248f45

Please sign in to comment.