Jump to content

A monitor thread in mangosd?


Guest rilex

Recommended Posts

Is there a thread in mangosd that make sure it is still running? I'm trying to look into adding Windows Service support back to mangosd, as right now it is effectively broken since you cannot gracefully stop mangosd.

If there is a thread that says "while not shutting down, do nothing (or, run a select query from our db, etc.)", support for stopping the service can probably be entered back in.

Link to comment
Share on other sites

  • 2 weeks later...
Ok, I must be blind. Where is the loop?

src/mangosd/Master.cpp:

    void run(void)
   {   
       if(!_delaytime)
           return;
       sLog.outString("Starting up anti-freeze thread (%u seconds max stuck time)...",_delaytime/1000);
       m_loops = 0;
       w_loops = 0;
       m_lastchange = 0;
       w_lastchange = 0;
       while(!World::IsStopped())
       {
           ZThread::Thread::sleep(1000);
           uint32 curtime = getMSTime();
           // normal work
           if(w_loops != World::m_worldLoopCounter)
           {
               w_lastchange = curtime;
               w_loops = World::m_worldLoopCounter;
           }
           // possible freeze
           else if(getMSTimeDiff(w_lastchange,curtime) > _delaytime)
           {
               sLog.outError("World Thread hangs, kicking out server!");
               *((uint32 volatile*)NULL) = 0;                       // bang crash
           }
       }
       sLog.outString("Anti-freeze thread exiting without problems.");
   }  

Link to comment
Share on other sites

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue. Privacy Policy Terms of Use