github-actions[bot] commented on code in PR #65279:
URL: https://github.com/apache/doris/pull/65279#discussion_r3628027327


##########
be/src/http/ev_http_server.cpp:
##########
@@ -136,22 +134,49 @@ void EvHttpServer::start() {
             evhttp_set_newreqcb(http.get(), on_connection, this);
             evhttp_set_gencb(http.get(), on_request, this);
 
+            _evhttp_servers[i] = http;
+        }
+    }
+
+    for (int i = 0; i < _num_workers; ++i) {
+        auto status = _workers->submit_func([this, i]() {
+            std::shared_ptr<event_base> base;
+            {
+                std::lock_guard lock(_event_bases_lock);
+                base = _event_bases[i];
+            }
             event_base_dispatch(base.get());
         });
         CHECK(status.ok());
     }
 }
 
 void EvHttpServer::stop() {
+    // 1. Close server fd first to reject new connections
+    close(_server_fd);

Review Comment:
   [P1] Keep libevent listener ownership valid until teardown
   
   In Doris's pinned libevent 2.1.12.1, [`evhttp_accept_socket()` creates a 
listener with 
`LEV_OPT_CLOSE_ON_FREE`](https://github.com/apache/doris-thirdparty/blob/libevent-2.1.12.1/http.c#L3609-L3619),
 and [`evhttp_free()` later closes that listener 
fd](https://github.com/apache/doris-thirdparty/blob/libevent-2.1.12.1/listener.c#L281-L289).
 Every worker registers the same `_server_fd`, so closing it here leaves all of 
those listeners holding a stale fd number while `_workers->shutdown()` waits. 
If any finishing handler or other process thread opens a descriptor in that 
window, the number can be reused and `_evhttp_servers.clear()` will close the 
unrelated descriptor, potentially once per worker. Please give each listener 
one valid ownership unit (for example, a distinct duplicate or a non-owning 
listener), disable/remove acceptance before stopping the loops, and close each 
descriptor exactly once.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to