in reply to Odd bug - Sleep 1 cures CGI proxy issue - But Why???

This smells like a unix issue with usleep.

The perl Time::HiRes module is implemented over the unix usleep function, which uses the real-time timer of the process. Each unix process has only one real-time timer. Now, what happens is that if Apache server has already setup the real-time timer for the cgi process, subsequent calls in the perl script to usleep will have no effect.

Have you timed the usleep function to see if it has really suspended the process by 2 seconds?
  • Comment on Re: Odd bug - Sleep 1 cures CGI proxy issue - But Why???

Replies are listed 'Best First'.
Re: Re: Odd bug - Sleep 1 cures CGI proxy issue - But Why???
by sgifford (Prior) on Sep 06, 2003 at 03:09 UTC

    If that's the problem, select(undef,undef,undef,2) is a good alternative.

    Another possibility is that the delivery of the ALRM signal is what's fixing the problem. Maybe kill $$,'CONT' will achieve the same thing without the pause.

    Not that either of these is a good long-term solution, but knowing that one fixes the problem and one doesn't might help point you to why it's getting stuck.

Re: Re: Odd bug - Sleep 1 cures CGI proxy issue - But Why???
by Anonymous Monk on Sep 08, 2003 at 12:05 UTC
    usleep is microseconds, not milliseconds, so it's really 0.002 sec