Return-Path: Delivered-To: apmail-httpd-apreq-dev-archive@httpd.apache.org Received: (qmail 27120 invoked by uid 500); 10 Aug 2001 14:46:34 -0000 Mailing-List: contact apreq-dev-help@httpd.apache.org; run by ezmlm Precedence: bulk X-No-Archive: yes List-Post: List-Help: List-Unsubscribe: List-Subscribe: Delivered-To: mailing list apreq-dev@httpd.apache.org Received: (qmail 27092 invoked from network); 10 Aug 2001 14:46:34 -0000 Sender: joe@sunstarsys.com To: apreq-dev@httpd.apache.org Cc: "Jeffrey Hartmann" Subject: [patch] Re: Apache::Upload bug? References: From: Joe Schaefer Date: 10 Aug 2001 10:46:26 -0400 In-Reply-To: Joe Schaefer's message of "09 Aug 2001 15:51:42 -0400" Message-ID: Lines: 108 User-Agent: Gnus/5.0802 (Gnus v5.8.2) Emacs/20.5 MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Spam-Rating: h31.sny.collab.net 1.6.2 0/1000/N Joe Schaefer 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