| 82 | } |
| 83 | |
| 84 | Action * |
| 85 | UnixNetProcessor::accept_internal(Continuation *cont, int fd, AcceptOptions const &opt) |
| 86 | { |
| 87 | static int net_accept_number = 0; |
| 88 | int accept_threads = opt.accept_threads; // might be changed. |
| 89 | int listen_per_thread = 0; |
| 90 | IpEndpoint accept_ip; // local binding address. |
| 91 | |
| 92 | NetAccept *na = createNetAccept(opt); |
| 93 | na->id = ink_atomic_increment(&net_accept_number, 1); |
| 94 | Dbg(dbg_ctl_iocore_net_accept, "creating new net accept number %d", na->id); |
| 95 | |
| 96 | // Fill in accept thread from configuration if necessary. |
| 97 | if (opt.accept_threads < 0) { |
| 98 | REC_ReadConfigInteger(accept_threads, "proxy.config.accept_threads"); |
| 99 | } |
| 100 | REC_ReadConfigInteger(listen_per_thread, "proxy.config.exec_thread.listen"); |
| 101 | if (accept_threads > 0 && listen_per_thread > 0) { |
| 102 | Fatal("Please disable accept_threads or exec_thread.listen"); |
| 103 | } |
| 104 | |
| 105 | Metrics::Gauge::increment(net_rsb.accepts_currently_open); |
| 106 | |
| 107 | // We've handled the config stuff at start up, but there are a few cases |
| 108 | // we must handle at this point. |
| 109 | if (opt.ip_family == AF_UNIX) { |
| 110 | accept_ip.assign(opt.local_path); |
| 111 | } else if (opt.localhost_only) { |
| 112 | accept_ip.setToLoopback(opt.ip_family); |
| 113 | } else if (opt.local_ip.isValid()) { |
| 114 | accept_ip.assign(opt.local_ip); |
| 115 | } else { |
| 116 | accept_ip.setToAnyAddr(opt.ip_family); |
| 117 | } |
| 118 | ink_assert(opt.ip_family == AF_UNIX || (0 < opt.local_port && opt.local_port < 65536)); |
| 119 | accept_ip.network_order_port() = htons(opt.local_port); |
| 120 | |
| 121 | na->server.sock = UnixSocket{fd}; |
| 122 | ats_ip_copy(&na->server.accept_addr, &accept_ip); |
| 123 | |
| 124 | if (opt.f_inbound_transparent) { |
| 125 | Dbg(dbg_ctl_http_tproxy, "Marked accept server %p on port %d as inbound transparent", na, opt.local_port); |
| 126 | } |
| 127 | |
| 128 | if (opt.f_proxy_protocol) { |
| 129 | Dbg(dbg_ctl_http_tproxy, "Marked accept server %p on port %d for proxy protocol", na, opt.local_port); |
| 130 | } |
| 131 | |
| 132 | SessionAccept *sa = dynamic_cast<SessionAccept *>(cont); |
| 133 | na->proxyPort = sa ? sa->proxyPort : nullptr; |
| 134 | na->snpa = dynamic_cast<SSLNextProtocolAccept *>(cont); |
| 135 | |
| 136 | na->action_ = new NetAcceptAction(); |
| 137 | *na->action_ = cont; |
| 138 | na->action_->server = &na->server; |
| 139 | |
| 140 | if (opt.frequent_accept) { // true |
| 141 | if (accept_threads > 0 && listen_per_thread == 0) { |
nothing calls this directly
no test coverage detected