summaryrefslogtreecommitdiff
path: root/pjsip/src/pjsua-lib
diff options
context:
space:
mode:
authorBenny Prijono <bennylp@teluu.com>2009-04-28 22:19:49 +0000
committerBenny Prijono <bennylp@teluu.com>2009-04-28 22:19:49 +0000
commit00ed64489de3c39a6a452e11bb43b2c1090c9307 (patch)
treee871adbe53ea5daa64515cdb0feb1102df7e34cc /pjsip/src/pjsua-lib
parent7a0ee1a7208ddfe8575d1f1179f66fda2fa99339 (diff)
Ticket #760: Enhancements to PUBLISH management (thanks Johan Lantz for the suggestion)
- Changes in PJSUA-LIB - retry with fresh request on 412/Conditional Request Failed response - changed default Expires in PUBLISH request to none (we will not put Expires), to avoid getting 423/Interval Too Brief response - if the PUBLISH fails for any reason, it will be retried on every PJSUA_PRES_TIMER (default 300 seconds), similar to how failed SUBSCRIBE will be retried - Changes to publish.h: - added API to add headers in every PUBLISH request - Added test scenario in Python unit tests git-svn-id: http://svn.pjsip.org/repos/pjproject/trunk@2661 74dad513-b988-da41-8d7b-12977e46ad98
Diffstat (limited to 'pjsip/src/pjsua-lib')
-rw-r--r--pjsip/src/pjsua-lib/pjsua_pres.c30
1 files changed, 27 insertions, 3 deletions
diff --git a/pjsip/src/pjsua-lib/pjsua_pres.c b/pjsip/src/pjsua-lib/pjsua_pres.c
index d619dd47..d980e617 100644
--- a/pjsip/src/pjsua-lib/pjsua_pres.c
+++ b/pjsip/src/pjsua-lib/pjsua_pres.c
@@ -961,6 +961,10 @@ static void publish_cb(struct pjsip_publishc_cbparam *param)
pjsua_acc *acc = (pjsua_acc*) param->token;
if (param->code/100 != 2 || param->status != PJ_SUCCESS) {
+
+ pjsip_publishc_destroy(param->pubc);
+ acc->publish_sess = NULL;
+
if (param->status != PJ_SUCCESS) {
char errmsg[PJ_ERR_MSG_SIZE];
@@ -968,6 +972,12 @@ static void publish_cb(struct pjsip_publishc_cbparam *param)
PJ_LOG(1,(THIS_FILE,
"Client publication (PUBLISH) failed, status=%d, msg=%s",
param->status, errmsg));
+ } else if (param->code == 412) {
+ /* 412 (Conditional Request Failed)
+ * The PUBLISH refresh has failed, retry with new one.
+ */
+ pjsua_pres_init_publish_acc(acc->index);
+
} else {
PJ_LOG(1,(THIS_FILE,
"Client publication (PUBLISH) failed (%d/%.*s)",
@@ -975,8 +985,14 @@ static void publish_cb(struct pjsip_publishc_cbparam *param)
param->reason.ptr));
}
- pjsip_publishc_destroy(param->pubc);
- acc->publish_sess = NULL;
+ } else {
+ if (param->expiration == -1) {
+ /* Could happen if server "forgot" to include Expires header
+ * in the response. We will not renew, so destroy the pubc.
+ */
+ pjsip_publishc_destroy(param->pubc);
+ acc->publish_sess = NULL;
+ }
}
}
@@ -1091,7 +1107,7 @@ pj_status_t pjsua_pres_init_publish_acc(int acc_id)
status = pjsip_publishc_init(acc->publish_sess, &STR_PRESENCE,
&acc_cfg->id, &acc_cfg->id,
&acc_cfg->id,
- PJSUA_PRES_TIMER);
+ PJSUA_PUBLISH_EXPIRATION);
if (status != PJ_SUCCESS) {
acc->publish_sess = NULL;
return status;
@@ -1606,8 +1622,16 @@ static void refresh_client_subscriptions(void)
static void pres_timer_cb(pj_timer_heap_t *th,
pj_timer_entry *entry)
{
+ unsigned i;
pj_time_val delay = { PJSUA_PRES_TIMER, 0 };
+ /* Retry failed PUBLISH requests */
+ for (i=0; i<PJ_ARRAY_SIZE(pjsua_var.acc); ++i) {
+ pjsua_acc *acc = &pjsua_var.acc[i];
+ if (acc->cfg.publish_enabled && acc->publish_sess==NULL)
+ pjsua_pres_init_publish_acc(acc->index);
+ }
+
entry->id = PJ_FALSE;
refresh_client_subscriptions();