summaryrefslogtreecommitdiff
path: root/pjsip/src/pjsip-simple
diff options
context:
space:
mode:
authorBenny Prijono <bennylp@teluu.com>2009-06-30 13:47:44 +0000
committerBenny Prijono <bennylp@teluu.com>2009-06-30 13:47:44 +0000
commit7e2a92f69ec23e30e9c7714cb397e28c0c5d31ba (patch)
tree29796f4b77d285f428a9561adb2ca71ca4793f00 /pjsip/src/pjsip-simple
parentc2ffe11838cd6966a79df6749828ca0d14f9b5a7 (diff)
Ticket #911: Crash when receiving NOTIFY after subscription is terminated (thanks Johan Lantz for the report)
- fixed the bug by not processing the NOTIFY if the subscription is already terminated - also added SIPp scenario to reproduce the bug git-svn-id: http://svn.pjsip.org/repos/pjproject/trunk@2822 74dad513-b988-da41-8d7b-12977e46ad98
Diffstat (limited to 'pjsip/src/pjsip-simple')
-rw-r--r--pjsip/src/pjsip-simple/evsub.c18
1 files changed, 15 insertions, 3 deletions
diff --git a/pjsip/src/pjsip-simple/evsub.c b/pjsip/src/pjsip-simple/evsub.c
index d4dc8b4b..7acd0bad 100644
--- a/pjsip/src/pjsip-simple/evsub.c
+++ b/pjsip/src/pjsip-simple/evsub.c
@@ -1378,10 +1378,21 @@ static pjsip_evsub *on_new_transaction( pjsip_transaction *tsx,
dlgsub = dlgsub->next;
}
- if (dlgsub == dlgsub_head) {
+ /* Note:
+ * the second condition is for http://trac.pjsip.org/repos/ticket/911
+ */
+ if (dlgsub == dlgsub_head ||
+ (dlgsub->sub &&
+ pjsip_evsub_get_state(dlgsub->sub)==PJSIP_EVSUB_STATE_TERMINATED))
+ {
+ const char *reason_msg =
+ (dlgsub == dlgsub_head ? "Subscription Does Not Exist" :
+ "Subscription already terminated");
+
/* This could be incoming request to create new subscription */
PJ_LOG(4,(THIS_FILE,
- "Subscription not found for %.*s, event=%.*s;id=%.*s",
+ "%s for %.*s, event=%.*s;id=%.*s",
+ reason_msg,
(int)tsx->method.name.slen,
tsx->method.name.ptr,
(int)event_hdr->event_type.slen,
@@ -1393,10 +1404,11 @@ static pjsip_evsub *on_new_transaction( pjsip_transaction *tsx,
if (tsx->state == PJSIP_TSX_STATE_TRYING &&
pjsip_method_cmp(&tsx->method, &pjsip_notify_method)==0)
{
- pj_str_t reason = pj_str("Subscription Does Not Exist");
+ pj_str_t reason;
pjsip_tx_data *tdata;
pj_status_t status;
+ pj_cstr(&reason, reason_msg);
status = pjsip_dlg_create_response(dlg,
event->body.tsx_state.src.rdata,
481, &reason,