Added local setting that controls if channel pointer is set in emitted messages.

A channel creating call.execute message no longer looks up for user data in the waiting messages as it could result in immediate destruction.


git-svn-id: http://yate.null.ro/svn/yate/trunk@2410 acf43c95-373e-0410-b603-e72c3f656dc1
This commit is contained in:
paulc 2008-12-23 15:50:13 +00:00
parent 67178500d9
commit f51989fc1b
2 changed files with 13 additions and 5 deletions

View File

@ -204,6 +204,7 @@ disconnected (bool) - Enable or disable sending "chan.disconnected" me
reason (string) - Set the disconnect reason that gets received by the peer channel<br />
timeout (int) - Timeout in milliseconds for answering to messages<br />
timebomb (bool) - Terminate this module instance if a timeout occured<br />
setdata (bool) - Attach channel pointer as user data to generated messages<br />
reenter (bool) - If this module is allowed to handle messages generated by itself<br />
selfwatch (bool) - If this module is allowed to watch messages generated by itself<br />
restart (bool) - Restart this global module if it terminates unexpectedly. Must be turned off to allow normal termination<br />

View File

@ -250,6 +250,7 @@ private:
MsgWatcher* m_watcher;
bool m_selfWatch;
bool m_reenter;
bool m_setdata;
int m_timeout;
bool m_timebomb;
bool m_restart;
@ -680,7 +681,7 @@ ExtModReceiver::ExtModReceiver(const char* script, const char* args, File* ain,
: Mutex(true),
m_role(RoleUnknown), m_dead(false), m_use(1), m_pid(-1),
m_in(0), m_out(0), m_ain(ain), m_aout(aout),
m_chan(chan), m_watcher(0), m_selfWatch(false), m_reenter(false),
m_chan(chan), m_watcher(0), m_selfWatch(false), m_reenter(false), m_setdata(true),
m_timeout(s_timeout), m_timebomb(s_timebomb), m_restart(false),
m_script(script), m_args(args)
{
@ -697,7 +698,7 @@ ExtModReceiver::ExtModReceiver(const char* name, Stream* io, ExtModChan* chan, i
: Mutex(true),
m_role(role), m_dead(false), m_use(1), m_pid(-1),
m_in(io), m_out(io), m_ain(0), m_aout(0),
m_chan(chan), m_watcher(0), m_selfWatch(false), m_reenter(false),
m_chan(chan), m_watcher(0), m_selfWatch(false), m_reenter(false), m_setdata(true),
m_timeout(s_timeout), m_timebomb(s_timebomb), m_restart(false),
m_script(name)
{
@ -1313,6 +1314,11 @@ bool ExtModReceiver::processLine(const char* line)
val = m_reenter;
ok = true;
}
else if (id == "setdata") {
m_setdata = val.toBoolean(m_setdata);
val = m_setdata;
ok = true;
}
else if (id == "selfwatch") {
m_selfWatch = val.toBoolean(m_selfWatch);
val = m_selfWatch;
@ -1357,18 +1363,19 @@ bool ExtModReceiver::processLine(const char* line)
lock();
}
ExtModChan* chan = 0;
if ((m_role == RoleChannel) && !m_chan && (*m == "call.execute")) {
if ((m_role == RoleChannel) && !m_chan && m_setdata && (*m == "call.execute")) {
// we delayed channel creation as there was nothing to ref() it
chan = new ExtModChan(this);
m_chan = chan;
m->setParam("id",chan->id());
}
m->userData(m_chan);
if (m_setdata)
m->userData(m_chan);
// now the newly created channel is referenced by the message
if (chan)
chan->deref();
id = m->id();
if (id) {
if (id && !chan) {
// Copy the user data pointer from waiting message with same id
ObjList *p = &m_waiting;
for (; p; p=p->next()) {