MCPcopy Create free account
hub / github.com/apache/trafficserver / initialize_thread_for_udp_net

Function initialize_thread_for_udp_net

src/iocore/net/UnixUDPNet.cc:235–295  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

233sockaddr_in6 G_bwGrapherLoc;
234
235void
236initialize_thread_for_udp_net(EThread *thread)
237{
238 int enable_gso, enable_gro;
239 REC_ReadConfigInteger(enable_gso, "proxy.config.udp.enable_gso");
240 REC_ReadConfigInteger(enable_gro, "proxy.config.udp.enable_gro");
241
242 UDPNetHandler *nh = get_UDPNetHandler(thread);
243
244 UDPNetHandler::Cfg cfg{static_cast<bool>(enable_gso), static_cast<bool>(enable_gro)};
245
246 G_udp_config = cfg; // keep a global copy.
247 new (reinterpret_cast<ink_dummy_for_new *>(nh)) UDPNetHandler(std::move(cfg));
248
249#ifndef SOL_UDP
250 if (G_udp_config.enable_gro) {
251 Warning("Attempted to use UDP GRO per configuration, but it is unavailable");
252 }
253#endif
254
255 new (reinterpret_cast<ink_dummy_for_new *>(get_UDPPollCont(thread))) PollCont(thread->mutex);
256 // The UDPNetHandler cannot be accessed across EThreads.
257 // Because the UDPNetHandler should be called back immediately after UDPPollCont.
258 nh->mutex = thread->mutex.get();
259 nh->thread = thread;
260
261 PollCont *upc = get_UDPPollCont(thread);
262 PollDescriptor *upd = upc->pollDescriptor;
263
264 REC_ReadConfigInteger(g_udp_pollTimeout, "proxy.config.udp.poll_timeout");
265 upc->poll_timeout = g_udp_pollTimeout;
266
267 // This variable controls how often we cleanup the cancelled packets.
268 // If it is set to 0, then cleanup never occurs.
269 REC_ReadConfigInt32(g_udp_periodicFreeCancelledPkts, "proxy.config.udp.free_cancelled_pkts_sec");
270
271 // This variable controls how many "slots" of the udp calendar queue we cleanup.
272 // If it is set to 0, then cleanup never occurs. This value makes sense
273 // only if the above variable is set.
274 REC_ReadConfigInt32(g_udp_periodicCleanupSlots, "proxy.config.udp.periodic_cleanup");
275
276 // UDP sends can fail with errno=EAGAIN. This variable determines the # of
277 // times the UDP thread retries before giving up. Set to 0 to keep trying forever.
278 REC_ReadConfigInt32(g_udp_numSendRetries, "proxy.config.udp.send_retries");
279 g_udp_numSendRetries = g_udp_numSendRetries < 0 ? 0 : g_udp_numSendRetries;
280
281 thread->set_tail_handler(nh);
282#if HAVE_EVENTFD
283#if TS_USE_LINUX_IO_URING
284 auto ep = new IOUringEventIO();
285 ep->start(upd, IOUringContext::local_context());
286#else
287 auto ep = new AsyncSignalEventIO();
288 ep->start(upd, thread->evfd, EVENTIO_READ);
289#endif
290#else
291 auto ep = new AsyncSignalEventIO();
292 ep->start(upd, thread->evpipe[0], EVENTIO_READ);

Callers

nothing calls this directly

Calls 5

get_UDPNetHandlerFunction · 0.85
get_UDPPollContFunction · 0.85
set_tail_handlerMethod · 0.80
getMethod · 0.45
startMethod · 0.45

Tested by

no test coverage detected