On Aug 28, Dave Thomas wrote:
> I applied the patch from the archives but the httpd child process is
> still
> growing by the size of the file. Is that normal, or is there an update
> to the patch that Jim Winstead placed out there
>
> The system that I am running on is:
> SunOS 5.6 on a sparc Ultra-1
>
> Thanks in advance for any help that can be provided.
i haven't tested on solaris, but attached is the latest version of
our patch. this may or may not be identical to the most recent
version that was last posted here.
you might also want to triple-check that you're using the patched
version of libapreq. i know i've forgotten to "make install" or do
a restart after recompiling more times than i've got fingers to
count on. :)
there's also another patch to solve this problem. i haven't tested
it (and don't know if handles some of the problems that i'm sure
our patch does, like work around a bug in internet explorer on the
macintosh), but you might want to try that out, too.
(this patch is being used on production servers run by homepage.com
that power a whole bunch of quite busy personal-publishing sites,
and has been quite heavily exercised by our qa team. while it
avoids the memory-bloat problem, it also doesn't ever spin out of
control, which is what we found the 'stock' libapreq to do. we run
mostly freebsd in production, and some linux, so it has seen the
most testing on those.)
jim
diff -ruN libapreq-0.31/c/apache_request.c libapreq-0.31-new/c/apache_request.c
--- libapreq-0.31/c/apache_request.cFri Jul 2 18:00:17 1999
+++ libapreq-0.31-new/c/apache_request.cTue Jul 11 17:23:58 2000
@@ -293,7 +293,7 @@
int rc = OK;
if (r->method_number == M_POST) {
- const char *data, *type;
+ const char *data = NULL, *type;
type = ap_table_get(r->headers_in, "Content-Type");
@@ -374,7 +374,8 @@
while (!multipart_buffer_eof(mbuff)) {
table *header = multipart_buffer_headers(mbuff);
- const char *cd, *param=NULL, *filename=NULL, *buff;
+ const char *cd, *param=NULL, *filename=NULL;
+ char buff[FILLUNIT];
int blen;
if (!header) {
@@ -401,8 +402,8 @@
}
}
if (!filename) {
- char *value = multipart_buffer_read_body(mbuff);
- ap_table_add(req->parms, param, value);
+ char *value = multipart_buffer_read_body(mbuff);
+ ap_table_add(req->parms, param, value);
continue;
}
ap_table_add(req->parms, param, filename);
@@ -424,7 +425,7 @@
upload->filename = ap_pstrdup(req->r->pool, filename);
upload->name = ap_pstrdup(req->r->pool, param);
- while ((buff = multipart_buffer_read(mbuff, 0, &blen))) {
+ while ((blen = multipart_buffer_read(mbuff, buff, sizeof(buff {
/* write the file */
upload->size += fwrite(buff, 1, blen, upload->fp);
}
diff -ruN libapreq-0.31/c/multipart_buffer.c libapreq-0.31-new/c/multipart_buffer.c
--- libapreq-0.31/c/multipart_buffer.c Fri Apr 30 23:44:28 1999
+++ libapreq-0.31-new/c/multipart_buffer.c Tue Jul 11 17:38:11 2000
@@ -57,271 +57,280 @@
#include "multipart_buffer.h"
-#define FILLUNIT (1024 * 5)
-#ifndef CRLF
-#define CRLF "\015\012"
-#endif
-#define CRLF_CRLF "\015\012\015\012"
+/*** internal functions */
-static char *my_join(pool *p, char *one, int lenone, char *two, int lentwo)
+/*
+ search for a string in a fixed-length byte string.
+ if partial is true, partial matches are allowed at the end of the buffer.
+ returns NULL if not found, or a pointer to the start of the first match.
+*/
+void* my_memstr(void* haystack, int haystacklen, const char* needle,
+ int partial)
{
-char *res;
-int len = lenone+lentwo;
-res = (char *)ap_palloc(p, len + 1);
-memcpy(res, one, lenone);
-memcpy(res+lenone, two, lentwo);
-return res;
-}
+ int needlen = strlen(needle);
+ int len = haystacklen;
+ void *ptr = haystack;
+
+ /* iterate through first character matches */
+ while( (ptr = memchr(ptr, needle[0], len)) )
+{
+ /* calculate length after match */
+ len = haystacklen - (ptr - haystack);
-static char *
-my_ninstr(register char *big, register char *bigend, char *little, char *lend)
-{
-register char *s, *x;
-register int first = *little;
-register char *littleend = lend;
-
-if (!first && little >= littleend) {
-return big;
-}
-if (bigend - big < littleend - little) {
-return NULL;
+ /* done if matches up to capacity of buffer */
+ if(memcmp(needle, ptr, needlen < len ? needlen : len) == 0 &&
+(partial || len >= needlen))
+ break;
+
+ /* next character */
+ ptr++; len--;
}
-bigend -= littleend - little++;
-while (big <= bigend) {
- if (*big++