Author: coreyfarrell Date: Sat Oct 4 19:41:16 2014 New Revision: 424578 URL: http://svnview.digium.com/svn/asterisk?view=rev&rev=424578 Log: Release AMI connections on shutdown.
ASTERISK-24378 #close Reported by: Corey Farrell Review: https://reviewboard.asterisk.org/r/4037/ Modified: branches/11/main/manager.c Modified: branches/11/main/manager.c URL: http://svnview.digium.com/svn/asterisk/branches/11/main/manager.c?view=diff&rev=424578&r1=424577&r2=424578 ============================================================================== --- branches/11/main/manager.c (original) +++ branches/11/main/manager.c Sat Oct 4 19:41:16 2014 @@ -1027,6 +1027,9 @@ static int unauth_sessions = 0; static struct ast_event_sub *acl_change_event_subscription; + +/*! \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. @@ -4875,6 +4878,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) { @@ -5793,7 +5800,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)); @@ -7503,6 +7510,9 @@ { 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"); ast_manager_unregister("Logoff"); -- _____________________________________________________________________ -- 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
