You are viewing a plain text version of this content. The canonical link for it is here.
Posted to modperl@perl.apache.org by Nicholas Studt <ns...@angrydwarf.org> on 2004/06/29 17:20:07 UTC

[mp2] $r->senfile() curiosity

I don't know if this is a bug, or if I don't understand how bucket
brigades work. I have some code which does the following:

$r->print( "First" );
$r->sendfile( "/any/file" );
$r->print( "Last" );

This Produces:
	<the contents of /any/file>
	First
	Last
	
I thought it should produce:
	First
	<the contents of /and/file>
	Last

When I add an $r->rflush immediately before the sendfile the behavior is
as I expect, but should the rflush be required?

I am running perl 5.8.3, httpd 2.0.49 and have seen this behavior in
1.99_12 and 1.99_14.

-- 
  nicholas studt - 29 June 2004

-- 
Report problems: http://perl.apache.org/bugs/
Mail list info: http://perl.apache.org/maillist/modperl.html
List etiquette: http://perl.apache.org/maillist/email-etiquette.html


Re: [mp2] $r->senfile() curiosity

Posted by Stas Bekman <st...@stason.org>.
Stas Bekman wrote:
> Nicholas Studt wrote:
> 
>> I don't know if this is a bug, or if I don't understand how bucket
>> brigades work. I have some code which does the following:
>>
>> $r->print( "First" );
>> $r->sendfile( "/any/file" );
>> $r->print( "Last" );
>>
>> This Produces:
>>     <the contents of /any/file>
>>     First
>>     Last
>>     
>> I thought it should produce:
>>     First
>>     <the contents of /and/file>
>>     Last
>>
>> When I add an $r->rflush immediately before the sendfile the behavior is
>> as I expect, but should the rflush be required?
>>
>> I am running perl 5.8.3, httpd 2.0.49 and have seen this behavior in
>> 1.99_12 and 1.99_14.
> 
> 
> Yes, there is a discrepancy between print() and sendfile(), the latter, 
> implemented by Apache, has no idea we are buffering IO on the modperl 
> side. So it's probably a good idea to fix the modperl sendfile wrapper 
> to call rflush, to have it DWIM.

Now it's in cvs.

-- 
__________________________________________________________________
Stas Bekman            JAm_pH ------> Just Another mod_perl Hacker
http://stason.org/     mod_perl Guide ---> http://perl.apache.org
mailto:stas@stason.org http://use.perl.org http://apacheweek.com
http://modperlbook.org http://apache.org   http://ticketmaster.com

-- 
Report problems: http://perl.apache.org/bugs/
Mail list info: http://perl.apache.org/maillist/modperl.html
List etiquette: http://perl.apache.org/maillist/email-etiquette.html


Re: [mp2] $r->senfile() curiosity

Posted by Stas Bekman <st...@stason.org>.
Nicholas Studt wrote:
> I don't know if this is a bug, or if I don't understand how bucket
> brigades work. I have some code which does the following:
> 
> $r->print( "First" );
> $r->sendfile( "/any/file" );
> $r->print( "Last" );
> 
> This Produces:
> 	<the contents of /any/file>
> 	First
> 	Last
> 	
> I thought it should produce:
> 	First
> 	<the contents of /and/file>
> 	Last
> 
> When I add an $r->rflush immediately before the sendfile the behavior is
> as I expect, but should the rflush be required?
> 
> I am running perl 5.8.3, httpd 2.0.49 and have seen this behavior in
> 1.99_12 and 1.99_14.

Yes, there is a discrepancy between print() and sendfile(), the latter, 
implemented by Apache, has no idea we are buffering IO on the modperl side. So 
it's probably a good idea to fix the modperl sendfile wrapper to call rflush, 
to have it DWIM.


-- 
__________________________________________________________________
Stas Bekman            JAm_pH ------> Just Another mod_perl Hacker
http://stason.org/     mod_perl Guide ---> http://perl.apache.org
mailto:stas@stason.org http://use.perl.org http://apacheweek.com
http://modperlbook.org http://apache.org   http://ticketmaster.com

-- 
Report problems: http://perl.apache.org/bugs/
Mail list info: http://perl.apache.org/maillist/modperl.html
List etiquette: http://perl.apache.org/maillist/email-etiquette.html