Skip to content

Commit 7728901

Browse files
Specify connection when creating Allocation/Admin session for Glacier2
1 parent d177c1b commit 7728901

File tree

7 files changed

+42
-22
lines changed

7 files changed

+42
-22
lines changed

cpp/src/IceGrid/AdminSessionI.cpp

Lines changed: 13 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -459,12 +459,15 @@ AdminSessionFactory::AdminSessionFactory(
459459
}
460460

461461
Glacier2::SessionPrx
462-
AdminSessionFactory::createGlacier2Session(const string& sessionId, const optional<Glacier2::SessionControlPrx>& ctl)
462+
AdminSessionFactory::createGlacier2Session(
463+
const string& sessionId,
464+
const optional<Glacier2::SessionControlPrx>& ctl,
465+
const Ice::ConnectionPtr& con)
463466
{
464467
assert(_servantManager);
465468

466469
auto session = createSessionServant(sessionId);
467-
auto proxy = session->_register(_servantManager, nullptr);
470+
auto proxy = session->_register(_servantManager, con);
468471

469472
if (ctl)
470473
{
@@ -489,7 +492,7 @@ AdminSessionFactory::createGlacier2Session(const string& sessionId, const option
489492
// We can't use a non-0 timeout such as the Glacier2 session timeout. As of Ice 3.8, heartbeats may not be sent
490493
// at all on a busy connection. Furthermore, as of Ice 3.8, Glacier2 no longer "converts" heartbeats into
491494
// keepAlive requests.
492-
_reaper->add(make_shared<SessionReapable<AdminSessionI>>(_database->getTraceLevels()->logger, session), 0s);
495+
_reaper->add(make_shared<SessionReapable<AdminSessionI>>(_database->getTraceLevels()->logger, session), 0s, con);
493496
return Ice::uncheckedCast<Glacier2::SessionPrx>(proxy);
494497
}
495498

@@ -508,15 +511,18 @@ AdminSessionFactory::getTraceLevels() const
508511
AdminSessionManagerI::AdminSessionManagerI(const shared_ptr<AdminSessionFactory>& factory) : _factory(factory) {}
509512

510513
optional<Glacier2::SessionPrx>
511-
AdminSessionManagerI::create(string userId, optional<Glacier2::SessionControlPrx> ctl, const Ice::Current&)
514+
AdminSessionManagerI::create(string userId, optional<Glacier2::SessionControlPrx> ctl, const Ice::Current& current)
512515
{
513-
return _factory->createGlacier2Session(std::move(userId), std::move(ctl));
516+
return _factory->createGlacier2Session(std::move(userId), std::move(ctl), current.con);
514517
}
515518

516519
AdminSSLSessionManagerI::AdminSSLSessionManagerI(const shared_ptr<AdminSessionFactory>& factory) : _factory(factory) {}
517520

518521
optional<Glacier2::SessionPrx>
519-
AdminSSLSessionManagerI::create(Glacier2::SSLInfo info, optional<Glacier2::SessionControlPrx> ctl, const Ice::Current&)
522+
AdminSSLSessionManagerI::create(
523+
Glacier2::SSLInfo info,
524+
optional<Glacier2::SessionControlPrx> ctl,
525+
const Ice::Current& current)
520526
{
521527
string userDN;
522528
if (!info.certs.empty()) // TODO: Require userDN?
@@ -535,5 +541,5 @@ AdminSSLSessionManagerI::create(Glacier2::SSLInfo info, optional<Glacier2::Sessi
535541
}
536542
}
537543

538-
return _factory->createGlacier2Session(std::move(userDN), std::move(ctl));
544+
return _factory->createGlacier2Session(std::move(userDN), std::move(ctl), current.con);
539545
}

cpp/src/IceGrid/AdminSessionI.h

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -86,8 +86,11 @@ namespace IceGrid
8686
const std::shared_ptr<ReapThread>&,
8787
const std::shared_ptr<RegistryI>&);
8888

89-
Glacier2::SessionPrx
90-
createGlacier2Session(const std::string&, const std::optional<Glacier2::SessionControlPrx>&);
89+
Glacier2::SessionPrx createGlacier2Session(
90+
const std::string& sessionId,
91+
const std::optional<Glacier2::SessionControlPrx>& ctl,
92+
const Ice::ConnectionPtr& con);
93+
9194
std::shared_ptr<AdminSessionI> createSessionServant(const std::string&);
9295

9396
const std::shared_ptr<TraceLevels>& getTraceLevels() const;

