You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@trafficserver.apache.org by sh...@apache.org on 2020/09/16 15:46:25 UTC

[trafficserver] branch master updated: Remove unused HttpUpdate mechanism (#7194)

This is an automated email from the ASF dual-hosted git repository.

shinrich pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/trafficserver.git


The following commit(s) were added to refs/heads/master by this push:
     new 5da4ca3  Remove unused HttpUpdate mechanism (#7194)
5da4ca3 is described below

commit 5da4ca37a6ac922d95c862c976e509d136e7b19d
Author: Susan Hinrichs <sh...@yahoo-inc.com>
AuthorDate: Wed Sep 16 10:46:09 2020 -0500

    Remove unused HttpUpdate mechanism (#7194)
---
 proxy/http/HttpDebugNames.cc      |  17 ---
 proxy/http/HttpProxyServerMain.cc |   7 --
 proxy/http/HttpUpdateSM.cc        | 222 --------------------------------------
 proxy/http/HttpUpdateSM.h         |  77 -------------
 proxy/http/HttpUpdateTester.cc    | 128 ----------------------
 proxy/http/Makefile.am            |   5 +-
 6 files changed, 1 insertion(+), 455 deletions(-)

diff --git a/proxy/http/HttpDebugNames.cc b/proxy/http/HttpDebugNames.cc
index f99e5b1..2eb03f8 100644
--- a/proxy/http/HttpDebugNames.cc
+++ b/proxy/http/HttpDebugNames.cc
@@ -27,7 +27,6 @@
 #include "HttpTunnel.h"
 #include "Transform.h"
 #include "HttpSM.h"
-#include "HttpUpdateSM.h"
 #include <ts/apidefs.h>
 #include <I_Event.h>
 
@@ -231,22 +230,6 @@ HttpDebugNames::get_event_name(int event)
     static_assert(static_cast<int>(HTTP_API_ERROR) == static_cast<int>(TS_EVENT_HTTP_ERROR));
     return "HTTP_API_ERROR/TS_EVENT_HTTP_ERROR";
 
-  ///////////////////////////////
-  //  Scheduled Update Events
-  ///////////////////////////////
-  case HTTP_SCH_UPDATE_EVENT_WRITTEN:
-    return "HTTP_SCH_UPDATE_EVENT_WRITTEN";
-  case HTTP_SCH_UPDATE_EVENT_UPDATED:
-    return "HTTP_SCH_UPDATE_EVENT_UPDATED";
-  case HTTP_SCH_UPDATE_EVENT_DELETED:
-    return "HTTP_SCH_UPDATE_EVENT_DELETED";
-  case HTTP_SCH_UPDATE_EVENT_NOT_CACHED:
-    return "HTTP_SCH_UPDATE_EVENT_NOT_CACHED";
-  case HTTP_SCH_UPDATE_EVENT_ERROR:
-    return "HTTP_SCH_UPDATE_EVENT_ERROR";
-  case HTTP_SCH_UPDATE_EVENT_NO_ACTION:
-    return "HTTP_SCH_UPDATE_EVENT_NO_ACTION";
-
   case TS_EVENT_NET_ACCEPT_FAILED:
     return "TS_EVENT_NET_ACCEPT_FAILED";
   case TS_EVENT_INTERNAL_206:
diff --git a/proxy/http/HttpProxyServerMain.cc b/proxy/http/HttpProxyServerMain.cc
index 2dbac63..2a75537 100644
--- a/proxy/http/HttpProxyServerMain.cc
+++ b/proxy/http/HttpProxyServerMain.cc
@@ -27,7 +27,6 @@
 #include "HttpSessionAccept.h"
 #include "ReverseProxy.h"
 #include "HttpSessionManager.h"
-#include "HttpUpdateSM.h"
 #ifdef USE_HTTP_DEBUG_LISTS
 #include "Http1ClientSession.h"
 #endif
@@ -360,12 +359,6 @@ start_HttpProxyServer()
     // NULL. It would be useful to be able to detect errors and spew them here though.
   }
 
-#if TS_HAS_TESTS
-  if (is_action_tag_set("http_update_test")) {
-    init_http_update_test();
-  }
-#endif
-
   // Set up stat page for http connection count
   statPagesManager.register_http("connection_count", register_ShowConnectionCount);
 
diff --git a/proxy/http/HttpUpdateSM.cc b/proxy/http/HttpUpdateSM.cc
deleted file mode 100644
index fa89ac5..0000000
--- a/proxy/http/HttpUpdateSM.cc
+++ /dev/null
@@ -1,222 +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.
- */
-
-/****************************************************************************
-
-   HttpSM_update.cc
-
-   Description:
-        An HttpSM sub class for support scheduled update functionality
-
-
-
- ****************************************************************************/
-
-#include "HttpUpdateSM.h"
-#include "HttpDebugNames.h"
-
-ClassAllocator<HttpUpdateSM> httpUpdateSMAllocator("httpUpdateSMAllocator");
-
-#define STATE_ENTER(state_name, event, vio)                                                             \
-  {                                                                                                     \
-    Debug("http", "[%" PRId64 "] [%s, %s]", sm_id, #state_name, HttpDebugNames::get_event_name(event)); \
-  }
-
-HttpUpdateSM::HttpUpdateSM() : cb_action(), cb_event(HTTP_SCH_UPDATE_EVENT_ERROR) {}
-
-void
-HttpUpdateSM::destroy()
-{
-  cleanup();
-  cb_action = nullptr;
-  httpUpdateSMAllocator.free(this);
-}
-
-Action *
-HttpUpdateSM::start_scheduled_update(Continuation *cont, HTTPHdr *request)
-{
-  // Use passed continuation's mutex for this state machine
-  this->mutex = cont->mutex;
-  SCOPED_MUTEX_LOCK(lock, this->mutex, this_ethread());
-
-  // Set up the Action
-  cb_cont   = cont;
-  cb_action = cont;
-
-  start_sub_sm();
-
-  // Make a copy of the request we being asked to do
-  t_state.hdr_info.client_request.create(HTTP_TYPE_REQUEST);
-  t_state.hdr_info.client_request.copy(request);
-
-  // Fix ME: What should these be set to since there is not a
-  //   real client
-  ats_ip4_set(&t_state.client_info.src_addr, htonl(INADDR_LOOPBACK), 0);
-  t_state.client_info.port_attribute = HttpProxyPort::TRANSPORT_DEFAULT;
-
-  t_state.req_flavor = HttpTransact::REQ_FLAVOR_SCHEDULED_UPDATE;
-
-  // We always deallocate this later so initialize it down
-  http_parser_init(&http_parser);
-
-  // We need to call state to add us to the http sm list
-  //   but since we can terminate the state machine on this
-  //   stack, do this by calling througth the main handler
-  //   so the sm will be properly terminated
-  this->default_handler = &HttpUpdateSM::state_add_to_list;
-  this->handleEvent(EVENT_NONE, nullptr);
-
-  if (cb_occured == 0) {
-    return &cb_action;
-  } else {
-    return ACTION_RESULT_DONE;
-  }
-}
-
-void
-HttpUpdateSM::handle_api_return()
-{
-  switch (t_state.api_next_action) {
-  case HttpTransact::SM_ACTION_API_SM_START:
-    call_transact_and_set_next_state(&HttpTransact::ModifyRequest);
-    return;
-  case HttpTransact::SM_ACTION_API_SEND_RESPONSE_HDR:
-    // we have further processing to do
-    //  based on what t_state.next_action is
-    break;
-  default:
-    HttpSM::handle_api_return();
-    return;
-  }
-
-  switch (t_state.next_action) {
-  case HttpTransact::SM_ACTION_TRANSFORM_READ: {
-    if (t_state.cache_info.transform_action == HttpTransact::CACHE_DO_WRITE) {
-      // Transform output cachable so initiate the transfer
-      //   to the cache
-      HttpTunnelProducer *p = setup_transfer_from_transform_to_cache_only();
-      tunnel.tunnel_run(p);
-    } else {
-      // We aren't caching the transformed response abort the
-      //  transform
-
-      Debug("http",
-            "[%" PRId64 "] [HttpUpdateSM] aborting "
-            "transform since result is not cached",
-            sm_id);
-      HttpTunnelConsumer *c = tunnel.get_consumer(transform_info.vc);
-      ink_release_assert(c != nullptr);
-
-      if (tunnel.is_tunnel_active()) {
-        default_handler = &HttpUpdateSM::tunnel_handler;
-        if (c->alive == true) {
-          // We're still streaming data to read
-          //  side of the transform so abort it
-          tunnel.handleEvent(VC_EVENT_ERROR, c->write_vio);
-        } else {
-          // The read side of the transform is done but
-          //  the tunnel is still going, presumably streaming
-          //  to the cache.  Just change the handler and
-          //  wait for the tunnel to complete
-          ink_assert(transform_info.entry->in_tunnel == false);
-        }
-      } else {
-        // tunnel is not active so caching the untransformed
-        //  copy is done - bail out
-        ink_assert(transform_info.entry->in_tunnel == false);
-        terminate_sm = true;
-      }
-    }
-    break;
-  }
-  case HttpTransact::SM_ACTION_INTERNAL_CACHE_WRITE:
-  case HttpTransact::SM_ACTION_SERVER_READ:
-  case HttpTransact::SM_ACTION_INTERNAL_CACHE_NOOP:
-  case HttpTransact::SM_ACTION_SEND_ERROR_CACHE_NOOP:
-  case HttpTransact::SM_ACTION_SERVE_FROM_CACHE: {
-    cb_event                     = HTTP_SCH_UPDATE_EVENT_NOT_CACHED;
-    t_state.squid_codes.log_code = SQUID_LOG_TCP_MISS;
-    terminate_sm                 = true;
-    return;
-  }
-
-  case HttpTransact::SM_ACTION_INTERNAL_CACHE_DELETE:
-  case HttpTransact::SM_ACTION_INTERNAL_CACHE_UPDATE_HEADERS: {
-    if (t_state.next_action == HttpTransact::SM_ACTION_INTERNAL_CACHE_DELETE) {
-      cb_event = HTTP_SCH_UPDATE_EVENT_DELETED;
-    } else {
-      cb_event = HTTP_SCH_UPDATE_EVENT_UPDATED;
-    }
-
-    perform_cache_write_action();
-    terminate_sm = true;
-    return;
-  }
-
-  default: {
-    ink_release_assert(!"Should not get here");
-  }
-  }
-}
-
-void
-HttpUpdateSM::set_next_state()
-{
-  if (t_state.cache_info.action == HttpTransact::CACHE_DO_NO_ACTION || t_state.cache_info.action == HttpTransact::CACHE_DO_SERVE) {
-    if (t_state.next_action == HttpTransact::SM_ACTION_SERVE_FROM_CACHE) {
-      cb_event                     = HTTP_SCH_UPDATE_EVENT_NO_ACTION;
-      t_state.squid_codes.log_code = SQUID_LOG_TCP_HIT;
-    } else {
-      t_state.squid_codes.log_code = SQUID_LOG_TCP_MISS;
-    }
-
-    terminate_sm = true;
-    ink_assert(tunnel.is_tunnel_active() == false);
-    return;
-  }
-
-  HttpSM::set_next_state();
-}
-
-int
-HttpUpdateSM::kill_this_async_hook(int event, void * /* data ATS_UNUSED */)
-{
-  STATE_ENTER(&HttpUpdateSM::user_cb_handler, event, data);
-
-  MUTEX_TRY_LOCK(lock, cb_action.mutex, this_ethread());
-
-  if (!lock.is_locked()) {
-    default_handler = (HttpSMHandler)&HttpUpdateSM::kill_this_async_hook;
-    eventProcessor.schedule_in(this, HRTIME_MSECONDS(10), ET_CALL);
-    return EVENT_DONE;
-  }
-
-  if (!cb_action.cancelled) {
-    Debug("http", "[%" PRId64 "] [HttpUpdateSM] calling back user with event %s", sm_id, HttpDebugNames::get_event_name(cb_event));
-    cb_cont->handleEvent(cb_event, nullptr);
-  }
-
-  cb_occured = true;
-
-  return HttpSM::kill_this_async_hook(EVENT_NONE, nullptr);
-}
diff --git a/proxy/http/HttpUpdateSM.h b/proxy/http/HttpUpdateSM.h
deleted file mode 100644
index a552589..0000000
--- a/proxy/http/HttpUpdateSM.h
+++ /dev/null
@@ -1,77 +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.
- */
-
-/****************************************************************************
-
-   HttpUpdateSM.h
-
-   Description:
-        An HttpSM sub class for support scheduled update functionality
-
-
-
- ****************************************************************************/
-
-#pragma once
-
-#include "P_EventSystem.h"
-#include "HttpSM.h"
-
-#define HTTP_SCH_UPDATE_EVENT_WRITTEN (HTTP_SCH_UPDATE_EVENTS_START + 1)
-#define HTTP_SCH_UPDATE_EVENT_UPDATED (HTTP_SCH_UPDATE_EVENTS_START + 2)
-#define HTTP_SCH_UPDATE_EVENT_DELETED (HTTP_SCH_UPDATE_EVENTS_START + 3)
-#define HTTP_SCH_UPDATE_EVENT_NOT_CACHED (HTTP_SCH_UPDATE_EVENTS_START + 4)
-#define HTTP_SCH_UPDATE_EVENT_ERROR (HTTP_SCH_UPDATE_EVENTS_START + 5)
-#define HTTP_SCH_UPDATE_EVENT_NO_ACTION (HTTP_SCH_UPDATE_EVENTS_START + 6)
-
-class HttpUpdateSM : public HttpSM
-{
-public:
-  HttpUpdateSM();
-
-  static HttpUpdateSM *allocate();
-  void destroy() override;
-
-  Action *start_scheduled_update(Continuation *cont, HTTPHdr *req);
-
-  //  private:
-  bool cb_occured       = false;
-  Continuation *cb_cont = nullptr;
-  Action cb_action;
-  int cb_event;
-
-protected:
-  void handle_api_return() override;
-  void set_next_state() override;
-  int kill_this_async_hook(int event, void *data) override;
-};
-
-inline HttpUpdateSM *
-HttpUpdateSM::allocate()
-{
-  extern ClassAllocator<HttpUpdateSM> httpUpdateSMAllocator;
-  return httpUpdateSMAllocator.alloc();
-}
-
-// Regression/Testing Routing
-void init_http_update_test();
diff --git a/proxy/http/HttpUpdateTester.cc b/proxy/http/HttpUpdateTester.cc
deleted file mode 100644
index 3841aa2..0000000
--- a/proxy/http/HttpUpdateTester.cc
+++ /dev/null
@@ -1,128 +0,0 @@
-/** @file
-
-        Tests http scheduled functionality by requesting URLs out of a file
-
-  @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 "HttpUpdateSM.h"
-#include "HttpDebugNames.h"
-#include "tscore/Diags.h"
-#include "tscore/ink_platform.h"
-
-#define MAX_ACTIVE_REQUESTS 5
-#define MAX_TOTAL_REQUESTS 100
-
-class UpTest : public Continuation
-{
-public:
-  UpTest(FILE *f, ProxyMutex *amutex);
-  int main_handler(int event, void *data);
-
-private:
-  void make_requests();
-  int active_req;
-#ifdef GO_AWAY
-  int total_req;
-  FILE *file;
-#endif
-};
-
-UpTest::UpTest(FILE * /* f ATS_UNUSED */, ProxyMutex *amutex)
-  : Continuation(amutex),
-    active_req(0)
-#ifdef GO_AWAY
-    ,
-    total_req(0),
-    file(f)
-#endif
-{
-  SET_HANDLER(&UpTest::main_handler);
-}
-
-void
-UpTest::make_requests()
-{
-  ink_release_assert(0);
-// HDR FIX ME
-#ifdef GO_AWAY
-  while (active_req < MAX_ACTIVE_REQUESTS && file != NULL && total_req < MAX_TOTAL_REQUESTS) {
-    char url_buf[2048];
-    char req_buf[4096];
-
-    if (!fgets(url_buf, 2047, file)) {
-      Note("[Http Update Tester] url file exhausted");
-      fclose(file);
-      file = NULL;
-      return;
-    }
-    url_buf[strlen(url_buf) - 1] = '\0';
-
-    Debug("http_sch", "Firing off request for %s", url_buf);
-
-    sprintf(req_buf, "GET %s HTTP/1.0\r\nCache-Control: max-age=0\r\n\r\n", url_buf);
-    const char *req = req_buf;
-
-    HTTPHdr test_req;
-    HTTPParser http_parser;
-    http_parser_init(&http_parser);
-    test_req.create();
-
-    test_req.parse_req(&http_parser, &req, req + strlen(req), false);
-    http_parser_clear(&http_parser);
-
-    HttpUpdateSM *_sm = HttpUpdateSM::allocate();
-    _sm->init();
-    Action *a = _sm->start_scheduled_update(this, test_req);
-    (void)a;
-
-    active_req++;
-    total_req++;
-  }
-#endif
-}
-
-int
-UpTest::main_handler(int event, void * /* data ATS_UNUSED */)
-{
-  Debug("http_sch", "Received Event %s", HttpDebugNames::get_event_name(event));
-
-  if (event != EVENT_NONE && event != VC_EVENT_IMMEDIATE) {
-    active_req--;
-  }
-
-  make_requests();
-
-  return EVENT_DONE;
-}
-
-void
-init_http_update_test()
-{
-  FILE *f = fopen("urls", "r");
-
-  if (f == nullptr) {
-    Warning("[Http Update Tester] could not open URL file");
-    return;
-  }
-
-  UpTest *u = new UpTest(f, new_ProxyMutex());
-  fclose(f); // UpTest doesn't take ownership of f.
-  eventProcessor.schedule_imm(u);
-}
diff --git a/proxy/http/Makefile.am b/proxy/http/Makefile.am
index edc10ff..8f816d2 100644
--- a/proxy/http/Makefile.am
+++ b/proxy/http/Makefile.am
@@ -74,13 +74,10 @@ libhttp_a_SOURCES = \
 	HttpTransactHeaders.h \
 	HttpTunnel.cc \
 	HttpTunnel.h \
-	HttpUpdateSM.cc \
-	HttpUpdateSM.h \
 	ForwardedConfig.cc
 
 if BUILD_TESTS
-libhttp_a_SOURCES += HttpUpdateTester.cc \
-	RegressionHttpTransact.cc
+libhttp_a_SOURCES += RegressionHttpTransact.cc
 endif
 
 check_PROGRAMS = test_proxy_http