Added default initialization of billid so it can track calls.
git-svn-id: http://yate.null.ro/svn/yate/trunk@589 acf43c95-373e-0410-b603-e72c3f656dc1
This commit is contained in:
parent
7f490b5366
commit
8c8af3dad4
|
@ -27,6 +27,9 @@
|
|||
|
||||
using namespace TelEngine;
|
||||
|
||||
static unsigned int s_callid = 0;
|
||||
static Mutex s_callidMutex;
|
||||
|
||||
// this is to protect against two threads trying to (dis)connect a pair
|
||||
// of call endpoints at the same time
|
||||
static Mutex s_mutex(true);
|
||||
|
@ -250,6 +253,9 @@ void Channel::init()
|
|||
m_driver->changed();
|
||||
m_driver->unlock();
|
||||
}
|
||||
// assign a new billid only to incoming calls
|
||||
if (m_billid.null() && !m_outgoing)
|
||||
m_billid << Engine::runId() << "-" << allocId();
|
||||
DDebug(this,DebugInfo,"Channel::init() '%s' [%p]",m_id.c_str(),this);
|
||||
}
|
||||
|
||||
|
@ -281,6 +287,13 @@ void Channel::zeroRefs()
|
|||
CallEndpoint::zeroRefs();
|
||||
}
|
||||
|
||||
void Channel::connected(const char* reason)
|
||||
{
|
||||
Channel* peer = YOBJECT(Channel,getPeer());
|
||||
if (peer && peer->billid() && m_billid.null())
|
||||
m_billid = peer->billid();
|
||||
}
|
||||
|
||||
void Channel::disconnected(bool final, const char* reason)
|
||||
{
|
||||
if (final || Engine::exiting())
|
||||
|
@ -477,6 +490,13 @@ bool Channel::setDebug(Message& msg)
|
|||
return true;
|
||||
}
|
||||
|
||||
unsigned int Channel::allocId()
|
||||
{
|
||||
s_callidMutex.lock();
|
||||
unsigned int id = ++s_callid;
|
||||
s_callidMutex.unlock();
|
||||
return id;
|
||||
}
|
||||
|
||||
TokenDict Module::s_messages[] = {
|
||||
{ "engine.status", Module::Status },
|
||||
|
|
|
@ -131,11 +131,12 @@ bool s_dynplugin = false;
|
|||
int s_maxworkers = 10;
|
||||
|
||||
static bool s_sigabrt = false;
|
||||
const char* s_cfgfile = 0;
|
||||
const char* s_logfile = 0;
|
||||
Configuration s_cfg;
|
||||
ObjList plugins;
|
||||
ObjList* s_cmds = 0;
|
||||
static const char* s_cfgfile = 0;
|
||||
static const char* s_logfile = 0;
|
||||
static Configuration s_cfg;
|
||||
static ObjList plugins;
|
||||
static ObjList* s_cmds = 0;
|
||||
static unsigned int s_runid = 0;
|
||||
|
||||
class SLib : public GenObject
|
||||
{
|
||||
|
@ -478,6 +479,7 @@ int Engine::run()
|
|||
#else
|
||||
::signal(SIGPIPE,SIG_IGN);
|
||||
#endif
|
||||
s_runid = Time::secNow();
|
||||
s_cfg = configFile(s_cfgfile);
|
||||
s_cfg.load();
|
||||
Debug(DebugAll,"Engine::run()");
|
||||
|
@ -807,6 +809,11 @@ bool Engine::dispatch(const char* name)
|
|||
return s_self->m_dispatcher.dispatch(msg);
|
||||
}
|
||||
|
||||
unsigned int Engine::runId()
|
||||
{
|
||||
return s_runid;
|
||||
}
|
||||
|
||||
static void usage(bool client, FILE* f)
|
||||
{
|
||||
::fprintf(f,
|
||||
|
|
|
@ -1409,6 +1409,13 @@ YateSIPConnection::YateSIPConnection(Message& msg, const String& uri, const char
|
|||
if (hl)
|
||||
*hl = desc + *hl;
|
||||
}
|
||||
if (msg.getParam("calledname")) {
|
||||
String desc;
|
||||
desc << "\"" << msg.getValue("calledname") << "\" ";
|
||||
SIPHeaderLine* hl = const_cast<SIPHeaderLine*>(m->getHeader("To"));
|
||||
if (hl)
|
||||
*hl = desc + *hl;
|
||||
}
|
||||
if (plugin.ep()->engine()->prack())
|
||||
m->addHeader("Supported","100rel");
|
||||
m_host = m->getParty()->getPartyAddr();
|
||||
|
|
|
@ -723,6 +723,12 @@ public:
|
|||
*/
|
||||
static const Configuration& config();
|
||||
|
||||
/**
|
||||
* Get a - supposedly unique - instance ID
|
||||
* @return Unique ID of the current running instance
|
||||
*/
|
||||
static unsigned int runId();
|
||||
|
||||
/**
|
||||
* Reinitialize the plugins
|
||||
*/
|
||||
|
|
12
yatephone.h
12
yatephone.h
|
@ -1349,6 +1349,12 @@ public:
|
|||
*/
|
||||
bool startRouter(Message* msg);
|
||||
|
||||
/**
|
||||
* Allocate an unique (per engine run) call ID
|
||||
* @return Unique call ID number
|
||||
*/
|
||||
static unsigned int allocId();
|
||||
|
||||
protected:
|
||||
/**
|
||||
* Constructor
|
||||
|
@ -1377,6 +1383,12 @@ protected:
|
|||
*/
|
||||
virtual void zeroRefs();
|
||||
|
||||
/**
|
||||
* Connect notification method.
|
||||
* @param reason Text that describes connect reason.
|
||||
*/
|
||||
virtual void connected(const char* reason);
|
||||
|
||||
/**
|
||||
* Disconnect notification method.
|
||||
* @param final True if this disconnect was called from the destructor.
|
||||
|
|
Loading…
Reference in New Issue