cpp/src/IceGrid/InternalRegistryI.cpp

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,10 @@ InternalRegistryI::registerNode(
6262
try
6363
{
6464
auto session = NodeSessionI::create(_database, std::move(*node), info, _nodeSessionTimeout, load);
65-
_reaper->add(make_shared<SessionReapable<NodeSessionI>>(logger, session), _nodeSessionTimeout);
65+
66+
// nullptr for the connection parameter, meaning the reaper won't destroy the session if the connection is
67+
// closed.
68+
_reaper->add(make_shared<SessionReapable<NodeSessionI>>(logger, session), _nodeSessionTimeout, nullptr);
6669
return session->getProxy();
6770
}
6871
catch (const Ice::ObjectAdapterDestroyedException&)
@@ -93,7 +96,10 @@ InternalRegistryI::registerReplica(
9396
try
9497
{
9598
auto s = ReplicaSessionI::create(_database, _wellKnownObjects, info, std::move(*prx), _replicaSessionTimeout);
96-
_reaper->add(make_shared<SessionReapable<ReplicaSessionI>>(logger, s), _replicaSessionTimeout);
99+
100+
// nullptr for the connection parameter, meaning the reaper won't destroy the session if the connection is
101+
// closed.
102+
_reaper->add(make_shared<SessionReapable<ReplicaSessionI>>(logger, s), _replicaSessionTimeout, nullptr);
97103
return s->getProxy();
98104
}
99105
catch (const Ice::ObjectAdapterDestroyedException&)

cpp/src/IceGrid/ReapThread.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -141,7 +141,7 @@ ReapThread::add(const shared_ptr<Reapable>& reapable, chrono::seconds timeout, c
141141
}
142142

143143
// NOTE: registering a reapable with a 0s timeout is allowed. The reapable is reaped only when the reaper thread is
144-
// shutdown or the connection is closed.
144+
// shutdown or the connection is closed (when connection is not null).
145145

146146
//
147147
// 10 seconds is the minimum permissable timeout (for non-zero timeouts).

cpp/src/IceGrid/ReapThread.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ namespace IceGrid
6969

7070
void terminate();
7171
void join();
72-
void add(const std::shared_ptr<Reapable>&, std::chrono::seconds, const Ice::ConnectionPtr& = nullptr);
72+
void add(const std::shared_ptr<Reapable>&, std::chrono::seconds, const Ice::ConnectionPtr&);
7373

7474
void connectionClosed(const Ice::ConnectionPtr&);
7575

cpp/src/IceGrid/SessionI.cpp

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -277,12 +277,15 @@ ClientSessionFactory::ClientSessionFactory(
277277
}
278278

279279
Glacier2::SessionPrx
280-
ClientSessionFactory::createGlacier2Session(const string& sessionId, const optional<Glacier2::SessionControlPrx>& ctl)
280+
ClientSessionFactory::createGlacier2Session(
281+
const string& sessionId,
282+
const optional<Glacier2::SessionControlPrx>& ctl,
283+
const Ice::ConnectionPtr& con)
281284
{
282285
assert(_servantManager);
283286

284287
auto session = createSessionServant(sessionId);
285-
auto proxy = session->_register(_servantManager, nullptr);
288+
auto proxy = session->_register(_servantManager, con);
286289

287290
if (ctl)
288291
{
@@ -308,7 +311,7 @@ ClientSessionFactory::createGlacier2Session(const string& sessionId, const optio
308311
// We can't use a non-0 timeout such as the Glacier2 session timeout. As of Ice 3.8, heartbeats may not be sent
309312
// at all on a busy connection. Furthermore, as of Ice 3.8, Glacier2 no longer "converts" heartbeats into
310313
// keepAlive requests.
311-
_reaper->add(make_shared<SessionReapable<SessionI>>(_database->getTraceLevels()->logger, session), 0s);
314+
_reaper->add(make_shared<SessionReapable<SessionI>>(_database->getTraceLevels()->logger, session), 0s, con);
312315
return Ice::uncheckedCast<Glacier2::SessionPrx>(proxy);
313316
}
314317

@@ -327,9 +330,9 @@ ClientSessionFactory::getTraceLevels() const
327330
ClientSessionManagerI::ClientSessionManagerI(const shared_ptr<ClientSessionFactory>& factory) : _factory(factory) {}
328331

329332
std::optional<Glacier2::SessionPrx>
330-
ClientSessionManagerI::create(string user, std::optional<Glacier2::SessionControlPrx> ctl, const Ice::Current&)
333+
ClientSessionManagerI::create(string user, std::optional<Glacier2::SessionControlPrx> ctl, const Ice::Current& current)
331334
{
332-
return _factory->createGlacier2Session(std::move(user), std::move(ctl));
335+
return _factory->createGlacier2Session(std::move(user), std::move(ctl), current.con);
333336
}
334337

335338
ClientSSLSessionManagerI::ClientSSLSessionManagerI(const shared_ptr<ClientSessionFactory>& factory) : _factory(factory)
@@ -340,7 +343,7 @@ std::optional<Glacier2::SessionPrx>
340343
ClientSSLSessionManagerI::create(
341344
Glacier2::SSLInfo info,
342345
std::optional<Glacier2::SessionControlPrx> ctl,
343-
const Ice::Current&)
346+
const Ice::Current& current)
344347
{
345348
string userDN;
346349
if (!info.certs.empty()) // TODO: Require userDN?
@@ -360,5 +363,5 @@ ClientSSLSessionManagerI::create(
360363
}
361364
}
362365

363-
return _factory->createGlacier2Session(userDN, ctl);
366+
return _factory->createGlacier2Session(userDN, ctl, current.con);
364367
}

cpp/src/IceGrid/SessionI.h

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -99,8 +99,10 @@ namespace IceGrid
9999
const IceInternal::TimerPtr&,
100100
const std::shared_ptr<ReapThread>&);
101101

102-
Glacier2::SessionPrx
103-
createGlacier2Session(const std::string&, const std::optional<Glacier2::SessionControlPrx>&);
102+
Glacier2::SessionPrx createGlacier2Session(
103+
const std::string& sessionId,
104+
const std::optional<Glacier2::SessionControlPrx>& ctl,
105+
const Ice::ConnectionPtr& con);
104106

105107
std::shared_ptr<SessionI> createSessionServant(const std::string&);
106108

0 commit comments

Comments
 (0)