diff options
author | Benny Prijono <bennylp@teluu.com> | 2009-06-02 08:17:56 +0000 |
---|---|---|
committer | Benny Prijono <bennylp@teluu.com> | 2009-06-02 08:17:56 +0000 |
commit | fad187f773f6ce7de945f95feecf24c589e985c8 (patch) | |
tree | 0bc8858e415d792d89d4079adf73b8406b672874 | |
parent | db8640b0bc2a82c87576ed4b7ae33cdf25620c6d (diff) |
Ticket #870: Changed the mapping of host resolution failure to SIP status code 502 from 503 (thanks Robert Cichielo for the report)
- also fixed client registration to use the reason phrase of the transaction rather than to retrieve the default reason phrase for the status code
git-svn-id: http://svn.pjsip.org/repos/pjproject/trunk@2732 74dad513-b988-da41-8d7b-12977e46ad98
-rw-r--r-- | pjsip/src/pjsip-ua/sip_reg.c | 2 | ||||
-rw-r--r-- | pjsip/src/pjsip/sip_transaction.c | 13 |
2 files changed, 13 insertions, 2 deletions
diff --git a/pjsip/src/pjsip-ua/sip_reg.c b/pjsip/src/pjsip-ua/sip_reg.c index d08427db..5278ae48 100644 --- a/pjsip/src/pjsip-ua/sip_reg.c +++ b/pjsip/src/pjsip-ua/sip_reg.c @@ -1056,7 +1056,7 @@ static void tsx_callback(void *token, pjsip_event *event) pj_lock_release(regc->lock); call_callback(regc, PJ_SUCCESS, tsx->status_code, (rdata ? &rdata->msg_info.msg->line.status.reason - : pjsip_get_status_text(tsx->status_code)), + : &tsx->status_text), rdata, expiration, contact_cnt, contact); pj_lock_acquire(regc->lock); diff --git a/pjsip/src/pjsip/sip_transaction.c b/pjsip/src/pjsip/sip_transaction.c index d10906db..f205ff5d 100644 --- a/pjsip/src/pjsip/sip_transaction.c +++ b/pjsip/src/pjsip/sip_transaction.c @@ -23,6 +23,7 @@ #include <pjsip/sip_endpoint.h> #include <pjsip/sip_errno.h> #include <pjsip/sip_event.h> +#include <pjlib-util/errno.h> #include <pj/hash.h> #include <pj/pool.h> #include <pj/os.h> @@ -1691,6 +1692,7 @@ static void send_msg_callback( pjsip_send_state *send_state, if (!*cont) { char errmsg[PJ_ERR_MSG_SIZE]; + pjsip_status_code sc; pj_str_t err; tsx->transport_err = -sent; @@ -1708,8 +1710,17 @@ static void send_msg_callback( pjsip_send_state *send_state, /* Mark that we have resolved the addresses. */ tsx->transport_flag |= TSX_HAS_RESOLVED_SERVER; + /* Server resolution error is now mapped to 502 instead of 503, + * since with 503 normally client should try again. + * See http://trac.pjsip.org/repos/ticket/870 + */ + if (-sent==PJ_ERESOLVE || -sent==PJLIB_UTIL_EDNS_NXDOMAIN) + sc = PJSIP_SC_BAD_GATEWAY; + else + sc = PJSIP_SC_TSX_TRANSPORT_ERROR; + /* Terminate transaction, if it's not already terminated. */ - tsx_set_status_code(tsx, PJSIP_SC_TSX_TRANSPORT_ERROR, &err); + tsx_set_status_code(tsx, sc, &err); if (tsx->state != PJSIP_TSX_STATE_TERMINATED && tsx->state != PJSIP_TSX_STATE_DESTROYED) { |