From 6239e671a8a2a5cb89d170f1a6af4b58e1551086 Mon Sep 17 00:00:00 2001 From: tscmoo Date: Wed, 10 Feb 2021 19:55:27 +0100 Subject: [PATCH] init listener impl boilerplate with runInLoop This fixes a bug in core/listener_impl.cc where: context->listen(address) does a deferred init of the listener, but listener->addr()) 2 lines down does a runInLoop addr() on the same listener. When this is run from within the loop itself, init will be deferred but addr will be called immediately. addr will then throw an exception since listener has not been initialized. This fix simply makes init use runInLoop too, which makes it initialize immediately when run from within the loop. Note that the code usually works since new listeners are usually not created from within the loop, but I don't see why this should not be allowed --- tensorpipe/transport/listener_impl_boilerplate.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tensorpipe/transport/listener_impl_boilerplate.h b/tensorpipe/transport/listener_impl_boilerplate.h index cb0718658..f1f14aeb5 100644 --- a/tensorpipe/transport/listener_impl_boilerplate.h +++ b/tensorpipe/transport/listener_impl_boilerplate.h @@ -128,7 +128,7 @@ ListenerImplBoilerplate::ListenerImplBoilerplate( template void ListenerImplBoilerplate::init() { - context_->deferToLoop( + context_->runInLoop( [impl{this->shared_from_this()}]() { impl->initFromLoop(); }); }