Re: mp1 rflush() and buffer size

2003-08-14 Thread Stas Bekman
Douglas Theobald wrote:
I have a question concerning the proper behavior of rflush() with mp1. I'm
using Apache/1.3.28 and mod_perl/1.28 on OSX jaguar 10.2.6. Overall mp1
appears to work great. However, the following code does not work as
expected:
use CGI ();
my $r = shift;
my $q = new CGI;
print $q-header('text/html');
print $q-start_html;
print $q-p(Searching...Please wait);

$r-rflush;
# imitate a lengthy operation
for (1..3) {
  sleep 1;
}
print $q-p(Done!);
The Searching...Please wait text does not display until the sleeps are
done. Adding $|=1; up top does not help. However, this code does work:
use CGI ();
my $r = shift;
my $q = new CGI;
print $q-header('text/html');
print $q-start_html;
for (1..263)
{
print $q-p(Searching...Please wait);
}
$r-rflush;
# imitate a lengthy operation
for (1..3) {
  sleep 1;
}
print $q-p(Done!);
It appears that if I print out over 8k, the buffers flush. Less than that,
no flush. Is this proper behavior? And, if so, is there a parameter I can
change somewhere to lower the value or force a flush regardless of what's in
the buffer? I have tried very hard to find documentation or previous
discussion in this group to no avail.
Sounds like you have a buffering proxy in front of your mod_perl server. Test 
it without any front-end proxy, accessing the back-end server directly.

If you don't believe that it works, you can run strace on the process, to see 
it working correctly. You can see an example here:
http://perl.apache.org/docs/1.0/guide/debug.html#Detecting_Aborted_Connections

__
Stas BekmanJAm_pH -- Just Another mod_perl Hacker
http://stason.org/ mod_perl Guide --- http://perl.apache.org
mailto:[EMAIL PROTECTED] http://use.perl.org http://apacheweek.com
http://modperlbook.org http://apache.org   http://ticketmaster.com


Re: mp1 rflush() and buffer size

2003-08-14 Thread Stas Bekman
Douglas Theobald wrote:
On 8/10/03 2:46 PM, Stas Bekman [EMAIL PROTECTED] a écrit :


Douglas Theobald wrote:

The Searching...Please wait text does not display until the sleeps are
done. Adding $|=1; up top does not help. However, this code does work:
use CGI ();
my $r = shift;
my $q = new CGI;
print $q-header('text/html');
print $q-start_html;
for (1..263)
{
   print $q-p(Searching...Please wait);
}
$r-rflush;
# imitate a lengthy operation
for (1..3) {
 sleep 1;
}
print $q-p(Done!);
It appears that if I print out over 8k, the buffers flush. Less than that,
no flush. Is this proper behavior? And, if so, is there a parameter I can
change somewhere to lower the value or force a flush regardless of what's in
the buffer? I have tried very hard to find documentation or previous
discussion in this group to no avail.
Sounds like you have a buffering proxy in front of your mod_perl server. Test
it without any front-end proxy, accessing the back-end server directly.


Pardon my ignorance, but I know next-to-nothing about proxies (pointers for
reading up would be welcome). I setup this custom apache server myself on an
OSX box. OSX ships with perl 5.6, and I wanted a static mod_perl/apache
build with perl 5.8.0 (actually I wanted mp2 and Apache2, but can't get
Apache2 to fireup iff it loads mod_perl.so). So, unless there's a front-end
proxy hidden from me somewhere or configured by default somehow, I don't
think that's my problem. My httpd.conf has all proxy stuff commented out and
should by default send Pragma: no-cache.
I meant if there is something between your mod_perl server and the client, 
that could buffer things up, e.g. mod_proxy.

If you don't believe that it works, you can run strace on the process, to see
it working correctly. You can see an example here:
http://perl.apache.org/docs/1.0/guide/debug.html#Detecting_Aborted_Connections


Thanks, I ran ktrace on the code above with an additional print $q-h3(PID
= $$); line inserted. Part of it is below. As you thought, it looks like
its working to me - it wrote out three chunks, the first two being 4098
bytes. 
ah, you should probably add sleep(1) calls between the perl calls so you will 
be able to see them between the write calls. Otherwise it's hard to tell 
whether it really works or not. Like so:

for (1..3) {
  $r-print($_);
  $r-rflush;
  sleep 1;
}

BTW, looks like somebody needs to sub an 'eq' for a '==' in the httpd
code somewhere. 
  13247 httpdGIO   fd 2 wrote 73 bytes
Argument en-US isn't numeric in numeric eq (==) at (eval 124) line
 40.

I doubt this has to do anything with mod_perl. some locale stuff?

__
Stas BekmanJAm_pH -- Just Another mod_perl Hacker
http://stason.org/ mod_perl Guide --- http://perl.apache.org
mailto:[EMAIL PROTECTED] http://use.perl.org http://apacheweek.com
http://modperlbook.org http://apache.org   http://ticketmaster.com