Performance improvments suggested by Allan Sandfeld:
Change order of transaction to match most recent ones first. Don't wait in select in SIP channel if we had events last loop. git-svn-id: http://voip.null.ro/svn/yate@1631 acf43c95-373e-0410-b603-e72c3f656dc1
This commit is contained in:
parent
10862f1edf
commit
25dbed9cde
|
@ -126,7 +126,13 @@ SIPTransaction::SIPTransaction(const SIPTransaction& original, const String& tag
|
|||
if (m_firstMessage)
|
||||
m_firstMessage->ref();
|
||||
|
||||
#ifdef SIP_PRESERVE_TRANSACTION_ORDER
|
||||
// new transactions at the end, preserve "natural" order
|
||||
m_engine->TransList.append(this);
|
||||
#else
|
||||
// put new transactions first - faster to match new messages
|
||||
m_engine->TransList.insert(this);
|
||||
#endif
|
||||
}
|
||||
|
||||
SIPTransaction::~SIPTransaction()
|
||||
|
|
|
@ -517,6 +517,7 @@ static Configuration s_cfg;
|
|||
static String s_realm = "Yate";
|
||||
static String s_audio = "alaw,mulaw";
|
||||
static String s_rtpip;
|
||||
static int s_floodEvents = 20;
|
||||
static int s_maxForwards = 20;
|
||||
static int s_nat_refresh = 25;
|
||||
static bool s_privacy = false;
|
||||
|
@ -1350,14 +1351,26 @@ void YateSIPEndPoint::run()
|
|||
{
|
||||
struct timeval tv;
|
||||
char buf[1500];
|
||||
/* Watch stdin (fd 0) to see when it has input. */
|
||||
int evCount = 0;
|
||||
|
||||
for (;;)
|
||||
{
|
||||
/* Wait up to 5000 microseconds. */
|
||||
tv.tv_sec = 0;
|
||||
tv.tv_usec = 5000;
|
||||
bool ok = false;
|
||||
m_sock->select(&ok,0,0,&tv);
|
||||
if ((s_floodEvents <= 1) || (evCount < s_floodEvents))
|
||||
ok = true;
|
||||
else if (evCount == s_floodEvents)
|
||||
Debug(&plugin,DebugMild,"Flood detected: %d handled events",evCount);
|
||||
else if ((evCount % s_floodEvents) == 0)
|
||||
Debug(&plugin,DebugWarn,"Severe flood detected: %d events",evCount);
|
||||
// in any case, try to read a packet now and then to keep up
|
||||
ok = ok || ((evCount & 3) == 0);
|
||||
if (ok) {
|
||||
// wait up to 5000 microseconds if we had no events in last run
|
||||
tv.tv_sec = 0;
|
||||
tv.tv_usec = (evCount <= 0) ? 5000 : 0;
|
||||
ok = false;
|
||||
m_sock->select(&ok,0,0,&tv);
|
||||
}
|
||||
if (ok)
|
||||
{
|
||||
// we can read the data
|
||||
|
@ -1387,6 +1400,10 @@ void YateSIPEndPoint::run()
|
|||
else
|
||||
Thread::check();
|
||||
SIPEvent* e = m_engine->getEvent();
|
||||
if (e)
|
||||
evCount++;
|
||||
else
|
||||
evCount = 0;
|
||||
// hack: use a loop so we can use break and continue
|
||||
for (; e; m_engine->processEvent(e),e = 0) {
|
||||
if (!e->getTransaction())
|
||||
|
@ -4150,6 +4167,7 @@ void SIPDriver::initialize()
|
|||
s_cfg.load();
|
||||
s_realm = s_cfg.getValue("general","realm","Yate");
|
||||
s_maxForwards = s_cfg.getIntValue("general","maxforwards",20);
|
||||
s_floodEvents = s_cfg.getIntValue("general","floodevents",20);
|
||||
s_privacy = s_cfg.getBoolValue("general","privacy");
|
||||
s_auto_nat = s_cfg.getBoolValue("general","nat",true);
|
||||
s_progress = s_cfg.getBoolValue("general","progress",false);
|
||||
|
|
Loading…
Reference in New Issue