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
+4 -2
View File
@@ -456,9 +456,11 @@ static
void gpr_cleanup(std::shared_ptr<Operation>& ret, std::shared_ptr<GPROp>&& op)
{
auto cap(std::move(op));
ret.reset(cap.get(), [cap](Operation*) mutable {
auto loop(cap->chan->context->tcp_loop);
ret.reset(cap.get(), [cap, loop](Operation*) mutable {
auto L(std::move(loop));
// from use thread
cap->chan->context->tcp_loop.call([&cap]() {
L.call([&cap]() {
auto temp(std::move(cap));
// on worker
try {