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

Method do_blocking_accept

src/iocore/net/UnixNetAccept.cc:353–456  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

351}
352
353int
354NetAccept::do_blocking_accept(EThread *t)
355{
356 int res = 0;
357 UnixNetVConnection *vc = nullptr;
358 Connection con;
359 con.sock_type = SOCK_STREAM;
360
361 int count = 0;
362 int additional_accepts = NetHandler::get_additional_accepts();
363
364 // do-while for accepting all the connections
365 // added by YTS Team, yamsat
366 do {
367 if ((res = server.accept(&con)) < 0) {
368 int seriousness = accept_error_seriousness(res);
369 switch (seriousness) {
370 case 0:
371 // bad enough to warn about
372 check_transient_accept_error(res);
373 safe_delay(net_throttle_delay);
374 return 0;
375 case 1:
376 // not so bad but needs delay
377 safe_delay(net_throttle_delay);
378 return 0;
379 case 2:
380 // ignore
381 return 0;
382 case -1:
383 [[fallthrough]];
384 default:
385 if (!action_->cancelled) {
386 SCOPED_MUTEX_LOCK(lock, action_->mutex ? action_->mutex : t->mutex, t);
387 action_->continuation->handleEvent(EVENT_ERROR, reinterpret_cast<void *>(res));
388 Warning("accept thread received fatal error: errno = %d", errno);
389 }
390 return -1;
391 }
392 }
393 // check for throttle
394 if (check_net_throttle(ACCEPT)) {
395 check_throttle_warning(ACCEPT);
396 // close the connection as we are in throttle state
397 con.close();
398 Metrics::Counter::increment(net_rsb.connections_throttled_in);
399 continue;
400 }
401 std::shared_ptr<ConnectionTracker::Group> conn_track_group;
402 if (!handle_max_client_connections(con.addr, conn_track_group)) {
403 con.close();
404 continue;
405 }
406
407 if (TSSystemState::is_event_system_shut_down()) {
408 return -1;
409 }
410

Callers

nothing calls this directly

Calls 15

getNetProcessorMethod · 0.95
accept_error_seriousnessFunction · 0.85
safe_delayFunction · 0.85
check_net_throttleFunction · 0.85
check_throttle_warningFunction · 0.85
incrementFunction · 0.85
ink_get_hrtimeFunction · 0.85
get_NetHandlerFunction · 0.85

Tested by

no test coverage detected