Return-Path: Delivered-To: apmail-perl-dev-archive@www.apache.org Received: (qmail 39922 invoked from network); 8 Dec 2010 18:32:29 -0000 Received: from unknown (HELO mail.apache.org) (140.211.11.3) by 140.211.11.9 with SMTP; 8 Dec 2010 18:32:29 -0000 Received: (qmail 33850 invoked by uid 500); 8 Dec 2010 18:32:29 -0000 Delivered-To: apmail-perl-dev-archive@perl.apache.org Received: (qmail 33805 invoked by uid 500); 8 Dec 2010 18:32:28 -0000 Mailing-List: contact dev-help@perl.apache.org; run by ezmlm Precedence: bulk list-help: list-unsubscribe: List-Post: List-Id: Delivered-To: mailing list dev@perl.apache.org Received: (qmail 33798 invoked by uid 99); 8 Dec 2010 18:32:28 -0000 Received: from nike.apache.org (HELO nike.apache.org) (192.87.106.230) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 08 Dec 2010 18:32:28 +0000 X-ASF-Spam-Status: No, hits=-0.0 required=10.0 tests=SPF_PASS X-Spam-Check-By: apache.org Received-SPF: pass (nike.apache.org: domain of SteveHay@planit.com designates 213.1.249.253 as permitted sender) Received: from [213.1.249.253] (HELO mailgate.planit.com) (213.1.249.253) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 08 Dec 2010 18:32:21 +0000 Received: from mailgate.planit.com (localhost [127.0.0.1]) by mailgate.planit.com (Postfix) with ESMTP id 8B77043ED28 for ; Wed, 8 Dec 2010 18:32:00 +0000 (GMT) X-Virus-Scanned: by SpamTitan at planit.com Received: from ukmail02.planit.group (unknown [10.20.200.12]) by mailgate.planit.com (Postfix) with ESMTP id 18CFF43EC5C for ; Wed, 8 Dec 2010 18:32:00 +0000 (GMT) X-MimeOLE: Produced By Microsoft Exchange V6.5 Content-class: urn:content-classes:message MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable Subject: APR errors not working on Win32 Date: Wed, 8 Dec 2010 18:31:59 -0000 Message-ID: <1B32FF956ABF414C9BCE5E487A1497E70874ED5E@ukmail02.planit.group> X-MS-Has-Attach: X-MS-TNEF-Correlator: Thread-Topic: APR errors not working on Win32 Thread-Index: AcuXBjL+jpgc9k1sSOG0Z7flZ+TmJQ== From: "Steve Hay" To: X-Virus-Checked: Checked by ClamAV on apache.org I have some mod_perl-2 software which keeps causing the Apache server to crash, and I believe the cause of it is users pressing the Stop button in their browsers, causing the pipe to be broken, which then leads to the crash when CGI::Carp's fatalsToBrowser feature tries to send an HTML error message to the browser (... saying that data can't be sent to the client!!!). I want to catch the "broken pipe" error and simply log it in the error.log, and rethrow other exceptions (to be picked up by CGI::Carp's fatalsToBrowser), but instead of getting an APR::Error object, I'm getting a string saying "APR does not understand this error code" The following program (running via ModPerl::Registry) reproduces the problem: use strict; use warnings; BEGIN { require CGI::Carp; CGI::Carp->import(qw(fatalsToBrowser)); CGI::Carp::set_message(' '); } print "Content-Type: text/plain\n\n"; print '-' x 80, "\n" while (1); Set the program running, then press Stop in the web browser. The Apache server crashes (usually just the child exiting with status 9, and the parent spawns a new one, but occasionally the whole thing seems to abort with status 2) with this in the error.log: [Wed Dec 08 18:07:02 2010] [info] [client 10.23.100.22] (OS 10054)An existing connection was forcibly closed by the remote host. : core_output_filter: writing data to the network :Apache2 IO flush: (620018) APR does not understand this error code at -e line 0[Wed Dec 08 18:07:02 2010] [notice] Parent: child process exited with status 9 -- Restarting. If I change the last two lines of code to: my $ok =3D eval { print "Content-Type: text/plain\n\n"; print '-' x 80, "\n" while (1); }; if (not defined $ok) { if ($@) { if (ref $@) { printf STDERR "Caught an %s: %s\n", ref($@), $@; } else { printf STDERR "Caught a string: %s\n", $@; } } else { printf STDERR "Unexpected\n"; } } then it no longer crashes. The error is simply caught and logged to error.log, which now says: [Wed Dec 08 18:23:35 2010] [info] [client 10.23.100.22] (OS 10054)An existing connection was forcibly closed by the remote host. : core_output_filter: writing data to the network Caught a string: APR does not understand this error code at C:/Radview/apache/cgi-bin/problem.pl line 12. However, I want to only do that in certain cases where a useful HTML error message can't be written back to the browser, but (as seen above) $@ is a fairly useless string (not even with the "(620018)" bit that Apache normally logs) instead of the useful APR::Error object that I was hoping for. What's gone wrong here and/or is there some other way of handling this situation (which works on Win32!)? --------------------------------------------------------------------- To unsubscribe, e-mail: dev-unsubscribe@perl.apache.org For additional commands, e-mail: dev-help@perl.apache.org