Added an engine.stop message that modules can use to keep engine running while cleaning up.
The engine emits engine.stop every second (but at most 5 times) and shuts down only if the message returned false. git-svn-id: http://yate.null.ro/svn/yate/trunk@3381 acf43c95-373e-0410-b603-e72c3f656dc1
This commit is contained in:
parent
65c34956b5
commit
a6a00f9660
|
@ -118,6 +118,10 @@ using namespace TelEngine;
|
||||||
#define CFG_SUFFIX ".conf"
|
#define CFG_SUFFIX ".conf"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
// Maximum number of engine.stop messages we allow
|
||||||
|
#ifndef MAX_STOP
|
||||||
|
#define MAX_STOP 5
|
||||||
|
#endif
|
||||||
|
|
||||||
// Supervisor control constants
|
// Supervisor control constants
|
||||||
|
|
||||||
|
@ -1066,7 +1070,8 @@ int Engine::run()
|
||||||
#endif
|
#endif
|
||||||
Output("Yate%s engine is initialized and starting up%s%s",
|
Output("Yate%s engine is initialized and starting up%s%s",
|
||||||
clientMode() ? " client" : "",s_node.null() ? "" : " on " ,s_node.safe());
|
clientMode() ? " client" : "",s_node.null() ? "" : " on " ,s_node.safe());
|
||||||
while (s_haltcode == -1) {
|
int stops = MAX_STOP;
|
||||||
|
while (s_haltcode == -1 || ((--stops >= 0) && dispatch("engine.stop"))) {
|
||||||
if (s_cmds) {
|
if (s_cmds) {
|
||||||
Output("Executing initial commands");
|
Output("Executing initial commands");
|
||||||
for (ObjList* c = s_cmds->skipNull(); c; c=c->skipNext()) {
|
for (ObjList* c = s_cmds->skipNull(); c; c=c->skipNext()) {
|
||||||
|
@ -1136,13 +1141,15 @@ int Engine::run()
|
||||||
m->addParam("time",String((int)m->msgTime().sec()));
|
m->addParam("time",String((int)m->msgTime().sec()));
|
||||||
if (nodeName())
|
if (nodeName())
|
||||||
m->addParam("nodename",nodeName());
|
m->addParam("nodename",nodeName());
|
||||||
// Try to fine tune the ticker
|
if (s_haltcode == -1) {
|
||||||
t = (long)(m->msgTime().usec() % 1000000);
|
// Try to fine tune the ticker unless exiting
|
||||||
if (t > 500000)
|
t = (long)(m->msgTime().usec() % 1000000);
|
||||||
corr -= (1000000-t)/10;
|
if (t > 500000)
|
||||||
else
|
corr -= (1000000-t)/10;
|
||||||
corr += t/10;
|
else
|
||||||
XDebug(DebugAll,"Adjustment at %ld, corr %ld",t,corr);
|
corr += t/10;
|
||||||
|
XDebug(DebugAll,"Adjustment at %ld, corr %ld",t,corr);
|
||||||
|
}
|
||||||
enqueue(m);
|
enqueue(m);
|
||||||
Thread::yield();
|
Thread::yield();
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue