diff --git a/evpp/EventLoopThread.h b/evpp/EventLoopThread.h index 47f20db50..51b87b9cc 100644 --- a/evpp/EventLoopThread.h +++ b/evpp/EventLoopThread.h @@ -44,6 +44,7 @@ class EventLoopThread : public Status { Functor pre = Functor(), Functor post = Functor()) { if (status() >= kStarting && status() < kStopped) return; + if (isRunning()) return; setStatus(kStarting); thread_ = std::make_shared(&EventLoopThread::loop_thread, this, pre, post); diff --git a/evpp/TcpServer.h b/evpp/TcpServer.h index 7c9322ecd..df6a932c6 100644 --- a/evpp/TcpServer.h +++ b/evpp/TcpServer.h @@ -298,7 +298,9 @@ class TcpServerTmpl : private EventLoopThread, public TcpServerEventLoopTmpl::start(wait_threads_started); - EventLoopThread::start(wait_threads_started); + if (!isRunning()) { + EventLoopThread::start(wait_threads_started); + } } // stop thread-safe