[asterisk-commits] coreyfarrell: branch 13 r431917 - in /branches/13: ./ channels/ include/aster...
SVN commits to the Asterisk project
asterisk-commits at lists.digium.com
Wed Feb 18 20:01:37 CST 2015
Author: coreyfarrell
Date: Wed Feb 18 20:01:34 2015
New Revision: 431917
URL: http://svnview.digium.com/svn/asterisk?view=rev&rev=431917
Log:
Create work around for scheduler leaks during shutdown.
* Added ast_sched_clean_by_callback for cleanup of scheduled events
that have not yet fired.
* Run all pending peercnt_remove_cb and replace_callno events in chan_iax2.
Cleanup of replace_callno events is only run 11, since it no longer
releases any references or allocations in 13+.
ASTERISK-24451 #close
Reported by: Corey Farrell
Review: https://reviewboard.asterisk.org/r/4425/
........
Merged revisions 431916 from http://svn.asterisk.org/svn/asterisk/branches/11
Modified:
branches/13/ (props changed)
branches/13/channels/chan_iax2.c
branches/13/include/asterisk/sched.h
branches/13/main/sched.c
Propchange: branches/13/
------------------------------------------------------------------------------
--- branch-11-merged (original)
+++ branch-11-merged Wed Feb 18 20:01:34 2015
@@ -1,1 +1,1 @@
-/branches/11:1-429517,429539,429632,429783,429804,429825,429867,429893,429982,430009,430126,430415,430487,430506,430564,430589,430795,430798,430920,430993,430996-430997,431049,431135,431187,431218,431384,431423,431617,431662,431669,431673,431788
+/branches/11:1-429517,429539,429632,429783,429804,429825,429867,429893,429982,430009,430126,430415,430487,430506,430564,430589,430795,430798,430920,430993,430996-430997,431049,431135,431187,431218,431384,431423,431617,431662,431669,431673,431788,431916
Modified: branches/13/channels/chan_iax2.c
URL: http://svnview.digium.com/svn/asterisk/branches/13/channels/chan_iax2.c?view=diff&rev=431917&r1=431916&r2=431917
==============================================================================
--- branches/13/channels/chan_iax2.c (original)
+++ branches/13/channels/chan_iax2.c Wed Feb 18 20:01:34 2015
@@ -14692,7 +14692,6 @@
ao2_ref(users, -1);
ao2_ref(iax_peercallno_pvts, -1);
ao2_ref(iax_transfercallno_pvts, -1);
- ao2_ref(peercnts, -1);
ao2_ref(callno_limits, -1);
ao2_ref(calltoken_ignores, -1);
if (timer) {
@@ -14700,8 +14699,11 @@
timer = NULL;
}
transmit_processor = ast_taskprocessor_unreference(transmit_processor);
+
+ ast_sched_clean_by_callback(sched, peercnt_remove_cb, peercnt_remove_cb);
ast_sched_context_destroy(sched);
sched = NULL;
+ ao2_ref(peercnts, -1);
con = ast_context_find(regcontext);
if (con)
Modified: branches/13/include/asterisk/sched.h
URL: http://svnview.digium.com/svn/asterisk/branches/13/include/asterisk/sched.h?view=diff&rev=431917&r1=431916&r2=431917
==============================================================================
--- branches/13/include/asterisk/sched.h (original)
+++ branches/13/include/asterisk/sched.h Wed Feb 18 20:01:34 2015
@@ -170,6 +170,17 @@
typedef int (*ast_sched_cb)(const void *data);
#define AST_SCHED_CB(a) ((ast_sched_cb)(a))
+/*!
+ * \brief Clean all scheduled events with matching callback.
+ *
+ * \param con Scheduler Context
+ * \param match Callback to match
+ * \param cleanup_cb Callback to run
+ *
+ * \note The return of cleanup_cb is ignored. No events are rescheduled.
+ */
+void ast_sched_clean_by_callback(struct ast_sched_context *con, ast_sched_cb match, ast_sched_cb cleanup_cb);
+
struct ast_cb_names {
int numassocs;
char *list[10];
Modified: branches/13/main/sched.c
URL: http://svnview.digium.com/svn/asterisk/branches/13/main/sched.c?view=diff&rev=431917&r1=431916&r2=431917
==============================================================================
--- branches/13/main/sched.c (original)
+++ branches/13/main/sched.c Wed Feb 18 20:01:34 2015
@@ -289,6 +289,26 @@
sched_free(tmp);
}
+void ast_sched_clean_by_callback(struct ast_sched_context *con, ast_sched_cb match, ast_sched_cb cleanup_cb)
+{
+ int i = 1;
+ struct sched *current;
+
+ ast_mutex_lock(&con->lock);
+ while ((current = ast_heap_peek(con->sched_heap, i))) {
+ if (current->callback != match) {
+ i++;
+ continue;
+ }
+
+ ast_heap_remove(con->sched_heap, current);
+
+ cleanup_cb(current->data);
+ sched_release(con, current);
+ }
+ ast_mutex_unlock(&con->lock);
+}
+
/*! \brief
* Return the number of milliseconds
* until the next scheduled event
More information about the asterisk-commits
mailing list