Skip to content

Commit

Permalink
Update SessionControl::destroy impl to close the connection
Browse files Browse the repository at this point in the history
  • Loading branch information
bernardnormier committed Aug 5, 2024
1 parent 20b0152 commit f916f36
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 8 deletions.
4 changes: 4 additions & 0 deletions cpp/src/Glacier2/SessionRouterI.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,10 @@ namespace Glacier2
{
_sessionRouter->destroySession(_connection);
_filters->destroy();

// Initiate a graceful closure of the connection. Only initiate and graceful because the ultimate caller
// can be the Glacier2 client calling us over _connection.
_connection->close(ConnectionClose::Gracefully);
}

private:
Expand Down
18 changes: 10 additions & 8 deletions cpp/test/Glacier2/sessionControl/Client.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,9 @@
#include "Ice/Ice.h"
#include "Session.h"
#include "TestHelper.h"

#include <chrono>
#include <future>
#include <set>

using namespace std;
Expand Down Expand Up @@ -44,6 +47,10 @@ SessionControlClient::run(int argc, char** argv)
cout << "ok" << endl;

cout << "testing destroy... " << flush;
ConnectionPtr connection = session->ice_getConnection();
promise<void> connectionClosed;
connection->setCloseCallback([&connectionClosed](const ConnectionPtr&) { connectionClosed.set_value(); });

try
{
session->destroyFromClient();
Expand All @@ -52,14 +59,9 @@ SessionControlClient::run(int argc, char** argv)
{
test(false);
}
try
{
session->ice_ping();
test(false);
}
catch (const Ice::ConnectionLostException&)
{
}

// Make sure destroy closes the connection to the router.
test(connectionClosed.get_future().wait_for(chrono::milliseconds(100)) == future_status::ready);
cout << "ok" << endl;

cout << "testing create exceptions... " << flush;
Expand Down

0 comments on commit f916f36

Please sign in to comment.