This is an automated email from the ASF dual-hosted git repository. zwoop pushed a commit to branch 9.1.x in repository https://gitbox.apache.org/repos/asf/trafficserver.git
commit cd434e7f4e0277d134a8a1cbc38337308e7d9e87 Author: YuanYingdong <[email protected]> AuthorDate: Fri Jan 29 07:16:26 2021 +0800 Add synchronization between UDPNetProcessor::UDPBind in main Thread and initialize_thread_for_udp_net in ET_UDP Thread (#7407) Co-authored-by: yingdongyuan <[email protected]> --- proxy/http/HttpProxyServerMain.cc | 13 +++++++++++++ proxy/http/HttpProxyServerMain.h | 4 ++++ src/traffic_server/traffic_server.cc | 7 +++++++ 3 files changed, 24 insertions(+) diff --git a/proxy/http/HttpProxyServerMain.cc b/proxy/http/HttpProxyServerMain.cc index 2a75537..0da59e0 100644 --- a/proxy/http/HttpProxyServerMain.cc +++ b/proxy/http/HttpProxyServerMain.cc @@ -56,6 +56,10 @@ std::mutex proxyServerMutex; std::condition_variable proxyServerCheck; bool et_net_threads_ready = false; +std::mutex etUdpMutex; +std::condition_variable etUdpCheck; +bool et_udp_threads_ready = false; + extern int num_of_net_threads; extern int num_accept_threads; @@ -322,6 +326,15 @@ init_HttpProxyServer() lock.unlock(); proxyServerCheck.notify_one(); } + +#if TS_USE_QUIC == 1 + if (eventProcessor.has_tg_started(ET_UDP)) { + std::unique_lock<std::mutex> lock(etUdpMutex); + et_udp_threads_ready = true; + lock.unlock(); + etUdpCheck.notify_one(); + } +#endif } void diff --git a/proxy/http/HttpProxyServerMain.h b/proxy/http/HttpProxyServerMain.h index 1de9ced..46f59aa 100644 --- a/proxy/http/HttpProxyServerMain.h +++ b/proxy/http/HttpProxyServerMain.h @@ -52,3 +52,7 @@ NetProcessor::AcceptOptions make_net_accept_options(const HttpProxyPort *port, u extern std::mutex proxyServerMutex; extern std::condition_variable proxyServerCheck; extern bool et_net_threads_ready; + +extern std::mutex etUdpMutex; +extern std::condition_variable etUdpCheck; +extern bool et_udp_threads_ready; diff --git a/src/traffic_server/traffic_server.cc b/src/traffic_server/traffic_server.cc index 4f54e98..c251698 100644 --- a/src/traffic_server/traffic_server.cc +++ b/src/traffic_server/traffic_server.cc @@ -2098,6 +2098,7 @@ main(int /* argc ATS_UNUSED */, const char **argv) } if (num_of_udp_threads) { udpNet.start(num_of_udp_threads, stacksize); + eventProcessor.thread_group[ET_UDP]._afterStartCallback = init_HttpProxyServer; } // Initialize Response Body Factory @@ -2135,6 +2136,12 @@ main(int /* argc ATS_UNUSED */, const char **argv) proxyServerCheck.wait(lock, [] { return et_net_threads_ready; }); } +#if TS_USE_QUIC == 1 + if (num_of_udp_threads) { + std::unique_lock<std::mutex> lock(etUdpMutex); + etUdpCheck.wait(lock, [] { return et_udp_threads_ready; }); + } +#endif // Delay only if config value set and flag value is zero // (-1 => cache already initialized) if (delay_p && ink_atomic_cas(&delay_listen_for_cache, 0, 1)) {
