You are viewing a plain text version of this content. The canonical link for it is here.
Posted to modperl@perl.apache.org by pradeep kumar <pr...@gmail.com> on 2005/09/12 10:37:15 UTC

Re:[mp2] $| doesn't work with mod_perl

Hi Tom,
 I am using mp2.
 Thanks and Regards,
Pradeep

 On 9/12/05, Tom Schindl <to...@gmx.at> wrote: 
> 
> -----BEGIN PGP SIGNED MESSAGE-----
> Hash: SHA1
> 
> What version of mp are you using if you are running mp2 i think the
> apache-filter-system is the problem.
> 
> Tom
> 
> pradeep kumar wrote:
> > Hi,
> >
> > I have a perl script which uses $| to set autoflush on. Basically, it
> > flushes after every print. This script is working fine from the command
> > line when run using standalone perl interpreter. But when the same
> > script is accessed via mod_perl/apache setup, mod_perl is not flushing
> > after every print, instead buffering and printing all output at one 
> shot.
> > Any idea why $| is not working with mod_perl.
> >
> > Here is my sample script:
> >
> > #!/usr/bin/perl -w
> >
> > use CGI qw/:standard/;
> > use strict;
> > select(STDOUT);
> > $| = 1;
> > print STDOUT "Content-type: text/html\n\n"; print STDOUT <<END; <html>
> > <head> </head> <body> END print STDOUT 'hello'; print STDOUT '<br>';
> > sleep(2); print STDOUT 'World'; print STDOUT '<br>'; sleep(2); print
> > STDOUT 'Testing'; print STDOUT "</body></html>";
> >
> >
> > Thanks in advance,
> > Pradeep
> 
> -----BEGIN PGP SIGNATURE-----
> Version: GnuPG v1.4.0 (GNU/Linux)
> Comment: Using GnuPG with Mandriva - http://enigmail.mozdev.org
> 
> iD8DBQFDJTzSkVPeOFLgZFIRApj0AKCMTBdxV+2QHD3A09oXuZH86Qv1/wCgoSuu
> 8w1b1u2xYzy6lZF9XJA3GD8=
> =VjYy
> -----END PGP SIGNATURE-----
>

Re: [mp2] $| doesn't work with mod_perl

Posted by "Philip M. Gollucci" <pg...@p6m7g8.com>.
Alexander Charbonnet wrote:
> Are you sure mod_deflate isn't one of your active Apache filters?  mod_deflate 
> will not output until its buffer is full, $| notwithstanding.  I tore my hair 
> out trying to work around it, and ended up writing my own compression filter.  
> But if you don't need compression, try disabling mod_deflate.
You might try Apache2::DebugFilter to look at the bucket contents.  Its pretty well documented.


Its in my CPAN dir, previously by Stas.


-- 
END
------------------------------------------------------------
     What doesn't kill us can only make us stronger.
                 Nothing is impossible.
				
Philip M. Gollucci (pgollucci@p6m7g8.com) 301.254.5198
Consultant / http://p6m7g8.net/Resume/
Senior Developer / Liquidity Services, Inc.
   http://www.liquidityservicesinc.com
        http://www.liquidation.com
        http://www.uksurplus.com
        http://www.govliquidation.com
        http://www.gowholesale.com


Re: [mp2] $| doesn't work with mod_perl

Posted by Alexander Charbonnet <al...@charbonnet.com>.
Are you sure mod_deflate isn't one of your active Apache filters?  mod_deflate 
will not output until its buffer is full, $| notwithstanding.  I tore my hair 
out trying to work around it, and ended up writing my own compression filter.  
But if you don't need compression, try disabling mod_deflate.

-Alex


