From f4d3c3923a9508cb9333b1969818b616209b8ec5 Mon Sep 17 00:00:00 2001 From: Xie Han <63350856@qq.com> Date: Tue, 17 Oct 2023 15:42:17 +0800 Subject: [PATCH] Switch thread if connection is NULL. --- src/factory/WFTaskFactory.inl | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/src/factory/WFTaskFactory.inl b/src/factory/WFTaskFactory.inl index 369fc17a72..04e13afc02 100644 --- a/src/factory/WFTaskFactory.inl +++ b/src/factory/WFTaskFactory.inl @@ -453,12 +453,10 @@ SubTask *WFComplexClientTask::done() } } - /* - * When target is NULL, it's very likely that we are in the caller's - * thread or DNS thread (dns failed). Running a timer will switch callback - * function to a handler thread, and this can prevent stack overflow. - */ - if (!this->target) + /* When the target or the connection is NULL, it's very likely that we are + * in the caller's thread. Running a timer will switch callback function to + * a handler thread, and this can prevent stack overflow. */ + if (!this->target || !this->CommSession::get_connection()) { auto&& cb = std::bind(&WFComplexClientTask::switch_callback, this,