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 1

This is not the most recent revision of the diff. The latest diff is revision 2. See what's changed.

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
			if ((con = ast_context_find(p->parking_con))) {

    
   
4867
				ast_context_destroy(con, registrar);

    
   
4868
			}

    
   
4869
			if ((con = ast_context_find(p->parking_con_dial))) {

    
   
4870
				ast_context_destroy(con, registrar);

    
   
4871
			}

    
   
4872
			ao2_unlink(parkinglots, p);

    
   
4873
			parkinglot_destroy(p);

    
   
4874
		}

    
   
4875
	}

    
   
4876
	
4860
	default_parkinglot = build_parkinglot(DEFAULT_PARKINGLOT, NULL);
4877
	default_parkinglot = build_parkinglot(DEFAULT_PARKINGLOT, NULL);
4861
	if (default_parkinglot) {
4878
	if (default_parkinglot) {
4862
		ao2_lock(default_parkinglot);
4879
		ao2_lock(default_parkinglot);
4863
		ast_copy_string(default_parkinglot->parkext, DEFAULT_PARK_EXTENSION, sizeof(default_parkinglot->parkext));
4880
		ast_copy_string(default_parkinglot->parkext, DEFAULT_PARK_EXTENSION, sizeof(default_parkinglot->parkext));
4864
		default_parkinglot->parking_start = 701;
4881
		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);
4921
	cfg = ast_config_load2("features.conf", "features", config_flags);
4905
	if (cfg == CONFIG_STATUS_FILEMISSING || cfg == CONFIG_STATUS_FILEUNCHANGED || cfg == CONFIG_STATUS_FILEINVALID) {
4922
	if (cfg == CONFIG_STATUS_FILEMISSING || cfg == CONFIG_STATUS_FILEUNCHANGED || cfg == CONFIG_STATUS_FILEINVALID) {
4906
		ast_log(LOG_WARNING,"Could not load features.conf\n");
4923
		ast_log(LOG_WARNING,"Could not load features.conf\n");
4907
		return 0;
4924
		return 0;
4908
	}
4925
	}
4909
	for (var = ast_variable_browse(cfg, "general"); var; var = var->next) {
4926

   

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

    
   
4928
		/* if we find a general context in features.conf, we need to clear our existing default context */

    
   
4929
		if ((con = ast_context_find("parkedcalls"))) {

    
   
4930
			ast_context_destroy(con, NULL);

    
   
4931
		}

    
   
4932
	} 

    
   
4933

   

    
   
4934
	for (; var; var = var->next) {
4910
		if (!strcasecmp(var->name, "parkext")) {
4935
		if (!strcasecmp(var->name, "parkext")) {
4911
			ast_copy_string(default_parkinglot->parkext, var->value, sizeof(default_parkinglot->parkext));
4936
			ast_copy_string(default_parkinglot->parkext, var->value, sizeof(default_parkinglot->parkext));
4912
		} else if (!strcasecmp(var->name, "context")) {
4937
		} else if (!strcasecmp(var->name, "context")) {
4913
			ast_copy_string(default_parkinglot->parking_con, var->value, sizeof(default_parkinglot->parking_con));
4938
			ast_copy_string(default_parkinglot->parking_con, var->value, sizeof(default_parkinglot->parking_con));
4914
		} else if (!strcasecmp(var->name, "parkingtime")) {
4939
		} 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.