[asterisk-scf-commits] asterisk-scf/integration/sip.git branch "master" updated.
Commits to the Asterisk SCF project code repositories
asterisk-scf-commits at lists.digium.com
Mon Sep 20 11:22:19 CDT 2010
branch "master" has been updated
via edaa4a16245eec1f43e0304e1230861e9018f902 (commit)
from d97711f244f7fdddc8abcb96437d035a70e08da8 (commit)
Summary of changes:
src/PJSipSessionModule.cpp | 40 +++++++++++++++++++++++++++-------------
1 files changed, 27 insertions(+), 13 deletions(-)
- Log -----------------------------------------------------------------
commit edaa4a16245eec1f43e0304e1230861e9018f902
Author: Mark Michelson <mmichelson at digium.com>
Date: Mon Sep 20 11:22:49 2010 -0500
Add comment detailing state replication strategy and add the one exception I know of.
diff --git a/src/PJSipSessionModule.cpp b/src/PJSipSessionModule.cpp
index ec47ad7..3a486c3 100644
--- a/src/PJSipSessionModule.cpp
+++ b/src/PJSipSessionModule.cpp
@@ -512,6 +512,8 @@ static void handle_invite_response(pjsip_inv_session *inv, pjsip_rx_data *rdata,
}
}
+static void invOnTransactionStateChanged(pjsip_inv_session *inv, pjsip_transaction *tsx, pjsip_event *event);
+
static void invOnStateChanged(pjsip_inv_session *inv, pjsip_event *event)
{
if ((inv->state == PJSIP_INV_STATE_EARLY || inv->state == PJSIP_INV_STATE_CONNECTING) &&
@@ -552,7 +554,18 @@ static void invOnStateChanged(pjsip_inv_session *inv, pjsip_event *event)
delete session_mod_info;
inv->mod_data[pjsip_ua_instance()->id] = 0;
}
- //stub
+ if (event->type == PJSIP_EVENT_RX_MSG && inv->state == PJSIP_INV_STATE_CONFIRMED)
+ {
+ //We received an ACK for our 2XX response.
+ //See comment in invOnTransactionStateChanged() for explanation of this.
+
+ //Compare branches to see if this got handled by the transaction layer.
+ if (pj_strcmp(&event->body.rx_msg.rdata->msg_info.via->branch_param, &inv->invite_tsx->branch) != 0)
+ {
+ //Mismatched branch!
+ invOnTransactionStateChanged(inv, inv->invite_tsx, event);
+ }
+ }
}
static void invOnNewSession(pjsip_inv_session *inv, pjsip_event *event)
@@ -567,17 +580,18 @@ static void invOnTransactionStateChanged(pjsip_inv_session *inv, pjsip_transacti
//itself as the transaction user, so this won't be called on the initial
//INVITE we receive.
//
- //The methodology here is a bit odd, and that's due to the order in which
- //PJSIP iterates through modules. This function is called from the
- //transaction layer. On message reception, this will get called before
- //our application has a chance to update dialog and session state. So
- //in that case, we just update transaction state and move on. When
- //transmitting messages, though, this is basically the last thing
- //that gets called prior to the message actually being sent out, so
- //this is the opportune time to both update the transaction state and
- //update the state replicator with all pending transaction, dialog,
- //and session changes.
-
+ //Having taken a look at the pjsip inv_session code, the transaction state
+ //changed callback is called *after* the inv_state_changed callback. This
+ //means that on both reception and transmission of requests, this is called
+ //last, meaning this is the prime spot to do state replication of dialogs,
+ //transactions, sessions.
+ //
+ //There is one exception. If we receive an ACK for an INVITE transaction and
+ //the ACK has a different Via branch parameter than the INVITE and its response,
+ //then this callback will not be called at all, and we will need to perform the
+ //proper state replication in the invOnStateChanged function. This can be
+ //done simply by calling this function from there.
+
pjsip_module *module = pjsip_ua_instance();
PJSipTransactionModInfo *tsx_mod_info = static_cast<PJSipTransactionModInfo *> (tsx->mod_data[module->id]);
if (tsx->state != PJSIP_TSX_STATE_DESTROYED)
@@ -588,7 +602,7 @@ static void invOnTransactionStateChanged(pjsip_inv_session *inv, pjsip_transacti
{
tsx_mod_info->mNeedsRemoval = true;
}
- if (e->type == PJSIP_EVENT_TX_MSG)
+ if (e->type == PJSIP_EVENT_TX_MSG || e->type == PJSIP_EVENT_RX_MSG)
{
pjsip_dialog *dlg = pjsip_tsx_get_dlg(tsx);
PJSipDialogModInfo *dlg_mod_info = NULL;
-----------------------------------------------------------------------
--
asterisk-scf/integration/sip.git
More information about the asterisk-scf-commits
mailing list