[asterisk-commits] mmichelson: branch group/CCSS r228265 - in /team/group/CCSS: include/asterisk...

SVN commits to the Asterisk project asterisk-commits at lists.digium.com
Thu Nov 5 17:56:24 CST 2009


Author: mmichelson
Date: Thu Nov  5 17:56:17 2009
New Revision: 228265

URL: http://svnview.digium.com/svn/asterisk?view=rev&rev=228265
Log:
Fix frame handling code.

The short version was that it was messed up and had a memory leak.
Now the frame-handling code has been moved into ccss.c from channel.c

In addition I fixed a memory leak pointed out by russell based on my
misunderstanding of how frames were handled.


Modified:
    team/group/CCSS/include/asterisk/ccss.h
    team/group/CCSS/include/asterisk/channel.h
    team/group/CCSS/main/ccss.c
    team/group/CCSS/main/channel.c

Modified: team/group/CCSS/include/asterisk/ccss.h
URL: http://svnview.digium.com/svn/asterisk/team/group/CCSS/include/asterisk/ccss.h?view=diff&rev=228265&r1=228264&r2=228265
==============================================================================
--- team/group/CCSS/include/asterisk/ccss.h (original)
+++ team/group/CCSS/include/asterisk/ccss.h Thu Nov  5 17:56:17 2009
@@ -87,14 +87,22 @@
 	AST_CC_MONITOR_ALWAYS,
 };
 
-struct ast_control_cc_payload {
-	enum ast_cc_service_type service;
-	const char *monitor_type;
-	struct ast_cc_config_params *config_params;
-};
-
 /* Forward declaration. Struct is in main/ccss.c */
 struct ast_cc_config_params;
+
+/*!
+ * \since 1.6.4
+ * \brief Queue an AST_CONTROL_CC frame
+ *
+ * Since this function calls ast_queue_frame, the channel will be
+ * locked during the course of this function.
+ *
+ * \param chan The channel onto which to queue the frame
+ * \param monitor_type The type of monitor to use when CC is requested
+ * \retval 0 Success
+ * \retval -1 Error
+ */
+int ast_queue_cc_frame(struct ast_channel *chan, const char * const monitor_type, enum ast_cc_service_type service);
 
 /*!
  * \brief Allocate and initialize an ast_cc_config_params structure

Modified: team/group/CCSS/include/asterisk/channel.h
URL: http://svnview.digium.com/svn/asterisk/team/group/CCSS/include/asterisk/channel.h?view=diff&rev=228265&r1=228264&r2=228265
==============================================================================
--- team/group/CCSS/include/asterisk/channel.h (original)
+++ team/group/CCSS/include/asterisk/channel.h Thu Nov  5 17:56:17 2009
@@ -2784,19 +2784,6 @@
  */
 struct ast_cc_config_params *ast_channel_get_cc_config_params(struct ast_channel *chan);
 
