On Sep 13, 2012, at 3:42 PM, jmrhide-p...@yahoo.com wrote:

> Hi, and thanks for volunteering to help!
> 
> 
> I installed the following script last year and it seemed to be working fine. 
> Yesterday, however, my hosting service took down my site because the script 
> was 
> tying up so much of their server resources that it was a threat to their 
> business. One of the folks I talked to there said he thought it was starting 
> multiple copies of itself that were never terminated. The logs didn't show 
> the 
> script being accessed more than a few times a day on average.
> 
> I would appreciate help debugging this thing:
> 
> ****************************************************************************************************************************


> 
> # NEXT QUESTION
> 
> if ($answer or $restart) { # AVOID CHANGING $lastnum FOR WRONG ANSWER
> if ($playlevel < 1) {
>    while (1) {
>        $termnum[0] = int(rand($defnum));
>        last unless ($termnum[0] == $lastnum);
>        }
>    $lastnum = $termnum[0];

You have a number of these while(1) loops, which, if something goes wrong, can 
loop forever. For example, in the loop above, if $defnum is zero or one and 
$lastnum is zero, the loop might not terminate (I am not sure exactly what 
rand(0) returns). Perhaps your data file is corrupted and is causing one of 
these loops to go into an infinite loop. I doubt that the program is spawning 
multiple copies, but if every copy started by a CGI call hangs around forever, 
it might look like it.

You are going to have to try debugging this on some development system. 
Debugging CGI programs is difficult. You might want to print debugging 
statements to a log file.



--
To unsubscribe, e-mail: beginners-unsubscr...@perl.org
For additional commands, e-mail: beginners-h...@perl.org
http://learn.perl.org/


Reply via email to