Return-Path: Delivered-To: apmail-httpd-apreq-dev-archive@www.apache.org Received: (qmail 73323 invoked from network); 24 Jun 2006 21:19:52 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (209.237.227.199) by minotaur.apache.org with SMTP; 24 Jun 2006 21:19:52 -0000 Received: (qmail 66869 invoked by uid 500); 24 Jun 2006 21:19:51 -0000 Delivered-To: apmail-httpd-apreq-dev-archive@httpd.apache.org Received: (qmail 66834 invoked by uid 500); 24 Jun 2006 21:19:51 -0000 Mailing-List: contact apreq-dev-help@httpd.apache.org; run by ezmlm Precedence: bulk List-Post: List-Help: List-Unsubscribe: List-Id: Delivered-To: mailing list apreq-dev@httpd.apache.org Received: (qmail 66821 invoked by uid 99); 24 Jun 2006 21:19:51 -0000 Received: from asf.osuosl.org (HELO asf.osuosl.org) (140.211.166.49) by apache.org (qpsmtpd/0.29) with ESMTP; Sat, 24 Jun 2006 14:19:51 -0700 X-ASF-Spam-Status: No, hits=0.0 required=10.0 tests= X-Spam-Check-By: apache.org Received-SPF: pass (asf.osuosl.org: local policy) Received: from [209.104.226.121] (HELO apricot.bitscrap.com) (209.104.226.121) by apache.org (qpsmtpd/0.29) with ESMTP; Sat, 24 Jun 2006 14:19:49 -0700 Received: from [192.168.2.85] (68-116-168-81.dhcp.oxfr.ma.charter.com [68.116.168.81]) by apricot.bitscrap.com (Postfix) with ESMTP id 0F0C63B4494; Sat, 24 Jun 2006 17:17:35 -0400 (EDT) Message-ID: <449DAC56.60702@bitscrap.com> Date: Sat, 24 Jun 2006 17:19:18 -0400 From: "Edward L. Abrams" Reply-To: abrams@bitscrap.com Organization: bitScrap User-Agent: Thunderbird 1.5.0.4 (Windows/20060516) MIME-Version: 1.0 To: "Philip M. Gollucci" Cc: apreq-dev@httpd.apache.org Subject: Re: Newbie: Question References: <4498A326.8010909@bitscrap.com> <449CE567.70107@p6m7g8.com> In-Reply-To: <449CE567.70107@p6m7g8.com> Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-Virus-Checked: Checked by ClamAV on apache.org X-Spam-Rating: minotaur.apache.org 1.6.2 0/1000/N Thank you for your reply. Unfortunately, my module is written in C, so I suspect the modperl list might not be as helpful. Here is the skeleton of my upload code. The function given is the content handler for this particular request. There are no significant prior input filters, and no significant posterior output filters. When I POST an upload, this content handler saves the files in the multipart POST, and returns a trivial response (not fully shown). In my testing, it tends to leak memory proportional (but not equal) to the size of the total upload. I initialize mod_apreq in the way offered in the documentation: by LoadModule'ing it, and expecting it to insert itself into the latest possible input filter position (which should not be difficult, since I have no other custom input filters). I apologize for the length of this email. Thank you for helping out! Eddie __snip__ // a content handler static int do_post(request_rec *r) { apreq_handle_t *handle; const apreq_module_t *module; apreq_param_t *filebody, *testfilebody; apr_bucket_brigade *bb; apr_bucket *b; char *loopfilename, *myip, *disk, *tmpfile, *newfilename, *extensionfilename, *lastdot; char *localorigfilename_raw, *localorigfilename, *nameindex = NULL; const char *buf = NULL; apr_file_t *f = NULL; unsigned int md_len, copies, filesize = 0, any_processed = 0; apr_size_t bytes; int i, lresult = 0; handle = (apreq_handle_t *)apreq_handle_apache2(r); apreq_read_limit_set(handle, READ_LIMIT); module = handle->module; localorigfilename_raw = (char *)apr_pcalloc(r->pool, 512); loopfilename = (char *)apr_pcalloc(r->pool, 16); for (i = 0; i < MAX_FILES_PROCESSED; i++) { filesize = 0; sprintf(loopfilename, "%s%d", DEFAULT_FILE_PARAM_NAME, i); // i do typically test whether this mulitpart part is a file -- for the sake of this skeleton, that code is omitted filebody = module->body_get(handle, loopfilename); memcpy(localorigfilename_raw, (filebody->v).data, strlen((filebody->v).data)); bb = filebody->upload; tmpfile = create_temp_path(disk, (char *)localorigfilename); if (apr_file_open(&f, tmpfile,APR_WRITE|APR_CREATE|APR_BINARY|APR_TRUNCATE,APR_UREAD|APR_UWRITE|APR_UEXECUTE, r->pool) != APR_SUCCESS) { return HTTP_FORBIDDEN; } // dump the values in this brigade: for (b = APR_BRIGADE_FIRST(bb); b != APR_BRIGADE_SENTINEL(bb); b = APR_BUCKET_NEXT(b)) { if (APR_BUCKET_IS_EOS(b)) { break; } else if (apr_bucket_read(b, &buf, &bytes, APR_BLOCK_READ) == APR_SUCCESS) { // We have a bucket full of raw data apr_file_write(f, buf, &bytes); filesize += bytes; } } apr_file_close(f); if (bb != NULL) { apr_brigade_destroy(bb); // apr_brigade_cleanup(bb); } } // for i in 0 to MAX_FILES_PROCESSED if (any_processed > 0) { return OK; } else { return HTTP_FORBIDDEN; } } __snip__ Philip M. Gollucci wrote: > Edward L. Abrams wrote: >> Hello, >> >> I apologize for my brief intrusion on this list for a question that >> may or may not be within the boundaries of the list's purpose. I >> have been using libapreq to do file uploads for some time. Lately, >> I've noticed that I have memory leaks. I don't know whether it's my >> newbie use of mostly-undocumented code, or the code itself (I favor >> the former!). > This is generally for developement of libapreq itself, but sometimes > user questions are on topic. > > You might try modperl (at) perl (dot) apache (dot) org > >> If this is the wrong place to ask what I am doing wrong in my code, >> where is the right place to ask? The modules@ list was unresponsive, >> and I could find no other close candidate. If this is not the wrong >> place to ask, then let me know, and I'll show you something that I >> believe you will be able to help me correct very easily. > Can you show some code ? > >