[Freeswitch-svn] [commit] r13052 - in freeswitch/trunk/src: . include mod/applications/mod_skel

FreeSWITCH SVN mrene at freeswitch.org
Wed Apr 15 19:26:33 PDT 2009


Author: mrene
Date: Wed Apr 15 21:26:32 2009
New Revision: 13052

Log:
xml_config: Fix issue where default NULL strings were ignored on reload

Modified:
   freeswitch/trunk/src/include/switch_xml_config.h
   freeswitch/trunk/src/mod/applications/mod_skel/mod_skel.c
   freeswitch/trunk/src/switch_xml_config.c

Modified: freeswitch/trunk/src/include/switch_xml_config.h
==============================================================================
--- freeswitch/trunk/src/include/switch_xml_config.h	(original)
+++ freeswitch/trunk/src/include/switch_xml_config.h	Wed Apr 15 21:26:32 2009
@@ -100,8 +100,8 @@
 
 #define SWITCH_CONFIG_ITEM(_key, _type, _flags, _ptr, _defaultvalue, _data, _syntax, _helptext)	{ _key, _type, _flags, _ptr, _defaultvalue, _data, NULL, _syntax, _helptext }
 #define SWITCH_CONFIG_ITEM_STRING_STRDUP(_key, _flags, _ptr, _defaultvalue, _syntax, _helptext)	{ _key, SWITCH_CONFIG_STRING, _flags, _ptr, _defaultvalue, &switch_config_string_strdup, NULL, _helptext}
-#define SWITCH_CONFIG_ITEM_CALLBACK(_key, _type, _flags, _ptr, _defaultvalue, _data, _functiondata, _syntax, _helptext)	{ _key, _type, _flags, _ptr, _defaultvalue, _functiondata, _data, _helptext}
-#define SWITCH_CONFIG_ITEM_END() { NULL, SWITCH_CONFIG_LAST, 0, NULL ,NULL, NULL, NULL, NULL, NULL }
+#define SWITCH_CONFIG_ITEM_CALLBACK(_key, _type, _flags, _ptr, _defaultvalue, _data, _functiondata, _syntax, _helptext)	{ _key, _type, _flags, _ptr, _defaultvalue, _functiondata, _data, _syntax, _helptext }
+#define SWITCH_CONFIG_ITEM_END() { NULL, SWITCH_CONFIG_LAST, 0, NULL, NULL, NULL, NULL, NULL, NULL }
 
 /*! 
  * \brief Gets the int representation of an enum

Modified: freeswitch/trunk/src/mod/applications/mod_skel/mod_skel.c
==============================================================================
--- freeswitch/trunk/src/mod/applications/mod_skel/mod_skel.c	(original)
+++ freeswitch/trunk/src/mod/applications/mod_skel/mod_skel.c	Wed Apr 15 21:26:32 2009
@@ -89,7 +89,7 @@
 		"greedy|generous|evil", "Specifies the codec negotiation scheme to be used."),
 	SWITCH_CONFIG_ITEM_CALLBACK("sip-trace", SWITCH_CONFIG_BOOL, CONFIG_RELOADABLE, &globals.sip_trace,  (void*)SWITCH_FALSE,  config_callback_siptrace, NULL ,
 		"yes|no", "If enabled, print out sip messages on the console."),
-	SWITCH_CONFIG_ITEM("integer", SWITCH_CONFIG_INT, CONFIG_RELOADABLE | CONFIG_REQUIRED, &globals.integer, (void*)100, &config_opt_integer,
+	SWITCH_CONFIG_ITEM("integer", SWITCH_CONFIG_INT, CONFIG_RELOADABLE, &globals.integer, (void*)100, &config_opt_integer,
 		NULL, NULL),
 	SWITCH_CONFIG_ITEM_END()
 };
@@ -108,8 +108,8 @@
 
 SWITCH_STANDARD_API(skel_function)
 {
-	stream->write_function(stream, "+OK Reloading\n");
 	do_config(SWITCH_TRUE);
+	
 	return SWITCH_STATUS_SUCCESS;
 }
 

Modified: freeswitch/trunk/src/switch_xml_config.c
==============================================================================
--- freeswitch/trunk/src/switch_xml_config.c	(original)
+++ freeswitch/trunk/src/switch_xml_config.c	Wed Apr 15 21:26:32 2009
@@ -232,27 +232,49 @@
 						newstring = (char*)item->defaultvalue;
 					}
 
-					
-					if (newstring) {
-						if (string_options->length > 0) {
-							/* We have a preallocated buffer */
-							char *dest = (char*)item->ptr;
+					if (string_options->length > 0) {
+						/* We have a preallocated buffer */
+						char *dest = (char*)item->ptr;
 						
+						if (newstring) {
 							if (strncasecmp(dest, newstring, string_options->length)) {
 								switch_copy_string(dest, newstring, string_options->length);
 								changed = SWITCH_TRUE;
 							}
 						} else {
-							char **dest = (char**)item->ptr;
+							if (*dest != '\0') {
+								*dest = '\0';
+								changed = SWITCH_TRUE;
+							}
+						}
+					} else if (string_options->pool) {
+						/* Pool-allocated buffer */
+						char **dest = (char**)item->ptr;
 						
-							if (!*dest || strcasecmp(*dest, newstring)) {
-								if (string_options->pool) {
-									*dest = switch_core_strdup(string_options->pool, newstring);
-								} else {
-									switch_safe_free(*dest);
-									*dest = strdup(newstring);
-								}
-								changed = SWITCH_TRUE;								
+						if (newstring) {
+							if (!*dest || strcmp(*dest, newstring)) {
+								*dest = switch_core_strdup(string_options->pool, newstring);
+							}
+						} else {
+							if (*dest) {
+								changed = SWITCH_TRUE;
+								*dest = NULL;
+							}
+						}
+					} else {
+						/* Dynamically allocated buffer */
+						char **dest = (char**)item->ptr;
+						
+						if (newstring) {
+							if (!*dest || strcmp(*dest, newstring)) {
+								switch_safe_free(*dest);
+								*dest = strdup(newstring);
+								changed = SWITCH_TRUE;						
+							}	
+						} else {
+							if (*dest) {
+								switch_safe_free(*dest);
+								changed = SWITCH_TRUE;
 							}
 						}
 					}



More information about the Freeswitch-svn mailing list