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

Method acceptFastEvent

src/iocore/net/UnixNetAccept.cc:498–638  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

496}
497
498int
499NetAccept::acceptFastEvent(int event, void *ep)
500{
501 Event *e = static_cast<Event *>(ep);
502 (void)event;
503 (void)e;
504 int bufsz, res = 0;
505 Connection con;
506 con.sock_type = SOCK_STREAM;
507
508 UnixNetVConnection *vc = nullptr;
509 int count = 0;
510 EThread *t = e->ethread;
511 NetHandler *h = get_NetHandler(t);
512 int additional_accepts = NetHandler::get_additional_accepts();
513
514 do {
515 socklen_t sz = sizeof(con.addr);
516 UnixSocket sock{-1};
517 if (int res{server.sock.accept4(&con.addr.sa, &sz, SOCK_NONBLOCK | SOCK_CLOEXEC)}; res >= 0) {
518 sock = UnixSocket{res};
519 }
520 con.sock = sock;
521 std::shared_ptr<ConnectionTracker::Group> conn_track_group;
522
523 if (likely(sock.is_ok())) {
524 // check for throttle
525 if (check_net_throttle(ACCEPT)) {
526 // close the connection as we are in throttle state
527 con.close();
528 Metrics::Counter::increment(net_rsb.connections_throttled_in);
529 continue;
530 }
531 if (!handle_max_client_connections(con.addr, conn_track_group)) {
532 con.close();
533 continue;
534 }
535 Dbg(dbg_ctl_iocore_net, "accepted a new socket: %d", sock.get_fd());
536 Metrics::Counter::increment(net_rsb.tcp_accept);
537 if (opt.send_bufsize > 0) {
538 if (unlikely(sock.set_sndbuf_size(opt.send_bufsize))) {
539 bufsz = ROUNDUP(opt.send_bufsize, 1024);
540 while (bufsz > 0) {
541 if (!sock.set_sndbuf_size(bufsz)) {
542 break;
543 }
544 bufsz -= 1024;
545 }
546 }
547 }
548 if (opt.recv_bufsize > 0) {
549 if (unlikely(sock.set_rcvbuf_size(opt.recv_bufsize))) {
550 bufsz = ROUNDUP(opt.recv_bufsize, 1024);
551 while (bufsz > 0) {
552 if (!sock.set_rcvbuf_size(bufsz)) {
553 break;
554 }
555 bufsz -= 1024;

Callers

nothing calls this directly

Calls 15

getNetProcessorMethod · 0.95
get_NetHandlerFunction · 0.85
check_net_throttleFunction · 0.85
incrementFunction · 0.85
ROUNDUPFunction · 0.85
accept_error_seriousnessFunction · 0.85
ink_get_hrtimeFunction · 0.85
this_ethreadFunction · 0.85
accept4Method · 0.80

Tested by

no test coverage detected