-/*!
- * \since 1.6.4
- * \brief Queue an AST_CONTROL_CC frame
- *
- * Since this function calls ast_queue_frame, the channel will be
- * locked during the course of this function.
- *
- * \param chan The channel onto which to queue the frame
- * \param monitor_type The type of monitor to use when CC is requested
- * \retval 0 Success
- * \retval -1 Error
- */
-int ast_queue_cc_frame(struct ast_channel *chan, const char * const monitor_type, enum ast_cc_service_type service);
 
 /*!
  * \since 1.6.4

Modified: team/group/CCSS/main/ccss.c
URL: http://svnview.digium.com/svn/asterisk/team/group/CCSS/main/ccss.c?view=diff&rev=228265&r1=228264&r2=228265
==============================================================================
--- team/group/CCSS/main/ccss.c (original)
+++ team/group/CCSS/main/ccss.c Thu Nov  5 17:56:17 2009
@@ -1471,6 +1471,12 @@
 	return 0;
 }
 
+struct ast_control_cc_payload {
+	enum ast_cc_service_type service;
+	const char *monitor_type;
+	struct ast_cc_config_params config_params;
+};
+
 /*!
  * \brief Allocate and intitialize a device cc_tree_item
  *
@@ -1521,7 +1527,7 @@
 	cc_interface->monitor_type = cc_data->monitor_type;
 	cc_interface->monitor_class = AST_CC_DEVICE_MONITOR;
 	tree_item->interface = cc_interface;
-	ast_cc_copy_config_params(cc_interface->config_params, cc_data->config_params);
+	ast_cc_copy_config_params(cc_interface->config_params, &cc_data->config_params);
 	ast_log_dynamic_level(cc_logger_level, "Created a device cc interface for '%s' with id %d and parent %d\n", cc_interface->name, tree_item->id, tree_item->parent_id);
 	return tree_item;
 }
@@ -3055,6 +3061,27 @@
 			cc_ref(core_instance, "Ref core instance for status response callback"));
 }
 
+int ast_queue_cc_frame(struct ast_channel *chan, const char *monitor_type, enum ast_cc_service_type service)
+{
+	struct ast_frame frame = {.frametype = AST_FRAME_CONTROL, .subclass.integer = AST_CONTROL_CC };
+	struct ast_control_cc_payload payload;
+	char chan_name[AST_CHANNEL_NAME];
+
+	ast_channel_get_device_name(chan, chan_name, sizeof(chan_name));
+
+	if (ast_cc_monitor_count(chan_name, monitor_type) >= ast_get_cc_max_monitors(ast_channel_get_cc_config_params(chan))) {
+		ast_log(LOG_NOTICE, "Not queuing a CC frame for channel %s since it already has its maximum monitors allocated\n", chan_name);
+		return 0;
+	}
+
+	payload.monitor_type = monitor_type;
+	payload.service = service;
+	ast_cc_copy_config_params(&payload.config_params, ast_channel_get_cc_config_params(chan));
+	frame.data.ptr = &payload;
+	frame.datalen = sizeof(payload);
+	return ast_queue_frame(chan, &frame);
+}
+
 static char *ccreq_app = "CallCompletionRequest";
 
 static int ccreq_exec(struct ast_channel *chan, const char *data)

Modified: team/group/CCSS/main/channel.c
URL: http://svnview.digium.com/svn/asterisk/team/group/CCSS/main/channel.c?view=diff&rev=228265&r1=228264&r2=228265
==============================================================================
--- team/group/CCSS/main/channel.c (original)
+++ team/group/CCSS/main/channel.c Thu Nov  5 17:56:17 2009
@@ -7472,37 +7472,6 @@
 	return cc_datastore->data;
 }
 
-int ast_queue_cc_frame(struct ast_channel *chan, const char *monitor_type, enum ast_cc_service_type service)
-{
-	struct ast_frame frame = {.frametype = AST_FRAME_CONTROL, .subclass.integer = AST_CONTROL_CC };
-	struct ast_control_cc_payload *payload;
-	char chan_name[AST_CHANNEL_NAME];
-
-	if (!(payload = ast_calloc(1, sizeof(*payload)))) {
-		return -1;
-	}
-
-	ast_channel_get_device_name(chan, chan_name, sizeof(chan_name));
-
-	if (ast_cc_monitor_count(chan_name, monitor_type) >= ast_get_cc_max_monitors(ast_channel_get_cc_config_params(chan))) {
-		ast_log(LOG_NOTICE, "Not queuing a CC frame for channel %s since it already has its maximum monitors allocated\n", chan_name);
-		ast_free(payload);
-		return 0;
-	}
-
-	payload->monitor_type = monitor_type;
-	payload->service = service;
-	if (!(payload->config_params = ast_cc_config_params_init())) {
-		ast_free(payload);
-		return -1;
-	}
-	ast_cc_copy_config_params(payload->config_params, ast_channel_get_cc_config_params(chan));
-	frame.mallocd = AST_MALLOCD_DATA;
-	frame.data.ptr = payload;
-	frame.datalen = sizeof(*payload);
-	return ast_queue_frame(chan, &frame);
-}
-
 int ast_channel_get_device_name(struct ast_channel *chan, char *device_name, size_t name_buffer_length)
 {
 	int len = name_buffer_length;




More information about the asterisk-commits mailing list