Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Perl Flush Problem.

Status
Not open for further replies.

tbahr

IS-IT--Management
Jan 12, 2001
6
0
0
US
I have a perl script that appears to hang the browser. I added some logging to my script (to a text file) and I know that the script is finishing, closing the db and even calling exit at the end, but all of the print statements including Content-Type: text/html are not showing up the in browser. The browser just sits there trying to load the page with the status bar increasing. Some times I get no page and other times partial page. I tried adding the following line at the top of my script but it did not seem to help: $|++; or $|=1; Any ideas what could be causing this strange behavior. This script has run in our environment, Windows 2000 Server running 5.6 version of Perl and Microsoft SQL 7.0 for almost a year now. The new server is running Windows 2000 Server and SQL 7.0; but ActiveStates version of PERL. Could this new version of PERL be causing the new problems.
 
it's very possible that the new version of perl is what is making it hang, but, if you post your code, we can go through it and see if the problem is somewhere wlse. adam@aauser.com
 
thanks for your response Adam. I would like to post the code but it is in several modules and about 300K in length total. It is basically a full e-commerce solution written in perl as well as support for mod-perl. I doubt my boss would like me sharing our solution. Basically what it does is read an HTML template that has proprietary markup tags that alerts our parsing script to do database lookups as well as variable substitutions. I know this is probably is not much help, I was just looking for some guidance in trouble shooting it. I did notice that the web server logs state 502 errors which could be server overload issues. It is just bizarre to me that the scripts execute fine and exit; but the print statements lag behind and cause the browser to never catch up. Although it is hit or miss.
 
got it. another question; is every user having this problem? or is it sporadic?

adam@aauser.com
 
since this is a new box, only a few people are testing it before we go live with it. Each one of them has experienced some form of this problem. Only today was I able to determine it to not be a hang, but a flushing issue???
 
Why don't we approach it this way... what could cause the browser to hang? Well, ruling out client-side problems, it must be that the browser is still receiving (or expecting) data. This would suggest that the script has not in fact exited. How are you determining that it is exiting? If it should be, but is not exiting, then there could be a number of causes. An infinite loop? Perhaps you did not close your database connection properly. Are you outputting so much data that it might overflow a buffer somewhere? Do you have any forks?

I would try running it from the command line. Also turn on the -w switch and check your error log to see if you are getting any warnings. Put print statements throughout your code before and after the points at which you think it might have problems to narrow down the cause. Also, try telnetting to your webserver port and spoof a browser... see what output it gives you.

I think the problem has to do with something which was poorly written but was forgiven on your previous system. The new webserver/interpreter/database/whatever is probably more stringent. Make sure you follow all the rules.
Sincerely,

Tom Anderson
CEO, Order amid Chaos, Inc.
 
if you are using apache(i don't remember why i had a feeling that that's what you were using), check to see if it is the same version and it is configured the same/properly. also, take a look at SQL Server. i know that i've had lag problems because of tables that weren't indexed properly. i'm not really all that good at trouble-shooting, but, i'm sure that if you don't find a solution, someone in here will have some input for you. adam@aauser.com
 
I have replicated the problem on my laptop. My laptop is running the same OS Windows 2000 Server running Microsoft SQL 7.0. Originally we wrote our solution using PERL 5.0505 and 5.6.0. The new box is running on the latest build of ActiveState version of Perl 5.6. It appears when I toggle which interpreter to run I notice the problem. Under the old two versions the perl interpreter runs and exits cleaning, under the new version of ActiveState the perl.exe process stays in memory for quite some time. Usually it cleans itself up around 5 minutes. The CPU time for the process is 1 second. Even though the page loads and my log file which I use print statements to a log report I have closed the db and exited the perl script, the process still stays in memory. I am going to try some troubleshooting; but it seems strange the process stays in memory. I can see how after multiple page loads, the processes just grow. I had 14 perl processes running hence probably the hangs, even though each time the script finishes based on my logging. Any ideas. I am not using any forking or any modules outside DBI, CGI and SOCKETS.
 
I remember reading something about Apache which might be of interest to you.

Apache, as I understand it, has a built-in Perl interpreter. The advantage of this would be that the web server would not have to load the Perl executable each time a Perl script was run.
Mike
michael.j.lacey@ntlworld.com
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top