diff options
author | Matt Jordan <mjordan@digium.com> | 2015-11-18 07:33:53 -0600 |
---|---|---|
committer | Gerrit Code Review <gerrit2@gerrit.digium.api> | 2015-11-18 07:33:53 -0600 |
commit | ccf80f95a21c380fb9e96a367bece411e349edb0 (patch) | |
tree | c7a8c3a87377e930800b4b1a292e5824bbd6831f /res | |
parent | e3cb27d341b5288c8845f9a4382c56cd867d93eb (diff) | |
parent | c0f2f8de458e68e412be91ccc363a9f7aae77c78 (diff) |
Merge "res_pjsip_rfc3326.c: Fix crash when channel goes away." into 13
Diffstat (limited to 'res')
-rw-r--r-- | res/res_pjsip_rfc3326.c | 17 |
1 files changed, 13 insertions, 4 deletions
diff --git a/res/res_pjsip_rfc3326.c b/res/res_pjsip_rfc3326.c index 3ed8de659..ab92d6f7f 100644 --- a/res/res_pjsip_rfc3326.c +++ b/res/res_pjsip_rfc3326.c @@ -32,6 +32,7 @@ #include "asterisk/res_pjsip_session.h" #include "asterisk/module.h" #include "asterisk/causes.h" +#include "asterisk/threadpool.h" static void rfc3326_use_reason_header(struct ast_sip_session *session, struct pjsip_rx_data *rdata) { @@ -101,9 +102,15 @@ static void rfc3326_add_reason_header(struct ast_sip_session *session, struct pj static void rfc3326_outgoing_request(struct ast_sip_session *session, struct pjsip_tx_data *tdata) { - if ((pjsip_method_cmp(&tdata->msg->line.req.method, &pjsip_bye_method) && - pjsip_method_cmp(&tdata->msg->line.req.method, &pjsip_cancel_method)) || - !session->channel) { + if ((pjsip_method_cmp(&tdata->msg->line.req.method, &pjsip_bye_method) + && pjsip_method_cmp(&tdata->msg->line.req.method, &pjsip_cancel_method)) + || !session->channel + /* + * The session->channel has been seen to go away on us between + * checks so we must also be running under the call's serializer + * thread. + */ + || session->serializer != ast_threadpool_serializer_get_current()) { return; } @@ -114,7 +121,9 @@ static void rfc3326_outgoing_response(struct ast_sip_session *session, struct pj { struct pjsip_status_line status = tdata->msg->line.status; - if ((status.code < 300) || !session->channel) { + if (status.code < 300 + || !session->channel + || session->serializer != ast_threadpool_serializer_get_current()) { return; } |