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,