Re: [Speedycgi-users] alarm function does not seem to work
Brought to you by:
samh
From: Sam H. <sa...@da...> - 2002-03-30 05:48:16
|
Here's a patch against 2.11 to fix it. The problem is that the frontend blocks sigalarms, but fails to unblock them after forking the backend. This patch just adds a cleanup after the fork. *** src/speedy_frontend.c.orig Mon Mar 19 14:53:05 2001 --- src/speedy_frontend.c Fri Mar 29 21:40:22 2002 *************** *** 76,81 **** --- 76,84 ---- } } else { /* Child */ + static void sig_handler_teardown(); + + sig_handler_teardown(); /* Fork */ pid = fork(); > Subject: alarm function does not seem to work > <TOP> > Greetings, > > I have been successfully using your Speedy CGI module for quite > some time now, Thanks! However, I can not get Perl's "alarm" function to > work (doesn't ever time out and raise exception). Exact same code works fine > under normal CGI. For some strange reason, it seems to work with the "sleep" > function. I have included below a sample program that always times out > with normal CGI, but ALWAYS completese successfully (but should time out) > when using Speedy. Please advise by replying to this email. > > > Thanks in advance! > > > Jim Turner > jim...@lm... > > ============================================================================ > #!/applocal/bin/speedy > > print "Content-type: text/html\nWindow-target: _parent", "\n\n"; > use lib '.'; > use CGI ':standard'; > eval 'use CGI::SpeedyCGI; 1'; > > $runtype = 'NORMAL CGI'; > ++$runcnt; > eval {$sp_query = CGI::SpeedyCGI->new; $runtype = 'SPEEDY' if ($sp_query->i_am_speedy);}; > > sub setAlarm > { > die "timeout"; > } > > > $SIG{ALRM} = \&setAlarm; > > print "<BR>BEFORE time=".scalar(localtime); > alarm(1); > > eval > { > for ($i=0;$i<=1999999;$i++) #LONG-RUNNING LOOP! > { > } > }; > print "<BR> AFTER time=".scalar(localtime); > > print "<BR>PID=$$ cnt=$runcnt= i=$i= runtype=$runtype Error code =$@=\n"; > if ($@ =~ /timeout/) > { > print "<BR>--- TIMED OUT!\n"; > } > else > { > print "<BR>Success!\n"; > } > alarm(0); > ============================================================================ > > > > > . > > _______________________________________________ > Speedycgi-users mailing list > Spe...@li... > https://lists.sourceforge.net/lists/listinfo/speedycgi-users |