On Friday 16 September 2005 05:36 am, pradeep kumar wrote:
> Can you please elaborate on why apache filters can be an issue with the
> autoflush problem that I noticed ?
>
> Also, I noticed that the autoflush work properly when I flush it to a
> regular file. Its only when I choose STDOUT that the flushing gets delayed.
> Is there some buffering that happens with STDOUT alone ? I am confused if
> this is a modperl problem or an Apache problem.
>
> On 9/12/05, pradeep kumar <pr...@gmail.com> wrote:
> > Hi Tom,
> >  I am using mp2.
> >  Thanks and Regards,
> > Pradeep
> >
> >  On 9/12/05, Tom Schindl <to...@gmx.at> wrote:
> > > -----BEGIN PGP SIGNED MESSAGE-----
> > > Hash: SHA1
> > >
> > > What version of mp are you using if you are running mp2 i think the
> > > apache-filter-system is the problem.
> > >
> > > Tom
> > >
> > > pradeep kumar wrote:
> > > > Hi,
> > > >
> > > > I have a perl script which uses $| to set autoflush on. Basically, it
> > > > flushes after every print. This script is working fine from the
> > >
> > > command
> > >
> > > > line when run using standalone perl interpreter. But when the same
> > > > script is accessed via mod_perl/apache setup, mod_perl is not
> > > > flushing after every print, instead buffering and printing all output
> > > > at one
> > >
> > > shot.
> > >
> > > > Any idea why $| is not working with mod_perl.
> > > >
> > > > Here is my sample script:
> > > >
> > > > #!/usr/bin/perl -w
> > > >
> > > > use CGI qw/:standard/;
> > > > use strict;
> > > > select(STDOUT);
> > > > $| = 1;
> > > > print STDOUT "Content-type: text/html\n\n"; print STDOUT <<END;
> > > > <html> <head> </head> <body> END print STDOUT 'hello'; print STDOUT
> > > > '<br>'; sleep(2); print STDOUT 'World'; print STDOUT '<br>';
> > > > sleep(2); print STDOUT 'Testing'; print STDOUT "</body></html>";
> > > >
> > > >
> > > > Thanks in advance,
> > > > Pradeep
> > >
> > > -----BEGIN PGP SIGNATURE-----
> > > Version: GnuPG v1.4.0 (GNU/Linux)
> > > Comment: Using GnuPG with Mandriva - http://enigmail.mozdev.org
> > >
> > > iD8DBQFDJTzSkVPeOFLgZFIRApj0AKCMTBdxV+2QHD3A09oXuZH86Qv1/wCgoSuu
> > > 8w1b1u2xYzy6lZF9XJA3GD8=
> > > =VjYy
> > > -----END PGP SIGNATURE-----

Re: [mp2] $| doesn't work with mod_perl

Posted by Tom Schindl <to...@gmx.at>.
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Hi pradeep,

is $r->flush(); working, or not?

Tom

pradeep kumar wrote:
> mod_deflate is not loaded on my system and I can still see this problem.
> 
> I instrumented some portion of the code to understand the flow and I
> have some questions. The modperl_filter.c has a function
> modperl_wbucket_flush(). Now the add_flush_bucket variable that is
> passed to this function is not set even when $| is enabled. If I
> manually set it, the autoflush happens as expected. I wanted to know
> when this variable is set and why setting it manually seems to solve the
> problem.
> 
> Thanks in advance for any help on this.
> 
> 
> On 9/23/05, *Tom Schindl* <tomAtLinux@gmx.at <ma...@gmx.at>>
> wrote:
> 
> Does $r->rflush(); help? Although it should do the same then seting $|
> to undef.
> 
> Tom
> 
> Tom Schindl wrote:
>> pradeep kumar wrote:
> 
>>>>Can you please elaborate on why apache filters can be an issue
> with the
>>>>autoflush problem that I noticed ?
>>>>
>>>>Also, I noticed that the autoflush work properly when I flush it to a
>>>>regular file. Its only when I choose STDOUT that the flushing gets
>>>>delayed. Is there some buffering that happens with STDOUT alone ?
> I am
>>>>confused if this is a modperl problem or an Apache problem.
>>>>
> 
> 
>> Well I guess that I read it a while ago but I'm not sure of. As
> far as I
>> understand the Apache2-Filter-System because a bucket is only sent to
>> the filter system after the BUFFER is full. But I really have no idea
>> what happens behind the scences after the print-call.
> 
>> Maybe Stas, Geoff or someone else can look at this and tell you more.
> 
>> Tom
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.0 (GNU/Linux)
Comment: Using GnuPG with Mandriva - http://enigmail.mozdev.org

