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
@@ -563,10 +563,12 @@ std::shared_ptr<Subscription> MonitorBuilder::exec()
chan->pending.push_back(op);
chan->createOperations();
ret.reset(op.get(), [op](Subscription*) mutable {
auto loop(op->chan->context->tcp_loop);
ret.reset(op.get(), [op, loop](Subscription*) mutable {
// on user thread
auto temp(std::move(op));
temp->chan->context->tcp_loop.call([&temp]() {
auto L(std::move(loop));
L.call([&temp]() {
// on worker
try {
temp->_cancel(true);