Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix proxy usage and creation in IceGrid implementation #1933

Merged
merged 3 commits into from
Mar 15, 2024

Conversation

pepone
Copy link
Member

@pepone pepone commented Mar 14, 2024

No description provided.

Copy link
Member

@externl externl left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good to me!

// Null observers are ignored
if (observer)
{
addObserver(*observer);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should we move it out of the optional?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes we should.

Comment on lines 332 to 333
name == _replicaName ? _database->getReplicaCache().getInternalRegistry()
: _database->getReplicaCache().getInternalRegistry(),
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Shouldn't the false case be _database->getReplica(std::move(name))->getProxy();

// the server is released during the server startup.
//
ServerPrxPtr server;
// NOTE: We pass false to the getServer call to indicate that we don't necessarily want an up-to-date adapter
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not specifically related to your PR, but where are we passing false to getServer?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think the comment refers to the the getProxy call in getServer(id)->getProxy(false);


ObjectPrxPtr proxy;
optional<ObjectPrx> proxy;
try
{
proxy = _database->getObjectProxy(id);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should getObjectProxy be updated to not return an optional?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think so. This way we know that we are getting non null proxies from the database.

const std::string&,
bool);
~ServerAdapterI() override;

void activateAsync(
std::function<void(const Ice::ObjectPrxPtr&)>, // TODO: pass by value!
std::function<void(const std::optional<Ice::ObjectPrx>&)>, // TODO: pass by value!
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this TODO still relevant?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, the callback is still taking a reference as before.

}
break;
case Disconnect:
assert(session);
destroySession(session);
destroySession(*session);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How do we now session is not null here (and below)?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The previous code already has an assert for this.

Ice::Identity id = {"Locator", _database->getInstanceName()};
return Ice::uncheckedCast<LocatorPrx>(getWellKnownObjectReplicatedProxy(std::move(id), "Client"));
return LocatorPrx{
getWellKnownObjectReplicatedProxy(Ice::Identity{"Locator", _database->getInstanceName()}, "Client")};
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is Ice::Identity required here?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not sure, but IMO it is more readable.

Copy link
Member

@bernardnormier bernardnormier left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good, but the Slice file doc-comments need some fixes.

// Null observers are ignored
if (observer)
{
addObserver(*std::move(observer));
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Uses optional's

constexpr T&& operator*() && noexcept;

@@ -129,7 +129,7 @@ namespace

private:
string _id;
ServerPrxPtr _proxy;
optional<ServerPrx> _proxy;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't see how _proxy can be null. It's just convenience for the constructor?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We can fix this by using a helper function, and moving the SynchronizationException handling to the helper method.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I will try to fix in a follow up PR.

@@ -87,7 +87,7 @@ interface LocatorRegistry
/// Set the adapter endpoints with the locator registry.
/// @param id The adapter id.
/// @param proxy The adapter proxy (a dummy direct proxy created by the adapter). The direct proxy contains the
/// adapter endpoints.
/// adapter endpoints. The proxy is never null.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is bogus. We pass a null proxy during object adapter deactivation.

@@ -97,19 +97,19 @@ interface LocatorRegistry
/// Set the adapter endpoints with the locator registry.
/// @param adapterId The adapter id.
/// @param replicaGroupId The replica group id.
/// @param p The adapter proxy (a dummy direct proxy created by the adapter). The direct proxy contains the adapter
/// endpoints.
/// @param proxy The adapter proxy (a dummy direct proxy created by the adapter). The direct proxy contains the adapter
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It can be null, see above.

throws AdapterNotFoundException, AdapterAlreadyActiveException, InvalidReplicaGroupIdException;

/// Set the process proxy for a server.
/// @param id The server id.
/// @param proxy The process proxy.
/// @param proxy The process proxy. The proxy is never null.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I believe this is correct - this proxy is never null.

@@ -75,7 +75,7 @@ struct AdapterInfo
/// The id of the adapter.
string id;

/// A dummy direct proxy that contains the adapter endpoints.
/// A dummy direct proxy that contains the adapter endpoints. This proxy is never null.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think we can make this statement for struct fields in general. The application can always put a null proxy in a struct field.

Then, if you look at the Database implementation, this field is occasionally null.

Such information would be more valuable on an operation that accepts or returns an AdapterInfo or AdapterInfoSeq. Like (if accurate) "the proxy field of the returned adapter info is never null".

@pepone pepone merged commit 0cd3c4a into zeroc-ice:main Mar 15, 2024
24 checks passed
InsertCreativityHere pushed a commit to InsertCreativityHere/compiler-comparison that referenced this pull request Jan 1, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants