You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@trafficserver.apache.org by "bettydramit (JIRA)" <ji...@apache.org> on 2013/08/20 05:05:52 UTC

[jira] [Comment Edited] (TS-2008) Cache control with multiple suffixes

    [ https://issues.apache.org/jira/browse/TS-2008?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13744637#comment-13744637 ] 

bettydramit edited comment on TS-2008 at 8/20/13 3:04 AM:
----------------------------------------------------------

[~jamespeach]
Thank you for your help.
TextMod::~TextMod() call free() on text.data().So, I used free() instead of ats_free().
I forgot strtok_r is safer.Thanks for your reminding.

                
      was (Author: bettydreamit):
    [~jamespeach]
Thank you for your help.
I once wanted to copy the value before calling strtok on it once.Then I think if the value is no longer in use.I'll save some memory when I calling strtok on the origin value.
TextMod::~TextMod() call free() on text.data().So, I used free()  instead of ats_free().
I forgot strtok_r is safer.Thanks for your reminding.


                  
> Cache control with multiple suffixes
> ------------------------------------
>
>                 Key: TS-2008
>                 URL: https://issues.apache.org/jira/browse/TS-2008
>             Project: Traffic Server
>          Issue Type: New Feature
>          Components: Cache, HTTP
>    Affects Versions: 3.3.4
>            Reporter: bettydramit
>            Assignee: James Peach
>             Fix For: 3.5.1
>
>         Attachments: ts-2008-v3.patch
>
>
> if you want to control on ver many suffix in cache.config: jpeg js ... you need to specify:
> dest_domain=www.test.com suffix=jpeg ttl-in-cache=1m
> dest_domain=www.test.com suffix=js ttl-in-cache=1m
> ...
> and we can change to :
> dest_domain=www.test.com suffix=jpeg,js,css,html ttl-in-cache=1m
> by this patch:
> {code}
> diff -Nur ts-3.3.1/proxy/ControlMatcher.cc ts-3.3.1-new/proxy/ControlMatcher.cc
> --- ts-3.3.1/proxy/ControlMatcher.cc    2013-03-10 03:44:28.000000000 +0800
> +++ ts-3.3.1-new/proxy/ControlMatcher.cc        2013-07-08 22:42:31.568980245 +0800
> @@ -44,7 +44,7 @@
>  #include "P_Cache.h"
>  #include "P_SplitDNS.h"
>  #include "congest/Congestion.h"
> -
> +#include <string>
>  /****************************************************************
>   *   Place all template instantiations at the bottom of the file
>   ****************************************************************/
> @@ -815,6 +815,63 @@
>    if (file_buf == NULL) {
>      return 1;
>    }
> +  /* add by reggie */
> +  if(strcmp("[CacheControl]",matcher_name) == 0){
> +       Debug("reggie-suffix","file_string is begin" );
> +       char *strbuffern = NULL;
> +       char *strfile_buf = file_buf, *tmpvalue = NULL;
> +       char *cp_line[64];
> +       int in = 0;
> +       char buffer1[128] = {0};
> +       char *outer_ptr=NULL;
> +       std::string file_string;
> +       while((strbuffern = strtok_r(strfile_buf,"\n",&outer_ptr)) != NULL){
> +               Debug("reggie-suffix","strbuffern  is %s",strbuffern);
> +               if(*strbuffern == '#'){
> +                       Debug("reggie-suffix","# is %s ",strbuffern);
> +                       strfile_buf = NULL; 
> +                       continue;
> +               }
> +               if((strchr(strbuffern,',')) != NULL){
> +                       in = 0;
> +                       while((cp_line[in]=strtok(strbuffern," "))!=NULL) {
> +                               strbuffern = NULL;
> +                               in++;
> +                       }
> +                       if((strchr(cp_line[1],'=') != NULL) && (strstr(cp_line[1],"suffix"))){
> +                               if((cp_line[in] = strtok(cp_line[1],"=")) != NULL)
> +                                       tmpvalue = strtok(NULL,"=");
> +                               while((cp_line[in] = strtok(tmpvalue,",")) != NULL){
> +                                       in++;
> +                                       tmpvalue = NULL;
> +                               } 
> +                       }
> +                       for(int nk = 3; nk < in ;nk++){
> +                               //nbuf_len = strlen(cp_line[0]) + strlen(cp_line[2]) +strlen(cp_line[nk]) + 9;
> +                               //snprintf(buffer1,nbuf_len,"%s suffix=%s %s\n",cp_line[0],cp_line[nk],cp_line[2]);
> +                               sprintf(buffer1,"%s suffix=%s %s\n",cp_line[0],cp_line[nk],cp_line[2]);
> +                               file_string.append(buffer1);
> +                       }
> +               }
> +               else{
> +                       file_string.append(strbuffern);
> +                       file_string += "\n";
> +               }
> +               strfile_buf = NULL;
> +       }
> +      //file_string.erase(file_string.end()-1);
> +       Debug("reggie_suffix","file_string is %s ",file_string.c_str());
> +       ats_free(file_buf);
> +       file_buf = (char*) ats_malloc(file_string.size()+1);
> +       if(strcpy(file_buf,file_string.c_str()) == NULL){
> +               ats_free(file_buf);
> +               return 2;
> +       }
> +       ret = BuildTableFromString(file_buf);
> +       ats_free(file_buf);
> +       return ret;
> +  }
> +         /*end by reggie */
>  
>    ret = BuildTableFromString(file_buf);
>    ats_free(file_buf);
> {code}

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators
For more information on JIRA, see: http://www.atlassian.com/software/jira