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

    https://github.com/apache/trafficserver/pull/834#discussion_r78286892
  
    --- Diff: proxy/ParentConsistentHash.cc ---
    @@ -63,21 +66,104 @@ ParentConsistentHash::getPathHash(HttpRequestData 
*hrdata, ATSHash64 *h)
     {
       const char *tmp = NULL;
       int len;
    -  URL *url = hrdata->hdr->url_get();
    +  URL *url     = hrdata->hdr->url_get();
    +  int num_dirs = 0;
    +
    +  // Use over-ride URL from HttpTransact::State's 
cache_info.parent_selection_url, if present.
    +  URL *ps_url = NULL;
    +  Debug("parent_select", "hrdata->cache_info_parent_selection_url = %p", 
hrdata->cache_info_parent_selection_url);
    +  if (hrdata->cache_info_parent_selection_url) {
    +    ps_url = *(hrdata->cache_info_parent_selection_url);
    +    Debug("parent_select", "ps_url = %p", ps_url);
    +    if (ps_url) {
    +      tmp = ps_url->string_get_ref(&len);
    +      if (tmp && len > 0) {
    +        // Print the over-ride URL
    +        Debug("parent_select", "Using Over-Ride String='%.*s'.", len, tmp);
    +        h->update(tmp, len);
    +        h->final();
    +        return h->get();
    +      }
    +    }
    +  }
     
       // Always hash on '/' because paths returned by ATS are always stripped 
of it
       h->update("/", 1);
     
       tmp = url->path_get(&len);
    -  if (tmp) {
    +
    +  if (tmp && len > 0) {
    +    // Print the Original path.
    +    Debug("parent_select", "Original Path='%.*s'.", len, tmp);
    +
    +    // Process the 'maxdirs' directive.
    +    if (max_dirs != 0) {
    +      // Determine number of directory components in the path.
    +      // NOTE: Leading '/' is gone already.
    +      for (int x = 0; x < len; x++) {
    +        if (tmp[x] == '/')
    +          num_dirs++;
    +      }
    +      // If max_dirs positive , include directory components from the left 
up to max_dirs.
    +      // If max_dirs negative , include directory components from the left 
up to num_dirs - ( abs(max_dirs) - 1 ).
    +      int limit = 0;
    +      if (max_dirs > 0)
    +        limit = max_dirs;
    +      else if (max_dirs < 0) {
    +        int md = abs(max_dirs) - 1;
    +        if (md < num_dirs)
    +          limit = num_dirs - md;
    +        else
    +          limit = 0;
    +      }
    +      if (limit > 0) {
    +        int x     = 0;
    +        int count = 0;
    +        for (; x < len; x++) {
    --- End diff --
    
    ```C
    for (int x = 0; x < len; ++x) { ... }
    ```


---
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 [email protected] or file a JIRA ticket
with INFRA.
---

Reply via email to