Re: [LONG]Strange Loop

From: Chris Gilbert (chris@buzzbee.freeserve.co.uk)
Date: 05/20/00


Benjamin Draper wrote:
[snip]
>     /* Go to sleep */
>     do {
>       circle_sleep(&timeout);
>       gettimeofday(&now, (struct timezone *) 0);
>       timediff(&timeout, &last_time, &now);
>       log("last_time : tv_sec = %ld, tv_usec = %ld", last_time.tv_sec,
> last_time.tv_usec);
>       log("now       : tv_sec = %ld, tv_usec = %ld", now.tv_sec,
> now.tv_usec);
>       log("timeout   : tv_sec = %ld, tv_usec = %ld", timeout.tv_sec,
> timeout.tv_usec);
>     } while (timeout.tv_usec || timeout.tv_sec);
>
>     log("out of sleep");
>
>  Not having another shell account on another machine I don't have a
> syslog of a 'normal' connection, so the log below could be nothing out
> of the ordinary.
>
> May 20 08:35:44 :: Entering game loop.
> May 20 08:35:44 :: No connections.  Going to sleep.
> May 20 08:35:46 :: New connection.  Waking up.
> May 20 08:35:46 :: last_time : tv_sec = 958826146, tv_usec = 527391
> May 20 08:35:46 :: now       : tv_sec = 958826146, tv_usec = 533526
> May 20 08:35:46 :: timeout   : tv_sec = 0, tv_usec = 0
> May 20 08:35:46 :: out of sleep
> May 20 08:35:46 :: end of while(!circle_shutdown)
> May 20 08:35:46 :: last_time : tv_sec = 958826146, tv_usec = 627391
> May 20 08:35:46 :: now       : tv_sec = 958826146, tv_usec = 643314
> May 20 08:35:46 :: timeout   : tv_sec = 21293477, tv_usec = 160000
> May 20 08:35:46 :: last_time : tv_sec = 958826146, tv_usec = 627391
> May 20 08:35:46 :: now       : tv_sec = 958826146, tv_usec = 644787
> May 20 08:35:46 :: timeout   : tv_sec = 21293477, tv_usec = 160000
> May 20 08:35:46 :: last_time : tv_sec = 958826146, tv_usec = 627391
> *** infinite loop ***

[snip]

I suspect that the problem lies in nulltime not being cleared at some
point, if you check in timediff, nulltime is used for the case where a <
b (and so returns 0, 0 as in the first case)  Nulltime could also become
undefined if select returns an error... (or so the man page on linux
says...)  But it should be cleared at the top of every loop.

I'd suggest comparing your usage of nulltime with that of stock
circlemud.  and your implementation of timediff...

Another possibility is that something is overruning, and runs into
nulltime and trashes the values.  if it's reproducable, I'd suggest
using a debugger and watching for any alteration of the contents of
nulltime (this varies from one debugger to another)   I'd also suggest
doing it on your home computer as it's very cpu intensive as it checks
for an alteration after every instruction, ie it does step -i, checks
value, step -i etc...  This should show when/where he value is being
updated.

You could also try putting a break point before that loop and check the
value of nulltime, or make it output the value of nulltime...

Cheers,
Chris


     +------------------------------------------------------------+
     | 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