Merge pull request #7810 from Icinga/bugfix/spawncoroutine-copy

IoEngine#SpawnCoroutine(): don't copy parameter
This commit is contained in:
Michael Friedrich 2020-02-10 15:31:31 +01:00 committed by GitHub
commit ccd354c16c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -114,33 +114,10 @@ public:
#endif /* _WIN32 */
}
/* With dedicated strand in *Connection classes. */
template <typename Handler, typename Function>
static void SpawnCoroutine(Handler h, Function f) {
static void SpawnCoroutine(Handler& h, Function f) {
boost::asio::spawn(std::forward<Handler>(h),
[f](boost::asio::yield_context yc) {
try {
f(yc);
} catch (const boost::coroutines::detail::forced_unwind &) {
// Required for proper stack unwinding when coroutines are destroyed.
// https://github.com/boostorg/coroutine/issues/39
throw;
} catch (...) {
// Handle uncaught exceptions outside of the coroutine.
rethrowBoostExceptionPointer();
}
},
boost::coroutines::attributes(GetCoroutineStackSize()) // Set a pre-defined stack size.
);
}
/* Without strand in the IO executor's context. */
template <typename Function>
static void SpawnCoroutine(boost::asio::io_context& io, Function f) {
boost::asio::spawn(io,
boost::asio::spawn(h,
[f](boost::asio::yield_context yc) {
try {