Added exiting flag to know when the client GUI application exited the main loop. Drop client channels when before exiting. Don't process proxy thread if the client is exiting.
git-svn-id: http://yate.null.ro/svn/yate/trunk@2196 acf43c95-373e-0410-b603-e72c3f656dc1
This commit is contained in:
parent
68acb14679
commit
ea4a20a465
|
@ -156,6 +156,7 @@ String Client::s_toggles[OptCount] = {
|
|||
"display_keypad"
|
||||
};
|
||||
bool Client::s_idleLogicsTick = false; // Call logics' timerTick()
|
||||
bool Client::s_exiting = false; // Client exiting flag
|
||||
ClientDriver* ClientDriver::s_driver = 0;
|
||||
String ClientDriver::s_confName = "conf/client"; // The name of the client's conference room
|
||||
bool ClientDriver::s_dropConfPeer = true; // Drop a channel's old peer when terminated while in conference
|
||||
|
@ -558,7 +559,7 @@ void ClientThreadProxy::process()
|
|||
{
|
||||
XDebug(DebugAll,"ClientThreadProxy::process()"," %d [%p]",m_func,this);
|
||||
Client* client = Client::self();
|
||||
if (!client) {
|
||||
if (!client || Client::exiting()) {
|
||||
s_busy = false;
|
||||
return;
|
||||
}
|
||||
|
@ -793,6 +794,9 @@ void Client::run()
|
|||
loadUI();
|
||||
// Run
|
||||
main();
|
||||
s_exiting = true;
|
||||
// Drop all calls
|
||||
ClientDriver::dropCalls();
|
||||
// Notify termination to logics
|
||||
for (ObjList* o = s_logics.skipNull(); o; o = o->skipNext()) {
|
||||
ClientLogic* logic = static_cast<ClientLogic*>(o->get());
|
||||
|
@ -2589,9 +2593,10 @@ bool ClientDriver::received(Message& msg, int id)
|
|||
return false;
|
||||
return Client::self() && Client::self()->imExecute(msg);
|
||||
}
|
||||
if (id == Halt && Client::self()) {
|
||||
dropAll(msg);
|
||||
Client::self()->quit();
|
||||
if (id == Halt) {
|
||||
dropCalls();
|
||||
if (Client::self())
|
||||
Client::self()->quit();
|
||||
}
|
||||
return Driver::received(msg,id);
|
||||
}
|
||||
|
@ -2634,6 +2639,18 @@ ClientChannel* ClientDriver::findLine(int line)
|
|||
return 0;
|
||||
}
|
||||
|
||||
// Drop all calls belonging to the active driver
|
||||
void ClientDriver::dropCalls(const char* reason)
|
||||
{
|
||||
Message m("call.drop");
|
||||
if (!reason && Engine::exiting())
|
||||
reason = "shutdown";
|
||||
if (reason)
|
||||
m.addParam("reason",reason);
|
||||
if (self())
|
||||
self()->dropAll(m);
|
||||
}
|
||||
|
||||
// Attach/detach client channels peers' source/consumer
|
||||
bool ClientDriver::setAudioTransfer(const String& id, const String& target)
|
||||
{
|
||||
|
|
17
yatecbase.h
17
yatecbase.h
|
@ -1126,6 +1126,13 @@ public:
|
|||
*/
|
||||
virtual void engineStart(Message& msg);
|
||||
|
||||
/**
|
||||
* Check if the client is exiting
|
||||
* @return True if the client therad is exiting
|
||||
*/
|
||||
static inline bool exiting()
|
||||
{ return s_exiting; }
|
||||
|
||||
/**
|
||||
* Add a logic to the list. The added object is not owned by the client
|
||||
* @param logic Pointer to the logic to add
|
||||
|
@ -1238,6 +1245,8 @@ protected:
|
|||
static bool driverLock(long maxwait = 0);
|
||||
static void driverUnlock();
|
||||
|
||||
static bool s_exiting; // Exiting flag
|
||||
|
||||
ObjList m_windows;
|
||||
bool m_initialized;
|
||||
int m_line;
|
||||
|
@ -1531,6 +1540,12 @@ public:
|
|||
inline static const String& device()
|
||||
{ return s_device; }
|
||||
|
||||
/**
|
||||
* Drop all calls belonging to the active driver
|
||||
* @param reason Optional drop reason
|
||||
*/
|
||||
static void dropCalls(const char* reason = 0);
|
||||
|
||||
/**
|
||||
* Attach/detach client channels peers' source/consumer
|
||||
* @param id The id of the channel to tranfer
|
||||
|
@ -1561,7 +1576,7 @@ public:
|
|||
* @param peer Peer id to check
|
||||
* @return Referenced ClientChannel pointer or 0
|
||||
*/
|
||||
static ClientChannel* findChanByPeer(const String& peer);
|
||||
static ClientChannel* findChanByPeer(const String& peer);
|
||||
|
||||
/**
|
||||
* Get the active channel
|
||||
|
|
Loading…
Reference in New Issue