[asterisk-commits] mmichelson: branch mmichelson/taskprocessor_memleak r378202 - in /team/mmiche...

SVN commits to the Asterisk project asterisk-commits at lists.digium.com
Mon Dec 24 12:24:20 CST 2012


Author: mmichelson
Date: Mon Dec 24 12:24:15 2012
New Revision: 378202

URL: http://svnview.digium.com/svn/asterisk?view=rev&rev=378202
Log:
Progress towards converting taskprocessor usage.

This gets

chan_iax2.c
event.c
pbx.c

This also backports ao2_cleanup to 1.8 so that
a function pointer in order to unreference an
ao2 object can be done.


Modified:
    team/mmichelson/taskprocessor_memleak/channels/chan_iax2.c
    team/mmichelson/taskprocessor_memleak/include/asterisk/astobj2.h
    team/mmichelson/taskprocessor_memleak/main/astobj2.c
    team/mmichelson/taskprocessor_memleak/main/event.c
    team/mmichelson/taskprocessor_memleak/main/pbx.c

Modified: team/mmichelson/taskprocessor_memleak/channels/chan_iax2.c
URL: http://svnview.digium.com/svn/asterisk/team/mmichelson/taskprocessor_memleak/channels/chan_iax2.c?view=diff&rev=378202&r1=378201&r2=378202
==============================================================================
--- team/mmichelson/taskprocessor_memleak/channels/chan_iax2.c (original)
+++ team/mmichelson/taskprocessor_memleak/channels/chan_iax2.c Mon Dec 24 12:24:15 2012
@@ -4285,7 +4285,7 @@
 {
 	fr->sentyet = 0;
 
-	return ast_taskprocessor_push(transmit_processor, transmit_frame, fr);
+	return ast_taskprocessor_push(transmit_processor, transmit_frame, NULL, fr);
 }
 
 static int iax2_digit_begin(struct ast_channel *c, char digit)

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=378202&r1=378201&r2=378202
==============================================================================
--- team/mmichelson/taskprocessor_memleak/include/asterisk/astobj2.h (original)
+++ team/mmichelson/taskprocessor_memleak/include/asterisk/astobj2.h Mon Dec 24 12:24:15 2012
@@ -1122,4 +1122,16 @@
 /* extra functions */
 void ao2_bt(void);	/* backtrace */
 
+/*! gcc __attribute__(cleanup()) functions
+ * \note they must be able to handle NULL parameters because most of the
+ * allocation/find functions can fail and we don't want to try to tear
+ * 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
+
 #endif /* _ASTERISK_ASTOBJ2_H */

Modified: team/mmichelson/taskprocessor_memleak/main/astobj2.c
URL: http://svnview.digium.com/svn/asterisk/team/mmichelson/taskprocessor_memleak/main/astobj2.c?view=diff&rev=378202&r1=378201&r2=378202
==============================================================================
--- team/mmichelson/taskprocessor_memleak/main/astobj2.c (original)
+++ team/mmichelson/taskprocessor_memleak/main/astobj2.c Mon Dec 24 12:24:15 2012
@@ -235,6 +235,20 @@
 int __ao2_ref(void *user_data, const int delta)
 {
 	return internal_ao2_ref(user_data, delta);
+}
+
+void __ao2_cleanup_debug(void *obj, const char *file, int line, const char *function)
+{
+	if (obj) {
+		__ao2_ref_debug(obj, -1, "ao2_cleanup", file, line, function);
+	}
+}
+
+void __ao2_cleanup(void *obj)
+{
+	if (obj) {
+		ao2_ref(obj, -1);
+	}
 }
 
 static int internal_ao2_ref(void *user_data, const int delta)

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=378202&r1=378201&r2=378202
==============================================================================
--- team/mmichelson/taskprocessor_memleak/main/event.c (original)
+++ team/mmichelson/taskprocessor_memleak/main/event.c Mon Dec 24 12:24:15 2012
@@ -1504,8 +1504,6 @@
 		AST_RWDLLIST_UNLOCK(&ast_event_subs[event_types[i]]);
 	}
 
-	ao2_ref(event_ref, -1);
-
 	return 0;
 }
 
@@ -1537,7 +1535,7 @@
 
 	event_ref->event = event;
 
-	res = ast_taskprocessor_push(event_dispatcher, handle_event, event_ref);
+	res = ast_taskprocessor_push(event_dispatcher, handle_event, ao2_cleanup, event_ref);
 	if (res) {
 		event_ref->event = NULL;
 		ao2_ref(event_ref, -1);

Modified: team/mmichelson/taskprocessor_memleak/main/pbx.c
URL: http://svnview.digium.com/svn/asterisk/team/mmichelson/taskprocessor_memleak/main/pbx.c?view=diff&rev=378202&r1=378201&r2=378202
==============================================================================
--- team/mmichelson/taskprocessor_memleak/main/pbx.c (original)
+++ team/mmichelson/taskprocessor_memleak/main/pbx.c Mon Dec 24 12:24:15 2012
@@ -4649,7 +4649,6 @@
 
 	hint_app = ast_str_create(1024);
 	if (!hint_app) {
-		ast_free(sc);
 		return -1;
 	}
 
@@ -4727,7 +4726,6 @@
 	ast_mutex_unlock(&context_merge_lock);
 
 	ast_free(hint_app);
-	ast_free(sc);
 	return 0;
 }
 
@@ -10496,7 +10494,7 @@
 	if (!(sc = ast_calloc(1, sizeof(*sc) + strlen(device) + 1)))
 		return;
 	strcpy(sc->dev, device);
-	if (ast_taskprocessor_push(device_state_tps, handle_statechange, sc) < 0) {
+	if (ast_taskprocessor_push(device_state_tps, handle_statechange, ast_free_ptr, sc) < 0) {
 		ast_free(sc);
 	}
 }




More information about the asterisk-commits mailing list