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 [patch] Re: Apache::Upload bug?
Date Fri, 10 Aug 2001 14:46:26 GMT
Joe Schaefer <joe+apache@sunstarsys.com> writes:

> 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 looks to me like the stub code in perl's ExtUtils/typemap for T_IN 
is causing the inflated refcount.  Here's a patch that overrides T_IN;
it also cleans up the "Apache::Upload" symbol table a little earlier
than the original code does.  Will commit if there's no objections.

% cvs diff
cvs server: Diffing .
Index: typemap
===================================================================
RCS file: /home/cvs/httpd-apreq/typemap,v
retrieving revision 1.1.1.1
diff -u -r1.1.1.1 typemap
--- typemap	1999/01/27 01:33:20	1.1.1.1
+++ typemap	2001/08/10 14:35:41
@@ -3,8 +3,20 @@
 Apache::Upload		T_PTROBJ
 Apache			T_APACHEOBJ
 const char *		T_PV
+ApreqInputStream        T_APREQIN
 
 OUTPUT
+
+T_APREQIN
+        {
+            GV *gv = newGVgen("$Package");
+            if ( do_open(gv, "<&", 2, FALSE, 0, 0, $var) )
+                sv_setsv($arg, sv_bless(newRV_noinc((SV*)gv), 
+                                        gv_stashpv("$Package",1)));
+            else
+                $arg = &PL_sv_undef;
+            (void)hv_delete(GvSTASH(gv), GvNAME(gv), GvNAMELEN(gv), G_DISCARD);
+        }
 
 T_APACHEOBJ
 	sv_setref_pv($arg, \"${ntype}\", (void*)$var);
cvs server: Diffing Cookie
cvs server: Diffing Request
Index: Request/Request.xs
===================================================================
RCS file: /home/cvs/httpd-apreq/Request/Request.xs,v
retrieving revision 1.25
diff -u -r1.25 Request.xs
--- Request/Request.xs	2001/06/29 19:13:17	1.25
+++ Request/Request.xs	2001/08/10 14:35:41
@@ -109,7 +109,7 @@
 #define ApacheUpload_tempname(upload) upload->tempname
 
 #ifdef PerlIO
-typedef PerlIO * InputStream;
+typedef PerlIO * ApreqInputStream;
 
 /* XXX: or should this be #ifdef PERL_IMPLICIT_SYS ? */
 #ifdef WIN32
@@ -125,7 +125,7 @@
 
 #else /*PerlIO not defined*/
 
-typedef FILE * InputStream;
+typedef FILE * ApreqInputStream;
 #define PerlIO_importFILE(fp,flags) 	fp
 #define PerlIO_write(a,b,c)  		fwrite((b),1,(c),(a))
 
@@ -256,14 +256,6 @@
     SvMAGIC(SvRV(sv))->mg_ptr = (char *)req->r;
 }
 
-static void apreq_close_handle(void *data)
-{
-    GV *handle = (GV*)data;
-    (void)hv_delete(GvSTASH(handle),
-		    GvNAME(handle), GvNAMELEN(handle), G_DISCARD);
-}
-
-
 #ifdef CGI_COMPAT
 static void register_uploads (ApacheRequest *req) {
     ApacheUpload *upload;
@@ -505,7 +497,7 @@
 
 PROTOTYPES: DISABLE 
 
-InputStream
+ApreqInputStream
 ApacheUpload_fh(upload)
     Apache::Upload upload
 
@@ -530,9 +522,7 @@
 	if (upload->req->parsed)
 	    PerlIO_seek(fp, 0, 0);
 
-	IoIFP(GvIOn((GV*)SvRV(ST(0)))) = fp;  	
-	ap_register_cleanup(upload->req->r->pool, (void*)SvRV(ST(0)), 
-			    apreq_close_handle, ap_null_cleanup);      
+	IoIFP(io) = fp;  	
     }
 
 long

-- 
Joe Schaefer


Mime
View raw message