[asterisk-commits] mmichelson: branch mmichelson/direct_media r382619 - /team/mmichelson/direct_...
SVN commits to the Asterisk project
asterisk-commits at lists.digium.com
Thu Mar 7 12:47:36 CST 2013
Author: mmichelson
Date: Thu Mar 7 12:47:32 2013
New Revision: 382619
URL: http://svnview.digium.com/svn/asterisk?view=rev&rev=382619
Log:
Prevent crashes from occurring when transactions time out after the session is destroyed.
This also adds some common debugging regarding inv_session and transaction state.
Modified:
team/mmichelson/direct_media/res/res_sip_session.c
Modified: team/mmichelson/direct_media/res/res_sip_session.c
URL: http://svnview.digium.com/svn/asterisk/team/mmichelson/direct_media/res/res_sip_session.c?view=diff&rev=382619&r1=382618&r2=382619
==============================================================================
--- team/mmichelson/direct_media/res/res_sip_session.c (original)
+++ team/mmichelson/direct_media/res/res_sip_session.c Thu Mar 7 12:47:32 2013
@@ -1006,15 +1006,51 @@
pjsip_endpt_schedule_timer(ast_sip_get_pjsip_endpoint(), &session->rescheduled_reinvite, &tv);
}
+static void print_debug_details(const char *function, pjsip_inv_session *inv, pjsip_transaction *tsx)
+{
+ struct ast_sip_session *session;
+ ast_log(LOG_NOTICE, "Function %s called\n", function);
+ if (!inv) {
+ ast_log(LOG_NOTICE, "Transaction %p does not belong to an inv_session?\n", tsx);
+ ast_log(LOG_NOTICE, "The transaction state is %s\n", pjsip_tsx_state_str(tsx->state));
+ return;
+ }
+ session = inv->mod_data[session_module.id];
+ if (!session) {
+ ast_log(LOG_NOTICE, "inv_session %p has no ast session\n", inv);
+ } else {
+ ast_log(LOG_NOTICE, "The state change pertains to the session with %s\n",
+ S_OR(ast_sorcery_object_get_id(session->endpoint), "outbound"));
+ }
+ if (inv->invite_tsx) {
+ ast_log(LOG_NOTICE, "The inv session still has an invite_tsx (%p)\n", inv->invite_tsx);
+ } else {
+ ast_log(LOG_NOTICE, "The inv session does NOT have an invite_tsx\n");
+ }
+ if (tsx) {
+ ast_log(LOG_NOTICE, "The transaction involved in this state change is %p\n", tsx);
+ ast_log(LOG_NOTICE, "The current transaction state is %s\n", pjsip_tsx_state_str(tsx->state));
+ } else {
+ ast_log(LOG_NOTICE, "There is no transaction involved in this state change\n");
+ }
+ ast_log(LOG_NOTICE, "The current inv state is %s\n", pjsip_inv_state_name(inv->state));
+}
+
static void session_on_tsx_state(pjsip_transaction *tsx, pjsip_event *event)
{
pjsip_inv_session *inv;
pjsip_dialog *dlg;
- ast_log(LOG_NOTICE, "Just curious if we're getting called back? State is %s\n", pjsip_tsx_state_str(tsx->state));
dlg = pjsip_tsx_get_dlg(tsx);
inv = pjsip_dlg_get_inv_session(dlg);
+ print_debug_details(__PRETTY_FUNCTION__, inv, tsx);
if (tsx->method.id == PJSIP_INVITE_METHOD) {
struct ast_sip_session *session = inv->mod_data[session_module.id];
+ if (!session) {
+ /* Transaction likely timed out after the call was hung up. Just
+ * ignore such transaction changes
+ */
+ return;
+ }
if (tsx->state == PJSIP_TSX_STATE_TERMINATED) {
queue_delayed_request(session);
if (session->endpoint->direct_media && session->channel) {
@@ -1138,6 +1174,8 @@
static void session_inv_on_state_changed(pjsip_inv_session *inv, pjsip_event *e)
{
struct ast_sip_session *session = inv->mod_data[session_module.id];
+
+ print_debug_details(__PRETTY_FUNCTION__, inv, NULL);
ast_debug(3, "on_state_changed callback called. Event dump to follow\n");
ast_debug(3, "inv state is %s, event type is %s\n", pjsip_inv_state_name(inv->state), pjsip_event_str(e->type));
@@ -1187,7 +1225,7 @@
static void session_inv_on_tsx_state_changed(pjsip_inv_session *inv, pjsip_transaction *tsx, pjsip_event *e)
{
- /* XXX STUB */
+ print_debug_details(__PRETTY_FUNCTION__, inv, tsx);
}
static int add_sdp_streams(void *obj, void *arg, void *data, int flags)
More information about the asterisk-commits
mailing list