Ticket #347: Assertion failure when handling incoming presence subscription with Expires=0
git-svn-id: https://svn.pjsip.org/repos/pjproject/trunk@1396 74dad513-b988-da41-8d7b-12977e46ad98
This commit is contained in:
parent
efb9b6b1c1
commit
c61cc04143
2 changed files with 14 additions and 20 deletions
|
@ -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);
|
||||
|
||||
|
|
|
@ -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);
|
||||
|
|
Loading…
Reference in a new issue