[asterisk-commits] mmichelson: branch group/pimp_my_sip r383311 - in /team/group/pimp_my_sip: in...
SVN commits to the Asterisk project
asterisk-commits at lists.digium.com
Mon Mar 18 09:11:07 CDT 2013
Author: mmichelson
Date: Mon Mar 18 09:11:03 2013
New Revision: 383311
URL: http://svnview.digium.com/svn/asterisk?view=rev&rev=383311
Log:
Eliminate the need for endpoint lookups on in-dialog requests.
This serves two purposes. One, it eliminates some unneeded processing. Two,
it prevents bugs due to potentially being unable to identify called endpoints
when they send a request.
Review: https://reviewboard.asterisk.org/r/2392
Modified:
team/group/pimp_my_sip/include/asterisk/res_sip.h
team/group/pimp_my_sip/res/res_sip.exports.in
team/group/pimp_my_sip/res/res_sip/sip_distributor.c
team/group/pimp_my_sip/res/res_sip_session.c
Modified: team/group/pimp_my_sip/include/asterisk/res_sip.h
URL: http://svnview.digium.com/svn/asterisk/team/group/pimp_my_sip/include/asterisk/res_sip.h?view=diff&rev=383311&r1=383310&r2=383311
==============================================================================
--- team/group/pimp_my_sip/include/asterisk/res_sip.h (original)
+++ team/group/pimp_my_sip/include/asterisk/res_sip.h Mon Mar 18 09:11:03 2013
@@ -644,6 +644,14 @@
void ast_sip_dialog_set_serializer(pjsip_dialog *dlg, struct ast_taskprocessor *serializer);
/*!
+ * \brief Set an endpoint on a SIP dialog so in-dialog requests do not undergo endpoint lookup.
+ *
+ * \param dlg The SIP dialog itself
+ * \param endpoint The endpoint that this dialog is communicating with
+ */
+void ast_sip_dialog_set_endpoint(pjsip_dialog *dlg, struct ast_sip_endpoint *endpoint);
+
+/*!
* \brief Pushes a task to SIP servants
*
* This uses the serializer provided to determine how to push the task.
Modified: team/group/pimp_my_sip/res/res_sip.exports.in
URL: http://svnview.digium.com/svn/asterisk/team/group/pimp_my_sip/res/res_sip.exports.in?view=diff&rev=383311&r1=383310&r2=383311
==============================================================================
--- team/group/pimp_my_sip/res/res_sip.exports.in (original)
+++ team/group/pimp_my_sip/res/res_sip.exports.in Mon Mar 18 09:11:03 2013
@@ -34,6 +34,7 @@
LINKER_SYMBOL_PREFIXast_pjsip_rdata_get_endpoint;
LINKER_SYMBOL_PREFIXast_sip_thread_is_servant;
LINKER_SYMBOL_PREFIXast_sip_dialog_set_serializer;
+ LINKER_SYMBOL_PREFIXast_sip_dialog_set_endpoint;
local:
*;
};
Modified: team/group/pimp_my_sip/res/res_sip/sip_distributor.c
URL: http://svnview.digium.com/svn/asterisk/team/group/pimp_my_sip/res/res_sip/sip_distributor.c?view=diff&rev=383311&r1=383310&r2=383311
==============================================================================
--- team/group/pimp_my_sip/res/res_sip/sip_distributor.c (original)
+++ team/group/pimp_my_sip/res/res_sip/sip_distributor.c Mon Mar 18 09:11:03 2013
@@ -32,24 +32,60 @@
.on_rx_response = distributor,
};
+/*! Dialog-specific information the distributor uses */
+struct distributor_dialog_data {
+ /* Serializer to distribute tasks to for this dialog */
+ struct ast_taskprocessor *serializer;
+ /* Endpoint associated with this dialog */
+ struct ast_sip_endpoint *endpoint;
+};
+
+static struct distributor_dialog_data *distributor_dialog_data_alloc(pjsip_dialog *dlg)
+{
+ struct distributor_dialog_data *dist;
+
+ pjsip_dlg_inc_lock(dlg);
+ dist = PJ_POOL_ZALLOC_T(dlg->pool, struct distributor_dialog_data);
+ pjsip_dlg_set_mod_data(dlg, distributor_mod.id, dist);
+ pjsip_dlg_dec_lock(dlg);
+
+ return dist;
+}
+
void ast_sip_dialog_set_serializer(pjsip_dialog *dlg, struct ast_taskprocessor *serializer)
{
- pjsip_dlg_inc_lock(dlg);
- pjsip_dlg_set_mod_data(dlg, distributor_mod.id, serializer);
- pjsip_dlg_dec_lock(dlg);
+ struct distributor_dialog_data *dist = pjsip_dlg_get_mod_data(dlg, distributor_mod.id);
+ if (!dist) {
+ dist = distributor_dialog_data_alloc(dlg);
+ }
+ dist->serializer = serializer;
+}
+
+void ast_sip_dialog_set_endpoint(pjsip_dialog *dlg, struct ast_sip_endpoint *endpoint)
+{
+ struct distributor_dialog_data *dist = pjsip_dlg_get_mod_data(dlg, distributor_mod.id);
+ if (!dist) {
+ dist = distributor_dialog_data_alloc(dlg);
+ }
+ dist->endpoint = endpoint;
}
static pj_bool_t distributor(pjsip_rx_data *rdata)
{
pjsip_dialog *dlg = pjsip_ua_find_dialog(&rdata->msg_info.cid->id, &rdata->msg_info.to->tag, &rdata->msg_info.from->tag, PJ_TRUE);
+ struct distributor_dialog_data *dist = NULL;
struct ast_taskprocessor *serializer = NULL;
pjsip_rx_data *clone;
+ pjsip_rx_data_clone(rdata, 0, &clone);
if (dlg) {
- serializer = pjsip_dlg_get_mod_data(dlg, distributor_mod.id);
- }
-
- pjsip_rx_data_clone(rdata, 0, &clone);
+ dist = pjsip_dlg_get_mod_data(dlg, distributor_mod.id);
+ if (dist) {
+ serializer = dist->serializer;
+ clone->endpt_info.mod_data[distributor_mod.id] = dist->endpoint;
+ }
+ }
+
ast_sip_push_task(serializer, distribute, clone);
if (dlg) {
@@ -69,8 +105,17 @@
static pj_bool_t endpoint_lookup(pjsip_rx_data *rdata)
{
- struct ast_sip_endpoint *endpoint = ast_sip_identify_endpoint(rdata);
+ struct ast_sip_endpoint *endpoint;
int is_ack = rdata->msg_info.msg->line.req.method.id == PJSIP_ACK_METHOD;
+
+ endpoint = rdata->endpt_info.mod_data[distributor_mod.id];
+ if (endpoint) {
+ /* Bumping the refcount makes refcounting consistent whether an endpoint
+ * is looked up or not */
+ ao2_ref(endpoint, +1);
+ } else {
+ endpoint = ast_sip_identify_endpoint(rdata);
+ }
if (!endpoint && !is_ack) {
/* XXX When we do an alwaysauthreject-like option, we'll need to take that into account
Modified: team/group/pimp_my_sip/res/res_sip_session.c
URL: http://svnview.digium.com/svn/asterisk/team/group/pimp_my_sip/res/res_sip_session.c?view=diff&rev=383311&r1=383310&r2=383311
==============================================================================
--- team/group/pimp_my_sip/res/res_sip_session.c (original)
+++ team/group/pimp_my_sip/res/res_sip_session.c Mon Mar 18 09:11:03 2013
@@ -756,6 +756,7 @@
return NULL;
}
ast_sip_dialog_set_serializer(inv_session->dlg, session->serializer);
+ ast_sip_dialog_set_endpoint(inv_session->dlg, endpoint);
ao2_ref(endpoint, +1);
inv_session->mod_data[session_module.id] = session;
session->endpoint = endpoint;
@@ -1165,6 +1166,7 @@
session->inv_session->mod_data[session_module.id] = NULL;
ast_sip_dialog_set_serializer(session->inv_session->dlg, NULL);
+ ast_sip_dialog_set_endpoint(session->inv_session->dlg, NULL);
ao2_cleanup(session);
return 0;
}
More information about the asterisk-commits
mailing list