You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@trafficserver.apache.org by jp...@apache.org on 2014/04/28 23:32:11 UTC
[4/6] git commit: TS-2746: rename HttpAcceptCont to HttpSessionAccept
TS-2746: rename HttpAcceptCont to HttpSessionAccept
Project: http://git-wip-us.apache.org/repos/asf/trafficserver/repo
Commit: http://git-wip-us.apache.org/repos/asf/trafficserver/commit/0d988fd9
Tree: http://git-wip-us.apache.org/repos/asf/trafficserver/tree/0d988fd9
Diff: http://git-wip-us.apache.org/repos/asf/trafficserver/diff/0d988fd9
Branch: refs/heads/master
Commit: 0d988fd9e0f9f381d5543c9a9d990978bed4966e
Parents: 523aa13
Author: James Peach <jp...@apache.org>
Authored: Thu Apr 24 13:14:36 2014 -0700
Committer: James Peach <jp...@apache.org>
Committed: Mon Apr 28 14:19:21 2014 -0700
----------------------------------------------------------------------
proxy/InkAPI.cc | 6 +-
proxy/SocksProxy.cc | 6 +-
proxy/http/HttpAcceptCont.cc | 98 ----------------
proxy/http/HttpAcceptCont.h | 198 ---------------------------------
proxy/http/HttpProxyServerMain.cc | 20 ++--
proxy/http/HttpSessionAccept.cc | 98 ++++++++++++++++
proxy/http/HttpSessionAccept.h | 198 +++++++++++++++++++++++++++++++++
proxy/http/Makefile.am | 4 +-
8 files changed, 314 insertions(+), 314 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/trafficserver/blob/0d988fd9/proxy/InkAPI.cc
----------------------------------------------------------------------
diff --git a/proxy/InkAPI.cc b/proxy/InkAPI.cc
index 501d931..44d37b9 100644
--- a/proxy/InkAPI.cc
+++ b/proxy/InkAPI.cc
@@ -51,7 +51,7 @@
#include "PluginVC.h"
#include "api/ts/experimental.h"
#include "ICP.h"
-#include "HttpAcceptCont.h"
+#include "HttpSessionAccept.h"
#include "PluginVC.h"
#include "FetchSM.h"
#include "HttpDebugNames.h"
@@ -6084,8 +6084,8 @@ TSClientProtoStackCreate(TSProtoType ptype, ...)
ink_release_assert(0);
}
-extern HttpAcceptCont *plugin_http_accept;
-extern HttpAcceptCont *plugin_http_transparent_accept;
+extern HttpSessionAccept *plugin_http_accept;
+extern HttpSessionAccept *plugin_http_transparent_accept;
TSVConn
TSHttpConnect(sockaddr const* addr)
http://git-wip-us.apache.org/repos/asf/trafficserver/blob/0d988fd9/proxy/SocksProxy.cc
----------------------------------------------------------------------
diff --git a/proxy/SocksProxy.cc b/proxy/SocksProxy.cc
index d855689..64079ca 100644
--- a/proxy/SocksProxy.cc
+++ b/proxy/SocksProxy.cc
@@ -31,7 +31,7 @@
#include "StatSystem.h"
#include "P_Net.h"
#include "I_OneWayTunnel.h"
-#include "HttpAcceptCont.h"
+#include "HttpSessionAccept.h"
enum
{
@@ -145,14 +145,14 @@ SocksProxy::mainEvent(int event, void *data)
switch (state) {
case HTTP_REQ:{
- HttpAcceptCont::Options ha_opt;
+ HttpSessionAccept::Options ha_opt;
//This is a WRITE_COMPLETE. vio->nbytes == vio->ndone is true
SOCKSPROXY_INC_STAT(socksproxy_http_connections_stat);
Debug("SocksProxy", "Handing over the HTTP request\n");
ha_opt.transport_type = clientVC->attributes;
- HttpAcceptCont http_accept(ha_opt);
+ HttpSessionAccept http_accept(ha_opt);
http_accept.mainEvent(NET_EVENT_ACCEPT, clientVC);
state = ALL_DONE;
break;
http://git-wip-us.apache.org/repos/asf/trafficserver/blob/0d988fd9/proxy/http/HttpAcceptCont.cc
----------------------------------------------------------------------
diff --git a/proxy/http/HttpAcceptCont.cc b/proxy/http/HttpAcceptCont.cc
deleted file mode 100644
index d3744e7..0000000
--- a/proxy/http/HttpAcceptCont.cc
+++ /dev/null
@@ -1,98 +0,0 @@
-/** @file
-
- A brief file description
-
- @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 "HttpAcceptCont.h"
-#include "IPAllow.h"
-#include "HttpClientSession.h"
-#include "I_Machine.h"
-#include "Error.h"
-
-int
-HttpAcceptCont::mainEvent(int event, void *data)
-{
- ink_release_assert(event == NET_EVENT_ACCEPT || event == EVENT_ERROR);
- ink_release_assert((event == NET_EVENT_ACCEPT) ? (data != 0) : (1));
-
- if (event == NET_EVENT_ACCEPT) {
- ////////////////////////////////////////////////////
- // if client address forbidden, close immediately //
- ////////////////////////////////////////////////////
- NetVConnection *netvc = static_cast<NetVConnection *>(data);
- sockaddr const* client_ip = netvc->get_remote_addr();
- uint32_t acl_method_mask = 0;
- ip_port_text_buffer ipb;
- IpAllow::scoped_config ipallow;
-
- // The backdoor port is now only bound to "localhost", so no
- // reason to check for if it's incoming from "localhost" or not.
- if (backdoor) {
- acl_method_mask = IpAllow::AllMethodMask();
- } else if (ipallow && ((acl_method_mask = ipallow->match(client_ip)) == 0)) {
- Warning("client '%s' prohibited by ip-allow policy", ats_ip_ntop(client_ip, ipb, sizeof(ipb)));
- netvc->do_io_close();
-
- return VC_EVENT_CONT;
- }
-
- netvc->attributes = transport_type;
-
- if (is_debug_tag_set("http_seq"))
- Debug("http_seq", "[HttpAcceptCont:mainEvent %p] accepted connection from %s transport type = %d", netvc, ats_ip_nptop(client_ip, ipb, sizeof(ipb)), netvc->attributes);
-
- HttpClientSession *new_session = THREAD_ALLOC_INIT(httpClientSessionAllocator, netvc->thread);
-
- // copy over session related data.
- new_session->f_outbound_transparent = f_outbound_transparent;
- new_session->f_transparent_passthrough = f_transparent_passthrough;
- new_session->outbound_ip4 = outbound_ip4;
- new_session->outbound_ip6 = outbound_ip6;
- new_session->outbound_port = outbound_port;
- new_session->host_res_style = ats_host_res_from(client_ip->sa_family, host_res_preference);
- new_session->acl_method_mask = acl_method_mask;
-
- new_session->new_connection(netvc, backdoor);
-
- return EVENT_CONT;
- }
-
- /////////////////
- // EVENT_ERROR //
- /////////////////
- if (((long) data) == -ECONNABORTED) {
- /////////////////////////////////////////////////
- // Under Solaris, when accept() fails and sets //
- // errno to EPROTO, it means the client has //
- // sent a TCP reset before the connection has //
- // been accepted by the server... Note that //
- // in 2.5.1 with the Internet Server Supplement//
- // and also in 2.6 the errno for this case has //
- // changed from EPROTO to ECONNABORTED. //
- /////////////////////////////////////////////////
-
- // FIX: add time to user_agent_hangup
- HTTP_SUM_DYN_STAT(http_ua_msecs_counts_errors_pre_accept_hangups_stat, 0);
- }
-
- MachineFatal("HTTP accept received fatal error: errno = %d", -((int)(intptr_t)data));
- return EVENT_CONT;
-}
http://git-wip-us.apache.org/repos/asf/trafficserver/blob/0d988fd9/proxy/http/HttpAcceptCont.h
----------------------------------------------------------------------
diff --git a/proxy/http/HttpAcceptCont.h b/proxy/http/HttpAcceptCont.h
deleted file mode 100644
index fcaa9e5..0000000
--- a/proxy/http/HttpAcceptCont.h
+++ /dev/null
@@ -1,198 +0,0 @@
-/** @file
-
- A brief file description
-
- @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.
- */
-
-#if !defined (_HttpAcceptCont_h_)
-#define _HttpAcceptCont_h_
-
-#include "libts.h"
-#include "P_EventSystem.h"
-#include "HttpConfig.h"
-#include "HTTP.h"
-#include "I_Net.h"
-
-namespace detail {
- /** Options for @c HttpAcceptCont.
-
- @internal This is done as a separate class for two reasons.
-
- The first is that in current usage many instances are created
- with the same options so (for the client) this is easier and
- more efficient than passing options directly to the @c
- HttpAcceptCont or calling setters.
-
- The second is that @c HttpAcceptCont is not provided with any thread
- safety because it is intended as an immutable object. Putting
- the setters here and not there makes that clearer.
-
- We don't do this directly as nested class because we want to
- inherit the data members rather than duplicate the declarations
- and initializations.
- */
- class HttpAcceptContOptions {
- private:
- typedef HttpAcceptContOptions self; ///< Self reference type.
- public:
- HttpAcceptContOptions();
-
- // Connection type (HttpProxyPort::TransportType)
- int transport_type;
- /// Set the transport type.
- self& setTransportType(int);
- /// Local address to bind for outbound connections.
- IpAddr outbound_ip4;
- /// Local address to bind for outbound connections.
- IpAddr outbound_ip6;
- /// Set the outbound IP address to @a ip.
- self& setOutboundIp(IpAddr& ip);
- /// Set the outbound IP address to @a ip.
- self& setOutboundIp(IpEndpoint* ip);
- /// Local port for outbound connection.
- uint16_t outbound_port;
- /// Set outbound port.
- self& setOutboundPort(uint16_t);
- /// Outbound transparent.
- bool f_outbound_transparent;
- /// Set outbound transparency.
- self& setOutboundTransparent(bool);
- /// Transparent pass-through.
- bool f_transparent_passthrough;
- /// Set transparent passthrough.
- self& setTransparentPassthrough(bool);
- /// Accepting backdoor connections.
- bool backdoor;
- /// Set backdoor accept.
- self& setBackdoor(bool);
- /// Host address resolution preference order.
- HostResPreferenceOrder host_res_preference;
- /// Set the host query preference.
- self& setHostResPreference(HostResPreferenceOrder const);
- };
-
- inline HttpAcceptContOptions::HttpAcceptContOptions()
- : transport_type(0)
- , outbound_port(0)
- , f_outbound_transparent(false)
- , f_transparent_passthrough(false)
- , backdoor(false)
- {
- memcpy(host_res_preference, host_res_default_preference_order, sizeof(host_res_preference));
- }
-
- inline HttpAcceptContOptions&
- HttpAcceptContOptions::setTransportType(int type) {
- transport_type = type;
- return *this;
- }
-
- inline HttpAcceptContOptions&
- HttpAcceptContOptions::setOutboundIp(IpAddr& ip) {
- if (ip.isIp4()) outbound_ip4 = ip;
- else if (ip.isIp6()) outbound_ip6 = ip;
- return *this;
- }
-
- inline HttpAcceptContOptions&
- HttpAcceptContOptions::setOutboundIp(IpEndpoint* ip) {
- if (ip->isIp4()) outbound_ip4 = *ip;
- else if (ip->isIp6()) outbound_ip6 = *ip;
- return *this;
- }
-
- inline HttpAcceptContOptions&
- HttpAcceptContOptions::setOutboundPort(uint16_t port) {
- outbound_port = port;
- return *this;
- }
-
- inline HttpAcceptContOptions&
- HttpAcceptContOptions::setOutboundTransparent(bool flag) {
- f_outbound_transparent = flag;
- return *this;
- }
-
- inline HttpAcceptContOptions&
- HttpAcceptContOptions::setTransparentPassthrough(bool flag) {
- f_transparent_passthrough = flag;
- return *this;
- }
-
- inline HttpAcceptContOptions&
- HttpAcceptContOptions::setBackdoor(bool flag) {
- backdoor = flag;
- return *this;
- }
-
- inline HttpAcceptContOptions&
- HttpAcceptContOptions::setHostResPreference(HostResPreferenceOrder const order) {
- memcpy(host_res_preference, order, sizeof(host_res_preference));
- return *this;
- }
-}
-
-/**
- The continuation mutex is NULL to allow parellel accepts in NT. No
- state is recorded by the handler and values are required to be set
- during construction via the @c Options struct and never changed. So
- a NULL mutex is safe.
-
- Most of the state is simply passed on to the @c ClientSession after
- an accept. It is done here because this is the least bad pathway
- from the top level configuration to the HTTP session.
-*/
-
-class HttpAcceptCont: public SessionAccept, private detail::HttpAcceptContOptions
-{
-private:
- typedef HttpAcceptCont self; ///< Self reference type.
-public:
- /** Construction options.
- Provide an easier to remember typedef for clients.
- */
- typedef detail::HttpAcceptContOptions Options;
-
- /** Default constructor.
- @internal We don't use a static default options object because of
- initialization order issues. It is important to pick up data that is read
- from the config file and a static is initialized long before that point.
- */
- HttpAcceptCont(Options const& opt = Options())
- : SessionAccept(NULL)
- , detail::HttpAcceptContOptions(opt) // copy these.
- {
- SET_HANDLER(&HttpAcceptCont::mainEvent);
- return;
- }
-
- ~HttpAcceptCont()
- {
- return;
- }
-
- int mainEvent(int event, void *netvc);
-
-private:
- HttpAcceptCont(const HttpAcceptCont &);
- HttpAcceptCont & operator =(const HttpAcceptCont &);
-};
-
-#endif
http://git-wip-us.apache.org/repos/asf/trafficserver/blob/0d988fd9/proxy/http/HttpProxyServerMain.cc
----------------------------------------------------------------------
diff --git a/proxy/http/HttpProxyServerMain.cc b/proxy/http/HttpProxyServerMain.cc
index 449418a..21e12ed 100644
--- a/proxy/http/HttpProxyServerMain.cc
+++ b/proxy/http/HttpProxyServerMain.cc
@@ -26,7 +26,7 @@
#include "Main.h"
#include "Error.h"
#include "HttpConfig.h"
-#include "HttpAcceptCont.h"
+#include "HttpSessionAccept.h"
#include "ReverseProxy.h"
#include "HttpSessionManager.h"
#include "HttpUpdateSM.h"
@@ -38,8 +38,8 @@
#include "P_ProtocolAcceptCont.h"
#include "P_SpdyAcceptCont.h"
-HttpAcceptCont *plugin_http_accept = NULL;
-HttpAcceptCont *plugin_http_transparent_accept = 0;
+HttpSessionAccept *plugin_http_accept = NULL;
+HttpSessionAccept *plugin_http_transparent_accept = 0;
static SLL<SSLNextProtocolAccept> ssl_plugin_acceptors;
static ink_mutex ssl_plugin_mutex = PTHREAD_MUTEX_INITIALIZER;
@@ -137,7 +137,7 @@ static void
MakeHttpProxyAcceptor(HttpProxyAcceptor& acceptor, HttpProxyPort& port, unsigned nthreads)
{
NetProcessor::AcceptOptions& net_opt = acceptor._net_opt;
- HttpAcceptCont::Options accept_opt;
+ HttpSessionAccept::Options accept_opt;
net_opt = make_net_accept_options(port, nthreads);
net_opt.create_default_NetAccept = false;
@@ -163,7 +163,7 @@ MakeHttpProxyAcceptor(HttpProxyAcceptor& acceptor, HttpProxyPort& port, unsigned
accept_opt.outbound_ip6 = HttpConfig::m_master.outbound_ip6;
}
- HttpAcceptCont *http = NEW(new HttpAcceptCont(accept_opt));
+ HttpSessionAccept *http = NEW(new HttpSessionAccept(accept_opt));
SpdyAcceptCont *spdy = NEW(new SpdyAcceptCont(http));
SSLNextProtocolAccept *ssl = NEW(new SSLNextProtocolAccept(http));
ProtocolAcceptCont *proto = NEW(new ProtocolAcceptCont());
@@ -214,14 +214,14 @@ init_HttpProxyServer(int n_accept_threads)
// port but without going through the operating system
//
if (plugin_http_accept == NULL) {
- plugin_http_accept = NEW(new HttpAcceptCont);
+ plugin_http_accept = NEW(new HttpSessionAccept);
plugin_http_accept->mutex = new_ProxyMutex();
}
// Same as plugin_http_accept except outbound transparent.
if (! plugin_http_transparent_accept) {
- HttpAcceptCont::Options ha_opt;
+ HttpSessionAccept::Options ha_opt;
ha_opt.setOutboundTransparent(true);
- plugin_http_transparent_accept = NEW(new HttpAcceptCont(ha_opt));
+ plugin_http_transparent_accept = NEW(new HttpSessionAccept(ha_opt));
plugin_http_transparent_accept->mutex = new_ProxyMutex();
}
ink_mutex_init(&ssl_plugin_mutex, "SSL Acceptor List");
@@ -279,7 +279,7 @@ void
start_HttpProxyServerBackDoor(int port, int accept_threads)
{
NetProcessor::AcceptOptions opt;
- HttpAcceptCont::Options ha_opt;
+ HttpSessionAccept::Options ha_opt;
opt.local_port = port;
opt.accept_threads = accept_threads;
@@ -288,5 +288,5 @@ start_HttpProxyServerBackDoor(int port, int accept_threads)
opt.backdoor = true;
// The backdoor only binds the loopback interface
- netProcessor.main_accept(NEW(new HttpAcceptCont(ha_opt)), NO_FD, opt);
+ netProcessor.main_accept(NEW(new HttpSessionAccept(ha_opt)), NO_FD, opt);
}
http://git-wip-us.apache.org/repos/asf/trafficserver/blob/0d988fd9/proxy/http/HttpSessionAccept.cc
----------------------------------------------------------------------
diff --git a/proxy/http/HttpSessionAccept.cc b/proxy/http/HttpSessionAccept.cc
new file mode 100644
index 0000000..ec8dc28
--- /dev/null
+++ b/proxy/http/HttpSessionAccept.cc
@@ -0,0 +1,98 @@
+/** @file
+
+ A brief file description
+
+ @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 "HttpSessionAccept.h"
+#include "IPAllow.h"
+#include "HttpClientSession.h"
+#include "I_Machine.h"
+#include "Error.h"
+
+int
+HttpSessionAccept::mainEvent(int event, void *data)
+{
+ ink_release_assert(event == NET_EVENT_ACCEPT || event == EVENT_ERROR);
+ ink_release_assert((event == NET_EVENT_ACCEPT) ? (data != 0) : (1));
+
+ if (event == NET_EVENT_ACCEPT) {
+ ////////////////////////////////////////////////////
+ // if client address forbidden, close immediately //
+ ////////////////////////////////////////////////////
+ NetVConnection *netvc = static_cast<NetVConnection *>(data);
+ sockaddr const* client_ip = netvc->get_remote_addr();
+ uint32_t acl_method_mask = 0;
+ ip_port_text_buffer ipb;
+ IpAllow::scoped_config ipallow;
+
+ // The backdoor port is now only bound to "localhost", so no
+ // reason to check for if it's incoming from "localhost" or not.
+ if (backdoor) {
+ acl_method_mask = IpAllow::AllMethodMask();
+ } else if (ipallow && ((acl_method_mask = ipallow->match(client_ip)) == 0)) {
+ Warning("client '%s' prohibited by ip-allow policy", ats_ip_ntop(client_ip, ipb, sizeof(ipb)));
+ netvc->do_io_close();
+
+ return VC_EVENT_CONT;
+ }
+
+ netvc->attributes = transport_type;
+
+ if (is_debug_tag_set("http_seq"))
+ Debug("http_seq", "[HttpSessionAccept:mainEvent %p] accepted connection from %s transport type = %d", netvc, ats_ip_nptop(client_ip, ipb, sizeof(ipb)), netvc->attributes);
+
+ HttpClientSession *new_session = THREAD_ALLOC_INIT(httpClientSessionAllocator, netvc->thread);
+
+ // copy over session related data.
+ new_session->f_outbound_transparent = f_outbound_transparent;
+ new_session->f_transparent_passthrough = f_transparent_passthrough;
+ new_session->outbound_ip4 = outbound_ip4;
+ new_session->outbound_ip6 = outbound_ip6;
+ new_session->outbound_port = outbound_port;
+ new_session->host_res_style = ats_host_res_from(client_ip->sa_family, host_res_preference);
+ new_session->acl_method_mask = acl_method_mask;
+
+ new_session->new_connection(netvc, backdoor);
+
+ return EVENT_CONT;
+ }
+
+ /////////////////
+ // EVENT_ERROR //
+ /////////////////
+ if (((long) data) == -ECONNABORTED) {
+ /////////////////////////////////////////////////
+ // Under Solaris, when accept() fails and sets //
+ // errno to EPROTO, it means the client has //
+ // sent a TCP reset before the connection has //
+ // been accepted by the server... Note that //
+ // in 2.5.1 with the Internet Server Supplement//
+ // and also in 2.6 the errno for this case has //
+ // changed from EPROTO to ECONNABORTED. //
+ /////////////////////////////////////////////////
+
+ // FIX: add time to user_agent_hangup
+ HTTP_SUM_DYN_STAT(http_ua_msecs_counts_errors_pre_accept_hangups_stat, 0);
+ }
+
+ MachineFatal("HTTP accept received fatal error: errno = %d", -((int)(intptr_t)data));
+ return EVENT_CONT;
+}
http://git-wip-us.apache.org/repos/asf/trafficserver/blob/0d988fd9/proxy/http/HttpSessionAccept.h
----------------------------------------------------------------------
diff --git a/proxy/http/HttpSessionAccept.h b/proxy/http/HttpSessionAccept.h
new file mode 100644
index 0000000..49947af
--- /dev/null
+++ b/proxy/http/HttpSessionAccept.h
@@ -0,0 +1,198 @@
+/** @file
+
+ A brief file description
+
+ @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.
+ */
+
+#if !defined (_HttpSessionAccept_h_)
+#define _HttpSessionAccept_h_
+
+#include "libts.h"
+#include "P_EventSystem.h"
+#include "HttpConfig.h"
+#include "HTTP.h"
+#include "I_Net.h"
+
+namespace detail {
+ /** Options for @c HttpSessionAccept.
+
+ @internal This is done as a separate class for two reasons.
+
+ The first is that in current usage many instances are created
+ with the same options so (for the client) this is easier and
+ more efficient than passing options directly to the @c
+ HttpSessionAccept or calling setters.
+
+ The second is that @c HttpSessionAccept is not provided with any thread
+ safety because it is intended as an immutable object. Putting
+ the setters here and not there makes that clearer.
+
+ We don't do this directly as nested class because we want to
+ inherit the data members rather than duplicate the declarations
+ and initializations.
+ */
+ class HttpSessionAcceptOptions {
+ private:
+ typedef HttpSessionAcceptOptions self; ///< Self reference type.
+ public:
+ HttpSessionAcceptOptions();
+
+ // Connection type (HttpProxyPort::TransportType)
+ int transport_type;
+ /// Set the transport type.
+ self& setTransportType(int);
+ /// Local address to bind for outbound connections.
+ IpAddr outbound_ip4;
+ /// Local address to bind for outbound connections.
+ IpAddr outbound_ip6;
+ /// Set the outbound IP address to @a ip.
+ self& setOutboundIp(IpAddr& ip);
+ /// Set the outbound IP address to @a ip.
+ self& setOutboundIp(IpEndpoint* ip);
+ /// Local port for outbound connection.
+ uint16_t outbound_port;
+ /// Set outbound port.
+ self& setOutboundPort(uint16_t);
+ /// Outbound transparent.
+ bool f_outbound_transparent;
+ /// Set outbound transparency.
+ self& setOutboundTransparent(bool);
+ /// Transparent pass-through.
+ bool f_transparent_passthrough;
+ /// Set transparent passthrough.
+ self& setTransparentPassthrough(bool);
+ /// Accepting backdoor connections.
+ bool backdoor;
+ /// Set backdoor accept.
+ self& setBackdoor(bool);
+ /// Host address resolution preference order.
+ HostResPreferenceOrder host_res_preference;
+ /// Set the host query preference.
+ self& setHostResPreference(HostResPreferenceOrder const);
+ };
+
+ inline HttpSessionAcceptOptions::HttpSessionAcceptOptions()
+ : transport_type(0)
+ , outbound_port(0)
+ , f_outbound_transparent(false)
+ , f_transparent_passthrough(false)
+ , backdoor(false)
+ {
+ memcpy(host_res_preference, host_res_default_preference_order, sizeof(host_res_preference));
+ }
+
+ inline HttpSessionAcceptOptions&
+ HttpSessionAcceptOptions::setTransportType(int type) {
+ transport_type = type;
+ return *this;
+ }
+
+ inline HttpSessionAcceptOptions&
+ HttpSessionAcceptOptions::setOutboundIp(IpAddr& ip) {
+ if (ip.isIp4()) outbound_ip4 = ip;
+ else if (ip.isIp6()) outbound_ip6 = ip;
+ return *this;
+ }
+
+ inline HttpSessionAcceptOptions&
+ HttpSessionAcceptOptions::setOutboundIp(IpEndpoint* ip) {
+ if (ip->isIp4()) outbound_ip4 = *ip;
+ else if (ip->isIp6()) outbound_ip6 = *ip;
+ return *this;
+ }
+
+ inline HttpSessionAcceptOptions&
+ HttpSessionAcceptOptions::setOutboundPort(uint16_t port) {
+ outbound_port = port;
+ return *this;
+ }
+
+ inline HttpSessionAcceptOptions&
+ HttpSessionAcceptOptions::setOutboundTransparent(bool flag) {
+ f_outbound_transparent = flag;
+ return *this;
+ }
+
+ inline HttpSessionAcceptOptions&
+ HttpSessionAcceptOptions::setTransparentPassthrough(bool flag) {
+ f_transparent_passthrough = flag;
+ return *this;
+ }
+
+ inline HttpSessionAcceptOptions&
+ HttpSessionAcceptOptions::setBackdoor(bool flag) {
+ backdoor = flag;
+ return *this;
+ }
+
+ inline HttpSessionAcceptOptions&
+ HttpSessionAcceptOptions::setHostResPreference(HostResPreferenceOrder const order) {
+ memcpy(host_res_preference, order, sizeof(host_res_preference));
+ return *this;
+ }
+}
+
+/**
+ The continuation mutex is NULL to allow parellel accepts in NT. No
+ state is recorded by the handler and values are required to be set
+ during construction via the @c Options struct and never changed. So
+ a NULL mutex is safe.
+
+ Most of the state is simply passed on to the @c ClientSession after
+ an accept. It is done here because this is the least bad pathway
+ from the top level configuration to the HTTP session.
+*/
+
+class HttpSessionAccept: public SessionAccept, private detail::HttpSessionAcceptOptions
+{
+private:
+ typedef HttpSessionAccept self; ///< Self reference type.
+public:
+ /** Construction options.
+ Provide an easier to remember typedef for clients.
+ */
+ typedef detail::HttpSessionAcceptOptions Options;
+
+ /** Default constructor.
+ @internal We don't use a static default options object because of
+ initialization order issues. It is important to pick up data that is read
+ from the config file and a static is initialized long before that point.
+ */
+ HttpSessionAccept(Options const& opt = Options())
+ : SessionAccept(NULL)
+ , detail::HttpSessionAcceptOptions(opt) // copy these.
+ {
+ SET_HANDLER(&HttpSessionAccept::mainEvent);
+ return;
+ }
+
+ ~HttpSessionAccept()
+ {
+ return;
+ }
+
+ int mainEvent(int event, void *netvc);
+
+private:
+ HttpSessionAccept(const HttpSessionAccept &);
+ HttpSessionAccept & operator =(const HttpSessionAccept &);
+};
+
+#endif
http://git-wip-us.apache.org/repos/asf/trafficserver/blob/0d988fd9/proxy/http/Makefile.am
----------------------------------------------------------------------
diff --git a/proxy/http/Makefile.am b/proxy/http/Makefile.am
index a71d287..b77604f 100644
--- a/proxy/http/Makefile.am
+++ b/proxy/http/Makefile.am
@@ -38,8 +38,8 @@ noinst_HEADERS = HttpProxyServerMain.h
noinst_LIBRARIES = libhttp.a
libhttp_a_SOURCES = \
- HttpAcceptCont.cc \
- HttpAcceptCont.h \
+ HttpSessionAccept.cc \
+ HttpSessionAccept.h \
HttpBodyFactory.cc \
HttpBodyFactory.h \
HttpCacheSM.cc \