Author: coreyfarrell Date: Sat Oct 4 19:49:45 2014 New Revision: 424581 URL: http://svnview.digium.com/svn/asterisk?view=rev&rev=424581 Log: Release AMI connections on shutdown.
ASTERISK-24378 #close Reported by: Corey Farrell Review: https://reviewboard.asterisk.org/r/4037/ ........ Merged revisions 424578 from http://svn.asterisk.org/svn/asterisk/branches/11 ........ Merged revisions 424579 from http://svn.asterisk.org/svn/asterisk/branches/12 ........ Merged revisions 424580 from http://svn.asterisk.org/svn/asterisk/branches/13 Modified: trunk/ (props changed) trunk/main/manager.c Propchange: trunk/ ------------------------------------------------------------------------------ Binary property 'branch-13-merged' - no diff available. Modified: trunk/main/manager.c URL: http://svnview.digium.com/svn/asterisk/trunk/main/manager.c?view=diff&rev=424581&r1=424580&r2=424581 ============================================================================== --- trunk/main/manager.c (original) +++ trunk/main/manager.c Sat Oct 4 19:49:45 2014 @@ -1261,6 +1261,9 @@ #define MAX_VARS 128 +/*! \brief Fake event class used to end sessions at shutdown */ +#define EVENT_FLAG_SHUTDOWN -1 + /*! \brief * Descriptor for a manager session, either on the AMI socket or over HTTP. * @@ -5401,6 +5404,10 @@ struct eventqent *eqe = s->session->last_ev; while ((eqe = advance_event(eqe))) { + if (eqe->category == EVENT_FLAG_SHUTDOWN) { + ast_debug(3, "Received CloseSession event\n"); + ret = -1; + } if (!ret && s->session->authenticated && (s->session->readperm & eqe->category) == eqe->category && (s->session->send_events & eqe->category) == eqe->category) { @@ -6331,7 +6338,7 @@ ao2_iterator_destroy(&i); } - if (!AST_RWLIST_EMPTY(&manager_hooks)) { + if (category != EVENT_FLAG_SHUTDOWN && !AST_RWLIST_EMPTY(&manager_hooks)) { AST_RWLIST_RDLOCK(&manager_hooks); AST_RWLIST_TRAVERSE(&manager_hooks, hook, list) { hook->helper(category, event, ast_str_buffer(buf)); @@ -8113,6 +8120,9 @@ static void manager_shutdown(void) { struct ast_manager_user *user; + + /* This event is not actually transmitted, but causes all TCP sessions to be closed */ + manager_event(EVENT_FLAG_SHUTDOWN, "CloseSession", "CloseSession: true\r\n"); ast_manager_unregister("Ping"); ast_manager_unregister("Events"); -- _____________________________________________________________________ -- Bandwidth and Colocation Provided by http://www.api-digital.com -- svn-commits mailing list To UNSUBSCRIBE or update options visit: http://lists.digium.com/mailman/listinfo/svn-commits
