client: Handle orphaned Operations

Allow Operation instances to outlive
the Context through which they were
created.
This commit is contained in:
Michael Davidsaver
2020-07-27 11:41:07 -07:00
parent 5f421ce46b
commit 33b6f362db
11 changed files with 88 additions and 13 deletions
+13 -1
View File
@@ -48,7 +48,7 @@ struct BasicTest {
~BasicTest()
{
if(cli.use_count()!=1u)
if(cli.use_count()>1u)
testAbort("Tester Context leak");
}
@@ -84,6 +84,17 @@ struct BasicTest {
}
return ret;
}
void orphan()
{
testShow()<<__func__;
auto op = cli.monitor("nonexistent").exec();
// clear Context to orphan in-progress operation
cli = client::Context();
op.reset();
}
};
struct TestLifeCycle : public BasicTest
@@ -253,6 +264,7 @@ MAIN(testmon)
testPlan(22);
testSetup();
logger_config_env();
BasicTest().orphan();
TestLifeCycle().testBasic(true);
TestLifeCycle().testBasic(false);
TestLifeCycle().testSecond();