From b7af9e6639f29feb4db6d0866c98e552b025ec96 Mon Sep 17 00:00:00 2001 From: George Joseph Date: Mon, 6 Feb 2017 15:39:29 -0700 Subject: [PATCH] evsub: Add pjsip_evsub_set_uas_timeout. A UAS which needs to recreate incoming subscriptions from a persistent store can call pjsip_dlg_create_uas_and_inc_lock and pjsip_evsub_create_uas as long as they've persisted the correct data but since the timer is triggered by an incoming subscribe, it's never set and the subscription never expires. * Add pjsip_evsub_set_uas_timeout which is just a wrapper around evsub.c:set_timeout(sub, TIMER_TYPE_UAS_TIMEOUT, seconds) * Also, fixed copy-paste error in pjsip_sub_state_hdr_print when printing retry-after parameter. --- pjsip/include/pjsip-simple/evsub.h | 14 ++++++++++++++ pjsip/src/pjsip-simple/evsub.c | 10 ++++++++++ pjsip/src/pjsip-simple/evsub_msg.c | 2 +- 3 files changed, 25 insertions(+), 1 deletion(-) diff --git a/pjsip/include/pjsip-simple/evsub.h b/pjsip/include/pjsip-simple/evsub.h index 82e0a7c..45e6411 100644 --- a/pjsip/include/pjsip-simple/evsub.h +++ b/pjsip/include/pjsip-simple/evsub.h @@ -511,6 +511,20 @@ PJ_DEF(pj_status_t) pjsip_evsub_add_ref(pjsip_evsub *sub); PJ_DEF(pj_status_t) pjsip_evsub_dec_ref(pjsip_evsub *sub); +/** + * Sets, resets or cancels the UAS subscription timeout. + * + * If there is an existing timer, it is cancelled before any + * other action. + * + * A timeout of 0 is ignored except that any existing timer + * is cancelled. + * + * @param sub The server subscription instance. + * @param seconds The new timeout. + */ +PJ_DEF(void) pjsip_evsub_set_uas_timeout(pjsip_evsub *sub, pj_int32_t seconds); + PJ_END_DECL diff --git a/pjsip/src/pjsip-simple/evsub.c b/pjsip/src/pjsip-simple/evsub.c index 3fe4b49..6918a8c 100644 --- a/pjsip/src/pjsip-simple/evsub.c +++ b/pjsip/src/pjsip-simple/evsub.c @@ -530,6 +530,16 @@ static void set_timer( pjsip_evsub *sub, int timer_id, /* + * Set event subscription UAS timout. + */ +PJ_DEF(void) pjsip_evsub_set_uas_timeout(pjsip_evsub *sub, pj_int32_t seconds) +{ + PJ_ASSERT_RETURN(sub != NULL, PJ_EINVAL); + set_timer(sub, TIMER_TYPE_UAS_TIMEOUT, seconds); +} + + +/* * Destructor. */ static void evsub_on_destroy(void *obj) diff --git a/pjsip/src/pjsip-simple/evsub_msg.c b/pjsip/src/pjsip-simple/evsub_msg.c index b44a715..b37db1c 100644 --- a/pjsip/src/pjsip-simple/evsub_msg.c +++ b/pjsip/src/pjsip-simple/evsub_msg.c @@ -179,7 +179,7 @@ static int pjsip_sub_state_hdr_print(pjsip_sub_state_hdr *hdr, } if (hdr->retry_after >= 0) { pj_memcpy(p, ";retry-after=", 13); - p += 9; + p += 13; printed = pj_utoa(hdr->retry_after, p); p += printed; } -- 2.9.3