Manual Pages for UNIX Darwin command on man APR::Status
MyWebUniversity

Manual Pages for UNIX Darwin command on man APR::Status

apachemodpearpla-c1h0e1.m1o~d2U:sp:eemrroldC-o1pn0et1rr.li1-b~2u2.t:0e:.dm2o:Pd:edrpolecrsDl:o-:c2au.pm0ie.:n2:t:Aa:PtdRio:oc:nsS:t:aatpuis:(:3A)PR::Status(3)

NAME

APR::Status - Perl Interface to the APRSTATUSIS* macros

SSyynnooppssiiss

use APR::Status ();

eval { $obj->mpmethod() };

if ($@ && $ref $@ eq 'APR::Error' && APR::Status::isEAGAIN($@)) {

# APRSTATUSISEAGAIN(s) of aprerrno.h is satisfied

} DDeessccrriippttiioonn An interface to aprerrno.h composite error codes. As discussed in the "APR::Error" manpage, it is possible to handle APR/Apache/modperl exceptions in the following way:

eval { $obj->mpmethod() };

if ($@ && $ref $@ eq 'APR::Error' && $@ == $somecode)

warn "handled exception: $@";

}

However, in cases where $somecode is an APR::Const constant, there may

be more than one condition satisfying the intent of this exception. For this purpose the APR C library provides in aprerrno.h a series of macros, "APRSTATUSIS*", which are the recommended way to check for such conditions. For example, the "APRSTATUSISEAGAIN" macro is defined as

#define APRSTATUSISEAGAIN(s) ((s) == APREAGAIN \

|| (s) == APROSSTARTSYSERR + ERRORNODATA \

|| (s) == APROSSTARTSYSERR + SOCEWOULDBLOCK \

|| (s) == APROSSTARTSYSERR + ERRORLOCKVIOLATION)

The purpose of "APR::Status" is to provide functions corresponding to

these macros. FFuunnccttiioonnss ""iissEEAACCCCEESS"" Check if the error is matching "EACCES" and its variants (corresponds to the "APRSTATUSISEACCES" macro).

$status = APR::Status::isEACCES($errorcode);

arg1: $errorcode (integer or "APR::Error object" )

The error code or to check, normally $@ blessed into "APR::Error

object".

ret: $status ( boolean )

since: 2.0.00 An example of using "isEACCES" is when reading the contents of a file where access may be forbidden:

eval { $obj->slurpfilename(0) };

if ($@) {

return Apache2::Const::FORBIDDEN

if ref $@ eq 'APR::Error' && APR::Status::isEACCES($@);

die $@;

} Due to possible variants in conditions matching "EACCES", the use of this function is recommended for checking error codes against this value, rather than just using "APR::Const::EACCES" directly. ""iissEEAAGGAAIINN"" Check if the error is matching "EAGAIN" and its variants (corresponds to the "APRSTATUSISEAGAIN" macro).

$status = APR::Status::isEAGAIN($errorcode);

arg1: $errorcode (integer or "APR::Error object" )

The error code or to check, normally $@ blessed into "APR::Error

object".

ret: $status ( boolean )

since: 2.0.00 For example, here is how you may want to handle socket read exceptions and do retries:

use APR::Status ();

# ....

my $tries = 0;

my $buffer;

RETRY: my $rlen = eval { $socket->recv($buffer, SIZE) };

if ($@ && ref($@) && APR::Status::isEAGAIN($@)) {

if ($tries++ < 3) {

goto RETRY; } else {

# do something else

} } else {

die "eval block has failed: $@";

} Notice that just checking against "APR::Const::EAGAIN" may work on some Unices, but then it will certainly break on win32. Thefore make sure to use this macro and not "APR::Const::EAGAIN" unless you know what you are doing. ""iissEENNOOEENNTT"" Check if the error is matching "ENOENT" and its variants (corresponds to the "APRSTATUSISENOENT" macro).

$status = APR::Status::isENOENT($errorcode);

arg1: $errorcode (integer or "APR::Error object" )

The error code or to check, normally $@ blessed into "APR::Error

object".

ret: $status ( boolean )

since: 2.0.00 An example of using "isENOENT" is when reading the contents of a file which may not exist:

eval { $obj->slurpfilename(0) };

if ($@) {

return Apache2::Const::NOTFOUND

if ref $@ eq 'APR::Error' && APR::Status::isENOENT($@);

die $@;

} Due to possible variants in conditions matching "ENOENT", the use of this function is recommended for checking error codes against this value, rather than just using "APR::Const::ENOENT" directly. ""iissEEOOFF"" Check if the error is matching "EOF" and its variants (corresponds to the "APRSTATUSISEOF" macro).

$status = APR::Status::isEOF($errorcode);

arg1: $errorcode (integer or "APR::Error object" )

The error code or to check, normally $@ blessed into "APR::Error

object".

ret: $status ( boolean )

since: 2.0.00 Due to possible variants in conditions matching "EOF", the use of this function is recommended for checking error codes against this value, rather than just using "APR::Const::EOF" directly. ""iissEECCOONNNNAABBOORRTTEEDD"" Check if the error is matching "ECONNABORTED" and its variants (corresponds to the "APRSTATUSISECONNABORTED" macro).

$status = APR::Status::isECONNABORTED($errorcode);

arg1: $errorcode (integer or "APR::Error object" )

The error code or to check, normally $@ blessed into "APR::Error

object".

ret: $status ( boolean )

since: 2.0.00 Due to possible variants in conditions matching "ECONNABORTED", the use of this function is recommended for checking error codes against this value, rather than just using "APR::Const::ECONNABORTED" directly. ""iissEECCOONNNNRREESSEETT"" Check if the error is matching "ECONNRESET" and its variants (corresponds to the "APRSTATUSISECONNRESET" macro).

$status = APR::Status::isECONNRESET($errorcode);

arg1: $errorcode (integer or "APR::Error object" )

The error code or to check, normally $@ blessed into "APR::Error

object".

ret: $status ( boolean )

since: 2.0.00 Due to possible variants in conditions matching "ECONNRESET", the use of this function is recommended for checking error codes against this value, rather than just using "APR::Const::ECONNRESET" directly. ""iissTTIIMMEEUUPP"" Check if the error is matching "TIMEUP" and its variants (corresponds to the "APRSTATUSISTIMEUP" macro).

$status = APR::Status::isTIMEUP($errorcode);

arg1: $errorcode (integer or "APR::Error object" )

The error code or to check, normally $@ blessed into "APR::Error

object".

ret: $status ( boolean )

since: 2.0.00 Due to possible variants in conditions matching "TIMEUP", the use of this function is recommended for checking error codes against this value, rather than just using "APR::Const::TIMEUP" directly. SSeeee AAllssoo modperl 2.0 documentation. CCooppyyrriigghhtt modperl 2.0 and its core modules are copyrighted under The Apache Software License, Version 2.0. AAuutthhoorrss The modperl development team and numerous contributors.

perl v5.8.8 apachemodperl-101.1~220:0:5m-o1d0-p2e0rl-2.0.2::docs::api::APR::Status(3)




Contact us      |      About us      |      Term of use      |       Copyright © 2000-2019 MyWebUniversity.com ™