summaryrefslogtreecommitdiff
path: root/pjsip
diff options
context:
space:
mode:
authorBenny Prijono <bennylp@teluu.com>2007-06-27 13:01:59 +0000
committerBenny Prijono <bennylp@teluu.com>2007-06-27 13:01:59 +0000
commitdc88226fa06a68d43dfcd716fc50635c0eddf535 (patch)
tree0b195386b8391d32a928fc23c55ed43f29965b59 /pjsip
parent95c98b95136c97f511beed1636379b909b3181d0 (diff)
Ticket #347: Assertion failure when handling incoming presence subscription with Expires=0
git-svn-id: http://svn.pjsip.org/repos/pjproject/trunk@1396 74dad513-b988-da41-8d7b-12977e46ad98
Diffstat (limited to 'pjsip')
-rw-r--r--pjsip/src/pjsip-simple/presence.c18
-rw-r--r--pjsip/src/pjsua-lib/pjsua_pres.c16
2 files changed, 14 insertions, 20 deletions
diff --git a/pjsip/src/pjsip-simple/presence.c b/pjsip/src/pjsip-simple/presence.c
index dc65637f..88aa8d66 100644
--- a/pjsip/src/pjsip-simple/presence.c
+++ b/pjsip/src/pjsip-simple/presence.c
@@ -224,8 +224,6 @@ PJ_DEF(pj_status_t) pjsip_pres_create_uas( pjsip_dialog *dlg,
{
pjsip_accept_hdr *accept;
pjsip_event_hdr *event;
- pjsip_expires_hdr *expires_hdr;
- unsigned expires;
content_type_e content_type = CONTENT_TYPE_NONE;
pjsip_evsub *sub;
pjsip_pres *pres;
@@ -281,22 +279,6 @@ PJ_DEF(pj_status_t) pjsip_pres_create_uas( pjsip_dialog *dlg,
content_type = CONTENT_TYPE_PIDF;
}
- /* Check that expires is not too short. */
- expires_hdr=(pjsip_expires_hdr*)
- pjsip_msg_find_hdr(rdata->msg_info.msg, PJSIP_H_EXPIRES, NULL);
- if (expires_hdr) {
- if (expires_hdr->ivalue < 5) {
- return PJSIP_ERRNO_FROM_SIP_STATUS(PJSIP_SC_INTERVAL_TOO_BRIEF);
- }
-
- expires = expires_hdr->ivalue;
- if (expires > PRES_DEFAULT_EXPIRES)
- expires = PRES_DEFAULT_EXPIRES;
-
- } else {
- expires = PRES_DEFAULT_EXPIRES;
- }
-
/* Lock dialog */
pjsip_dlg_inc_lock(dlg);
diff --git a/pjsip/src/pjsua-lib/pjsua_pres.c b/pjsip/src/pjsua-lib/pjsua_pres.c
index df9918fd..070c6f00 100644
--- a/pjsip/src/pjsua-lib/pjsua_pres.c
+++ b/pjsip/src/pjsua-lib/pjsua_pres.c
@@ -456,6 +456,8 @@ static pj_bool_t pres_on_rx_request(pjsip_rx_data *rdata)
pjsip_tx_data *tdata;
pjsip_pres_status pres_status;
pjsip_dialog *dlg;
+ pjsip_expires_hdr *expires_hdr;
+ pjsip_evsub_state ev_state;
pj_status_t status;
if (pjsip_method_cmp(req_method, &pjsip_subscribe_method) != 0)
@@ -558,9 +560,19 @@ static pj_bool_t pres_on_rx_request(pjsip_rx_data *rdata)
pjsip_pres_set_status(sub, &pres_status);
+ /* Check expires value. If it's zero, send our presense state but
+ * set subscription state to TERMINATED.
+ */
+ expires_hdr=(pjsip_expires_hdr*)
+ pjsip_msg_find_hdr(rdata->msg_info.msg, PJSIP_H_EXPIRES, NULL);
+
+ if (expires_hdr && expires_hdr->ivalue == 0)
+ ev_state = PJSIP_EVSUB_STATE_TERMINATED;
+ else
+ ev_state = PJSIP_EVSUB_STATE_ACTIVE;
+
/* Create and send the first NOTIFY to active subscription: */
- status = pjsip_pres_notify( sub, PJSIP_EVSUB_STATE_ACTIVE, NULL,
- NULL, &tdata);
+ status = pjsip_pres_notify( sub, ev_state, NULL, NULL, &tdata);
if (status == PJ_SUCCESS) {
pjsua_process_msg_data(tdata, NULL);
status = pjsip_pres_send_request( sub, tdata);