Beefy Boxes and Bandwidth Generously Provided by pair Networks
Think about Loose Coupling
 
PerlMonks  

Everything gets output twice

by jepri (Parson)
on May 21, 2001 at 09:38 UTC ( [id://81918]=perlquestion: print w/replies, xml ) Need Help??

jepri has asked for the wisdom of the Perl Monks concerning the following question:

I think I must have gone nuts. One browser request gives me two of everything. Everything is doubled - the log file entries and the brwoser output. The two outputs seem to be separated by about a second. As you can imagine this really screws up my output html.

This problem also happens when I switch apache into single-threaded mode, if I use straight CGI, whatever. Running it off the command line, it appears that my module (Common.pm) gets loaded twice, but the program only runs once.

Going through my backups they all seem to do it, and yet I'm sure I would have noticed this problem a week ago. What could I have done to get this effect?

Server version: Apache/1.3.9 (Unix) Debian/GNU Server built: Apr 30 2000 12:54:24 perl5 (5.0 patchlevel 5 subversion 3)

Take note of the random numbers, which were generated with a print rand(1000)

==> /var/log/apache/error.log <== Config file loaded About to initialise variables for create_user.pl Started initialisation routine for Common,pm-------------- ################### This is a random number 326.732844579965 ################### CGI setup - new CGI=HASH(0x80d1fd0) created Got session ID: 786743dec247e75e60135ee4d159332f Tieing %userinfo to database... ==> /var/log/apache/error.log <== Config file loaded About to initialise variables for create_user.pl Started initialisation routine for Common,pm-------------- ######################### This is a random number 326.732844579965 ######################### CGI setup - new CGI=HASH(0x80d1fd0) created Got session ID: 786743dec247e75e60135ee4d159332f Tieing %userinfo to database... ==> /var/log/apache/error.log <==

____________________
Jeremy
I didn't believe in evil until I dated it.

Replies are listed 'Best First'.
Re: Everything gets output twice
by lemming (Priest) on May 21, 2001 at 10:46 UTC
    Are you loading Common.pm from more than one perl program?
    Without code, this is just guesswork. And is it really supposed to say "routine for Common,pm---"?
      I am indeed loading common.pm from more than one program. And yeah, it's meant to say that. I have some other modules - it's just telling me which module is currently running

      I do have a small update - the html was a separate problem, now fixed (I was dropping through an if statement, rather than jumping to the end of the script). However it is still duplicating everything to the log file. I don't really care about the log file that much, but it would be nice to know what's going on.

      The duplicates from the command line (the duplicate module messages) thing has vanished too. I think I may have a very sick system.

      ____________________
      Jeremy
      I didn't believe in evil until I dated it.

Re: Everything gets output twice
by clintp (Curate) on May 21, 2001 at 18:00 UTC
    Since there's no code here, can I ask a silly question? Is there a fork() anywhere in your code?
      Absolutely no forks, and I put that random number check in just to make sure of that (in case Apache was forking twice or something). In case of a fork the random number generator would be called twice, and would return two different random numebrs.

      It really is looking like something is copying STDERR and returning it about a second later.

      ____________________
      Jeremy
      I didn't believe in evil until I dated it.

        Actually, the most common problem with doubled output and fork is when the stdio buffers are copied by the fork. In that case, you'd get the same number as the call to rand would have happened before the fork.

        Also, fork duplicates the whole process including the current seed used by rand, so even if the fork happened before the call to rand, you'd get the same number in both processes unless you managed to get Perl's implicit use of srand to happen after the fork.

                - tye (but my friends call me "Tye")
Re: Everything gets output twice
by koolade (Pilgrim) on May 21, 2001 at 21:48 UTC

    Very odd coincidence--hiroki and I experienced a similar problem this morning.

    We were using path info in the URL to the script: http://script.pl/OTHER_DATA. Our script was pulling in an HTML template which pulled in an image: src="images/test.png". Of course, the browser didn't handle the path info correctly and interpreted the image source to be http://script.pl/images/test.png. Thus, the script was being called twice by the browser and printing duplicates to the error log.

    If this was your exact same problem then that'd be an odd coincidence indeed. Else, it would be helpful if you post the code, or else dump the environment variables to the log file and post those.

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: perlquestion [id://81918]
Approved by root
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others about the Monastery: (9)
As of 2024-04-23 09:04 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found