iD8DBQFDQpqikVPeOFLgZFIRAtbPAJ92zeoQZ9varLcVyGRgXEIK5kJBiACeKJWT
Co6Ie/a0wN0sNMTioRnezPw=
=ft3W
-----END PGP SIGNATURE-----

Re: [mp2] $| doesn't work with mod_perl

Posted by pradeep kumar <pr...@gmail.com>.
mod_deflate is not loaded on my system and I can still see this problem.

I instrumented some portion of the code to understand the flow and I have
some questions. The modperl_filter.c has a function modperl_wbucket_flush().
Now the add_flush_bucket variable that is passed to this function is not set
even when $| is enabled. If I manually set it, the autoflush happens as
expected. I wanted to know when this variable is set and why setting it
manually seems to solve the problem.

Thanks in advance for any help on this.


On 9/23/05, Tom Schindl <to...@gmx.at> wrote:
>
> -----BEGIN PGP SIGNED MESSAGE-----
> Hash: SHA1
>
> Does $r->rflush(); help? Although it should do the same then seting $|
> to undef.
>
> Tom
>
> Tom Schindl wrote:
> > pradeep kumar wrote:
> >
> >>>Can you please elaborate on why apache filters can be an issue with the
> >>>autoflush problem that I noticed ?
> >>>
> >>>Also, I noticed that the autoflush work properly when I flush it to a
> >>>regular file. Its only when I choose STDOUT that the flushing gets
> >>>delayed. Is there some buffering that happens with STDOUT alone ? I am
> >>>confused if this is a modperl problem or an Apache problem.
> >>>
> >
> >
> > Well I guess that I read it a while ago but I'm not sure of. As far as I
> > understand the Apache2-Filter-System because a bucket is only sent to
> > the filter system after the BUFFER is full. But I really have no idea
> > what happens behind the scences after the print-call.
> >
> > Maybe Stas, Geoff or someone else can look at this and tell you more.
> >
> > Tom
> -----BEGIN PGP SIGNATURE-----
> Version: GnuPG v1.4.0 (GNU/Linux)
> Comment: Using GnuPG with Mandriva - http://enigmail.mozdev.org
>
> iD8DBQFDM7TOkVPeOFLgZFIRAmewAJ9gR/jcCR0YitKzNTOzen6QQph25QCfYkBA
> 6m1LigFv/t2L7512tyICVpw=
> =QcQk
> -----END PGP SIGNATURE-----
>

Re: [mp2] $| doesn't work with mod_perl

Posted by Tom Schindl <to...@gmx.at>.
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Does $r->rflush(); help? Although it should do the same then seting $|
to undef.

Tom

Tom Schindl wrote:
> pradeep kumar wrote:
> 
>>>Can you please elaborate on why apache filters can be an issue with the
>>>autoflush problem that I noticed ?
>>>
>>>Also, I noticed that the autoflush work properly when I flush it to a
>>>regular file. Its only when I choose STDOUT that the flushing gets
>>>delayed. Is there some buffering that happens with STDOUT alone ? I am
>>>confused if this is a modperl problem or an Apache problem.
>>>
> 
> 
> Well I guess that I read it a while ago but I'm not sure of. As far as I
> understand the Apache2-Filter-System because a bucket is only sent to
> the filter system after the BUFFER is full. But I really have no idea
> what happens behind the scences after the print-call.
> 
> Maybe Stas, Geoff or someone else can look at this and tell you more.
> 
> Tom
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.0 (GNU/Linux)
Comment: Using GnuPG with Mandriva - http://enigmail.mozdev.org

