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

jpeach pushed a commit to branch master
in repository https://git-dual.apache.org/repos/asf/trafficserver.git

commit de07bc2d3a6f15a3aff05bf9cda789bca85e06a1
Author: James Peach <jpe...@apache.org>
AuthorDate: Tue Oct 11 12:07:59 2016 -0700

    TS-4955: Assign the Plugin VC acceptor at allocation time.
    
    Since we always require a continuation to receive the accept event,
    just require it at allocation time, rather than requiring the caller to
    remember to call an additional function.
---
 proxy/InkAPI.cc   | 12 ++++--------
 proxy/PluginVC.cc | 23 +++++------------------
 proxy/PluginVC.h  |  7 ++++---
 3 files changed, 13 insertions(+), 29 deletions(-)

diff --git a/proxy/InkAPI.cc b/proxy/InkAPI.cc
index 669b567..8cd0645 100644
--- a/proxy/InkAPI.cc
+++ b/proxy/InkAPI.cc
@@ -6345,12 +6345,11 @@ TSHttpConnectWithPluginId(sockaddr const *addr, char 
const *tag, int64_t id)
   sdk_assert(ats_ip_port_cast(addr));
 
   if (plugin_http_accept) {
-    PluginVCCore *new_pvc = PluginVCCore::alloc();
+    PluginVCCore *new_pvc = PluginVCCore::alloc(plugin_http_accept);
 
     new_pvc->set_active_addr(addr);
     new_pvc->set_plugin_id(id);
     new_pvc->set_plugin_tag(tag);
-    new_pvc->set_accept_cont(plugin_http_accept);
 
     PluginVC *return_vc = new_pvc->connect();
 
@@ -6385,14 +6384,13 @@ TSHttpConnectTransparent(sockaddr const *client_addr, 
sockaddr const *server_add
   sdk_assert(ats_ip_port_cast(server_addr));
 
   if (plugin_http_transparent_accept) {
-    PluginVCCore *new_pvc = PluginVCCore::alloc();
+    PluginVCCore *new_pvc = 
PluginVCCore::alloc(plugin_http_transparent_accept);
 
     // set active address expects host ordering and the above casts do not
     // swap when it is required
     new_pvc->set_active_addr(client_addr);
     new_pvc->set_passive_addr(server_addr);
     new_pvc->set_transparent(true, true);
-    new_pvc->set_accept_cont(plugin_http_transparent_accept);
 
     PluginVC *return_vc = new_pvc->connect();
 
@@ -6663,8 +6661,7 @@ TSHttpTxnServerIntercept(TSCont contp, TSHttpTxn txnp)
   sdk_assert(sdk_sanity_check_mutex(i->mutex) == TS_SUCCESS);
 
   http_sm->plugin_tunnel_type = HTTP_PLUGIN_AS_SERVER;
-  http_sm->plugin_tunnel      = PluginVCCore::alloc();
-  http_sm->plugin_tunnel->set_accept_cont(i);
+  http_sm->plugin_tunnel      = PluginVCCore::alloc(i);
 }
 
 void
@@ -6680,8 +6677,7 @@ TSHttpTxnIntercept(TSCont contp, TSHttpTxn txnp)
   sdk_assert(sdk_sanity_check_mutex(i->mutex) == TS_SUCCESS);
 
   http_sm->plugin_tunnel_type = HTTP_PLUGIN_AS_INTERCEPT;
-  http_sm->plugin_tunnel      = PluginVCCore::alloc();
-  http_sm->plugin_tunnel->set_accept_cont(i);
+  http_sm->plugin_tunnel      = PluginVCCore::alloc(i);
 }
 
 // The API below require timer values as TSHRTime parameters
diff --git a/proxy/PluginVC.cc b/proxy/PluginVC.cc
index 5658efa..77c4843 100644
--- a/proxy/PluginVC.cc
+++ b/proxy/PluginVC.cc
@@ -1001,10 +1001,11 @@ PluginVCCore::~PluginVCCore()
 }
 
 PluginVCCore *
-PluginVCCore::alloc()
+PluginVCCore::alloc(Continuation *acceptor)
 {
   PluginVCCore *pvc = new PluginVCCore;
   pvc->init();
+  pvc->connect_to = acceptor;
   return pvc;
 }
 
@@ -1065,20 +1066,10 @@ PluginVCCore::destroy()
   delete this;
 }
 
-void
-PluginVCCore::set_accept_cont(Continuation *c)
-{
-  connect_to = c;
-  // FIX ME - must return action
-}
-
 PluginVC *
 PluginVCCore::connect()
 {
-  // Make sure there is another end to connect to
-  if (connect_to == NULL) {
-    return NULL;
-  }
+  ink_release_assert(connect_to != NULL);
 
   connected = true;
   state_send_accept(EVENT_IMMEDIATE, NULL);
@@ -1089,10 +1080,7 @@ PluginVCCore::connect()
 Action *
 PluginVCCore::connect_re(Continuation *c)
 {
-  // Make sure there is another end to connect to
-  if (connect_to == NULL) {
-    return NULL;
-  }
+  ink_release_assert(connect_to != NULL);
 
   EThread *my_thread = this_ethread();
   MUTEX_TAKE_LOCK(this->mutex, my_thread);
@@ -1294,8 +1282,7 @@ PVCTestDriver::run_next_test()
 
   NetVCTest *p       = new NetVCTest;
   NetVCTest *a       = new NetVCTest;
-  PluginVCCore *core = PluginVCCore::alloc();
-  core->set_accept_cont(p);
+  PluginVCCore *core = PluginVCCore::alloc(p);
 
   p->init_test(NET_VC_TEST_PASSIVE, this, NULL, r, &netvc_tests_def[p_index], 
"PluginVC", "pvc_test_detail");
   PluginVC *a_vc = core->connect();
diff --git a/proxy/PluginVC.h b/proxy/PluginVC.h
index daa9c03..db50a68 100644
--- a/proxy/PluginVC.h
+++ b/proxy/PluginVC.h
@@ -196,9 +196,9 @@ public:
   PluginVCCore();
   ~PluginVCCore();
 
-  static PluginVCCore *alloc();
-  void init();
-  void set_accept_cont(Continuation *c);
+  // Allocate a PluginVCCore object, passing the continuation which
+  // will receive NET_EVENT_ACCEPT to accept the new session.
+  static PluginVCCore *alloc(Continuation *acceptor);
 
   int state_send_accept(int event, void *data);
   int state_send_accept_failed(int event, void *data);
@@ -241,6 +241,7 @@ public:
   PluginVC passive_vc;
 
 private:
+  void init();
   void destroy();
 
   Continuation *connect_to;

-- 
To stop receiving notification emails like this one, please contact
"commits@trafficserver.apache.org" <commits@trafficserver.apache.org>.

Reply via email to