Stas Bekman wrote:
yep, that closes the connection after $timeout_secs and looks to me like the right solution.
However, If I try to stop apache it exits with 'Segmentation fault' (in case a timeout occured),
seems due to the fact that the perl code haven't had a chance to clean up. Can I trap this timeout ?
I don't think you can. I think this API is not really used by anyone, hence no wonder if it causes a segfault. Can you post a backtrace?
how can I do that ? Strace with $r->server->timeout(1) :
brk(0x8a99000) = 0x8a99000
alarm(1) = 0
read(3, "------------5dcexM6YlOS1TIaELqOT"..., 4096) = 664
alarm(0) = 1
alarm(1) = 0
read(3, 0x8293b94, 4096) = ? ERESTARTSYS (To be restarted)
--- SIGALRM (Alarm clock) @ 0 (0) ---
time(NULL) = 1070572385
write(17, "127.0.0.1 - - [04/Dec/2003:23:13"..., 84) = 84
close(3) = 0
rt_sigprocmask(SIG_SETMASK, [RTMIN], NULL, 8) = 0
rt_sigaction(SIGURG, {0x401ab070, [], SA_RESTORER|SA_INTERRUPT, 0x401e06f8}, {0x401ab070, [], SA_RESTORER|SA_INTERRUPT, 0x401e06f8}, 8) = 0
rt_sigaction(SIGALRM, {0x401ab070, [], SA_RESTORER|SA_INTERRUPT, 0x401e06f8}, {0x401ab070, [], SA_RESTORER|SA_INTERRUPT, 0x401e06f8}, 8) = 0
rt_sigaction(SIGUSR1, {0x401ab070, [], SA_RESTORER|SA_INTERRUPT, 0x401e06f8}, {SIG_IGN}, 8) = 0
alarm(0) = 0
rt_sigaction(SIGALRM, {0x401ab070, [], SA_RESTORER, 0x401e06f8}, {0x401ab070, [], SA_RESTORER|SA_INTERRUPT, 0x401e06f8}, 8) = 0
accept(16,
Did you set the perl trap as well? You shouldn't if you set Apache's timeout already. Just wrap $apr->param in eval {}; in the above snippet to trap the failure.
Yep, I tried to eval $apr->request, as well as eval the whole block including the code which sets and restores the timeout
1. sub handler ($$) { my $orig_timeout = $r->server->timeout(1); eval { $apr->param }; $r->server->timeout($orig_timeout_secs); warn "-------", $@, $!; }
2. sub handler ($$) { eval { my $orig_timeout = $r->server->timeout(1); $apr->param; $r->server->timeout($orig_timeout_secs); } warn "-------", $@, $!; }
both ways do not work :(((
BTW, what happens if you set the Apache alarm to 0, does it still set it? Can you try:
my $orig_timeout = $r->server->timeout(0); $apr->param;
and then strace to see whether it sets it at all. I guess we can look at the source code, but strace is more fun ;)
all the alarms I got via strace: alarm(0) = 0 alarm(300) = 0 alarm(300) = 300 alarm(0) = 300 alarm(300) = 0 alarm(0) = 300 alarm(300) = 0
tail strace :
ead(5, "", 4096) = 0 close(5) = 0 munmap(0x40331000, 4096) = 0 brk(0x8a93000) = 0x8a93000 brk(0x8a94000) = 0x8a94000 brk(0x8a95000) = 0x8a95000 brk(0x8a96000) = 0x8a96000 read(4, "", 4096) = 0 close(4) = 0 munmap(0x40330000, 4096) = 0 brk(0x8a99000) = 0x8a99000 alarm(300) = 0 read(3, "------------5dcexM6YlOS1TIaELqOT"..., 4096) = 664 alarm(0) = 300 alarm(300) = 0 read(3, <unfinished ...>
(I pressed ctrl-c here :)
Sincerely, Alex
-- Reporting bugs: http://perl.apache.org/bugs/ Mail list info: http://perl.apache.org/maillist/modperl.html