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
+12
View File
@@ -201,6 +201,17 @@ struct Tester {
testEq(result["query.a"].as<int32_t>(), 5);
testEq(result["query.b"].as<std::string>(), "hello");
}
void orphan()
{
testShow()<<__func__;
auto op = cli.rpc("nonexistent").exec();
// clear Context to orphan in-progress operation
cli = client::Context();
op.reset();
}
};
} // namespace
@@ -216,6 +227,7 @@ MAIN(testrpc)
Tester().cancel();
Tester().error();
Tester().builder();
Tester().orphan();
cleanup_for_valgrind();
return testDone();
}