chicken-meisters
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Chicken-meisters] Restart of apache required


From: Felix
Subject: Re: [Chicken-meisters] Restart of apache required
Date: Wed, 11 May 2011 08:30:17 -0400 (EDT)

> 
> AFAICT, sendfile has the following idiom *everywhere* it sleeps:
> 
> (when (write-timeout)
>   (##sys#thread-block-for-timeout!
>    ##sys#current-thread
>    (+ (current-milliseconds) (write-timeout))))
> 
> Is this correct?  As far as I can see, because write-timeout is
> a parameter it should be thread-local so there should be no race
> condition between the "when" check and the block-for-timeout call.
> 
> Is it possible that after a program is running for a long time,
> current-milliseconds produces an overflow?

> Turns out this can happen, after hacking a bit:
> 
> address@hidden:~$ gdb 
> /usr/local/chickens/chicken-safer-scheduler-debug/bin/csi 
> (gdb) run
> Starting program: /usr/local/chickens/chicken-safer-scheduler-debug/bin/csi 
> 
> CHICKEN
> (c)2008-2010 The Chicken Team
> (c)2000-2007 Felix L. Winkelmann
> Version 4.6.0rc1 (safer-scheduler)
> linux-unix-gnu-x86 [ manyargs dload ptables ]
> compiled 2010-09-18 on hd-t1179cl (Linux)
> 
> #;1> ^C
> Program received signal SIGINT, Interrupt.
> 0xb7f3e424 in __kernel_vsyscall ()
> (gdb) set C_startup_time_seconds=0
> (gdb) c
> Continuing.
> (current-milliseconds)
> -559319127.0

Ugh. This is the implementation of C_milliseconds, which is used
by current-milliseconds:

    struct timeval tv;

    if(C_gettimeofday(&tv, NULL) == -1) return 0;
    else return (tv.tv_sec - C_startup_time_seconds) * 1000 + tv.tv_usec / 1000;

I think I forgot to cast to double before doing the arithmetic, right?

> 
> On the other hand, when I call current-seconds, it returns a greater
> number (is that right?) and it does go into flonum mode immediately
> on startup:
> #;2> (current-seconds)
> 1305112661.0
> 

current-seconds uses time(NULL), current-milliseconds uses
gettimeofday and returns the uptime of the process (sort of).

(btw, shouldn't discussions like this go to chicken-hackers?)


cheers,
felix



reply via email to

[Prev in Thread] Current Thread [Next in Thread]