Beefy Boxes and Bandwidth Generously Provided by pair Networks
laziness, impatience, and hubris
 
PerlMonks  

CGI.pm uploads under mod_Perl on WinNT

by ajt (Prior)
on Nov 16, 2001 at 18:07 UTC ( [id://125816]=perlquestion: print w/replies, xml ) Need Help??

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

Hi, I've written a file upload script for a simple Content Managment System I writing. It's pretty normal stuff, CGI.pm, strict and warnings. All works okay except that my temp folder is filling up with CGItempXXXX files.

At the moment the script is running as a mod_Perl 1.26_01-dev PerlRun script on my Apache 1.3.20/NT4 box. I'm running Perl 5.6.1 ActiveState build 628, and my CGI.pm is version 2.78.

I assume that as CGI.pm is loaded once into mod_Perl on start, rather than per CGI call, then, it's normal temp file destruction is failing to happen. As far as I can tell stopping and starting Apache does not delete the files either, though it does free any locks on them.

I'm well aware that NT isn't the best possible platform, and that PerlRun is a bit of a hack for those of us not able to use mod_Perl "properly", but it's a bit annoying watching your temp folder fill up with files.

Anyone else seen this?

Is file upload not a wise thing to run under mod_Perl/PerlRun?

I know when the script runs under CGI it's all okay.

I checked SuperSearch, but as CGI, upload and mod_Perl are very common, it was hard to find anything useful from the very large number of hits returned.

As ever humble thanks in advance.

P.S. This is my 50th post. Thanks to everyone for all the answers I've had in the past, they've been very helpful.

Replies are listed 'Best First'.
Re: CGI.pm uploads under mod_Perl on WinNT
by perrin (Chancellor) on Nov 16, 2001 at 20:07 UTC
    Check the CGI.pm code to see how it does the cleanup. Put some debug stuff in it to see if the cleanup code is being called. END blocks are supposed to be called under Registry, and so are cleanup handlers. Are you using any other Apache:: modules?
Re: CGI.pm uploads under mod_Perl on WinNT
by jlongino (Parson) on Nov 16, 2001 at 20:09 UTC
    I can't offer any help as to why it's happenning but until the problem's solved why don't you add an END{} subroutine to your program and clean things up? At least then you wouldn't have to worry about your temp folder filling up.

    --Jim

      Thanks to perrin and jlongino for their comments. I also contacted Lincoln and exchanged a few ideas with him. Apparently there have been some problems reported with file upload on CGI under mod_Perl, but they have been intermittent and hard to track down.

      I added some debugging code to the TempFile DESTROY routine, and after remembering to cycle Apache so that the change got noticed, I discovered that there was an "Permission denied" problem.

      Having previously had problems with File::Cache under NT before, I went back into my code and made sure that there was an explicit close to the uploaded file after I copied it from temp. Letting the handle go out of scope, appears to trigger CGI's DESTROY (it works find under CGI-BIN), but not under mod_Perl PerlRun. I added a close $handle at the end of the block just before it went out of scope, and now it works fine.

      Lessons learnt:

      • People here are helpful - thanks yet again.
      • Some module authors are helpful, even though they are very busy - thanks Lincoln.
      • NT can do stupid things - it's amazing that Perl and Apache/mod_Perl run on it at all. See timeout from UserAgent from mod_perl and multithreading mod_perl on Windows NT for examples, this had me stumped for a while too.
      • I constantly underestimate mod_Perl, it's powerful and complex.
      • Usually the problem is me, and trying to explain the problem to other people helps me to see where I went wrong.

      Many thanks in arrears.

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others having a coffee break in the Monastery: (3)
As of 2024-04-25 19:51 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found