Github user jpeach commented on a diff in the pull request:

    https://github.com/apache/trafficserver/pull/1111#discussion_r83462452
  
    --- Diff: plugins/experimental/collapsed_forwarding/collapsed_forwarding.cc 
---
    @@ -265,49 +307,69 @@ collapsed_cont(TSCont contp, TSEvent event, void 
*edata)
       return TS_SUCCESS;
     }
     
    -TSReturnCode
    -TSRemapInit(TSRemapInterface * /* api_info */, char * /* errbuf */, int /* 
errbuf_size */)
    -{
    -  TSDebug(DEBUG_TAG, "plugin is succesfully initialized");
    -  return TS_SUCCESS;
    -}
    -
    -TSReturnCode
    -TSRemapNewInstance(int argc, char *argv[], void ** /* ih */, char * /* 
errbuf */, int /* errbuf_size */)
    +void
    +process_args(int argc, const char **argv)
     {
       // basic argv processing..
    -  for (int i = 2; i < argc; ++i) {
    +  for (int i = 1; i < argc; ++i) {
         if (strncmp(argv[i], "--delay=", 8) == 0) {
           OPEN_WRITE_FAIL_REQ_DELAY_TIMEOUT = atoi((char *)(argv[i] + 8));
         } else if (strncmp(argv[i], "--retries=", 10) == 0) {
           OPEN_WRITE_FAIL_MAX_REQ_DELAY_RETRIES = atoi((char *)(argv[i] + 10));
         }
       }
    -
    -  return TS_SUCCESS;
     }
     
    -TSRemapStatus
    -TSRemapDoRemap(void *ih, TSHttpTxn rh, TSRemapRequestInfo *rri)
    +/*
    + * Initialize globally
    + */
    +void
    +TSPluginInit(int argc, const char *argv[])
     {
    +  TSPluginRegistrationInfo info;
    +
    +  info.plugin_name   = (char *)DEBUG_TAG;
    +  info.vendor_name   = (char *)"Apache Software Foundation";
    +  info.support_email = (char *)"d...@trafficserver.apache.org";
    +
    +  if (TS_SUCCESS != TSPluginRegister(&info)) {
    +    TSError("[%s] Plugin registration failed.", DEBUG_TAG);
    +  }
    +
    +  process_args(argc, argv);
    +
       TSCont cont = TSContCreate(collapsed_cont, TSMutexCreate());
     
    -  RequestData *req_data = new RequestData();
    +  TSDebug(DEBUG_TAG, "Global Initialized");
    +  // Set up the per transaction state in the READ_REQUEST event
    +  TSHttpHookAdd(TS_HTTP_READ_REQUEST_HDR_HOOK, cont);
     
    -  req_data->txnp     = rh;
    -  req_data->wl_retry = 0;
    +  global_init = true;
    --- End diff --
    
    It seems like the only reason I can't have this as a global and a 
transaction plugin is the config is in globals. What do you think about moving 
that into an instance config for the remap case?


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastruct...@apache.org or file a JIRA ticket
with INFRA.
---

Reply via email to