[asterisk-commits] file: branch file/gulp_connected_line r389903 - in /team/file/gulp_connected_...
SVN commits to the Asterisk project
asterisk-commits at lists.digium.com
Tue May 28 13:15:03 CDT 2013
Author: file
Date: Tue May 28 13:15:00 2013
New Revision: 389903
URL: http://svnview.digium.com/svn/asterisk?view=rev&rev=389903
Log:
Multiple revisions 389890,389898-389899
........
r389890 | file | 2013-05-28 14:12:44 -0300 (Tue, 28 May 2013) | 1 line
Fix some session reference counting with pushed tasks.
........
r389898 | file | 2013-05-28 14:55:27 -0300 (Tue, 28 May 2013) | 4 lines
Minor tweak to allow multiple methods to be specified when registering a supplement.
This is becoming a common occurence so moving filtering to a single place is nifty.
........
r389899 | file | 2013-05-28 15:07:19 -0300 (Tue, 28 May 2013) | 2 lines
Add method filtering to outgoing response handling.
........
Merged revisions 389890,389898-389899 from http://svn.asterisk.org/svn/asterisk/team/group/pimp_my_sip
Modified:
team/file/gulp_connected_line/ (props changed)
team/file/gulp_connected_line/channels/chan_gulp.c
team/file/gulp_connected_line/res/res_sip_session.c
Propchange: team/file/gulp_connected_line/
------------------------------------------------------------------------------
--- svnmerge-integrated (original)
+++ svnmerge-integrated Tue May 28 13:15:00 2013
@@ -1,1 +1,1 @@
-/team/group/pimp_my_sip:1-389888
+/team/group/pimp_my_sip:1-389902
Modified: team/file/gulp_connected_line/channels/chan_gulp.c
URL: http://svnview.digium.com/svn/asterisk/team/file/gulp_connected_line/channels/chan_gulp.c?view=diff&rev=389903&r1=389902&r2=389903
==============================================================================
--- team/file/gulp_connected_line/channels/chan_gulp.c (original)
+++ team/file/gulp_connected_line/channels/chan_gulp.c Tue May 28 13:15:00 2013
@@ -510,7 +510,11 @@
if (changed) {
ao2_ref(session, +1);
- ast_sip_push_task(session->serializer, send_direct_media_request, session);
+
+
+ if (ast_sip_push_task(session->serializer, send_direct_media_request, session)) {
+ ao2_cleanup(session);
+ }
}
return 0;
@@ -827,7 +831,7 @@
.body_text = xml
};
- struct ast_sip_session *session = data;
+ RAII_VAR(struct ast_sip_session *, session, data, ao2_cleanup);
struct pjsip_tx_data *tdata;
if (ast_sip_create_request("INFO", session->inv_session->dlg, session->endpoint, NULL, &tdata)) {
@@ -911,9 +915,14 @@
case AST_CONTROL_VIDUPDATE:
media = pvt->media[SIP_MEDIA_VIDEO];
if (media && media->rtp) {
- ast_sip_push_task(session->serializer, transmit_info_with_vidupdate, session);
- } else
+ ao2_ref(session, +1);
+
+ if (ast_sip_push_task(session->serializer, transmit_info_with_vidupdate, session)) {
+ ao2_cleanup(session);
+ }
+ } else {
res = -1;
+ }
break;
case AST_CONTROL_CONNECTED_LINE:
ao2_ref(session, +1);
Modified: team/file/gulp_connected_line/res/res_sip_session.c
URL: http://svnview.digium.com/svn/asterisk/team/file/gulp_connected_line/res/res_sip_session.c?view=diff&rev=389903&r1=389902&r2=389903
==============================================================================
--- team/file/gulp_connected_line/res/res_sip_session.c (original)
+++ team/file/gulp_connected_line/res/res_sip_session.c Tue May 28 13:15:00 2013
@@ -1325,7 +1325,20 @@
handle_incoming_request(session, rdata);
}
-static int has_supplement(struct ast_sip_session *session, pjsip_rx_data *rdata)
+static pj_bool_t does_method_match(const pj_str_t *message_method, const char *supplement_method)
+{
+ pj_str_t method;
+
+ if (ast_strlen_zero(supplement_method)) {
+ return PJ_TRUE;
+ }
+
+ pj_cstr(&method, supplement_method);
+
+ return pj_stristr(&method, message_method) ? PJ_TRUE : PJ_FALSE;
+}
+
+static pj_bool_t has_supplement(const struct ast_sip_session *session, const pjsip_rx_data *rdata)
{
struct ast_sip_session_supplement *supplement;
struct pjsip_method *method = &rdata->msg_info.msg->line.req.method;
@@ -1335,7 +1348,7 @@
}
AST_LIST_TRAVERSE(&session->supplements, supplement, next) {
- if (!supplement->method || !pj_strcmp2(&method->name, supplement->method)) {
+ if (does_method_match(&method->name, supplement->method)) {
return PJ_TRUE;
}
}
@@ -1485,8 +1498,7 @@
ast_debug(3, "Method is %.*s\n", (int) pj_strlen(&req.method.name), pj_strbuf(&req.method.name));
AST_LIST_TRAVERSE(&session->supplements, supplement, next) {
- if (supplement->incoming_request && (
- !supplement->method || !pj_strcmp2(&req.method.name, supplement->method))) {
+ if (supplement->incoming_request && does_method_match(&req.method.name, supplement->method)) {
if (supplement->incoming_request(session, rdata)) {
break;
}
@@ -1503,8 +1515,7 @@
pj_strbuf(&status.reason));
AST_LIST_TRAVERSE(&session->supplements, supplement, next) {
- if (supplement->incoming_response && (
- !supplement->method || !pj_strcmp2(&rdata->msg_info.cseq->method.name, supplement->method))) {
+ if (supplement->incoming_response && does_method_match(&rdata->msg_info.cseq->method.name, supplement->method)) {
supplement->incoming_response(session, rdata);
}
}
@@ -1531,8 +1542,7 @@
ast_debug(3, "Method is %.*s\n", (int) pj_strlen(&req.method.name), pj_strbuf(&req.method.name));
AST_LIST_TRAVERSE(&session->supplements, supplement, next) {
- if (supplement->outgoing_request &&
- (!supplement->method || !pj_strcmp2(&req.method.name, supplement->method))) {
+ if (supplement->outgoing_request && does_method_match(&req.method.name, supplement->method)) {
supplement->outgoing_request(session, tdata);
}
}
@@ -1542,15 +1552,13 @@
{
struct ast_sip_session_supplement *supplement;
struct pjsip_status_line status = tdata->msg->line.status;
- ast_debug(3, "Response is %d %.*s\n", status.code, (int) pj_strlen(&status.reason),
- pj_strbuf(&status.reason));
+ pjsip_cseq_hdr *cseq = pjsip_msg_find_hdr(tdata->msg, PJSIP_H_CSEQ, NULL);
+ ast_debug(3, "Method is %.*s, Response is %d %.*s\n", (int) pj_strlen(&cseq->method.name),
+ pj_strbuf(&cseq->method.name), status.code, (int) pj_strlen(&status.reason),
+ pj_strbuf(&status.reason));
AST_LIST_TRAVERSE(&session->supplements, supplement, next) {
- /* XXX Not sure how to get the method from a response.
- * For now, just call supplements on all responses, no
- * matter the method. This is less than ideal
- */
- if (supplement->outgoing_response) {
+ if (supplement->outgoing_response && does_method_match(&cseq->method.name, supplement->method)) {
supplement->outgoing_response(session, tdata);
}
}
More information about the asterisk-commits
mailing list