This is an automated email from the ASF dual-hosted git repository.

yiguolei pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/doris.git


The following commit(s) were added to refs/heads/master by this push:
     new 838fdc1354 [Bug](httpserver) Fix bug that http server should not be 
stoped in destructor if it not running
838fdc1354 is described below

commit 838fdc1354c39875b53f67680c04088e9b2a392e
Author: weizuo93 <wei...@apache.org>
AuthorDate: Wed Aug 3 19:44:46 2022 +0800

    [Bug](httpserver) Fix bug that http server should not be stoped in 
destructor if it not running
    
    Co-authored-by: weizuo <wei...@xiaomi.com>
---
 be/src/http/ev_http_server.cpp | 6 +++++-
 be/src/http/ev_http_server.h   | 1 +
 2 files changed, 6 insertions(+), 1 deletion(-)

diff --git a/be/src/http/ev_http_server.cpp b/be/src/http/ev_http_server.cpp
index bf612ca830..96a8709ace 100644
--- a/be/src/http/ev_http_server.cpp
+++ b/be/src/http/ev_http_server.cpp
@@ -83,10 +83,13 @@ EvHttpServer::EvHttpServer(const std::string& host, int 
port, int num_workers)
 }
 
 EvHttpServer::~EvHttpServer() {
-    stop();
+    if (_started) {
+        stop();
+    }
 }
 
 void EvHttpServer::start() {
+    _started = true;
     // bind to
     auto s = _bind();
     CHECK(s.ok()) << s.to_string();
@@ -137,6 +140,7 @@ void EvHttpServer::stop() {
     }
     _workers->shutdown();
     close(_server_fd);
+    _started = false;
 }
 
 void EvHttpServer::join() {}
diff --git a/be/src/http/ev_http_server.h b/be/src/http/ev_http_server.h
index f5ca94760a..7263b2f3ef 100644
--- a/be/src/http/ev_http_server.h
+++ b/be/src/http/ev_http_server.h
@@ -78,6 +78,7 @@ private:
     PathTrie<HttpHandler*> _delete_handlers;
     PathTrie<HttpHandler*> _head_handlers;
     PathTrie<HttpHandler*> _options_handlers;
+    bool _started = false;
 };
 
 } // namespace doris


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscr...@doris.apache.org
For additional commands, e-mail: commits-h...@doris.apache.org

Reply via email to