You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@trafficserver.apache.org by zw...@apache.org on 2011/05/19 21:13:23 UTC

svn commit: r1125060 - in /trafficserver/traffic/trunk/proxy: InkAPI.cc api/ts/ts.h.in http/HttpSM.cc

Author: zwoop
Date: Thu May 19 19:13:23 2011
New Revision: 1125060

URL: http://svn.apache.org/viewvc?rev=1125060&view=rev
Log:
TS-404 Add a new API, TSOSIpSet() which allows you to bypass the
origin server DNS lookup.

Review: amc

Modified:
    trafficserver/traffic/trunk/proxy/InkAPI.cc
    trafficserver/traffic/trunk/proxy/api/ts/ts.h.in
    trafficserver/traffic/trunk/proxy/http/HttpSM.cc

Modified: trafficserver/traffic/trunk/proxy/InkAPI.cc
URL: http://svn.apache.org/viewvc/trafficserver/traffic/trunk/proxy/InkAPI.cc?rev=1125060&r1=1125059&r2=1125060&view=diff
==============================================================================
--- trafficserver/traffic/trunk/proxy/InkAPI.cc (original)
+++ trafficserver/traffic/trunk/proxy/InkAPI.cc Thu May 19 19:13:23 2011
@@ -6128,6 +6128,17 @@ TSHostLookupResultIPGet(TSHostLookupResu
   return ((HostDBInfo *)lookup_result)->ip();
 }
 
+void
+TSOSIpSet(TSHttpTxn txnp, unsigned int ip)
+{
+  sdk_assert(sdk_sanity_check_txn(txnp) == TS_SUCCESS);
+  HttpSM *sm = (HttpSM *) txnp;
+  HttpTransact::State *s = &(sm->t_state);
+
+  s->dns_info.lookup_success = true;
+  s->host_db_info.ip() = ip;
+}
+
 /*
  * checks if the cache is ready
  */

Modified: trafficserver/traffic/trunk/proxy/api/ts/ts.h.in
URL: http://svn.apache.org/viewvc/trafficserver/traffic/trunk/proxy/api/ts/ts.h.in?rev=1125060&r1=1125059&r2=1125060&view=diff
==============================================================================
--- trafficserver/traffic/trunk/proxy/api/ts/ts.h.in (original)
+++ trafficserver/traffic/trunk/proxy/api/ts/ts.h.in Thu May 19 19:13:23 2011
@@ -2356,6 +2356,10 @@ extern "C"
      DNS Lookups */
   tsapi TSAction TSHostLookup(TSCont contp, char* hostname, int namelen);
   tsapi unsigned int TSHostLookupResultIPGet(TSHostLookupResult lookup_result);
+  tsapi void TSOSIpSet(TSHttpTxn txnp, unsigned int ip);
+  // TODO: Eventually, we might want something like this as well, but it requires
+  // support for building the HostDBInfo struct:
+  // tsapi void TSHostLookupResultSet(TSHttpTxn txnp, TSHostLookupResult result);
 
   /* --------------------------------------------------------------------------
      Cache VConnections */

Modified: trafficserver/traffic/trunk/proxy/http/HttpSM.cc
URL: http://svn.apache.org/viewvc/trafficserver/traffic/trunk/proxy/http/HttpSM.cc?rev=1125060&r1=1125059&r2=1125060&view=diff
==============================================================================
--- trafficserver/traffic/trunk/proxy/http/HttpSM.cc (original)
+++ trafficserver/traffic/trunk/proxy/http/HttpSM.cc Thu May 19 19:13:23 2011
@@ -404,26 +404,19 @@ HttpSM::init()
   // selection from alternates happens correctly.
   t_state.cache_info.config.cache_global_user_agent_header = t_state.http_config_param->global_user_agent_header ? true : false;
   t_state.cache_info.config.ignore_accept_mismatch = t_state.http_config_param->ignore_accept_mismatch ? true : false;
-
-  t_state.cache_info.config.ignore_accept_language_mismatch =
-    t_state.http_config_param->ignore_accept_language_mismatch ? true : false;
-
-  t_state.cache_info.config.ignore_accept_encoding_mismatch =
-    t_state.http_config_param->ignore_accept_encoding_mismatch ? true : false;
-
-  t_state.cache_info.config.ignore_accept_charset_mismatch =
-    t_state.http_config_param->ignore_accept_charset_mismatch ? true : false;
-
-
-  t_state.cache_info.config.cache_enable_default_vary_headers =
-    t_state.http_config_param->cache_enable_default_vary_headers ? true : false;
+  t_state.cache_info.config.ignore_accept_language_mismatch = t_state.http_config_param->ignore_accept_language_mismatch ? true : false;
+  t_state.cache_info.config.ignore_accept_encoding_mismatch = t_state.http_config_param->ignore_accept_encoding_mismatch ? true : false;
+  t_state.cache_info.config.ignore_accept_charset_mismatch = t_state.http_config_param->ignore_accept_charset_mismatch ? true : false;
+  t_state.cache_info.config.cache_enable_default_vary_headers = t_state.http_config_param->cache_enable_default_vary_headers ? true : false;
 
   t_state.cache_info.config.cache_vary_default_text = t_state.http_config_param->cache_vary_default_text;
   t_state.cache_info.config.cache_vary_default_images = t_state.http_config_param->cache_vary_default_images;
   t_state.cache_info.config.cache_vary_default_other = t_state.http_config_param->cache_vary_default_other;
 
   t_state.init();
-  // Added to skip dns if the document is in cache. DNS will be forced if there is a ip based based ACL in cache control or parent.config or if the doc_in_cache_skip_dns is disabled or if http caching is disabled
+  // Added to skip dns if the document is in cache. DNS will be forced if there is a ip based ACL in
+  // cache control or parent.config or if the doc_in_cache_skip_dns is disabled or if http caching is disabled
+  // TODO: This probably doesn't honor this as a per-transaction overridable config.
   t_state.force_dns = (ip_rule_in_CacheControlTable() || t_state.parent_params->ParentTable->ipMatch ||
                        !(t_state.txn_conf->doc_in_cache_skip_dns) || !(t_state.txn_conf->cache_http));
 
@@ -6413,30 +6406,30 @@ HttpSM::set_next_state()
         t_state.dns_info.lookup_success = true;
         call_transact_and_set_next_state(NULL);
         break;
+      } else if (t_state.dns_info.lookup_success) { // Already set, from a plugin presumably
+        ink_assert(t_state.host_db_info.ip());
+        Debug("dns", "[HttpTransact::HandleRequest] Skipping DNS lookup, provided by plugin");
+        call_transact_and_set_next_state(NULL);
+        break;
       }
 
       HTTP_SM_SET_DEFAULT_HANDLER(&HttpSM::state_hostdb_lookup);
 
       ink_assert(t_state.dns_info.looking_up != HttpTransact::UNDEFINED_LOOKUP);
       do_hostdb_lookup();
-
-
       break;
     }
 
   case HttpTransact::REVERSE_DNS_LOOKUP:
     {
       HTTP_SM_SET_DEFAULT_HANDLER(&HttpSM::state_hostdb_reverse_lookup);
-
       do_hostdb_reverse_lookup();
-
       break;
     }
 
   case HttpTransact::CACHE_LOOKUP:
     {
       HTTP_SM_SET_DEFAULT_HANDLER(&HttpSM::state_cache_open_read);
-
       do_cache_lookup_and_read();
       break;
     }