From: Kevin P. Fleming Date: Fri, 14 Oct 2005 01:14:29 +0000 (+0000) Subject: make chan_sip able to deal with PBX-level call limit being reached (issue #5131) X-Git-Tag: 1.2.0-beta2~133 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=4d1506e64d8d9a84db0dabd36f301bc6db286811;p=thirdparty%2Fasterisk.git make chan_sip able to deal with PBX-level call limit being reached (issue #5131) git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@6788 65c4cc65-6c06-0410-ace0-fbb531ad65f3 --- diff --git a/channels/chan_sip.c b/channels/chan_sip.c index fee4848bb0..3f338cfc54 100755 --- a/channels/chan_sip.c +++ b/channels/chan_sip.c @@ -10344,17 +10344,37 @@ static int handle_request_invite(struct sip_pvt *p, struct sip_request *req, int transmit_response(p, "100 Trying", req); ast_setstate(c, AST_STATE_RING); if (strcmp(p->exten, ast_pickup_ext())) { - if (ast_pbx_start(c)) { + enum ast_pbx_result res; + + res = ast_pbx_start(c); + + switch (res) { + case AST_PBX_FAILED: + ast_log(LOG_WARNING, "Failed to start PBX :(\n"); + if (ignore) + transmit_response(p, "503 Unavailable", req); + else + transmit_response_reliable(p, "503 Unavailable", req, 1); + break; + case AST_PBX_CALL_LIMIT: + ast_log(LOG_WARNING, "Failed to start PBX (call limit reached) \n"); + if (ignore) + transmit_response(p, "480 Temporarily Unavailable", req); + else + transmit_response_reliable(p, "480 Temporarily Unavailable", req, 1); + break; + case AST_PBX_SUCCESS: + /* nothing to do */ + break; + } + + if (res) { ast_log(LOG_WARNING, "Failed to start PBX :(\n"); /* Unlock locks so ast_hangup can do its magic */ ast_mutex_unlock(&c->lock); ast_mutex_unlock(&p->lock); ast_hangup(c); ast_mutex_lock(&p->lock); - if (ignore) - transmit_response(p, "503 Unavailable", req); - else - transmit_response_reliable(p, "503 Unavailable", req, 1); c = NULL; } } else {