From 63f87d112dc56a775debb2034501f6e7aaeae2a8 Mon Sep 17 00:00:00 2001 From: Olle Johansson Date: Wed, 15 Nov 2006 15:25:50 +0000 Subject: [PATCH] Send error message when we can't allocate SIP dialog, possibly due to limitation of file descriptors. (imported from 1.2) git-svn-id: https://origsvn.digium.com/svn/asterisk/branches/1.4@47656 65c4cc65-6c06-0410-ace0-fbb531ad65f3 --- channels/chan_sip.c | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/channels/chan_sip.c b/channels/chan_sip.c index a8b8353fab..6b1265d3fc 100644 --- a/channels/chan_sip.c +++ b/channels/chan_sip.c @@ -4306,9 +4306,22 @@ static struct sip_pvt *find_call(struct sip_request *req, struct sockaddr_in *si transmit_response_using_temp(callid, sin, 1, intended_method, req, "489 Bad event"); } else { /* Ok, time to create a new SIP dialog object, a pvt */ - if ((p = sip_alloc(callid, sin, 1, intended_method))) + if ((p = sip_alloc(callid, sin, 1, intended_method))) { /* Ok, we've created a dialog, let's go and process it */ ast_mutex_lock(&p->lock); + } else { + /* We have a memory or file/socket error (can't allocate RTP sockets or something) so we're not + getting a dialog from sip_alloc. + + Without a dialog we can't retransmit and handle ACKs and all that, but at least + send an error message. + + Sorry, we apologize for the inconvienience + */ + transmit_response_using_temp(callid, sin, 1, intended_method, req, "500 Server internal error"); + if (option_debug > 3) + ast_log(LOG_DEBUG, "Failed allocating SIP dialog, sending 500 Server internal error and giving up\n"); + } } return p; } else if( sip_methods[intended_method].can_create == CAN_CREATE_DIALOG_UNSUPPORTED_METHOD) {