diff options
author | Benny Prijono <bennylp@teluu.com> | 2010-12-02 11:21:01 +0000 |
---|---|---|
committer | Benny Prijono <bennylp@teluu.com> | 2010-12-02 11:21:01 +0000 |
commit | 02df27ae7d7b67421fb962d757b621414f8352bb (patch) | |
tree | 29c43fbe45683104a52b5ba7b8c5c132d8a6a21a /pjsip/src | |
parent | 92c1c5e39885b2014b838399d1c8038021f0eba1 (diff) |
Misc (re #1151): respond incoming re-INVITE with 491 instead of 500 if we are waiting for response for our outgoing re-INVITE. If we are currently processing another incoming re-INVITE, then respond with 500, as it is now
git-svn-id: http://svn.pjsip.org/repos/pjproject/trunk@3385 74dad513-b988-da41-8d7b-12977e46ad98
Diffstat (limited to 'pjsip/src')
-rw-r--r-- | pjsip/src/pjsip-ua/sip_inv.c | 20 |
1 files changed, 19 insertions, 1 deletions
diff --git a/pjsip/src/pjsip-ua/sip_inv.c b/pjsip/src/pjsip-ua/sip_inv.c index b9bfe896..e434a584 100644 --- a/pjsip/src/pjsip-ua/sip_inv.c +++ b/pjsip/src/pjsip-ua/sip_inv.c @@ -33,6 +33,7 @@ #include <pj/assert.h> #include <pj/os.h> #include <pj/log.h> +#include <pj/rand.h> /* * Note on offer/answer: @@ -3916,16 +3917,33 @@ static void inv_on_state_confirmed( pjsip_inv_session *inv, pjsip_event *e) /* Check if we have INVITE pending. */ if (inv->invite_tsx && inv->invite_tsx!=tsx) { + int code; pj_str_t reason; reason = pj_str("Another INVITE transaction in progress"); + if (inv->invite_tsx->role == PJSIP_ROLE_UAC) + code = 491; + else + code = 500; + /* Can not receive re-INVITE while another one is pending. */ - status = pjsip_dlg_create_response( inv->dlg, rdata, 500, + status = pjsip_dlg_create_response( inv->dlg, rdata, code, &reason, &tdata); if (status != PJ_SUCCESS) return; + if (code == 500) { + /* MUST include Retry-After header with random value + * between 0-10. + */ + pjsip_retry_after_hdr *ra_hdr; + int val = (pj_rand() % 10); + + ra_hdr = pjsip_retry_after_hdr_create(tdata->pool, val); + pjsip_msg_add_hdr(tdata->msg, (pjsip_hdr*)ra_hdr); + } + status = pjsip_dlg_send_response( inv->dlg, tsx, tdata); |