Author: jkaluza Date: Fri May 29 05:01:01 2015 New Revision: 1682366 URL: http://svn.apache.org/r1682366 Log: Add MP_*_CROAK_*_PUTBACK macros to call modperl_croak and also putback the interpreter if possible. Use them in modperl_filter related code.
Modified: perl/modperl/trunk/src/modules/perl/modperl_error.h perl/modperl/trunk/src/modules/perl/modperl_filter.c Modified: perl/modperl/trunk/src/modules/perl/modperl_error.h URL: http://svn.apache.org/viewvc/perl/modperl/trunk/src/modules/perl/modperl_error.h?rev=1682366&r1=1682365&r2=1682366&view=diff ============================================================================== --- perl/modperl/trunk/src/modules/perl/modperl_error.h (original) +++ perl/modperl/trunk/src/modules/perl/modperl_error.h Fri May 29 05:01:01 2015 @@ -37,6 +37,20 @@ char *modperl_error_strerror(pTHX_ apr_s void modperl_croak(pTHX_ apr_status_t rc, const char* func); +#define MP_PUTBACK_IF_USED() STMT_START \ + { \ + modperl_interp_t *interp = modperl_thx_interp_get(aTHX); \ + if (interp && interp->refcnt > 1) { \ + modperl_interp_unselect(interp); \ + } \ + } STMT_END + +#define MP_CROAK_PUTBACK(rc, func) STMT_START \ + { \ + MP_PUTBACK_IF_USED(); \ + modperl_croak(aTHX_ rc, func); \ + } STMT_END + #define MP_RUN_CROAK(rc_run, func) STMT_START \ { \ apr_status_t rc = rc_run; \ @@ -45,6 +59,15 @@ void modperl_croak(pTHX_ apr_status_t rc } \ } STMT_END +#define MP_RUN_CROAK_PUTBACK(rc_run, func) STMT_START \ + { \ + apr_status_t rc = rc_run; \ + if (rc != APR_SUCCESS) { \ + MP_PUTBACK_IF_USED(); \ + modperl_croak(aTHX_ rc, func); \ + } \ + } STMT_END + #define MP_RUN_CROAK_RESET_OK(s, rc_run, func) STMT_START \ { \ apr_status_t rc = rc_run; \ @@ -59,6 +82,23 @@ void modperl_croak(pTHX_ apr_status_t rc modperl_croak(aTHX_ rc, func); \ } \ } \ + } STMT_END + +#define MP_RUN_CROAK_RESET_OK_PUTBACK(s, rc_run, func) STMT_START \ + { \ + apr_status_t rc = rc_run; \ + if (rc != APR_SUCCESS) { \ + if (APR_STATUS_IS_ECONNRESET(rc) || \ + APR_STATUS_IS_ECONNABORTED(rc)) { \ + ap_log_error(APLOG_MARK, APLOG_INFO, 0, s, \ + "%s got: %s", func, \ + modperl_error_strerror(aTHX_ rc)); \ + } \ + else { \ + MP_PUTBACK_IF_USED(); \ + modperl_croak(aTHX_ rc, func); \ + } \ + } \ } STMT_END #endif /* MODPERL_ERROR_H */ Modified: perl/modperl/trunk/src/modules/perl/modperl_filter.c URL: http://svn.apache.org/viewvc/perl/modperl/trunk/src/modules/perl/modperl_filter.c?rev=1682366&r1=1682365&r2=1682366&view=diff ============================================================================== --- perl/modperl/trunk/src/modules/perl/modperl_filter.c (original) +++ perl/modperl/trunk/src/modules/perl/modperl_filter.c Fri May 29 05:01:01 2015 @@ -283,7 +283,7 @@ static apr_status_t modperl_filter_f_cle if (ctx->data){ #ifdef USE_ITHREADS dTHXa(ctx->interp->perl); - MP_ASSERT_CONTEXT(aTHX); +// MP_ASSERT_CONTEXT(aTHX); #endif if (SvOK(ctx->data) && SvREFCNT(ctx->data)) { SvREFCNT_dec(ctx->data); @@ -535,7 +535,7 @@ int modperl_run_filter(modperl_filter_t * pass the bucket brigade through after it called * $f->read(), since it causes a pre-fetch of the * bb */ - modperl_croak(aTHX_ MODPERL_FILTER_ERROR, + MP_CROAK_PUTBACK(MODPERL_FILTER_ERROR, "a filter calling $f->read " "must return OK and not DECLINED"); } @@ -546,11 +546,11 @@ int modperl_run_filter(modperl_filter_t apr_brigade_destroy(filter->bb_in); filter->bb_in = NULL; } - MP_RUN_CROAK_RESET_OK(s, modperl_input_filter_flush(filter), + MP_RUN_CROAK_RESET_OK_PUTBACK(s, modperl_input_filter_flush(filter), "Apache2::Filter internal flush"); } else { - MP_RUN_CROAK_RESET_OK(s, modperl_output_filter_flush(filter), + MP_RUN_CROAK_RESET_OK_PUTBACK(s, modperl_output_filter_flush(filter), "Apache2::Filter internal flush"); }