📄 status.pm
字号:
# # /*# * *********** WARNING **************# * This file generated by ModPerl::WrapXS/0.01# * Any changes made here will be lost# * ***********************************# * 01: lib/ModPerl/Code.pm:708# * 02: lib/ModPerl/WrapXS.pm:624# * 03: lib/ModPerl/WrapXS.pm:1173# * 04: Makefile.PL:423# * 05: Makefile.PL:325# * 06: Makefile.PL:56# */# package APR::Status;use strict;use warnings FATAL => 'all';use APR ();use APR::XSLoader ();our $VERSION = '0.009000';APR::XSLoader::load __PACKAGE__;1;__END__=head1 NAMEAPR::Status - Perl Interface to the APR_STATUS_IS_* macros=head1 Synopsis use APR::Status (); eval { $obj->mp_method() }; if ($@ && $ref $@ eq 'APR::Error' && APR::Status::is_EAGAIN($@)) { # APR_STATUS_IS_EAGAIN(s) of apr_errno.h is satisfied }=head1 DescriptionAn interface to F<apr_errno.h> composite error codes.As discussed in the C<L<APR::Error|docs::2.0::api::APR::Error>>manpage, it is possible to handle APR/Apache/mod_perl exceptions inthe following way: eval { $obj->mp_method() }; if ($@ && $ref $@ eq 'APR::Error' && $@ == $some_code) warn "handled exception: $@"; }However, in cases where C<$some_code> is an L<APR::Constconstant|docs::2.0::api::APR::Const>, there may be more than onecondition satisfying the intent of this exception. For this purposethe APR C library provides in F<apr_errno.h> a series of macros,C<APR_STATUS_IS_*>, which are the recommended way to check for suchconditions. For example, the C<APR_STATUS_IS_EAGAIN> macro is definedas #define APR_STATUS_IS_EAGAIN(s) ((s) == APR_EAGAIN \ || (s) == APR_OS_START_SYSERR + ERROR_NO_DATA \ || (s) == APR_OS_START_SYSERR + SOCEWOULDBLOCK \ || (s) == APR_OS_START_SYSERR + ERROR_LOCK_VIOLATION)The purpose of C<APR::Status> is to provide functions correspondingto these macros.=head1 Functions=head2 C<is_EACCES>Check if the error is matching C<EACCES> and its variants (correspondsto the C<APR_STATUS_IS_EACCES> macro). $status = APR::Status::is_EACCES($error_code);=over 4=item arg1: C<$error_code> (integer or C<L<APR::Errorobject|docs::2.0::api::APR::Error>> )The error code or to check, normally C<$@> blessed into C<L<APR::Errorobject|docs::2.0::api::APR::Error>>.=item ret: C<$status> ( boolean )=item since: 2.0.00=backAn example of using C<is_EACCES> is when reading the contents of afile where access may be forbidden: eval { $obj->slurp_filename(0) }; if ($@) { return Apache2::Const::FORBIDDEN if ref $@ eq 'APR::Error' && APR::Status::is_EACCES($@); die $@; }Due to possible variants in conditions matching C<EACCES>,the use of this function is recommended for checking error codesagainst this value, rather than just usingC<L<APR::Const::EACCES|docs::2.0::api::APR::Const/C_APR__Const__EACCES_>>directly.=head2 C<is_EAGAIN>Check if the error is matching C<EAGAIN> and its variants (correspondsto the C<APR_STATUS_IS_EAGAIN> macro). $status = APR::Status::is_EAGAIN($error_code);=over 4=item arg1: C<$error_code> (integer or C<L<APR::Errorobject|docs::2.0::api::APR::Error>> )The error code or to check, normally C<$@> blessed into C<L<APR::Errorobject|docs::2.0::api::APR::Error>>.=item ret: C<$status> ( boolean )=item since: 2.0.00=backFor example, here is how you may want to handle socket read exceptionsand do retries: use APR::Status (); # .... my $tries = 0; my $buffer; RETRY: my $rlen = eval { $socket->recv($buffer, SIZE) }; if ($@ && ref($@) && APR::Status::is_EAGAIN($@)) { if ($tries++ < 3) { goto RETRY; } else { # do something else } } else { die "eval block has failed: $@"; }Notice that just checking againstC<L<APR::Const::EAGAIN|docs::2.0::api::APR::Const/C_APR__Const__EAGAIN_>>may work on some Unices, but then it will certainly break onwin32. Thefore make sure to use this macro and notC<APR::Const::EAGAIN> unless you know what you are doing.=head2 C<is_ENOENT>Check if the error is matching C<ENOENT> and its variants (correspondsto the C<APR_STATUS_IS_ENOENT> macro). $status = APR::Status::is_ENOENT($error_code);=over 4=item arg1: C<$error_code> (integer or C<L<APR::Errorobject|docs::2.0::api::APR::Error>> )The error code or to check, normally C<$@> blessed into C<L<APR::Errorobject|docs::2.0::api::APR::Error>>.=item ret: C<$status> ( boolean )=item since: 2.0.00=backAn example of using C<is_ENOENT> is when reading the contents of afile which may not exist: eval { $obj->slurp_filename(0) }; if ($@) { return Apache2::Const::NOT_FOUND if ref $@ eq 'APR::Error' && APR::Status::is_ENOENT($@); die $@; }Due to possible variants in conditions matching C<ENOENT>,the use of this function is recommended for checking error codesagainst this value, rather than just usingC<L<APR::Const::ENOENT|docs::2.0::api::APR::Const/C_APR__Const__ENOENT_>>directly.=head2 C<is_EOF>Check if the error is matching C<EOF> and its variants (correspondsto the C<APR_STATUS_IS_EOF> macro). $status = APR::Status::is_EOF($error_code);=over 4=item arg1: C<$error_code> (integer or C<L<APR::Errorobject|docs::2.0::api::APR::Error>> )The error code or to check, normally C<$@> blessed into C<L<APR::Errorobject|docs::2.0::api::APR::Error>>.=item ret: C<$status> ( boolean )=item since: 2.0.00=backDue to possible variants in conditions matching C<EOF>,the use of this function is recommended for checking error codesagainst this value, rather than just usingC<L<APR::Const::EOF|docs::2.0::api::APR::Const/C_APR__Const__EOF_>>directly.=head2 C<is_ECONNABORTED>Check if the error is matching C<ECONNABORTED> and its variants (correspondsto the C<APR_STATUS_IS_ECONNABORTED> macro). $status = APR::Status::is_ECONNABORTED($error_code);=over 4=item arg1: C<$error_code> (integer or C<L<APR::Errorobject|docs::2.0::api::APR::Error>> )The error code or to check, normally C<$@> blessed into C<L<APR::Errorobject|docs::2.0::api::APR::Error>>.=item ret: C<$status> ( boolean )=item since: 2.0.00=backDue to possible variants in conditions matching C<ECONNABORTED>,the use of this function is recommended for checking error codesagainst this value, rather than just usingC<L<APR::Const::ECONNABORTED|docs::2.0::api::APR::Const/C_APR__Const__ECONNABORTED_>> directly.=head2 C<is_ECONNRESET>Check if the error is matching C<ECONNRESET> and its variants(corresponds to the C<APR_STATUS_IS_ECONNRESET> macro). $status = APR::Status::is_ECONNRESET($error_code);=over 4=item arg1: C<$error_code> (integer or C<L<APR::Errorobject|docs::2.0::api::APR::Error>> )The error code or to check, normally C<$@> blessed into C<L<APR::Errorobject|docs::2.0::api::APR::Error>>.=item ret: C<$status> ( boolean )=item since: 2.0.00=backDue to possible variants in conditions matching C<ECONNRESET>, the useof this function is recommended for checking error codes against thisvalue, rather than just usingC<L<APR::Const::ECONNRESET|docs::2.0::api::APR::Const/C_APR__Const__ECONNRESET_>>directly.=head2 C<is_TIMEUP>Check if the error is matching C<TIMEUP> and its variants (correspondsto the C<APR_STATUS_IS_TIMEUP> macro). $status = APR::Status::is_TIMEUP($error_code);=over 4=item arg1: C<$error_code> (integer or C<L<APR::Errorobject|docs::2.0::api::APR::Error>> )The error code or to check, normally C<$@> blessed into C<L<APR::Errorobject|docs::2.0::api::APR::Error>>.=item ret: C<$status> ( boolean )=item since: 2.0.00=backDue to possible variants in conditions matching C<TIMEUP>,the use of this function is recommended for checking error codesagainst this value, rather than just usingC<L<APR::Const::TIMEUP|docs::2.0::api::APR::Const/C_APR__Const__TIMEUP_>>directly.=head1 See AlsoL<mod_perl 2.0 documentation|docs::2.0::index>.=head1 Copyrightmod_perl 2.0 and its core modules are copyrighted underThe Apache Software License, Version 2.0.=head1 AuthorsL<The mod_perl development team and numerouscontributors|about::contributors::people>.=cut
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -