> Hey all. No im not asking for long range debugging on this one ;)
>
> Ok, heres the problem, somewhere, sometime, some command is
> going into a
> loop. (almost certin its a command, due
> to the fact i have 3 test ports running, both have been up
> for 72+ hours)
>
> First, is there any way to detect a loop and stop it before
> it happens? Second, is there an easy way to log everything
> short of #ifdef DEBUG in
> every function? (I knew i should
> of done this from the start)
>
> Third: Any other option avaible to me? =)
>
> -Thri
You could use alarm() and signal() to catch a loop.
Psuedo-code:
1) interp.c
char last_command[MIL];
in interpret() add:
strcpy(last_command, logline);
2) comm.c
add:
void sigalarm(int sig)
{
time_t tm;
extern char last_command[MIL];
time(&tm);
if((tm - current_time) > (60 * 2)) /* nothing for 2 minutes */
{
log_string("Mud inresponsive for 2 minutes, performing
reboot.");
logf("Last command: %s", last_command);
/*
Use copyover if you want instead
do_copyover(NULL, "");
*/
exit(1);
}
alarm(60 * 2);
}
and in main or the top of game_loop_xxx add:
signal(SIGALRM, sigalarm);
might help.
Markanth <[EMAIL PROTECTED]>