[ 
https://issues.apache.org/jira/browse/TS-4972?focusedWorklogId=30666&page=com.atlassian.jira.plugin.system.issuetabpanels:worklog-tabpanel#worklog-30666
 ]

ASF GitHub Bot logged work on TS-4972:
--------------------------------------

                Author: ASF GitHub Bot
            Created on: 14/Oct/16 19:46
            Start Date: 14/Oct/16 19:46
    Worklog Time Spent: 10m 
      Work Description: Github user shinrich commented on a diff in the pull 
request:

    https://github.com/apache/trafficserver/pull/1111#discussion_r83489086
  
    --- 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;
    +}
     
    -  int url_len = 0;
    -  char *url   = TSHttpTxnEffectiveUrlStringGet(rh, &url_len);
    -  req_data->req_url.assign(url, url_len);
    +TSReturnCode
    +TSRemapInit(TSRemapInterface * /* api_info */, char * /* errbuf */, int /* 
errbuf_size */)
    +{
    +  if (global_init) {
    +    TSError("Cannot initialize %s as both global and remap plugin", 
DEBUG_TAG);
    +    return TS_ERROR;
    +  } else {
    +    TSDebug(DEBUG_TAG, "plugin is succesfully initialized for remap");
    +    return TS_SUCCESS;
    +  }
    +}
     
    -  TSfree(url);
    -  TSContDataSet(cont, req_data);
    +TSReturnCode
    +TSRemapNewInstance(int argc, char *argv[], void ** /* ih */, char * /* 
errbuf */, int /* errbuf_size */)
    +{
    +  process_args(argc, const_cast<const char **>(argv + 1));
    --- End diff --
    
    Updated new version that decrements argc appropriately.  Verified that it 
is correct in the remap case.


Issue Time Tracking
-------------------

    Worklog Id:     (was: 30666)
    Time Spent: 1h 20m  (was: 1h 10m)

> Allow collapsed_forwarding plugin to be configured global or per remap
> ----------------------------------------------------------------------
>
>                 Key: TS-4972
>                 URL: https://issues.apache.org/jira/browse/TS-4972
>             Project: Traffic Server
>          Issue Type: Improvement
>          Components: Plugins
>            Reporter: Susan Hinrichs
>            Assignee: Susan Hinrichs
>          Time Spent: 1h 20m
>  Remaining Estimate: 0h
>
> Currently collpased_forwarding plugin can only be configured on remap rules.  
> It would be convenient to just configure it globally for some environments.



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)

Reply via email to