diff --git a/iocore/net/AcceptOptions.cc b/iocore/net/AcceptOptions.cc deleted file mode 100644 index e1fc4bebaad..00000000000 --- a/iocore/net/AcceptOptions.cc +++ /dev/null @@ -1,49 +0,0 @@ -/** @file - - Asynchronous networking API - - @section license License - - Licensed to the Apache Software Foundation (ASF) under one - or more contributor license agreements. See the NOTICE file - distributed with this work for additional information - regarding copyright ownership. The ASF licenses this file - to you under the Apache License, Version 2.0 (the - "License"); you may not use this file except in compliance - with the License. You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - - Unless required by applicable law or agreed to in writing, software - distributed under the License is distributed on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - See the License for the specific language governing permissions and - limitations under the License. - - */ - -#include "AcceptOptions.h" -#include "I_Net.h" - -AcceptOptions & -AcceptOptions::reset() -{ - local_port = 0; - local_ip.invalidate(); - accept_threads = -1; - ip_family = AF_INET; - etype = ET_NET; - localhost_only = false; - frequent_accept = true; - recv_bufsize = 0; - send_bufsize = 0; - sockopt_flags = 0; - packet_mark = 0; - packet_tos = 0; - packet_notsent_lowat = 0; - tfo_queue_length = 0; - f_inbound_transparent = false; - f_mptcp = false; - f_proxy_protocol = false; - return *this; -} diff --git a/iocore/net/AcceptOptions.h b/iocore/net/AcceptOptions.h index 22f9bc960db..e539bc94191 100644 --- a/iocore/net/AcceptOptions.h +++ b/iocore/net/AcceptOptions.h @@ -25,6 +25,7 @@ #pragma once #include "tscore/ink_inet.h" + #include "I_Event.h" struct AcceptOptions { @@ -32,45 +33,42 @@ struct AcceptOptions { /// Port on which to listen. /// 0 => don't care, which is useful if the socket is already bound. - int local_port; + int local_port = 0; /// Local address to bind for accept. /// If not set -> any address. IpAddr local_ip; /// IP address family. /// @note Ignored if an explicit incoming address is set in the /// the configuration (@c local_ip). If neither is set IPv4 is used. - int ip_family; + int ip_family = AF_INET; /// Should we use accept threads? If so, how many? - int accept_threads; - /// Event type to generate on accept. - EventType etype; + int accept_threads = -1; /** If @c true, the continuation is called back with @c NET_EVENT_ACCEPT_SUCCEED or @c NET_EVENT_ACCEPT_FAILED on success and failure resp. */ - - bool localhost_only; + bool localhost_only = false; /// Are frequent accepts expected? /// Default: @c false. - bool frequent_accept; + bool frequent_accept = true; /// Socket receive buffer size. /// 0 => OS default. - int recv_bufsize; + int recv_bufsize = 0; /// Socket transmit buffer size. /// 0 => OS default. - int send_bufsize; + int send_bufsize = 0; /// defer accept for @c sockopt. /// 0 => OS default. - int defer_accept; + int defer_accept = 0; /// Socket options for @c sockopt. /// 0 => do not set options. - uint32_t sockopt_flags; - uint32_t packet_mark; - uint32_t packet_tos; - uint32_t packet_notsent_lowat; + uint32_t sockopt_flags = 0; + uint32_t packet_mark = 0; + uint32_t packet_tos = 0; + uint32_t packet_notsent_lowat = 0; - int tfo_queue_length; + int tfo_queue_length = 0; /** Transparency on client (user agent) connection. @internal This is irrelevant at a socket level (since inbound @@ -79,20 +77,14 @@ struct AcceptOptions { whether the inbound (client / user agent) connection is transparent. */ - bool f_inbound_transparent; + bool f_inbound_transparent = false; /** MPTCP enabled on listener. @internal For logging and metrics purposes to know whether the listener enabled MPTCP or not. */ - bool f_mptcp; + bool f_mptcp = false; /// Proxy Protocol enabled - bool f_proxy_protocol; - - /// Default constructor. - /// Instance is constructed with default values. - AcceptOptions() { this->reset(); } - /// Reset all values to defaults. - self &reset(); + bool f_proxy_protocol = false; }; diff --git a/iocore/net/CMakeLists.txt b/iocore/net/CMakeLists.txt index 4a4426ee0ed..2897d6b7e50 100644 --- a/iocore/net/CMakeLists.txt +++ b/iocore/net/CMakeLists.txt @@ -17,7 +17,6 @@ add_library(inknet STATIC - AcceptOptions.cc ALPNSupport.cc AsyncSignalEventIO.cc BIO_fastopen.cc diff --git a/iocore/net/Connection.cc b/iocore/net/Connection.cc index 2e0c75ef01f..671e155f2f2 100644 --- a/iocore/net/Connection.cc +++ b/iocore/net/Connection.cc @@ -145,7 +145,7 @@ Server::setup_fd_for_listen(bool non_blocking, const NetProcessor::AcceptOptions ink_assert(fd != NO_FD); - if (opt.etype == ET_NET && opt.defer_accept > 0) { + if (opt.defer_accept > 0) { http_accept_filter = true; add_http_filter(fd); } diff --git a/iocore/net/Makefile.am b/iocore/net/Makefile.am index e8a7394d8b3..2cb1c640a99 100644 --- a/iocore/net/Makefile.am +++ b/iocore/net/Makefile.am @@ -140,7 +140,6 @@ test_libinknet_LDADD += \ endif libinknet_a_SOURCES = \ - AcceptOptions.cc \ AcceptOptions.h \ ALPNSupport.cc \ AsyncSignalEventIO.cc \ diff --git a/iocore/net/UnixNetAccept.cc b/iocore/net/UnixNetAccept.cc index e3394ed6822..dac10910981 100644 --- a/iocore/net/UnixNetAccept.cc +++ b/iocore/net/UnixNetAccept.cc @@ -103,7 +103,7 @@ net_accept(NetAccept *na, void *ep, bool blockable) EThread *t; NetHandler *h; - if (e->ethread->is_event_type(na->opt.etype)) { + if (e->ethread->is_event_type(ET_NET)) { t = e->ethread; h = get_NetHandler(t); // Assign NetHandler->mutex to NetVC @@ -115,7 +115,7 @@ net_accept(NetAccept *na, void *ep, bool blockable) vc->handleEvent(EVENT_NONE, e); } } else { - t = eventProcessor.assign_thread(na->opt.etype); + t = eventProcessor.assign_thread(ET_NET); h = get_NetHandler(t); // Assign NetHandler->mutex to NetVC vc->mutex = h->mutex; @@ -178,7 +178,7 @@ void NetAccept::init_accept(EThread *t) { if (!t) { - t = eventProcessor.assign_thread(opt.etype); + t = eventProcessor.assign_thread(ET_NET); } if (!action_->continuation->mutex) { @@ -227,7 +227,6 @@ NetAccept::init_accept_per_thread() int i, n; int listen_per_thread = 0; - ink_assert(opt.etype >= 0); REC_ReadConfigInteger(listen_per_thread, "proxy.config.exec_thread.listen"); if (listen_per_thread == 0) { @@ -238,11 +237,11 @@ NetAccept::init_accept_per_thread() } SET_HANDLER(&NetAccept::accept_per_thread); - n = eventProcessor.thread_group[opt.etype]._count; + n = eventProcessor.thread_group[ET_NET]._count; for (i = 0; i < n; i++) { NetAccept *a = (i < n - 1) ? clone() : this; - EThread *t = eventProcessor.thread_group[opt.etype]._thread[i]; + EThread *t = eventProcessor.thread_group[ET_NET]._thread[i]; a->mutex = get_NetHandler(t)->mutex; t->schedule_imm(a); } @@ -364,7 +363,7 @@ NetAccept::do_blocking_accept(EThread *t) #endif SET_CONTINUATION_HANDLER(vc, &UnixNetVConnection::acceptEvent); - EThread *localt = eventProcessor.assign_thread(opt.etype); + EThread *localt = eventProcessor.assign_thread(ET_NET); NetHandler *h = get_NetHandler(localt); // Assign NetHandler->mutex to NetVC vc->mutex = h->mutex;