[asterisk-commits] mmichelson: branch mmichelson/taskprocessor_memleak r378204 - in /team/mmiche...
SVN commits to the Asterisk project
asterisk-commits at lists.digium.com
Mon Dec 24 13:52:02 CST 2012
Author: mmichelson
Date: Mon Dec 24 13:51:58 2012
New Revision: 378204
URL: http://svnview.digium.com/svn/asterisk?view=rev&rev=378204
Log:
This converts ccss.c to use updated API and fixes compilation issues.
Modified:
team/mmichelson/taskprocessor_memleak/apps/app_voicemail.c
team/mmichelson/taskprocessor_memleak/include/asterisk/astobj2.h
team/mmichelson/taskprocessor_memleak/main/ccss.c
team/mmichelson/taskprocessor_memleak/main/event.c
team/mmichelson/taskprocessor_memleak/main/taskprocessor.c
Modified: team/mmichelson/taskprocessor_memleak/apps/app_voicemail.c
URL: http://svnview.digium.com/svn/asterisk/team/mmichelson/taskprocessor_memleak/apps/app_voicemail.c?view=diff&rev=378204&r1=378203&r2=378204
==============================================================================
--- team/mmichelson/taskprocessor_memleak/apps/app_voicemail.c (original)
+++ team/mmichelson/taskprocessor_memleak/apps/app_voicemail.c Mon Dec 24 13:51:58 2012
@@ -11539,8 +11539,8 @@
static void mwi_sub_task_destroy(void *data)
{
struct mwi_sub_task *mwist = data;
- ast_free(mwist->mailbox);
- ast_free(mwist->context);
+ ast_free((char *) mwist->mailbox);
+ ast_free((char *) mwist->context);
ast_free(mwist);
}
Modified: team/mmichelson/taskprocessor_memleak/include/asterisk/astobj2.h
URL: http://svnview.digium.com/svn/asterisk/team/mmichelson/taskprocessor_memleak/include/asterisk/astobj2.h?view=diff&rev=378204&r1=378203&r2=378204
==============================================================================
--- team/mmichelson/taskprocessor_memleak/include/asterisk/astobj2.h (original)
+++ team/mmichelson/taskprocessor_memleak/include/asterisk/astobj2.h Mon Dec 24 13:51:58 2012
@@ -1128,10 +1128,17 @@
* down a NULL */
void __ao2_cleanup(void *obj);
void __ao2_cleanup_debug(void *obj, const char *file, int line, const char *function);
+
#ifdef REF_DEBUG
#define ao2_cleanup(obj) __ao2_cleanup_debug((obj), __FILE__, __LINE__, __PRETTY_FUNCTION__)
#else
#define ao2_cleanup(obj) __ao2_cleanup(obj)
#endif
+static void ao2_cleanup_ptr(void *ptr) attribute_unused;
+static void ao2_cleanup_ptr(void *ptr)
+{
+ ao2_cleanup(ptr);
+}
+
#endif /* _ASTERISK_ASTOBJ2_H */
Modified: team/mmichelson/taskprocessor_memleak/main/ccss.c
URL: http://svnview.digium.com/svn/asterisk/team/mmichelson/taskprocessor_memleak/main/ccss.c?view=diff&rev=378204&r1=378203&r2=378204
==============================================================================
--- team/mmichelson/taskprocessor_memleak/main/ccss.c (original)
+++ team/mmichelson/taskprocessor_memleak/main/ccss.c Mon Dec 24 13:51:58 2012
@@ -1163,6 +1163,13 @@
enum ast_device_state new_state;
};
+static void generic_tp_cb_data_destroy(void *data)
+{
+ struct generic_tp_cb_data *gtcd = data;
+ ast_free((char *) gtcd->device_name);
+ ast_free(gtcd);
+}
+
static int generic_monitor_devstate_tp_cb(void *data)
{
struct generic_tp_cb_data *gtcd = data;
@@ -1177,16 +1184,12 @@
* time between subscribing to its device state and the time this executes.
* Not really a big deal.
*/
- ast_free((char *) gtcd->device_name);
- ast_free(gtcd);
return 0;
}
if (generic_list->current_state == new_state) {
/* The device state hasn't actually changed, so we don't really care */
cc_unref(generic_list, "Kill reference of generic list in devstate taskprocessor callback");
- ast_free((char *) gtcd->device_name);
- ast_free(gtcd);
return 0;
}
@@ -1206,8 +1209,6 @@
}
}
cc_unref(generic_list, "Kill reference of generic list in devstate taskprocessor callback");
- ast_free((char *) gtcd->device_name);
- ast_free(gtcd);
return 0;
}
@@ -1230,9 +1231,8 @@
}
gtcd->new_state = ast_event_get_ie_uint(event, AST_EVENT_IE_STATE);
- if (ast_taskprocessor_push(cc_core_taskprocessor, generic_monitor_devstate_tp_cb, gtcd)) {
- ast_free((char *)gtcd->device_name);
- ast_free(gtcd);
+ if (ast_taskprocessor_push(cc_core_taskprocessor, generic_monitor_devstate_tp_cb, generic_tp_cb_data_destroy, gtcd)) {
+ generic_tp_cb_data_destroy(gtcd);
}
}
@@ -2519,7 +2519,7 @@
}
/* We can't unsubscribe from device state events here because it causes a deadlock */
- if (ast_taskprocessor_push(cc_core_taskprocessor, generic_agent_devstate_unsubscribe,
+ if (ast_taskprocessor_push(cc_core_taskprocessor, generic_agent_devstate_unsubscribe, ao2_cleanup_ptr,
cc_ref(agent, "ref agent for device state unsubscription"))) {
cc_unref(agent, "Unref agent unsubscribing from devstate failed");
}
@@ -3021,6 +3021,13 @@
[CC_FAILED] = cc_failed,
};
+static void cc_state_change_args_destroy(void *data)
+{
+ struct cc_state_change_args *args = data;
+ cc_unref(args->core_instance, "Unref core instance since state change has completed");
+ ast_free(args);
+}
+
static int cc_do_state_change(void *datap)
{
struct cc_state_change_args *args = datap;
@@ -3044,8 +3051,6 @@
core_instance->agent->callbacks->respond(core_instance->agent,
AST_CC_AGENT_RESPONSE_FAILURE_INVALID);
}
- ast_free(args);
- cc_unref(core_instance, "Unref core instance from when it was found earlier");
return -1;
}
@@ -3054,8 +3059,6 @@
core_instance->current_state = args->state;
res = state_change_funcs[core_instance->current_state](core_instance, args, previous_state);
- ast_free(args);
- cc_unref(core_instance, "Unref since state change has completed"); /* From ao2_find */
return res;
}
@@ -3094,10 +3097,9 @@
args->core_id = core_id;
vsnprintf(args->debug, debuglen, debug, ap);
- res = ast_taskprocessor_push(cc_core_taskprocessor, cc_do_state_change, args);
+ res = ast_taskprocessor_push(cc_core_taskprocessor, cc_do_state_change, cc_state_change_args_destroy, args);
if (res) {
- cc_unref(core_instance, "Unref core instance. ast_taskprocessor_push failed");
- ast_free(args);
+ cc_state_change_args_destroy(args);
}
return res;
}
@@ -3627,6 +3629,14 @@
int core_id;
};
+static void cc_monitor_failure_data_destroy(void *data)
+{
+ struct ast_cc_monitor_failure_data *failure_data = data;
+ ast_free((char *) failure_data->device_name);
+ ast_free(failure_data->debug);
+ ast_free(failure_data);
+}
+
static int cc_monitor_failed(void *data)
{
struct ast_cc_monitor_failure_data *failure_data = data;
@@ -3639,9 +3649,6 @@
ast_log_dynamic_level(cc_logger_level,
"Core %d: Could not find core instance for device %s '%s'\n",
failure_data->core_id, failure_data->device_name, failure_data->debug);
- ast_free((char *) failure_data->device_name);
- ast_free((char *) failure_data->debug);
- ast_free(failure_data);
return -1;
}
@@ -3669,9 +3676,6 @@
AST_LIST_UNLOCK(core_instance->monitors);
cc_unref(core_instance, "Finished with core_instance in cc_monitor_failed\n");
- ast_free((char *) failure_data->device_name);
- ast_free((char *) failure_data->debug);
- ast_free(failure_data);
return 0;
}
@@ -3701,11 +3705,10 @@
failure_data->core_id = core_id;
- res = ast_taskprocessor_push(cc_core_taskprocessor, cc_monitor_failed, failure_data);
+ res = ast_taskprocessor_push(cc_core_taskprocessor, cc_monitor_failed,
+ cc_monitor_failure_data_destroy, failure_data);
if (res) {
- ast_free((char *)failure_data->device_name);
- ast_free((char *)failure_data->debug);
- ast_free(failure_data);
+ cc_monitor_failure_data_destroy(failure_data);
}
return res;
}
@@ -3729,7 +3732,7 @@
return -1;
}
- res = ast_taskprocessor_push(cc_core_taskprocessor, cc_status_request, core_instance);
+ res = ast_taskprocessor_push(cc_core_taskprocessor, cc_status_request, ao2_cleanup_ptr, core_instance);
if (res) {
cc_unref(core_instance, "Unref core instance. ast_taskprocessor_push failed");
}
@@ -3766,7 +3769,7 @@
return -1;
}
- res = ast_taskprocessor_push(cc_core_taskprocessor, cc_stop_ringing, core_instance);
+ res = ast_taskprocessor_push(cc_core_taskprocessor, cc_stop_ringing, ao2_cleanup_ptr, core_instance);
if (res) {
cc_unref(core_instance, "Unref core instance. ast_taskprocessor_push failed");
}
@@ -3794,7 +3797,7 @@
return -1;
}
- res = ast_taskprocessor_push(cc_core_taskprocessor, cc_party_b_free, core_instance);
+ res = ast_taskprocessor_push(cc_core_taskprocessor, cc_party_b_free, ao2_cleanup_ptr, core_instance);
if (res) {
cc_unref(core_instance, "Unref core instance. ast_taskprocessor_push failed");
}
@@ -3806,14 +3809,19 @@
enum ast_device_state devstate;
};
+static void cc_status_response_args_destroy(void *data)
+{
+ struct cc_state_change_args *args = data;
+ cc_unref(args->core_instance, "Unref core instance since state change has completed");
+ ast_free(args);
+}
+
static int cc_status_response(void *data)
{
struct cc_status_response_args *args = data;
struct cc_core_instance *core_instance = args->core_instance;
struct ast_cc_monitor *monitor_iter;
enum ast_device_state devstate = args->devstate;
-
- ast_free(args);
AST_LIST_LOCK(core_instance->monitors);
AST_LIST_TRAVERSE(core_instance->monitors, monitor_iter, next) {
@@ -3823,7 +3831,6 @@
}
}
AST_LIST_UNLOCK(core_instance->monitors);
- cc_unref(core_instance, "Status response finished. Unref core instance");
return 0;
}
@@ -3847,10 +3854,10 @@
args->core_instance = core_instance;
args->devstate = devstate;
- res = ast_taskprocessor_push(cc_core_taskprocessor, cc_status_response, args);
+ res = ast_taskprocessor_push(cc_core_taskprocessor, cc_status_response,
+ cc_status_response_args_destroy, args);
if (res) {
- cc_unref(core_instance, "Unref core instance. ast_taskprocessor_push failed");
- ast_free(args);
+ cc_status_response_args_destroy(args);
}
return res;
}
@@ -4188,7 +4195,6 @@
ast_cli(*cli_fd, "----------------------------------------------------------------------------\n");
ao2_t_callback(cc_core_instances, OBJ_NODATA, print_stats_cb, cli_fd, "Printing stats to CLI");
}
- ast_free(cli_fd);
return 0;
}
@@ -4218,7 +4224,7 @@
*cli_fd = a->fd;
- if (ast_taskprocessor_push(cc_core_taskprocessor, cc_cli_output_status, cli_fd)) {
+ if (ast_taskprocessor_push(cc_core_taskprocessor, cc_cli_output_status, ast_free_ptr, cli_fd)) {
ast_free(cli_fd);
return CLI_FAILURE;
}
Modified: team/mmichelson/taskprocessor_memleak/main/event.c
URL: http://svnview.digium.com/svn/asterisk/team/mmichelson/taskprocessor_memleak/main/event.c?view=diff&rev=378204&r1=378203&r2=378204
==============================================================================
--- team/mmichelson/taskprocessor_memleak/main/event.c (original)
+++ team/mmichelson/taskprocessor_memleak/main/event.c Mon Dec 24 13:51:58 2012
@@ -1535,7 +1535,7 @@
event_ref->event = event;
- res = ast_taskprocessor_push(event_dispatcher, handle_event, ao2_cleanup, event_ref);
+ res = ast_taskprocessor_push(event_dispatcher, handle_event, ao2_cleanup_ptr, event_ref);
if (res) {
event_ref->event = NULL;
ao2_ref(event_ref, -1);
Modified: team/mmichelson/taskprocessor_memleak/main/taskprocessor.c
URL: http://svnview.digium.com/svn/asterisk/team/mmichelson/taskprocessor_memleak/main/taskprocessor.c?view=diff&rev=378204&r1=378203&r2=378204
==============================================================================
--- team/mmichelson/taskprocessor_memleak/main/taskprocessor.c (original)
+++ team/mmichelson/taskprocessor_memleak/main/taskprocessor.c Mon Dec 24 13:51:58 2012
@@ -240,9 +240,8 @@
ts.tv_sec = when.tv_sec;
ts.tv_nsec = when.tv_usec * 1000;
ast_mutex_lock(&cli_ping_cond_lock);
- if (ast_taskprocessor_push(tps, tps_ping_handler, 0) < 0) {
+ if (ast_taskprocessor_push(tps, tps_ping_handler, ao2_cleanup_ptr, 0) < 0) {
ast_cli(a->fd, "\nping failed: could not push task to %s\n\n", name);
- ao2_ref(tps, -1);
return CLI_FAILURE;
}
ast_cond_timedwait(&cli_ping_cond, &cli_ping_cond_lock, &ts);
@@ -250,7 +249,6 @@
end = ast_tvnow();
delta = ast_tvsub(end, begin);
ast_cli(a->fd, "\n\t%24s ping time: %.1ld.%.6ld sec\n\n", name, (long)delta.tv_sec, (long int)delta.tv_usec);
- ao2_ref(tps, -1);
return CLI_SUCCESS;
}
@@ -511,7 +509,7 @@
ast_log(LOG_ERROR, "%s is missing!!\n", (tps) ? "task callback" : "taskprocessor");
return -1;
}
- if (!(t = tps_task_alloc(task_exe, datap))) {
+ if (!(t = tps_task_alloc(task_exe, destroy, datap))) {
ast_log(LOG_ERROR, "failed to allocate task! Can't push to '%s'\n", tps->name);
return -1;
}
More information about the asterisk-commits
mailing list