Skip to content

Commit

Permalink
ConnectionInfo fixes in C++ and C# (#3197)
Browse files Browse the repository at this point in the history
  • Loading branch information
bernardnormier authored Nov 26, 2024
1 parent 132f832 commit 0288df0
Show file tree
Hide file tree
Showing 8 changed files with 27 additions and 8 deletions.
9 changes: 5 additions & 4 deletions cpp/src/Ice/ConnectionI.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1050,6 +1050,9 @@ Ice::ConnectionI::setAdapterFromAdapter(const ObjectAdapterIPtr& adapter)
}
assert(adapter); // Called by ObjectAdapterI::setAdapterOnConnection
_adapter = adapter;

// Clear cached connection info (if any) as it's no longer accurate.
_info = nullptr;
}

#if defined(ICE_USE_IOCP)
Expand Down Expand Up @@ -3500,10 +3503,8 @@ Ice::ConnectionI::initConnectionInfo() const
return _info;
}

_info = _transceiver->getInfo(
_connector == nullptr,
_adapter ? _adapter->getName() : string{},
_endpoint->connectionId());
bool incoming = !_connector;
_info = _transceiver->getInfo(incoming, _adapter ? _adapter->getName() : string{}, _endpoint->connectionId());
return _info;
}

Expand Down
3 changes: 2 additions & 1 deletion cpp/src/Ice/SSL/OpenSSLTransceiverI.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -601,7 +601,8 @@ Ice::ConnectionInfoPtr
OpenSSL::TransceiverI::getInfo(bool incoming, string adapterName, string connectionId) const
{
assert(incoming == _incoming);
assert(adapterName == _adapterName);
// adapterName is the name of the object adapter currently associated with this connection, while _adapterName
// represents the name of the object adapter that created this connection (incoming only).

X509* peerCertificate = nullptr;
if (_peerCertificate)
Expand Down
3 changes: 2 additions & 1 deletion cpp/src/Ice/SSL/SchannelTransceiverI.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -933,7 +933,8 @@ Ice::ConnectionInfoPtr
Schannel::TransceiverI::getInfo(bool incoming, string adapterName, string connectionId) const
{
assert(incoming == _incoming);
assert(adapterName == _adapterName);
// adapterName is the name of the object adapter currently associated with this connection, while _adapterName
// represents the name of the object adapter that created this connection (incoming only).

return make_shared<ConnectionInfo>(
_delegate->getInfo(incoming, std::move(adapterName), std::move(connectionId)),
Expand Down
3 changes: 2 additions & 1 deletion cpp/src/Ice/SSL/SecureTransportTransceiverI.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -506,7 +506,8 @@ Ice::ConnectionInfoPtr
Ice::SSL::SecureTransport::TransceiverI::getInfo(bool incoming, string adapterName, string connectionId) const
{
assert(incoming == _incoming);
assert(adapterName == _adapterName);
// adapterName is the name of the object adapter currently associated with this connection, while _adapterName
// represents the name of the object adapter that created this connection (incoming only).

SecCertificateRef peerCertificate = nullptr;

Expand Down
5 changes: 5 additions & 0 deletions cpp/src/Ice/Transceiver.h
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,11 @@ namespace IceInternal
virtual std::string toString() const = 0;
virtual std::string toDetailedString() const = 0;

/// @brief Creates a connection info object for this connection.
/// @param incoming true for an incoming connection, false for an outgoing connection.
/// @param adapterName The name of the object adapter currently associated with this connection.
/// @param connectionId The connection ID of this connection.
/// @return The new connection info.
virtual Ice::ConnectionInfoPtr
getInfo(bool incoming, std::string adapterName, std::string connectionId) const = 0;

Expand Down
3 changes: 3 additions & 0 deletions csharp/src/Ice/ConnectionI.cs
Original file line number Diff line number Diff line change
Expand Up @@ -572,6 +572,9 @@ public void setAdapterFromAdapter(ObjectAdapter adapter)
}
Debug.Assert(adapter is not null); // Called by ObjectAdapter::setAdapterOnConnection
_adapter = adapter;

// Clear cached connection info (if any) as it's no longer accurate.
_info = null;
}
}

Expand Down
6 changes: 6 additions & 0 deletions csharp/src/Ice/Internal/Transceiver.cs
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,12 @@ public interface Transceiver

string toDetailedString();

/// <summary>Creates a connection info object for this connection.</summary>
/// <param name="incoming"><see langword="true"/> for an incoming connection, <see langword="true"/> for an outgoing
/// connection.</param>
/// <param name="adapterName">The name of the object adapter currently associated with this connection.</param>
/// <param name="connectionId">The connection ID of this connection.</param>
/// <returns>The new connection info.</returns>
ConnectionInfo getInfo(bool incoming, string adapterName, string connectionId);

void checkSendSize(Buffer buf);
Expand Down
3 changes: 2 additions & 1 deletion csharp/src/Ice/SSL/TransceiverI.cs
Original file line number Diff line number Diff line change
Expand Up @@ -312,7 +312,8 @@ public void finishWrite(Ice.Internal.Buffer buf)
public Ice.ConnectionInfo getInfo(bool incoming, string adapterName, string connectionId)
{
Debug.Assert(incoming == _incoming);
Debug.Assert(adapterName == _adapterName);
// adapterName is the name of the object adapter currently associated with this connection, while _adapterName
// represents the name of the object adapter that created this connection (incoming only).

return new Ice.SSL.ConnectionInfo(
_delegate.getInfo(incoming, adapterName, connectionId),
Expand Down

0 comments on commit 0288df0

Please sign in to comment.