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
@@ -45,7 +45,7 @@ struct Tester {
~Tester()
{
if(cli.use_count()!=1u)
if(cli.use_count()>1u)
testAbort("Tester Context leak");
}
@@ -173,6 +173,17 @@ struct Tester {
testOk1(!done.wait(2.1));
}
void orphan()
{
testShow()<<__func__;
auto op = cli.get("nonexistent").exec();
// clear Context to orphan in-progress operation
cli = client::Context();
op.reset();
}
};
struct ErrorSource : public server::Source
@@ -253,6 +264,7 @@ MAIN(testget)
Tester().lazy();
Tester().timeout();
Tester().cancel();
Tester().orphan();
testError(false);
testError(true);
cleanup_for_valgrind();