adds possibility to set UDP receive buffer size in config.

this can give the server some room for processing SIP messages in load spikes.
Obviously that can not help against constant overload though...


git-svn-id: http://svn.berlios.de/svnroot/repos/sems/trunk@1786 8eb893ce-cfd4-0310-b710-fb5ebe64c474
sayer/1.4-spce2.6
Stefan Sayer 16 years ago
parent 446ff886ba
commit 972283ff66

@ -57,6 +57,7 @@ unsigned int SipCtrlInterface::outbound_port = 0;
bool SipCtrlInterface::accept_fr_without_totag = false;
int SipCtrlInterface::log_raw_messages = 3;
bool SipCtrlInterface::log_parsed_messages = true;
int SipCtrlInterface::udp_rcvbuf = -1;
int SipCtrlInterface::load()
{
@ -103,6 +104,16 @@ int SipCtrlInterface::load()
DBG("log_parsed_messages = %s\n",
log_parsed_messages?"yes":"no");
if (cfg.hasParameter("udp_rcvbuf")) {
unsigned int config_udp_rcvbuf = -1;
if (str2i(cfg.getParameter("udp_rcvbuf"), config_udp_rcvbuf)) {
ERROR("invalid value specified for udp_rcvbuf\n");
return false;
}
udp_rcvbuf = config_udp_rcvbuf;
DBG("sipctrl: udp_rcvbuf = %d\n", udp_rcvbuf);
}
} else {
DBG("assuming SIP default settings.\n");
}

@ -62,6 +62,7 @@ public:
static bool log_parsed_messages;
static int log_raw_messages;
static bool accept_fr_without_totag;
static int udp_rcvbuf;
SipCtrlInterface();
~SipCtrlInterface(){}

@ -360,3 +360,31 @@ use_default_signature=yes
# default: error
#
# unhandled_reply_loglevel=info
############################################################
# SIP stack settings
# default settings (i.e. leave out) for these should be OK
# for most applications
#
# Log raw messages? [no|debug|info|warn|error]
#
# Default: debug
#
#log_raw_messages=no
#
# Log parsed received messages? [yes|no]
#
# Default: yes
#
#log_parsed_messages=no
# SIP UDP socket receive buffer size (in bytes)
#
# if not set, system default is used (which usually
# is modest). set sytem wide upper limit with
# e.g. sysctl -w net.core.rmem_max=8388608
#
# udp_rcvbuf = <value>

@ -222,6 +222,30 @@ int udp_trsp::bind(const string& address, unsigned short port)
return -1;
}
if (SipCtrlInterface::udp_rcvbuf > 0) {
DBG("trying to set SIP UDP socket buffer to %d\n",
SipCtrlInterface::udp_rcvbuf);
if(setsockopt(sd, SOL_SOCKET, SO_RCVBUF,
(void*)&SipCtrlInterface::udp_rcvbuf,
sizeof (SipCtrlInterface::udp_rcvbuf)) == -1) {
WARN("could not set SIP UDP socket buffer: '%s'\n",
strerror(errno));
} else {
socklen_t optlen;
int set_rcvbuf_size=0;
if (getsockopt(sd, SOL_SOCKET, SO_RCVBUF,
&set_rcvbuf_size, &optlen) == -1) {
WARN("could not read back SIP UDP socket buffer length: '%s'\n",
strerror(errno));
} else {
if (set_rcvbuf_size != SipCtrlInterface::udp_rcvbuf) {
WARN("failed to set SIP UDP RCVBUF size (wanted %d, got %d)\n",
SipCtrlInterface::udp_rcvbuf, set_rcvbuf_size);
}
}
}
}
local_port = port;
local_ip = address;

Loading…
Cancel
Save