httpd-apreq-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Joe Schaefer <joe+apa...@sunstarsys.com>
Subject Re: Apache::Upload bug?
Date Thu, 09 Aug 2001 19:51:42 GMT
"Jeffrey Hartmann" <perl@lefty.org> writes:

> After much tracing I found that the problem occurs in the command "my
> $fh = $file->fh;" where Apache::Upload dup()'s the filehandle and
> passed the duplicate to the perl script.  Then when the program exits
> the perl script still has an open filehandle to that file.  I fixed my
> problem by adding a "close $$fh;"  to my program which closed the
> duplicate filehandle. 

You have hit the nail on the head; the refcount for $$fh is too high.
I see the problem with apache1.3.19 + modperl 1.25 + perl 5.6.1, 
but I don't know if the same holds for earlier versions.  

It appears that the C code generated by xsubpp is the culprit, but I'm 
not exactly sure about this.

In the meantine, try inserting the following line at the top of the 
CLEANUP: section of ApacheUpload_fh in Request.xs:

      SvREFCNT_dec(SvRV(ST(0))); /* ~ line 523 in Request.xs */

It seems to do the trick for single file uploads.  Please let us
know if this fixes the problem for you.

> Now I'm not sure if this is a bug or if it's supposed to be like that, 
> but the documentation makes it sound like it gives you the actually 
> filehandle of the tempfile, and not a copy.  I just assumed that it 
> would be closed by Apache::Upload when the request was finished.

The duping behavior is desirable, but the filehandle remaining open 
is definitely a bug; and it may have been around for quite a while.

Thanks a bunch for fleshing it out.

-- 
Joe Schaefer


Mime
View raw message