You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@trafficserver.apache.org by "Aidan McGurn (JIRA)" <ji...@apache.org> on 2012/11/13 18:08:12 UTC

[jira] [Commented] (TS-1566) dynamic update for string vars does not work

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

Aidan McGurn commented on TS-1566:
----------------------------------

Actually this function is needed to keep the DEFAULT_xxx_str's up to date throughout the congestion update -
However it is wrong so i re-wrote to this:

static int
link_string_alloc(const char *name, RecDataT data_type, RecData data, void *cookie)
{
  REC_NOWARN_UNUSED(name);
  REC_NOWARN_UNUSED(data_type);
  
  RecString _ss = (RecString) data.rec_string;       
  RecString _new_value = 0;                          
                                                     
  int len = -1;                                      
  if (_ss) {                                         
    len = strlen(_ss);                               
    _new_value = (RecString)ats_malloc(len + 1);     
    memcpy(_new_value, _ss, len + 1);                
  }                                                  
                                                     
  //set new string for DEFAULT_xxx_str tp point to   
  RecString _temp2 = *((RecString *)cookie);         
  *((RecString *)cookie) = _new_value;               
  //free previous string DEFAULT_xxx_str points to   
  ats_free(_temp2);                                  

  return REC_ERR_OKAY;
}

could this be code reviewed and patched for general release if ok?

rgds,
/aidan


                
> dynamic update for string vars does not work
> --------------------------------------------
>
>                 Key: TS-1566
>                 URL: https://issues.apache.org/jira/browse/TS-1566
>             Project: Traffic Server
>          Issue Type: Bug
>          Components: Configuration
>    Affects Versions: 3.2.0
>            Reporter: Aidan McGurn
>            Priority: Critical
>
> i noticed that when i try to do a dynamic update of the scheme in congestion control it doesn't appear to work:
> registerd callback: CongestionControlDefaultSchemeChanged
> this function gets called back correctly when the var:
> CONFIG proxy.config.http.congestion_control.default.congestion_scheme STRING per_host
> is updated and 'traffic_line -x' is called..
> however the var returned via r->data (record data) or DEFAULT_congestion_scheme_str has not been updated unlike for its integer config counterparts -
> Th r->data has been overwritten with rubbish - in fact tracing it back i see 
> P_RecCore.i calls
>       for (cur_callback = r->config_meta.update_cb_list; cur_callback; cur_callback = cur_callback->next) {
>           (*(cur_callback->update_cb)) (r->name, r->data_type, r->data, cur_callback->update_cookie);
> this then calls before the callback function (r->data is correct at this point) a function called 'link_string_alloc' which has been registered via this function for all strings in general: 
>  CC_EstablishStaticConfigStringAlloc(DEFAULT_congestion_scheme_str, "proxy.config.http.congestion_control.default.congestion_scheme");
> The link_string_alloc overwrites the string with the passed in cookie var which has rubbish - this function looks completely wrong -
> i have commented it out updated string in r->data doesn't get overwritten and so is passed through ok - 
> ***could anyone explain what link_string alloc is actually needed for and does removing this lead to a memory leak?

--
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