Re: Infinite Loops

From: Dan Merillat (harik@chaos.ao.net)
Date: 05/02/00


Chris Gilbert writes:
> "Jon A. Nielsen" wrote:
> >
> > Hello,
> >
> > I'm writing to ask if anyone has devised a method to catch infinite loops in
> > the MUD' code at runtime.  Essentially, I would like to build a system into
> > the MUD by which the MUD would reboot itself in the case of an infinite
> > loop.  I have seen this done elsewhere, but I don't know how to go about
> > establishing such a system, and I imagine it would have to be an outside
> > script that would shutdown the MUD, since if the code is looping, it would
> > never reach a point outside of the loop.
>
> It's already in there, signal_setup in comm.c has the section that sets
> up a virtual timer, after 3 minutes it checks for tics=0, if it doesn't
> it sets it to 0, and then 3 minutes later checks again.  In theory the
> mud would reboot after 6 minutes at most.

If available, try using alarm() and extending it by 15 seconds every pass through
game_loop()

That way, if sigalarm ever gets raised it kills your mud.  If anything takes
more then 15 seconds to do, it's infinite.

--Dan


     +------------------------------------------------------------+
     | Ensure that you have read the CircleMUD Mailing List FAQ:  |
     |  http://qsilver.queensu.ca/~fletchra/Circle/list-faq.html  |
     +------------------------------------------------------------+



This archive was generated by hypermail 2b30 : 04/10/01 PDT