Copilot commented on code in PR #13898:
URL: https://github.com/apache/trafficserver/pull/13898#discussion_r4447725572


##########
src/iocore/net/UnixNetProcessor.cc:
##########
@@ -169,7 +177,7 @@ UnixNetProcessor::stop_accept()
   SCOPED_MUTEX_LOCK(lock, naVecMutex, this_ethread());
   for (auto *na : naVec) {
     na->stop_accept();
-    delete na;
+    na->retire();

Review Comment:
   After cancellation, the dedicated accept thread can observe 
`!is_listening()` and delete the original `NetAccept` before the stopping 
thread finishes `stop_accept()` or calls `retire()`, causing a use-after-free. 
`naVecMutex` does not protect the accept thread's deletion. Add an ownership 
handoff that keeps the acceptor alive until the stopping thread finishes 
accessing it, without waiting on the dedicated thread's lifetime-held mutex.



##########
src/iocore/net/UnixNetAccept.cc:
##########
@@ -85,6 +87,81 @@ count_client_connection(UnixNetVConnection *vc, bool exempt)
   }
 }
 
+/** Whether this acceptor should leave the connections queued on its listen 
socket for now.
+ *
+ * True while the peak awake span has reached
+ * @c proxy.config.exec_thread.watchdog.timeout_refuse_ms, where the queued 
connections cost nothing at
+ * all and the threads may yet catch up and serve them. Independent of the 
accept queue shrink, which
+ * has its own threshold (see @c watchdog_apply_backlog) and lets the *kernel* 
shed while ATS keeps
+ * accepting - a bounded queue only drains as fast as we call @c accept4, 
which is what keeps inflow
+ * near the rate we can actually serve. Both can be in force at once, in which 
case the queue is
+ * bounded and nothing is draining it.
+ *
+ * A listener marked @c f_watchdog_exempt is never subject to backpressure. 
Those are the loopback
+ * companion listeners opened alongside each proxy port, so local connections 
keep getting a
+ * truthful answer about the proxy however far behind the event threads are. 
The volume of local
+ * connections is small against the inbound load that caused the saturation.
+ *
+ * @param[in] na The acceptor.
+ *
+ * @return true if the caller should not drain its listen socket on this pass.
+ */
+bool
+watchdog_should_refuse(NetAccept *na)
+{
+  return !na->opt.f_watchdog_exempt && Watchdog::accept_refuse();

Review Comment:
   Existing local-only listeners, such as `ip-in=127.0.0.1`, `ip-in=::1`, and 
Unix-domain proxy ports, get no companion and retain `f_watchdog_exempt=false`, 
so overload shrinks their backlogs and stops accepting local health checks. 
Exempt these listeners in both watchdog actions (`watchdog_should_refuse` here 
and `watchdog_apply_backlog` at line 134) without changing the flag that also 
controls per-thread listener topology.



-- 
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]

Reply via email to