You are viewing a plain text version of this content. The canonical link for it is here.
Posted to modperl@perl.apache.org by Tyler Bird <bi...@epromo.com> on 2007/09/24 19:47:19 UTC

Question...

Hi List,

I have a script that exports records templates from our system to .csv 
files.
The thing is that if it run for over 80 seconds then the webserver seems 
to never send it to the browser.
My algorithm builds all of the data into an internal string variable 
then sends all records at once and not 1 record at a time ( this would take
some time to rewrite my algorithmn this way so I am trying to find an 
easier solution here )

Funny thing is that the apparent time limit does not exist on my apache 
2.x servers, but only my apache 1.x servers.

Below is an example of the script that will not run to completion.

Any help would be much appreciated.

Thanks

#------------------------------------------------------
#
#

#!/usr/bin/perl

test();

sub test
{

$| = 1;

require in;

my $max = 85;


foreach ( my $i = 0; $i < $max; $i++)
{
        warn("sleeping, iteration: " . $i);

        sleep(1);

}

# on apache 1.x this procedure never seems to reach the browser.
in::ct();

print("I rendered");

}


Re: Question...

Posted by Tobias Regneri <to...@gmail.com>.
Hi Tyler,

I gave your script a test run on an apache 1.3 and
had the same effect (blank page). I then modified
the script as follows and everything was fine.

#!/usr/bin/perl -w

my $time = 65;

for(my $i = 0; $i < $time; $i++)
{
        warn("iteration..." . $i);
       sleep(1);

}

print "Content-type: text/html\n\n";
print "<html><head><title>Test</title></head><body>";
print("version 2.x suceeded!!!");
print "</body></html>";

1;

I think apache2/mp2 automatically sends a header
and apache 1.3 doesn't. It's only a guess cause
I don't have any experiences with apache2.

Tobias









Re: Question...

Posted by Tyler Bird <bi...@epromo.com>.
Michael Peters wrote:
> Tyler Bird wrote:
>
>   
>> Attached is my script if you want to try it and have apache 1.x
>>     
>
>   
>> require in;
>>
>>
>> my $time = 120;
>>
>> for(my $i = 0; $i < $time; $i++)
>> {
>>         warn("iteration..." . $i); 
>>        sleep(1);
>>     
>
> Here in your interation, try printing out a null byte (or anything really) just
> to tell the browser that you're still working...
>
> 	print "\0";
>   
>> }
>>
>> in::ct();
>> print("version 2.x suceeded!!!");
>>     
>
> Hi,
>   

Well I ran a couple tests.

1.) I sent the content type first then the NULL bytes then the content.

results:  sent the header but then didnt' sent any content ... ( namedly 
the suceess string at the end of the file I gave you ).
results: on another text there were a bunch of 1 characters in my 
output.  but this was using print("%c", 0);


2.) I send the null bytes first then the content type header

This seemed to give me a blank file.
Didn't even seem like the content type was send down the stream, maybe a 
timeout before.



All of that said this appears to work fine on apache 2.x + mod_perl + 
linux rhel 5.0

Tyler

Re: Question...

Posted by Michael Peters <mi...@gmail.com>.
Tyler Bird wrote:

> Attached is my script if you want to try it and have apache 1.x

> require in;
> 
> 
> my $time = 120;
> 
> for(my $i = 0; $i < $time; $i++)
> {
>         warn("iteration..." . $i); 
>        sleep(1);

Here in your interation, try printing out a null byte (or anything really) just
to tell the browser that you're still working...

	print "\0";
> 
> }
> 
> in::ct();
> print("version 2.x suceeded!!!");



-- 
Michael Peters
Developer
Plus Three, LP


Re: Question...

Posted by Tyler Bird <bi...@epromo.com>.
Tobias Regneri wrote:
> Hi Tyler,
>
> I don't think that your script causes the issue.
> Is there a timeout value set in the httpd.conf?
>
> Hth,
>
> Tobias
>
>
>   
Well there is a Timeout Directive in httpd.conf which I have set to 3000
and the problem still occurs.

If I print the file line by line everything works.

I have also tried selecting the output channel and flushing it at the 
top of my script.

select(STDOUT);
$| = 1;

select(STDERR);
$| = 1;

That didn't seem to work for me.

Attached is my script if you want to try it and have apache 1.x




Re: Question...

Posted by Tyler Bird <bi...@epromo.com>.
Tobias Regneri wrote:
> Hi Tyler,
>
> I don't think that your script causes the issue.
> Is there a timeout value set in the httpd.conf?
>
> Hth,
>
> Tobias
>
>
>   
Sorry,

remove the line

require in;

and also the line

in::ct();

and replace the in::ct() line
with

print("Content-type: text/html\n\n");

sorry

TYler

Re: Question...

Posted by Tobias Regneri <to...@gmail.com>.
Hi Tyler,

I don't think that your script causes the issue.
Is there a timeout value set in the httpd.conf?

Hth,

Tobias