perl-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Philip M. Gollucci" <>
Subject Re: $|, flushing, etc... [was Next Release]
Date Sat, 01 Oct 2005 03:48:03 GMT
Tom Schindl wrote:
> Could someone please clarify this problem before releasing:

I'm probably going to screw up the way I say this, but here we go.
All files (11) mentioned are available here:

1.  perl 5.8.7 w/out ithreads with PerlIO / apache 2.0.54 apr not threaded / mp2-svn

2.  install Apache2::DebugFilter from CPAN

3.  2 test scripts:
	first uses print
		you can run me under cgi and mp2 / registry
	second use $r->print
		you can run me under mp2 registry

4. 3 runs of this script with the following configs in httpd.conf
	PerlModule Apache2::DebugFilter
	PerlOutputFilterHandler Apache2::DebugFilter::snoop_connection
         Alias  /perl-bb/ /usr/home/pgollucci/httpd/2.0.54/prefork/perl-bb/
	<Location /perl-bb/>
   		SetHandler perl-script
   		PerlResponseHandler ModPerl::RegistryBB
   		Options +ExecCGI
   		Allow from all

	cgi_log - flush.cgi  run under mod_cgi              (works as expected)
	mp2_log - flush.cgi  run under ModPerl::RegistryBB  (doesn't work as expected)
	mp2_api - flush2.cgi run under ModPerl::RegistryBB  (works as expected)

	You can clearly see that the FLUSH buckets don't get sent in the mp2_log.

         Some reading first

5.   pradeep.smani at gmai
      found the right underlying function here modperl_wbucket_pass()

       I can illustrate this by turning off the Apache2::Debug configs above
       and enabling tracing assuming I turned it on via  MP_TRACE=1 in the Makefile.PL step.
       So to httpd.conf I add
          PerlTrace fo
	   [Thats filter and I/O Tracing]

         [there is no tracing of filters under mod_cgi]
         mp2_trace       - flush.cgi under ModPerl::RegistryBB
         mp2_api_trace   - flush2.cgi ModPerl::RegistryBB
         mp2_trace_0     - flush.cgi under ModPerl::RegistryBB $|= 0
         mp2_api_trace_0 - flush2.cgi under ModPerl::RegistryBB $|= 0

	   The reason why seeting the add_flush_bucket variable "fixes" this is because it adds a
FLUSH bucket to the
	   output bucket brigade (you can see these were "missing" in the files from #4). This variable
is set
            in modperl_filter.c:get_bucket(modperl_filter_t *filter)

      else if (MP_FILTER_IS_FLUSH(filter)) {
                    "read in: FLUSH bucket\n",
         filter->flush = 1;
         return 0;

6.  Okay so from the 4 above attached files in #5 it looks like PerlIOApache_flush() is being
called, but not working.
	[I'll list this function at the end of the e-mail.]
	Basically, I think there is a SNAFU here

MP_RUN_CROAK(modperl_wbucket_flush(rcfg->wbucket, FALSE), ":Apache2 IO flush");

That FALSE ends up being add_flush_bucket so even though we call flush we never get a flush

Apply this diff
Index: modperl_io_apache.c
--- modperl_io_apache.c (revision 292912)
+++ modperl_io_apache.c (working copy)
@@ -170,7 +170,7 @@

-    MP_RUN_CROAK(modperl_wbucket_flush(rcfg->wbucket, FALSE),
+    MP_RUN_CROAK(modperl_wbucket_flush(rcfg->wbucket, TRUE),
                   ":Apache2 IO flush");

      return 0;

recompile yada yada

         mp2_trace       - flush.cgi under ModPerl::RegistryBB (NOW WORKS)
         mp2_api_trace   - flush2.cgi ModPerl::RegistryBB

         However, this needs to be conditionalized on $| which I've no idea how to test for
in XS yet.  Also, this sends 	
	a separate bucket briade (bb) with just a FLUSH bucket.  This case is avoided because of
the extra
	overhead. FYI, the test suite still passes with this.  I'm not quite sure how though, I thought
sure it should
	have broken some of the header parsing.

         I have don't think this is the correct solution, more likely, I think this might
be a bug in PerlIO Layers in
		PERL itself?


     What doesn't kill us can only make us stronger.
                 Nothing is impossible.
Philip M. Gollucci ( 301.254.5198
Consultant /
Senior Developer / Liquidity Services, Inc.

To unsubscribe, e-mail:
For additional commands, e-mail:

View raw message