Review Board 1.7.16


[18801] - features reload does not clear old configuration and always include 700 on parkedcalls : patch

Review Request #1161 - Created April 6, 2011 and submitted

Jonathan Rose
18801
Reviewers
asterisk-dev
dvossel, rbyrant
Asterisk
This fix follows a completely different approach from the other one, so I created a new review request.
This fix involves wiping all the parking lots in the parkinglots ao2_container while purging their extensions so that they have to be rebuilt when features reload is performed.

I have a bit more confidence in this one.  It's much more additive and much less destructive than the last one.
Tested with multiple parking lots, changing multiple parking lots, with and without [general], with general and then without general and then with general again (which showed a need for an additional change), and mixes of all the above.

Diff revision 2 (Latest)

1 2
1 2

  1. /trunk/main/features.c: Loading...
/trunk/main/features.c
Revision 312991 New Change
[20] 4854 lines
[+20] [+] static int load_config(void)
4855
		"general",
4855
		"general",
4856
		"featuremap",
4856
		"featuremap",
4857
		"applicationmap"
4857
		"applicationmap"
4858
	};
4858
	};
4859

    
   
4859

   

    
   
4860
	/* Clear the existing parkinglots in the parkinglots container. */

    
   
4861
	{

    
   
4862
		struct ast_parkinglot *p;

    
   
4863
		struct ao2_iterator iter = ao2_iterator_init(parkinglots, 0);

    
   
4864

   

    
   
4865
		while ((p = ao2_iterator_next(&iter))) {

    
   
4866
			ao2_unlink(parkinglots, p);

    
   
4867
			ao2_ref(p,-1);

    
   
4868
		}

    
   
4869
	}

    
   
4870
	
4860
	default_parkinglot = build_parkinglot(DEFAULT_PARKINGLOT, NULL);
4871
	default_parkinglot = build_parkinglot(DEFAULT_PARKINGLOT, NULL);
4861
	if (default_parkinglot) {
4872
	if (default_parkinglot) {
4862
		ao2_lock(default_parkinglot);
4873
		ao2_lock(default_parkinglot);
4863
		ast_copy_string(default_parkinglot->parkext, DEFAULT_PARK_EXTENSION, sizeof(default_parkinglot->parkext));
4874
		ast_copy_string(default_parkinglot->parkext, DEFAULT_PARK_EXTENSION, sizeof(default_parkinglot->parkext));
4864
		default_parkinglot->parking_start = 701;
4875
		default_parkinglot->parking_start = 701;
[+20] [20] 39 lines
[+20] static int load_config(void)
4904
	cfg = ast_config_load2("features.conf", "features", config_flags);
4915
	cfg = ast_config_load2("features.conf", "features", config_flags);
4905
	if (cfg == CONFIG_STATUS_FILEMISSING || cfg == CONFIG_STATUS_FILEUNCHANGED || cfg == CONFIG_STATUS_FILEINVALID) {
4916
	if (cfg == CONFIG_STATUS_FILEMISSING || cfg == CONFIG_STATUS_FILEUNCHANGED || cfg == CONFIG_STATUS_FILEINVALID) {
4906
		ast_log(LOG_WARNING,"Could not load features.conf\n");
4917
		ast_log(LOG_WARNING,"Could not load features.conf\n");
4907
		return 0;
4918
		return 0;
4908
	}
4919
	}
4909
	for (var = ast_variable_browse(cfg, "general"); var; var = var->next) {
4920

   

    
   
4921
	if (var = ast_variable_browse(cfg, "general")) {

    
   
4922
		/* Find a general context in features.conf, we need to clear our existing default context */

    
   
4923
		/* Can't outright destroy the parking lot because it's needed in a little while. */

    
   
4924
		if ((con = ast_context_find(default_parkinglot->parking_con))) {

    
   
4925
			ast_context_destroy(con, registrar);

    
   
4926
		}

    
   
4927
		if ((con = ast_context_find(default_parkinglot->parking_con_dial))) {

    
   
4928
			ast_context_destroy(con, registrar);

    
   
4929
		}

    
   
4930
	} 

    
   
4931

   

    
   
4932
	for (; var; var = var->next) {
4910
		if (!strcasecmp(var->name, "parkext")) {
4933
		if (!strcasecmp(var->name, "parkext")) {
4911
			ast_copy_string(default_parkinglot->parkext, var->value, sizeof(default_parkinglot->parkext));
4934
			ast_copy_string(default_parkinglot->parkext, var->value, sizeof(default_parkinglot->parkext));
4912
		} else if (!strcasecmp(var->name, "context")) {
4935
		} else if (!strcasecmp(var->name, "context")) {
4913
			ast_copy_string(default_parkinglot->parking_con, var->value, sizeof(default_parkinglot->parking_con));
4936
			ast_copy_string(default_parkinglot->parking_con, var->value, sizeof(default_parkinglot->parking_con));
4914
		} else if (!strcasecmp(var->name, "parkingtime")) {
4937
		} else if (!strcasecmp(var->name, "parkingtime")) {
[+20] [20] 1168 lines
  1. /trunk/main/features.c: Loading...

https://reviewboard.asterisk.org/ runs on a server provided by Digium, Inc. and uses bandwidth donated to the open source Asterisk community by API Digital Communications in Huntsville, AL USA.
Please report problems with this site to asteriskteam@digium.com.