iD8DBQFDM7TOkVPeOFLgZFIRAmewAJ9gR/jcCR0YitKzNTOzen6QQph25QCfYkBA
6m1LigFv/t2L7512tyICVpw=
=QcQk
-----END PGP SIGNATURE-----

Re: [mp2] $| doesn't work with mod_perl

Posted by Tom Schindl <to...@gmx.at>.
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

pradeep kumar wrote:
> Can you please elaborate on why apache filters can be an issue with the
> autoflush problem that I noticed ?
> 
> Also, I noticed that the autoflush work properly when I flush it to a
> regular file. Its only when I choose STDOUT that the flushing gets
> delayed. Is there some buffering that happens with STDOUT alone ? I am
> confused if this is a modperl problem or an Apache problem.
> 

Well I guess that I read it a while ago but I'm not sure of. As far as I
understand the Apache2-Filter-System because a bucket is only sent to
the filter system after the BUFFER is full. But I really have no idea
what happens behind the scences after the print-call.

Maybe Stas, Geoff or someone else can look at this and tell you more.

Tom
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.0 (GNU/Linux)
Comment: Using GnuPG with Mandriva - http://enigmail.mozdev.org

iD8DBQFDL5z2kVPeOFLgZFIRAn2iAJ4up4gQt5kptn558HyuHPVyoA72zACgmxKE
R6W7w6o5azBVbiidKGuxVVM=
=NbtZ
-----END PGP SIGNATURE-----

Re: [mp2] $| doesn't work with mod_perl

Posted by pradeep kumar <pr...@gmail.com>.
Can you please elaborate on why apache filters can be an issue with the 
autoflush problem that I noticed ?

Also, I noticed that the autoflush work properly when I flush it to a 
regular file. Its only when I choose STDOUT that the flushing gets delayed. 
Is there some buffering that happens with STDOUT alone ? I am confused if 
this is a modperl problem or an Apache problem.

On 9/12/05, pradeep kumar <pr...@gmail.com> wrote:
> 
> Hi Tom,
>  I am using mp2.
>  Thanks and Regards,
> Pradeep
> 
>  On 9/12/05, Tom Schindl <to...@gmx.at> wrote: 
> > 
> > -----BEGIN PGP SIGNED MESSAGE-----
> > Hash: SHA1
> > 
> > What version of mp are you using if you are running mp2 i think the 
> > apache-filter-system is the problem.
> > 
> > Tom
> > 
> > pradeep kumar wrote:
> > > Hi,
> > >
> > > I have a perl script which uses $| to set autoflush on. Basically, it
> > > flushes after every print. This script is working fine from the 
> > command 
> > > line when run using standalone perl interpreter. But when the same
> > > script is accessed via mod_perl/apache setup, mod_perl is not flushing
> > > after every print, instead buffering and printing all output at one 
> > shot. 
> > > Any idea why $| is not working with mod_perl.
> > >
> > > Here is my sample script:
> > >
> > > #!/usr/bin/perl -w
> > >
> > > use CGI qw/:standard/;
> > > use strict;
> > > select(STDOUT);
> > > $| = 1; 
> > > print STDOUT "Content-type: text/html\n\n"; print STDOUT <<END; <html>
> > > <head> </head> <body> END print STDOUT 'hello'; print STDOUT '<br>';
> > > sleep(2); print STDOUT 'World'; print STDOUT '<br>'; sleep(2); print 
> > > STDOUT 'Testing'; print STDOUT "</body></html>";
> > >
> > >
> > > Thanks in advance,
> > > Pradeep
> > 
> > -----BEGIN PGP SIGNATURE-----
> > Version: GnuPG v1.4.0 (GNU/Linux)
> > Comment: Using GnuPG with Mandriva - http://enigmail.mozdev.org
> > 
> > iD8DBQFDJTzSkVPeOFLgZFIRApj0AKCMTBdxV+2QHD3A09oXuZH86Qv1/wCgoSuu
> > 8w1b1u2xYzy6lZF9XJA3GD8=
> > =VjYy
> > -----END PGP SIGNATURE-----
> > 
> 
>