stas 2003/03/13 21:33:19
Modified: src/modules/perl modperl_util.h modperl_filter.c xs/Apache/RequestIO Apache__RequestIO.h . Changes Log: move the check that print/printf/puts/write/etc are called in the response phase into the functions themselves so 1) we can print a more useful error message 2) this check is not always needed in modperl_wbucket_write, when called internally, so we save some cycles. Revision Changes Path 1.40 +7 -1 modperl-2.0/src/modules/perl/modperl_util.h Index: modperl_util.h =================================================================== RCS file: /home/cvs/modperl-2.0/src/modules/perl/modperl_util.h,v retrieving revision 1.39 retrieving revision 1.40 diff -u -r1.39 -r1.40 --- modperl_util.h 4 Mar 2003 09:42:42 -0000 1.39 +++ modperl_util.h 14 Mar 2003 05:33:18 -0000 1.40 @@ -56,7 +56,13 @@ Perl_croak(aTHX_ modperl_apr_strerror(rc)); \ } \ } while (0) - + +/* check whether the response phase has been initialized already */ +#define MP_CHECK_WBUCKET_INIT(func) \ + if (!rcfg->wbucket) { \ + Perl_croak(aTHX_ func "can't be called before the response phase"); \ + } + MP_INLINE server_rec *modperl_sv2server_rec(pTHX_ SV *sv); MP_INLINE request_rec *modperl_sv2request_rec(pTHX_ SV *sv); 1.56 +0 -5 modperl-2.0/src/modules/perl/modperl_filter.c Index: modperl_filter.c =================================================================== RCS file: /home/cvs/modperl-2.0/src/modules/perl/modperl_filter.c,v retrieving revision 1.55 retrieving revision 1.56 diff -u -r1.55 -r1.56 --- modperl_filter.c 8 Mar 2003 09:15:16 -0000 1.55 +++ modperl_filter.c 14 Mar 2003 05:33:18 -0000 1.56 @@ -144,11 +144,6 @@ apr_size_t len = *wlen; *wlen = 0; - if (!wb) { - /* the response is not initialized yet */ - Perl_croak(aTHX_ "can't be called before the response phase"); - } - if ((len + wb->outcnt) > sizeof(wb->outbuf)) { apr_status_t rv; if ((rv = modperl_wbucket_flush(wb, FALSE)) != APR_SUCCESS) { 1.37 +6 -1 modperl-2.0/xs/Apache/RequestIO/Apache__RequestIO.h Index: Apache__RequestIO.h =================================================================== RCS file: /home/cvs/modperl-2.0/xs/Apache/RequestIO/Apache__RequestIO.h,v retrieving revision 1.36 retrieving revision 1.37 diff -u -r1.36 -r1.37 --- Apache__RequestIO.h 3 Mar 2003 03:39:06 -0000 1.36 +++ Apache__RequestIO.h 14 Mar 2003 05:33:19 -0000 1.37 @@ -40,6 +40,7 @@ MP_START_TIMES(); + MP_CHECK_WBUCKET_INIT("$r->puts"); mpxs_write_loop(modperl_wbucket_write, rcfg->wbucket); MP_END_TIMES(); @@ -66,7 +67,8 @@ mpxs_usage_va_1(r, "$r->print(...)"); rcfg = modperl_config_req_get(r); - + + MP_CHECK_WBUCKET_INIT("$r->print"); mpxs_write_loop(modperl_wbucket_write, rcfg->wbucket); mpxs_output_flush(r, rcfg); @@ -93,6 +95,7 @@ modperl_perl_do_sprintf(aTHX_ sv, items, MARK); bytes = SvCUR(sv); + MP_CHECK_WBUCKET_INIT("$r->printf"); MP_FAILURE_CROAK(modperl_wbucket_write(aTHX_ rcfg->wbucket, SvPVX(sv), &bytes)); @@ -126,6 +129,7 @@ wlen = bufsiz; } + MP_CHECK_WBUCKET_INIT("$r->write"); MP_FAILURE_CROAK(modperl_wbucket_write(aTHX_ rcfg->wbucket, buf+offset, &wlen)); @@ -144,6 +148,7 @@ rcfg = modperl_config_req_get(r); + MP_CHECK_WBUCKET_INIT("$r->rflush"); MP_FAILURE_CROAK(modperl_wbucket_flush(rcfg->wbucket, TRUE)); return APR_SUCCESS; 1.149 +10 -0 modperl-2.0/Changes Index: Changes =================================================================== RCS file: /home/cvs/modperl-2.0/Changes,v retrieving revision 1.148 retrieving revision 1.149 diff -u -r1.148 -r1.149 --- Changes 13 Mar 2003 06:10:46 -0000 1.148 +++ Changes 14 Mar 2003 05:33:19 -0000 1.149 @@ -10,6 +10,16 @@ =item 1.99_09-dev +move the check that print/printf/puts/write/etc are called in the +response phase into the functions themselves so 1) we can print a more +useful error message 2) this check is not always needed in +modperl_wbucket_write, when called internally, so we save some cycles. +[Stas] + +add checks that print/printf/puts/write/etc are called in the response +phase. move the check into the functions themselves so we can print a +more useful error message [Stas] + 'make install' now installs mod_perl*h files under httpd's include tree [Stas]